From 49e660bb1276c58094c01a24f4d702e7e2eb998d Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 10 May 2022 17:11:21 +0200 Subject: [PATCH 001/113] MDEV-11026 Make InnoDB number of IO write/read threads dynamic Resize the read/write slots, and recreate the io_context (for Linux libaio) --- .../r/innodb_file_io_threads_basic.result | 6 -- .../r/innodb_read_io_threads_basic.result | 14 +++- .../r/innodb_write_io_threads_basic.result | 12 ++- .../suite/sys_vars/r/sysvars_innodb.result | 4 +- .../t/innodb_file_io_threads_basic.test | 7 -- .../t/innodb_read_io_threads_basic.test | 16 +++- .../t/innodb_write_io_threads_basic.test | 16 +++- storage/innobase/handler/ha_innodb.cc | 37 ++++++++- storage/innobase/os/os0file.cc | 75 +++++++++++++++++++ tpool/tpool.h | 14 ++++ tpool/tpool_structs.h | 34 +++++++-- 11 files changed, 196 insertions(+), 39 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/innodb_file_io_threads_basic.result b/mysql-test/suite/sys_vars/r/innodb_file_io_threads_basic.result index 5ef7e1099e063..0442cee05514b 100644 --- a/mysql-test/suite/sys_vars/r/innodb_file_io_threads_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_file_io_threads_basic.result @@ -8,16 +8,10 @@ COUNT(@@GLOBAL.innodb_write_io_threads) 1 1 Expected '#---------------------BS_STVARS_027_02----------------------#' -SET @@GLOBAL.innodb_read_io_threads=1; -ERROR HY000: Variable 'innodb_read_io_threads' is a read only variable -Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_read_io_threads); COUNT(@@GLOBAL.innodb_read_io_threads) 1 1 Expected -SET @@GLOBAL.innodb_write_io_threads=1; -ERROR HY000: Variable 'innodb_write_io_threads' is a read only variable -Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_write_io_threads); COUNT(@@GLOBAL.innodb_write_io_threads) 1 diff --git a/mysql-test/suite/sys_vars/r/innodb_read_io_threads_basic.result b/mysql-test/suite/sys_vars/r/innodb_read_io_threads_basic.result index f43fa81c0d052..6ec897cea0212 100644 --- a/mysql-test/suite/sys_vars/r/innodb_read_io_threads_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_read_io_threads_basic.result @@ -15,7 +15,15 @@ INNODB_READ_IO_THREADS 2 select * from information_schema.session_variables where variable_name='innodb_read_io_threads'; VARIABLE_NAME VARIABLE_VALUE INNODB_READ_IO_THREADS 2 -set global innodb_read_io_threads=1; -ERROR HY000: Variable 'innodb_read_io_threads' is a read only variable +select @@innodb_read_io_threads into @n; +set global innodb_read_io_threads = 1; +select @@innodb_read_io_threads; +@@innodb_read_io_threads +1 +set global innodb_read_io_threads=64; +select @@innodb_read_io_threads; +@@innodb_read_io_threads +64 set session innodb_read_io_threads=1; -ERROR HY000: Variable 'innodb_read_io_threads' is a read only variable +ERROR HY000: Variable 'innodb_read_io_threads' is a GLOBAL variable and should be set with SET GLOBAL +set global innodb_read_io_threads=@n; diff --git a/mysql-test/suite/sys_vars/r/innodb_write_io_threads_basic.result b/mysql-test/suite/sys_vars/r/innodb_write_io_threads_basic.result index a363f4292ddd9..b9e5e083a9091 100644 --- a/mysql-test/suite/sys_vars/r/innodb_write_io_threads_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_write_io_threads_basic.result @@ -15,7 +15,13 @@ INNODB_WRITE_IO_THREADS 2 select * from information_schema.session_variables where variable_name='innodb_write_io_threads'; VARIABLE_NAME VARIABLE_VALUE INNODB_WRITE_IO_THREADS 2 +select @@innodb_write_io_threads into @n; set global innodb_write_io_threads=1; -ERROR HY000: Variable 'innodb_write_io_threads' is a read only variable -set session innodb_write_io_threads=1; -ERROR HY000: Variable 'innodb_write_io_threads' is a read only variable +select @@innodb_write_io_threads; +@@innodb_write_io_threads +2 +set global innodb_write_io_threads=64; +select @@innodb_write_io_threads; +@@innodb_write_io_threads +64 +set global innodb_write_io_threads=@n; diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 428036958138b..6eface8c09769 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -1349,7 +1349,7 @@ NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 64 NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL -READ_ONLY YES +READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_READ_ONLY SESSION_VALUE NULL @@ -1697,5 +1697,5 @@ NUMERIC_MIN_VALUE 2 NUMERIC_MAX_VALUE 64 NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL -READ_ONLY YES +READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED diff --git a/mysql-test/suite/sys_vars/t/innodb_file_io_threads_basic.test b/mysql-test/suite/sys_vars/t/innodb_file_io_threads_basic.test index c701c2ee171c8..802d7e836e777 100644 --- a/mysql-test/suite/sys_vars/t/innodb_file_io_threads_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_file_io_threads_basic.test @@ -39,17 +39,10 @@ SELECT COUNT(@@GLOBAL.innodb_write_io_threads); # Check if Value can set # #################################################################### ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -SET @@GLOBAL.innodb_read_io_threads=1; ---echo Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_read_io_threads); --echo 1 Expected ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -SET @@GLOBAL.innodb_write_io_threads=1; ---echo Expected error 'Read only variable' - SELECT COUNT(@@GLOBAL.innodb_write_io_threads); --echo 1 Expected diff --git a/mysql-test/suite/sys_vars/t/innodb_read_io_threads_basic.test b/mysql-test/suite/sys_vars/t/innodb_read_io_threads_basic.test index c4c49d5bb2036..148871478a7f3 100644 --- a/mysql-test/suite/sys_vars/t/innodb_read_io_threads_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_read_io_threads_basic.test @@ -19,10 +19,18 @@ select * from information_schema.session_variables where variable_name='innodb_r --enable_warnings # -# show that it's read-only +# show that it's not read-only # ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -set global innodb_read_io_threads=1; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR +select @@innodb_read_io_threads into @n; +--disable_warnings +set global innodb_read_io_threads = 1; +--enable_warnings +select @@innodb_read_io_threads; +--disable_warnings +set global innodb_read_io_threads=64; +--enable_warnings +select @@innodb_read_io_threads; +--error ER_GLOBAL_VARIABLE set session innodb_read_io_threads=1; +set global innodb_read_io_threads=@n; diff --git a/mysql-test/suite/sys_vars/t/innodb_write_io_threads_basic.test b/mysql-test/suite/sys_vars/t/innodb_write_io_threads_basic.test index d9556af37d16b..9ee9f5ba619f6 100644 --- a/mysql-test/suite/sys_vars/t/innodb_write_io_threads_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_write_io_threads_basic.test @@ -19,10 +19,18 @@ select * from information_schema.session_variables where variable_name='innodb_w --enable_warnings # -# show that it's read-only +# show that it's not read-only # ---error ER_INCORRECT_GLOBAL_LOCAL_VAR +select @@innodb_write_io_threads into @n; +--disable_warnings set global innodb_write_io_threads=1; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -set session innodb_write_io_threads=1; +--enable_warnings +select @@innodb_write_io_threads; +--disable_warnings +set global innodb_write_io_threads=64; +--enable_warnings +select @@innodb_write_io_threads; +--disable_warnings +set global innodb_write_io_threads=@n; +--enable_warnings diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e8a8e813c25a3..4ef2863090524 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -19261,15 +19261,44 @@ static MYSQL_SYSVAR_BOOL(optimize_fulltext_only, innodb_optimize_fulltext_only, "Only optimize the Fulltext index of the table", NULL, NULL, FALSE); +extern int os_aio_resize(ulint n_reader_threads, ulint n_writer_threads); +static void innodb_update_io_thread_count(THD *thd,ulint n_read, ulint n_write) +{ + int res = os_aio_resize(n_read, n_write); + if (res) + { +#ifndef __linux__ + ut_ad(0); +#else + ut_a(srv_use_native_aio); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_UNKNOWN_ERROR, + "Could not reserve max. number of concurrent ios." + "Increase the /proc/sys/fs/aio-max-nr to fix."); +#endif + } +} + +static void innodb_read_io_threads_update(THD* thd, struct st_mysql_sys_var*, void*, const void* save) +{ + srv_n_read_io_threads = *static_cast(save); + innodb_update_io_thread_count(thd, srv_n_read_io_threads, srv_n_write_io_threads); +} +static void innodb_write_io_threads_update(THD* thd, struct st_mysql_sys_var*, void*, const void* save) +{ + srv_n_write_io_threads = *static_cast(save); + innodb_update_io_thread_count(thd, srv_n_read_io_threads, srv_n_write_io_threads); +} + static MYSQL_SYSVAR_UINT(read_io_threads, srv_n_read_io_threads, - PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + PLUGIN_VAR_RQCMDARG, "Number of background read I/O threads in InnoDB.", - NULL, NULL, 4, 1, 64, 0); + NULL, innodb_read_io_threads_update , 4, 1, 64, 0); static MYSQL_SYSVAR_UINT(write_io_threads, srv_n_write_io_threads, - PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + PLUGIN_VAR_RQCMDARG, "Number of background write I/O threads in InnoDB.", - NULL, NULL, 4, 2, 64, 0); + NULL, innodb_write_io_threads_update, 4, 2, 64, 0); static MYSQL_SYSVAR_ULONG(force_recovery, srv_force_recovery, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 01af15befd31b..97a1fc44fe760 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -106,6 +106,11 @@ class io_slots } /* Wait for completions of all AIO operations */ + void wait(std::unique_lock &lk) + { + m_cache.wait(lk); + } + void wait() { m_cache.wait(); @@ -125,6 +130,24 @@ class io_slots { wait(); } + + std::mutex& mutex() + { + return m_cache.mutex(); + } + + void resize(int max_submitted_io, int max_callback_concurrency, std::unique_lock &lk) + { + ut_a(lk.owns_lock()); + m_cache.resize(max_submitted_io); + m_group.set_max_tasks(max_callback_concurrency); + m_max_aio = max_submitted_io; + } + + tpool::task_group& task_group() + { + return m_group; + } }; static std::unique_ptr read_slots; @@ -3698,6 +3721,58 @@ int os_aio_init() } +/** +Change reader or writer thread parameter on a running server. +This includes resizing the io slots, as we calculate +number of outstanding IOs based on the these variables. + +It is trickier with when Linux AIO is involved (io_context +needs to be recreated to account for different number of +max_events). With Linux AIO, depending on fs-max-aio number +and user and system wide max-aio limitation, this can fail. + +Otherwise, we just resize the slots, and allow for +more concurrent threads via thread_group setting. + +@param[in] n_reader_threads - max number of concurrently + executing read callbacks +@param[in] n_writer_thread - max number of cuncurrently + executing write callbacks +@return 0 for success, !=0 for error. +*/ +int os_aio_resize(ulint n_reader_threads, ulint n_writer_threads) +{ + /* Lock the slots, and wait until all current IOs finish.*/ + std::unique_lock lk_read(read_slots->mutex()); + std::unique_lock lk_write(write_slots->mutex()); + + read_slots->wait(lk_read); + write_slots->wait(lk_write); + + /* Now, all IOs have finished and no new ones can start, due to locks. */ + int max_read_events= int(n_reader_threads * OS_AIO_N_PENDING_IOS_PER_THREAD); + int max_write_events= int(n_writer_threads * OS_AIO_N_PENDING_IOS_PER_THREAD); + int events= max_read_events + max_write_events; + + /** Do the Linux AIO dance (this will try to create a new + io context with changed max_events ,etc*/ + + if (int ret= srv_thread_pool->reconfigure_aio(srv_use_native_aio, events)) + { + /** Do the best effort. We can't change the parallel io number, + but we still can adjust the number of concurrent completion handlers.*/ + read_slots->task_group().set_max_tasks(static_cast(n_reader_threads)); + write_slots->task_group().set_max_tasks(static_cast(n_writer_threads)); + return ret; + } + + /* Allocation succeeded, resize the slots*/ + read_slots->resize(max_read_events, static_cast(n_reader_threads), lk_read); + write_slots->resize(max_write_events, static_cast(n_writer_threads), lk_write); + + return 0; +} + void os_aio_free() { srv_thread_pool->disable_aio(); diff --git a/tpool/tpool.h b/tpool/tpool.h index 87a0122adcede..5ce886d83b5cc 100644 --- a/tpool/tpool.h +++ b/tpool/tpool.h @@ -231,6 +231,20 @@ class thread_pool m_aio.reset(create_simulated_aio(this)); return !m_aio ? -1 : 0; } + + int reconfigure_aio(bool use_native_aio, int max_io) + { + assert(m_aio); + if (use_native_aio) + { + auto new_aio = create_native_aio(max_io); + if (!new_aio) + return -1; + m_aio.reset(new_aio); + } + return 0; + } + void disable_aio() { m_aio.reset(); diff --git a/tpool/tpool_structs.h b/tpool/tpool_structs.h index 7b0fb8576950b..65ec3db307409 100644 --- a/tpool/tpool_structs.h +++ b/tpool/tpool_structs.h @@ -94,6 +94,10 @@ template class cache return ret; } + std::mutex& mutex() + { + return m_mtx; + } void put(T *ele) { @@ -112,19 +116,37 @@ template class cache return ele >= &m_base[0] && ele <= &m_base[m_base.size() -1]; } - /* Wait until cache is full.*/ - void wait() + + TPOOL_SUPPRESS_TSAN size_t size() + { + return m_cache.size(); + } + + /** Wait until cache is full + @param[in] lk - lock for the cache mutex + (which can be obtained with mutex()) */ + void wait(std::unique_lock &lk) { - std::unique_lock lk(m_mtx); m_waiters++; - while(!is_full()) + while (!is_full()) m_cv.wait(lk); m_waiters--; } - TPOOL_SUPPRESS_TSAN size_t size() + /* Wait until cache is full.*/ + void wait() { - return m_cache.size(); + std::unique_lock lk(m_mtx); + wait(lk); + } + + void resize(size_t count) + { + assert(is_full()); + m_base.resize(count); + m_cache.resize(count); + for (size_t i = 0; i < count; i++) + m_cache[i] = &m_base[i]; } }; From c8e3bcf79b3931dad9ce16fecc714d39d2247f89 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 1 Jun 2022 13:46:33 +0200 Subject: [PATCH 002/113] MDEV-11026 Make InnoDB number of IO write/read threads dynamic Fix concurrency error - avoid accessing deleted memory, when io_slots is resized. the deleted memory in this case was vftable pointer in aiocb::m_internal_task The fix avoids calling dummy release function, via a flag in task_group. --- storage/innobase/os/os0file.cc | 3 +-- tpool/task_group.cc | 22 +++++++++++++++++++--- tpool/tpool.h | 4 +++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 97a1fc44fe760..e37b19da87062 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -84,8 +84,7 @@ class io_slots int m_max_aio; public: io_slots(int max_submitted_io, int max_callback_concurrency) : - m_cache(max_submitted_io), - m_group(max_callback_concurrency), + m_cache(max_submitted_io), m_group(max_callback_concurrency, false), m_max_aio(max_submitted_io) { } diff --git a/tpool/task_group.cc b/tpool/task_group.cc index b52fe7c0f672b..eb57a8bee37fd 100644 --- a/tpool/task_group.cc +++ b/tpool/task_group.cc @@ -25,11 +25,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 - 1301 USA*/ #endif namespace tpool { - task_group::task_group(unsigned int max_concurrency) : + + /** + Task_group constructor + + @param max_threads - maximum number of threads allowed to execute + tasks from the group at the same time. + + @param enable_task_release - if true (default), task::release() will be + called after task execution.'false' should only be used in rare cases + when accessing memory, pointed by task structures, would be unsafe after. + the callback. Also 'false' is only possible ,if task::release() is a trivial function + */ + task_group::task_group(unsigned int max_concurrency, + bool enable_task_release) + : m_queue(8), m_mtx(), m_tasks_running(), - m_max_concurrent_tasks(max_concurrency) + m_max_concurrent_tasks(max_concurrency), + m_enable_task_release(enable_task_release) {}; void task_group::set_max_tasks(unsigned int max_concurrency) @@ -53,7 +68,8 @@ namespace tpool if (t) { t->m_func(t->m_arg); - t->release(); + if (m_enable_task_release) + t->release(); } lk.lock(); diff --git a/tpool/tpool.h b/tpool/tpool.h index 5ce886d83b5cc..f0b2b9f67350b 100644 --- a/tpool/tpool.h +++ b/tpool/tpool.h @@ -68,8 +68,10 @@ class task_group std::condition_variable m_cv; unsigned int m_tasks_running; unsigned int m_max_concurrent_tasks; + const bool m_enable_task_release; + public: - task_group(unsigned int max_concurrency= 100000); + task_group(unsigned int max_concurrency= 100000, bool m_enable_task_release= true); void set_max_tasks(unsigned int max_concurrent_tasks); void execute(task* t); void cancel_pending(task *t); From dbaeeb6168c91f5ca241d38ed7cae816a888dc28 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 25 Jul 2022 12:08:29 +0300 Subject: [PATCH 003/113] Create a 10.11 branch --- VERSION | 2 +- debian/additions/mariadb.conf.d/50-server.cnf | 4 +-- debian/changelog | 2 +- debian/control | 8 +++--- debian/salsa-ci.yml | 8 +++--- debian/source/lintian-overrides | 28 +++++++++---------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/VERSION b/VERSION index 6197e7f558bea..b93fbcee673a5 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 -MYSQL_VERSION_MINOR=10 +MYSQL_VERSION_MINOR=11 MYSQL_VERSION_PATCH=0 SERVER_MATURITY=alpha diff --git a/debian/additions/mariadb.conf.d/50-server.cnf b/debian/additions/mariadb.conf.d/50-server.cnf index aa61301297e49..76e93e2bd3001 100644 --- a/debian/additions/mariadb.conf.d/50-server.cnf +++ b/debian/additions/mariadb.conf.d/50-server.cnf @@ -108,7 +108,7 @@ collation-server = utf8mb4_general_ci # you can put MariaDB-only options here [mariadb] -# This group is only read by MariaDB-10.10 servers. +# This group is only read by MariaDB-10.11 servers. # If you use the same .cnf file for MariaDB of different versions, # use this group for options that older servers don't understand -[mariadb-10.10] +[mariadb-10.11] diff --git a/debian/changelog b/debian/changelog index 2f98eccffce89..af6536d9be9a0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -mariadb (1:10.10.0) unstable; urgency=medium +mariadb (1:10.11.0) unstable; urgency=medium * Initial Release diff --git a/debian/control b/debian/control index 8886da40fdf64..81418c1365626 100644 --- a/debian/control +++ b/debian/control @@ -384,7 +384,7 @@ Replaces: mariadb-client (<< ${source:Version}), percona-xtradb-cluster-server-5.7, virtual-mysql-client-core Provides: default-mysql-client-core, - mariadb-client-core-10.10, + mariadb-client-core-10.11, virtual-mysql-client-core Description: MariaDB database core client binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database @@ -544,7 +544,7 @@ Replaces: mariadb-client (<< ${source:Version}), percona-xtradb-cluster-server-5.7, virtual-mysql-client Provides: default-mysql-client, - mariadb-client-10.10, + mariadb-client-10.11, virtual-mysql-client Recommends: libdbd-mariadb-perl | libdbd-mysql-perl, libdbi-perl, @@ -658,7 +658,7 @@ Replaces: mariadb-client (<< ${source:Version}), percona-xtradb-cluster-server-5.7, virtual-mysql-server-core Provides: default-mysql-server-core, - mariadb-server-core-10.10, + mariadb-server-core-10.11, virtual-mysql-server-core Description: MariaDB database core server files MariaDB is a fast, stable and true multi-user, multi-threaded SQL database @@ -771,7 +771,7 @@ Replaces: handlersocket-mysql-5.5, percona-xtradb-cluster-server-5.7, virtual-mysql-server Provides: default-mysql-server, - mariadb-server-10.10, + mariadb-server-10.11, virtual-mysql-server Description: MariaDB database server binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml index d7ea01ea76055..c0c6116df5aef 100644 --- a/debian/salsa-ci.yml +++ b/debian/salsa-ci.yml @@ -494,7 +494,7 @@ mysql-8.0 Jammy to mariadb upgrade: variables: - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ -mariadb.org-10.7 to mariadb-10.10 upgrade: +mariadb.org-10.7 to mariadb-10.11 upgrade: stage: upgrade extras needs: - job: build @@ -569,12 +569,12 @@ mariadb.org-10.6 to mariadb-10.8 upgrade: variables: - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ allow_failure: true - # Installation on Sid fails on missing liburing1 because upstream 10.10 + # Installation on Sid fails on missing liburing1 because upstream 10.11 # MariaDB.org buildbot has not run 'apt upgrade' for a long time. - # Remove this allow_failure once buildbot has built a new 10.10 + # Remove this allow_failure once buildbot has built a new 10.11 # release using latest liburing-dev in Debian Sid. -mariadb.org-10.5 to mariadb-10.10 upgrade: +mariadb.org-10.5 to mariadb-10.11 upgrade: stage: upgrade extras needs: - job: build diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides index b71c56d95c0b9..fda0b24baa975 100644 --- a/debian/source/lintian-overrides +++ b/debian/source/lintian-overrides @@ -10,22 +10,22 @@ version-substvar-for-external-package mariadb-client-10.9 -> mysql-client-core-5 version-substvar-for-external-package mariadb-client-10.9 -> mysql-client-core-8.* version-substvar-for-external-package libmariadbd-dev -> libmariadbclient-dev # Intentional version-substvar-for-external-package as long as mariadb-server -# provides mariadb-server-10.10 and mariadb-client provides mariadb-client-10.10 -version-substvar-for-external-package Conflicts (line 408) ${source:Version} mariadb-client -> mariadb-client-10.10 -version-substvar-for-external-package Conflicts (line 575) ${source:Version} mariadb-server-core -> mariadb-server-core-10.10 -version-substvar-for-external-package Conflicts (line 711) ${source:Version} mariadb-server -> mariadb-server-10.10 +# provides mariadb-server-10.11 and mariadb-client provides mariadb-client-10.11 +version-substvar-for-external-package Conflicts (line 408) ${source:Version} mariadb-client -> mariadb-client-10.11 +version-substvar-for-external-package Conflicts (line 575) ${source:Version} mariadb-server-core -> mariadb-server-core-10.11 +version-substvar-for-external-package Conflicts (line 711) ${source:Version} mariadb-server -> mariadb-server-10.11 version-substvar-for-external-package Conflicts (line 95) ${source:Version} libmariadb-dev-compat -> libmariadbclient-dev version-substvar-for-external-package Replaces (line 109) ${source:Version} libmariadb-dev-compat -> libmariadbclient-dev -version-substvar-for-external-package Replaces (line 330) ${source:Version} mariadb-client-core -> mariadb-client-10.10 -version-substvar-for-external-package Replaces (line 330) ${source:Version} mariadb-client-core -> mariadb-server-core-10.10 -version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-client-10.10 -version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-client-core-10.10 -version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-server-10.10 -version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-server-core-10.10 -version-substvar-for-external-package Replaces (line 626) ${source:Version} mariadb-server-core -> mariadb-client-10.10 -version-substvar-for-external-package Replaces (line 626) ${source:Version} mariadb-server-core -> mariadb-server-10.10 -version-substvar-for-external-package Replaces (line 748) ${source:Version} mariadb-server -> mariadb-client-10.10 -version-substvar-for-external-package Replaces (line 748) ${source:Version} mariadb-server -> mariadb-server-10.10 +version-substvar-for-external-package Replaces (line 330) ${source:Version} mariadb-client-core -> mariadb-client-10.11 +version-substvar-for-external-package Replaces (line 330) ${source:Version} mariadb-client-core -> mariadb-server-core-10.11 +version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-client-10.11 +version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-client-core-10.11 +version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-server-10.11 +version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-server-core-10.11 +version-substvar-for-external-package Replaces (line 626) ${source:Version} mariadb-server-core -> mariadb-client-10.11 +version-substvar-for-external-package Replaces (line 626) ${source:Version} mariadb-server-core -> mariadb-server-10.11 +version-substvar-for-external-package Replaces (line 748) ${source:Version} mariadb-server -> mariadb-client-10.11 +version-substvar-for-external-package Replaces (line 748) ${source:Version} mariadb-server -> mariadb-server-10.11 # ColumnStore not used in Debian, safe to ignore. Reported upstream in https://jira.mariadb.org/browse/MDEV-24124 source-is-missing storage/columnstore/columnstore/utils/jemalloc/libjemalloc.so.2 # Must be fixed upstream From bc563f1a4b0b38de3b41fd0f0d3d8b7f1aacbd8b Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 16 Aug 2022 15:39:15 +0200 Subject: [PATCH 004/113] Fix test result. --- mysql-test/suite/sys_vars/r/sysvars_star.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/sys_vars/r/sysvars_star.result b/mysql-test/suite/sys_vars/r/sysvars_star.result index 54af0aa301424..b8a49a089b409 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_star.result +++ b/mysql-test/suite/sys_vars/r/sysvars_star.result @@ -60,7 +60,7 @@ VARIABLE_NAME PLUGIN_MATURITY SESSION_VALUE NULL GLOBAL_VALUE alpha GLOBAL_VALUE_ORIGIN CONFIG -DEFAULT_VALUE beta +DEFAULT_VALUE experimental VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded From 80fbd0ee94a507009cc679ba3534d9d10313678c Mon Sep 17 00:00:00 2001 From: NTH19 <74389817+NTH19@users.noreply.github.com> Date: Sat, 27 Aug 2022 17:19:16 +0800 Subject: [PATCH 005/113] Remove redundant variable (#2237) --- strings/ctype-simple.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 28405409e2dee..064ca50a13da9 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -176,7 +176,6 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, size_t a_length, { const uchar *map= cs->sort_order, *end; size_t length; - int res; end= a + (length= MY_MIN(a_length, b_length)); while (a < end) @@ -184,7 +183,6 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, size_t a_length, if (map[*a++] != map[*b++]) return ((int) map[a[-1]] - (int) map[b[-1]]); } - res= 0; if (a_length != b_length) { int swap= 1; @@ -198,15 +196,14 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, size_t a_length, a_length= b_length; a= b; swap= -1; /* swap sign of result */ - res= -res; } for (end= a + a_length-length; a < end ; a++) { if (map[*a] != map[' ']) - return (map[*a] < map[' ']) ? -swap : swap; + return (map[*a] < map[' ']) ? -swap : swap; } } - return res; + return 0; } From 5369df741b3a87d7b262aafe95438b33ed124295 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Wed, 31 Aug 2022 04:08:34 -0400 Subject: [PATCH 006/113] Remove FreeBSD CMake file (#2247) FreeBSD has libexecinfo as a system library. --- cmake/os/FreeBSD.cmake | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 cmake/os/FreeBSD.cmake diff --git a/cmake/os/FreeBSD.cmake b/cmake/os/FreeBSD.cmake deleted file mode 100644 index e1c764692bc53..0000000000000 --- a/cmake/os/FreeBSD.cmake +++ /dev/null @@ -1,30 +0,0 @@ - -# Copyright (c) 2010, 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 Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA - -# This file includes FreeBSD specific options and quirks, related to system checks - -# Should not be needed any more, but kept for easy resurrection if needed -# #Legacy option, maybe not needed anymore , taken as is from autotools build -# ADD_DEFINITIONS(-DNET_RETRY_COUNT=1000000) - -# The below was used for really old versions of FreeBSD, roughly: before 5.1.9 -# ADD_DEFINITIONS(-DHAVE_BROKEN_REALPATH) - -# Find libexecinfo (library that contains backtrace_symbols etc) -SET(EXECINFO_ROOT /usr/local CACHE INTERNAL "Where to find execinfo library and header") -INCLUDE_DIRECTORIES(${EXECINFO_ROOT}/include) -SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${EXECINFO_ROOT}/include) -SET(ENV{LIB} "$ENV{LIB}:${EXECINFO_ROOT}/lib") From f02af1d2295f108d96671b5a4f731ec998002dd5 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:02 +0300 Subject: [PATCH 007/113] MDEV-25292 Refactoring: moved select_field_count into Alter_info. There is a need in MDEV-25292 to have both C_ALTER_TABLE and select_field_count in one call. Semantically creation mode and field count are two different things. Making creation mode negative constants and field count positive variable into one parameter seems to be a lazy hack for not making the second parameter. select_count does not make sense without alter_info->create_list, so the natural way is to hold it in Alter_info too. select_count is now stored in member select_field_count. --- sql/handler.cc | 9 ++++----- sql/handler.h | 6 ++---- sql/sql_alter.h | 8 ++++++++ sql/sql_insert.cc | 7 +++---- sql/sql_table.cc | 5 ++--- sql/sql_table.h | 7 +++---- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 5743fc2a45526..47fa92a0d2f2e 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -8187,7 +8187,7 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields( bool Table_scope_and_contents_source_st::vers_check_system_fields( THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, - const Lex_table_name &db, int select_count) + const Lex_table_name &db) { if (!(options & HA_VERSIONED_TABLE)) return false; @@ -8208,7 +8208,7 @@ bool Table_scope_and_contents_source_st::vers_check_system_fields( SELECT go last there. */ bool is_dup= false; - if (fieldnr >= alter_info->create_list.elements - select_count) + if (fieldnr >= alter_info->field_count()) { List_iterator dup_it(alter_info->create_list); for (Create_field *dup= dup_it++; !is_dup && dup != f; dup= dup_it++) @@ -8616,10 +8616,9 @@ bool Table_period_info::check_field(const Create_field* f, bool Table_scope_and_contents_source_st::check_fields( THD *thd, Alter_info *alter_info, - const Lex_table_name &table_name, const Lex_table_name &db, int select_count) + const Lex_table_name &table_name, const Lex_table_name &db) { - return vers_check_system_fields(thd, alter_info, - table_name, db, select_count) || + return vers_check_system_fields(thd, alter_info, table_name, db) || check_period_fields(thd, alter_info); } diff --git a/sql/handler.h b/sql/handler.h index 60c6195e68e48..027d8351831e5 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2257,8 +2257,7 @@ struct Table_scope_and_contents_source_st: bool fix_period_fields(THD *thd, Alter_info *alter_info); bool check_fields(THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, - const Lex_table_name &db, - int select_count= 0); + const Lex_table_name &db); bool check_period_fields(THD *thd, Alter_info *alter_info); bool vers_fix_system_fields(THD *thd, Alter_info *alter_info, @@ -2266,8 +2265,7 @@ struct Table_scope_and_contents_source_st: bool vers_check_system_fields(THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, - const Lex_table_name &db, - int select_count= 0); + const Lex_table_name &db); }; diff --git a/sql/sql_alter.h b/sql/sql_alter.h index bf1edd4c964b2..142b71c725a54 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -96,6 +96,7 @@ class Alter_info List alter_rename_key_list; // List of columns, used by both CREATE and ALTER TABLE. List create_list; + uint select_field_count; // Indexes whose ignorability needs to be changed. List alter_index_ignorability_list; List check_constraint_list; @@ -118,6 +119,7 @@ class Alter_info Alter_info() : + select_field_count(0), flags(0), partition_flags(0), keys_onoff(LEAVE_AS_IS), num_parts(0), @@ -134,6 +136,7 @@ class Alter_info create_list.empty(); alter_index_ignorability_list.empty(); check_constraint_list.empty(); + select_field_count= 0; flags= 0; partition_flags= 0; keys_onoff= LEAVE_AS_IS; @@ -234,6 +237,11 @@ class Alter_info */ enum_alter_table_algorithm algorithm(const THD *thd) const; + uint field_count() const + { + return create_list.elements - select_field_count; + } + private: Alter_info &operator=(const Alter_info &rhs); // not implemented Alter_info(const Alter_info &rhs); // not implemented diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index baa7f78326678..d3919a161ed91 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4490,7 +4490,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, TABLE tmp_table; // Used during 'Create_field()' TABLE_SHARE share; TABLE *table= 0; - uint select_field_count= items->elements; + alter_info->select_field_count= items->elements; /* Add selected items to field list */ List_iterator_fast it(*items); Item *item; @@ -4550,8 +4550,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, if (create_info->check_fields(thd, alter_info, create_table->table_name, - create_table->db, - select_field_count)) + create_table->db)) DBUG_RETURN(NULL); DEBUG_SYNC(thd,"create_table_select_before_create"); @@ -4587,7 +4586,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, &create_table->db, &create_table->table_name, create_info, alter_info, NULL, - select_field_count, create_table)) + C_ORDINARY_CREATE, create_table)) { DEBUG_SYNC(thd,"create_table_select_before_open"); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c934d58087af3..7cbc5fbada0ea 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2741,7 +2741,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, List_iterator_fast it(alter_info->create_list); List_iterator it2(alter_info->create_list); uint total_uneven_bit_length= 0; - int select_field_count= C_CREATE_SELECT(create_table_mode); bool tmp_table= create_table_mode == C_ALTER_TABLE; const bool create_simple= thd->lex->create_simple(); bool is_hash_field_needed= false; @@ -2781,7 +2780,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(TRUE); } - select_field_pos= alter_info->create_list.elements - select_field_count; + select_field_pos= alter_info->field_count(); null_fields= 0; create_info->varchar= 0; max_key_length= file->max_key_length(); @@ -2956,7 +2955,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, from the select tables. This order may differ on master and slave. We therefore mark it as unsafe. */ - if (select_field_count > 0 && auto_increment) + if (alter_info->select_field_count > 0 && auto_increment) thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC); /* Create keys */ diff --git a/sql/sql_table.h b/sql/sql_table.h index c9e4d969482fa..4d74aadc02a4b 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -124,11 +124,10 @@ bool add_keyword_to_query(THD *thd, String *result, const LEX_CSTRING *keyword, (which should be the number of fields in the SELECT ... part), and other cases use constants as defined below. */ -#define C_CREATE_SELECT(X) ((X) > 0 ? (X) : 0) #define C_ORDINARY_CREATE 0 -#define C_ALTER_TABLE -1 -#define C_ALTER_TABLE_FRM_ONLY -2 -#define C_ASSISTED_DISCOVERY -3 +#define C_ALTER_TABLE 1 +#define C_ALTER_TABLE_FRM_ONLY 2 +#define C_ASSISTED_DISCOVERY 3 int mysql_create_table_no_lock(THD *thd, DDL_LOG_STATE *ddl_log_state, From 595dad83ad3c23879c59deec1173ea16b47871ed Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:03 +0300 Subject: [PATCH 008/113] MDEV-25292 Cleanups ddl_log_write_execute_entry() cleanup Rename functions renamed: do_rename() -> rename_table_and_triggers() do_rename_temporary() -> rename_temporary_table() check_rename() -> rename_check_preconditions() --- sql/ddl_log.cc | 4 ++-- sql/ddl_log.h | 6 ----- sql/handler.cc | 4 ++-- sql/log_event.h | 4 +++- sql/sql_class.cc | 2 +- sql/sql_partition.cc | 10 ++++---- sql/sql_partition_admin.cc | 2 +- sql/sql_rename.cc | 49 +++++++++++++++++++------------------- sql/sql_table.cc | 2 +- 9 files changed, 39 insertions(+), 44 deletions(-) diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index 2ac4e2561125e..80f2e4d2e3ebb 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -2761,7 +2761,7 @@ int ddl_log_execute_recovery() if (ddl_log_entry.entry_type == DDL_LOG_EXECUTE_CODE) { /* - Remeber information about executive ddl log entry, + Remember information about executive ddl log entry, used for binary logging during recovery */ recovery_state.execute_entry_pos= i; @@ -3532,7 +3532,7 @@ bool ddl_log_store_query(THD *thd, DDL_LOG_STATE *ddl_state, ddl_log_entry.extra_name.length= 0; max_query_length= ddl_log_free_space_in_entry(&ddl_log_entry); } - if (ddl_log_write_execute_entry(first_entry->entry_pos, + if (ddl_log_write_execute_entry(first_entry->entry_pos, 0, &ddl_state->execute_entry)) goto err; diff --git a/sql/ddl_log.h b/sql/ddl_log.h index 9960855a813a9..a74d2f1e492fa 100644 --- a/sql/ddl_log.h +++ b/sql/ddl_log.h @@ -264,12 +264,6 @@ bool ddl_log_write_entry(DDL_LOG_ENTRY *ddl_log_entry, bool ddl_log_write_execute_entry(uint first_entry, uint cond_entry, DDL_LOG_MEMORY_ENTRY** active_entry); -inline -bool ddl_log_write_execute_entry(uint first_entry, - DDL_LOG_MEMORY_ENTRY **active_entry) -{ - return ddl_log_write_execute_entry(first_entry, 0, active_entry); -} bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry); void ddl_log_complete(DDL_LOG_STATE *ddl_log_state); diff --git a/sql/handler.cc b/sql/handler.cc index 47fa92a0d2f2e..9835d42c8c5d2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -8618,8 +8618,8 @@ bool Table_scope_and_contents_source_st::check_fields( THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, const Lex_table_name &db) { - return vers_check_system_fields(thd, alter_info, table_name, db) || - check_period_fields(thd, alter_info); + return (vers_check_system_fields(thd, alter_info, table_name, db) || + check_period_fields(thd, alter_info)); } bool Table_scope_and_contents_source_st::check_period_fields( diff --git a/sql/log_event.h b/sql/log_event.h index 6a2f57f60e6e7..81b6f6f3fa364 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -680,9 +680,11 @@ enum Log_event_type /* New MySQL/Sun events are to be added right above this comment */ MYSQL_EVENTS_END, - MARIA_EVENTS_BEGIN= 160, /* New Maria event numbers start from here */ ANNOTATE_ROWS_EVENT= 160, + /* Keep that here for GDB to display ANNOTATE_ROWS_EVENT */ + MARIA_EVENTS_BEGIN= 160, + /* Binlog checkpoint event. Used for XA crash recovery on the master, not used in replication. diff --git a/sql/sql_class.cc b/sql/sql_class.cc index a9f6f26173dc6..65a417e2afc7a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2911,7 +2911,7 @@ struct Item_change_record: public ilink /* - Register an item tree tree transformation, performed by the query + Register an item tree transformation, performed by the query optimizer. We need a pointer to runtime_memroot because it may be != thd->mem_root (due to possible set_n_backup_active_arena called for thd). */ diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 77f46187bbc40..3eb78b2439b85 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6694,7 +6694,7 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt) goto error; log_entry= part_info->list; part_info->main_entry= log_entry; - if (ddl_log_write_execute_entry(log_entry->entry_pos, + if (ddl_log_write_execute_entry(log_entry->entry_pos, 0, &exec_log_entry)) goto error; release_part_info_log_entries(old_first_log_entry); @@ -6749,7 +6749,7 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt) goto error; log_entry= part_info->list; part_info->main_entry= log_entry; - if (ddl_log_write_execute_entry(log_entry->entry_pos, + if (ddl_log_write_execute_entry(log_entry->entry_pos, 0, &exec_log_entry)) goto error; release_part_info_log_entries(old_first_log_entry); @@ -6781,7 +6781,7 @@ static bool write_log_convert_partition(ALTER_PARTITION_PARAM_TYPE *lpt) if (write_log_convert_partition(lpt, &next_entry, (const char*)path)) goto error; DBUG_ASSERT(next_entry == part_info->list->entry_pos); - if (ddl_log_write_execute_entry(part_info->list->entry_pos, + if (ddl_log_write_execute_entry(part_info->list->entry_pos, 0, &part_info->execute_entry)) goto error; mysql_mutex_unlock(&LOCK_gdl); @@ -6836,7 +6836,7 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) goto error; log_entry= part_info->list; - if (ddl_log_write_execute_entry(log_entry->entry_pos, + if (ddl_log_write_execute_entry(log_entry->entry_pos, 0, &part_info->execute_entry)) goto error; mysql_mutex_unlock(&LOCK_gdl); @@ -6903,7 +6903,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) log_entry= part_info->list; part_info->main_entry= log_entry; /* Overwrite the revert execute log entry with this retry execute entry */ - if (ddl_log_write_execute_entry(log_entry->entry_pos, + if (ddl_log_write_execute_entry(log_entry->entry_pos, 0, &exec_log_entry)) goto error; release_part_info_log_entries(old_first_log_entry); diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 66f4311621147..842208986625e 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -382,7 +382,7 @@ static bool exchange_name_with_ddl_log(THD *thd, DBUG_EXECUTE_IF("exchange_partition_fail_2", goto err_no_execute_written;); DBUG_EXECUTE_IF("exchange_partition_abort_2", DBUG_SUICIDE();); - if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos, + if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos, 0, &exec_log_entry))) goto err_no_execute_written; /* ddl_log is written and synced */ diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 094578874a855..1ba92b5033da9 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -208,10 +208,10 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent, static bool -do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table) +rename_temporary_table(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table) { LEX_CSTRING *new_alias; - DBUG_ENTER("do_rename_temporary"); + DBUG_ENTER("rename_temporary_table"); new_alias= (lower_case_table_names == 2) ? &new_table->alias : &new_table->table_name; @@ -228,7 +228,7 @@ do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table) /** - Parameters for do_rename + Parameters for rename_table_and_triggers() */ struct rename_param @@ -240,8 +240,6 @@ struct rename_param /** - check_rename() - Check pre-conditions for rename - From table should exists - To table should not exists. @@ -258,14 +256,14 @@ struct rename_param */ static int -check_rename(THD *thd, rename_param *param, - TABLE_LIST *ren_table, - const LEX_CSTRING *new_db, - const LEX_CSTRING *new_table_name, - const LEX_CSTRING *new_table_alias, - bool if_exists) +rename_check_preconditions(THD *thd, rename_param *param, + TABLE_LIST *ren_table, + const LEX_CSTRING *new_db, + const LEX_CSTRING *new_table_name, + const LEX_CSTRING *new_table_alias, + bool if_exists) { - DBUG_ENTER("check_rename"); + DBUG_ENTER("rename_check_preconditions"); DBUG_PRINT("enter", ("if_exists: %d", (int) if_exists)); @@ -316,7 +314,6 @@ check_rename(THD *thd, rename_param *param, Rename a single table or a view SYNPOSIS - do_rename() thd Thread handle ren_table A table/view to be renamed new_db The database to which the table to be moved to @@ -334,15 +331,16 @@ check_rename(THD *thd, rename_param *param, */ static bool -do_rename(THD *thd, rename_param *param, DDL_LOG_STATE *ddl_log_state, - TABLE_LIST *ren_table, const LEX_CSTRING *new_db, - bool skip_error, bool *force_if_exists) +rename_table_and_triggers(THD *thd, rename_param *param, + DDL_LOG_STATE *ddl_log_state, + TABLE_LIST *ren_table, const LEX_CSTRING *new_db, + bool skip_error, bool *force_if_exists) { int rc= 1; handlerton *hton; LEX_CSTRING *old_alias, *new_alias; TRIGGER_RENAME_PARAM rename_param; - DBUG_ENTER("do_rename"); + DBUG_ENTER("rename_table_and_triggers"); DBUG_PRINT("enter", ("skip_error: %d", (int) skip_error)); old_alias= ¶m->old_alias; @@ -515,24 +513,25 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state, pair->from= ren_table; pair->to= new_table; - if (do_rename_temporary(thd, ren_table, new_table)) + if (rename_temporary_table(thd, ren_table, new_table)) goto revert_rename; } else { int error; rename_param param; - error= check_rename(thd, ¶m, ren_table, &new_table->db, - &new_table->table_name, - &new_table->alias, (skip_error || if_exists)); + error= rename_check_preconditions(thd, ¶m, ren_table, + &new_table->db, &new_table->table_name, + &new_table->alias, + (skip_error || if_exists)); if (error < 0) continue; // Ignore rename (if exists) if (error > 0) goto revert_rename; - if (do_rename(thd, ¶m, ddl_log_state, - ren_table, &new_table->db, - skip_error, force_if_exists)) + if (rename_table_and_triggers(thd, ¶m, ddl_log_state, + ren_table, &new_table->db, + skip_error, force_if_exists)) goto revert_rename; } } @@ -542,7 +541,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state, /* Revert temporary tables. Normal tables are reverted in the caller */ List_iterator_fast it(tmp_tables); while (TABLE_PAIR *pair= it++) - do_rename_temporary(thd, pair->to, pair->from); + rename_temporary_table(thd, pair->to, pair->from); DBUG_RETURN(1); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 7cbc5fbada0ea..d42ef7fedae24 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -869,7 +869,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) if (write_log_replace_frm(lpt, part_info->list->entry_pos, (const char*) bak_path, (const char*) path) || - ddl_log_write_execute_entry(part_info->list->entry_pos, + ddl_log_write_execute_entry(part_info->list->entry_pos, 0, &part_info->execute_entry)) { mysql_mutex_unlock(&LOCK_gdl); From 65e0d0ea66180168eb6539bb11a78aafb7247bd4 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:03 +0300 Subject: [PATCH 009/113] MDEV-25292 Removed thd argument in ddl_log functions --- sql/ddl_log.cc | 41 ++++++++++++++++++++--------------------- sql/ddl_log.h | 30 ++++++++++++++---------------- sql/sql_db.cc | 2 +- sql/sql_rename.cc | 4 ++-- sql/sql_table.cc | 18 +++++++++--------- sql/sql_trigger.cc | 8 ++++---- sql/sql_view.cc | 8 ++++---- 7 files changed, 54 insertions(+), 57 deletions(-) diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index 80f2e4d2e3ebb..35a3f54e61f11 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -3041,7 +3041,7 @@ static bool ddl_log_write(DDL_LOG_STATE *ddl_state, mysql_mutex_lock(&LOCK_gdl); error= ((ddl_log_write_entry(ddl_log_entry, &log_entry)) || - ddl_log_write_execute_entry(log_entry->entry_pos, + ddl_log_write_execute_entry(log_entry->entry_pos, 0, &ddl_state->execute_entry)); mysql_mutex_unlock(&LOCK_gdl); if (error) @@ -3060,7 +3060,7 @@ static bool ddl_log_write(DDL_LOG_STATE *ddl_state, Logging of rename table */ -bool ddl_log_rename_table(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, @@ -3089,7 +3089,7 @@ bool ddl_log_rename_table(THD *thd, DDL_LOG_STATE *ddl_state, Logging of rename view */ -bool ddl_log_rename_view(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_rename_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, const LEX_CSTRING *new_db, @@ -3120,7 +3120,7 @@ bool ddl_log_rename_view(THD *thd, DDL_LOG_STATE *ddl_state, is in original delete order. */ -static bool ddl_log_drop_init(THD *thd, DDL_LOG_STATE *ddl_state, +static bool ddl_log_drop_init(DDL_LOG_STATE *ddl_state, ddl_log_action_code action_code, const LEX_CSTRING *db, const LEX_CSTRING *comment) @@ -3138,18 +3138,18 @@ static bool ddl_log_drop_init(THD *thd, DDL_LOG_STATE *ddl_state, } -bool ddl_log_drop_table_init(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_table_init(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db, const LEX_CSTRING *comment) { - return ddl_log_drop_init(thd, ddl_state, DDL_LOG_DROP_INIT_ACTION, + return ddl_log_drop_init(ddl_state, DDL_LOG_DROP_INIT_ACTION, db, comment); } -bool ddl_log_drop_view_init(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_view_init(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db) { - return ddl_log_drop_init(thd, ddl_state, DDL_LOG_DROP_INIT_ACTION, + return ddl_log_drop_init(ddl_state, DDL_LOG_DROP_INIT_ACTION, db, &empty_clex_str); } @@ -3163,7 +3163,7 @@ bool ddl_log_drop_view_init(THD *thd, DDL_LOG_STATE *ddl_state, See also comment before ddl_log_drop_init(). */ -static bool ddl_log_drop(THD *thd, DDL_LOG_STATE *ddl_state, +static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, ddl_log_action_code action_code, uint phase, handlerton *hton, @@ -3209,32 +3209,32 @@ static bool ddl_log_drop(THD *thd, DDL_LOG_STATE *ddl_state, } -bool ddl_log_drop_table(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, const LEX_CSTRING *table) { DBUG_ENTER("ddl_log_drop_table"); - DBUG_RETURN(ddl_log_drop(thd, ddl_state, + DBUG_RETURN(ddl_log_drop(ddl_state, DDL_LOG_DROP_TABLE_ACTION, DDL_DROP_PHASE_TABLE, hton, path, db, table)); } -bool ddl_log_drop_view(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, const LEX_CSTRING *db, const LEX_CSTRING *table) { DBUG_ENTER("ddl_log_drop_view"); - DBUG_RETURN(ddl_log_drop(thd, ddl_state, + DBUG_RETURN(ddl_log_drop(ddl_state, DDL_LOG_DROP_VIEW_ACTION, 0, (handlerton*) 0, path, db, table)); } -bool ddl_log_drop_trigger(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_trigger(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db, const LEX_CSTRING *table, const LEX_CSTRING *trigger_name, @@ -3284,7 +3284,7 @@ bool ddl_log_drop_trigger(THD *thd, DDL_LOG_STATE *ddl_state, link to the previous entries (not setting ddl_log_entry.next_entry) */ -bool ddl_log_drop_db(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_db(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db, const LEX_CSTRING *path) { DDL_LOG_ENTRY ddl_log_entry; @@ -3305,7 +3305,7 @@ bool ddl_log_drop_db(THD *thd, DDL_LOG_STATE *ddl_state, example when deleting a table that was discovered. */ -bool ddl_log_create_table(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_create_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, @@ -3333,7 +3333,7 @@ bool ddl_log_create_table(THD *thd, DDL_LOG_STATE *ddl_state, Log CREATE VIEW */ -bool ddl_log_create_view(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_create_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, enum_ddl_log_create_view_phase phase) { @@ -3351,14 +3351,13 @@ bool ddl_log_create_view(THD *thd, DDL_LOG_STATE *ddl_state, /** Log creation of temporary file that should be deleted during recovery - @param thd Thread handler @param ddl_log_state ddl_state @param path Path to file to be deleted @param depending_state If not NULL, then do not delete the temp file if this entry exists and is active. */ -bool ddl_log_delete_tmp_file(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_delete_tmp_file(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, DDL_LOG_STATE *depending_state) { @@ -3379,7 +3378,7 @@ bool ddl_log_delete_tmp_file(THD *thd, DDL_LOG_STATE *ddl_state, Log CREATE TRIGGER */ -bool ddl_log_create_trigger(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_create_trigger(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db, const LEX_CSTRING *table, const LEX_CSTRING *trigger_name, enum_ddl_log_create_trigger_phase phase) @@ -3404,7 +3403,7 @@ bool ddl_log_create_trigger(THD *thd, DDL_LOG_STATE *ddl_state, this is the final table name */ -bool ddl_log_alter_table(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_alter_table(DDL_LOG_STATE *ddl_state, handlerton *org_hton, const LEX_CSTRING *db, const LEX_CSTRING *table, handlerton *new_hton, diff --git a/sql/ddl_log.h b/sql/ddl_log.h index a74d2f1e492fa..87b7af57102ee 100644 --- a/sql/ddl_log.h +++ b/sql/ddl_log.h @@ -281,61 +281,59 @@ bool ddl_log_execute_entry(THD *thd, uint first_entry); void ddl_log_add_entry(DDL_LOG_STATE *state, DDL_LOG_MEMORY_ENTRY *log_entry); void ddl_log_release_entries(DDL_LOG_STATE *ddl_log_state); -bool ddl_log_rename_table(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, const LEX_CSTRING *new_db, const LEX_CSTRING *new_alias); -bool ddl_log_rename_view(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_rename_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, const LEX_CSTRING *new_db, const LEX_CSTRING *new_alias); -bool ddl_log_drop_table_init(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_table_init(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db, const LEX_CSTRING *comment); -bool ddl_log_drop_view_init(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_view_init(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db); -bool ddl_log_drop_table(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, const LEX_CSTRING *table); -bool ddl_log_drop_view(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, const LEX_CSTRING *db, const LEX_CSTRING *table); -bool ddl_log_drop_trigger(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_trigger(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db, const LEX_CSTRING *table, const LEX_CSTRING *trigger_name, const LEX_CSTRING *query); -bool ddl_log_drop_view(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, const LEX_CSTRING *db, const LEX_CSTRING *table); -bool ddl_log_drop_view(THD *thd, DDL_LOG_STATE *ddl_state, - const LEX_CSTRING *db); -bool ddl_log_drop_db(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_drop_db(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db, const LEX_CSTRING *path); -bool ddl_log_create_table(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_create_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, const LEX_CSTRING *table, bool only_frm); -bool ddl_log_create_view(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_create_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, enum_ddl_log_create_view_phase phase); -bool ddl_log_delete_tmp_file(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_delete_tmp_file(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, DDL_LOG_STATE *depending_state); -bool ddl_log_create_trigger(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_create_trigger(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *db, const LEX_CSTRING *table, const LEX_CSTRING *trigger_name, enum_ddl_log_create_trigger_phase phase); -bool ddl_log_alter_table(THD *thd, DDL_LOG_STATE *ddl_state, +bool ddl_log_alter_table(DDL_LOG_STATE *ddl_state, handlerton *org_hton, const LEX_CSTRING *db, const LEX_CSTRING *table, handlerton *new_hton, diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 9da1ac5ca7796..7be4ba00b8618 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1129,7 +1129,7 @@ mysql_rm_db_internal(THD *thd, const LEX_CSTRING *db, bool if_exists, debug_crash_here("ddl_log_drop_after_drop_tables"); LEX_CSTRING cpath{ path, path_length}; - ddl_log_drop_db(thd, &ddl_log_state, &rm_db, &cpath); + ddl_log_drop_db(&ddl_log_state, &rm_db, &cpath); drop_database_objects(thd, &cpath, &rm_db, rm_mysql_schema); diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 1ba92b5033da9..5b0f77f5bcb99 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -373,7 +373,7 @@ rename_table_and_triggers(THD *thd, rename_param *param, thd->replication_flags= 0; - if (ddl_log_rename_table(thd, ddl_log_state, hton, + if (ddl_log_rename_table(ddl_log_state, hton, &ren_table->db, old_alias, new_db, new_alias)) DBUG_RETURN(1); @@ -437,7 +437,7 @@ rename_table_and_triggers(THD *thd, rename_param *param, DBUG_RETURN(1); } - ddl_log_rename_view(thd, ddl_log_state, &ren_table->db, + ddl_log_rename_view(ddl_log_state, &ren_table->db, &ren_table->table_name, new_db, new_alias); debug_crash_here("ddl_log_rename_before_rename_view"); rc= mysql_rename_view(thd, new_db, new_alias, &ren_table->db, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d42ef7fedae24..0d6f7e7a2c068 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -819,7 +819,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) create_info->db_type= work_part_info->default_engine_type; /* NOTE: partitioned temporary tables are not supported. */ DBUG_ASSERT(!create_info->tmp_table()); - if (ddl_log_create_table(thd, part_info, create_info->db_type, &new_path, + if (ddl_log_create_table(part_info, create_info->db_type, &new_path, &alter_ctx->new_db, &alter_ctx->new_name, true) || ERROR_INJECT("create_before_create_frm")) DBUG_RETURN(TRUE); @@ -1536,7 +1536,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, if (!table_count++) { LEX_CSTRING comment= {comment_start, (size_t) comment_len}; - if (ddl_log_drop_table_init(thd, ddl_log_state, current_db, &comment)) + if (ddl_log_drop_table_init(ddl_log_state, current_db, &comment)) { error= 1; goto err; @@ -1594,10 +1594,10 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool enoent_warning= !dont_log_query && !(hton && hton->discover_table); if (was_view) - res= ddl_log_drop_view(thd, ddl_log_state, &cpath, &db, + res= ddl_log_drop_view(ddl_log_state, &cpath, &db, &table_name); else - res= ddl_log_drop_table(thd, ddl_log_state, hton, &cpath, &db, + res= ddl_log_drop_table(ddl_log_state, hton, &cpath, &db, &table_name); if (res) { @@ -1675,7 +1675,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, int ferror= 0; DBUG_ASSERT(!was_view); - if (ddl_log_drop_table(thd, ddl_log_state, 0, &cpath, &db, + if (ddl_log_drop_table(ddl_log_state, 0, &cpath, &db, &table_name)) { error= -1; @@ -4539,7 +4539,7 @@ int create_table_impl(THD *thd, .frm files are deleted */ if (ddl_log_state_create) - ddl_log_create_table(thd, ddl_log_state_create, (handlerton*) 0, &path, + ddl_log_create_table(ddl_log_state_create, (handlerton*) 0, &path, &db, &table_name, 1); ha_err= hton->discover_table_structure(hton, thd, &share, create_info); @@ -4564,7 +4564,7 @@ int create_table_impl(THD *thd, else { if (ddl_log_state_create) - ddl_log_create_table(thd, ddl_log_state_create, create_info->db_type, + ddl_log_create_table(ddl_log_state_create, create_info->db_type, &path, &db, &table_name, frm_only); debug_crash_here("ddl_log_create_before_create_frm"); @@ -9446,7 +9446,7 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list, close_all_tables_for_name(thd, table->s, HA_EXTRA_PREPARE_FOR_RENAME, NULL); - (void) ddl_log_rename_table(thd, &ddl_log_state, old_db_type, + (void) ddl_log_rename_table(&ddl_log_state, old_db_type, &alter_ctx->db, &alter_ctx->table_name, &alter_ctx->new_db, &alter_ctx->new_alias); if (mysql_rename_table(old_db_type, &alter_ctx->db, &alter_ctx->table_name, @@ -10508,7 +10508,7 @@ do_continue:; if (alter_ctx.is_table_renamed()) tmp_table= alter_ctx.new_alias; - if (ddl_log_alter_table(thd, &ddl_log_state, + if (ddl_log_alter_table(&ddl_log_state, old_db_type, &alter_ctx.db, &alter_ctx.table_name, new_db_type, diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 6685b91b02ec0..77035219d2f2e 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -980,7 +980,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, /* Use the filesystem to enforce trigger namespace constraints. */ trigger_exists= !access(trigname_file.str, F_OK); - ddl_log_create_trigger(thd, ddl_log_state, &tables->db, &tables->table_name, + ddl_log_create_trigger(ddl_log_state, &tables->db, &tables->table_name, &lex->spname->m_name, trigger_exists || table->triggers->count ? DDL_CREATE_TRIGGER_PHASE_DELETE_COPY : @@ -989,7 +989,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, /* Make a backup of the .TRG file that we can restore in case of crash */ if (table->triggers->count && (sql_backup_definition_file(&file, &backup_name) || - ddl_log_delete_tmp_file(thd, ddl_log_state_tmp_file, &backup_name, + ddl_log_delete_tmp_file(ddl_log_state_tmp_file, &backup_name, ddl_log_state))) DBUG_RETURN(true); @@ -1001,7 +1001,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, /* Make a backup of the .TRN file that we can restore in case of crash */ if (sql_backup_definition_file(&trigname_file, &backup_name) || - ddl_log_delete_tmp_file(thd, ddl_log_state_tmp_file, &backup_name, + ddl_log_delete_tmp_file(ddl_log_state_tmp_file, &backup_name, ddl_log_state)) DBUG_RETURN(true); ddl_log_update_phase(ddl_log_state, DDL_CREATE_TRIGGER_PHASE_OLD_COPIED); @@ -1345,7 +1345,7 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables, /* This code is executed in case of DROP TRIGGER */ lex_string_set3(&query, thd->query(), thd->query_length()); } - if (ddl_log_drop_trigger(thd, ddl_log_state, + if (ddl_log_drop_trigger(ddl_log_state, &tables->db, &tables->table_name, sp_name, &query)) goto err; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 6dedd5e85bed5..166b67b68164c 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -724,7 +724,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, if (backup_file_name[0]) { LEX_CSTRING cpath= {backup_file_name, strlen(backup_file_name) }; - ddl_log_delete_tmp_file(thd, &ddl_log_state_tmp_file, &cpath, + ddl_log_delete_tmp_file(&ddl_log_state_tmp_file, &cpath, &ddl_log_state); } debug_crash_here("ddl_log_create_before_binlog"); @@ -1189,7 +1189,7 @@ static int mysql_register_view(THD *thd, DDL_LOG_STATE *ddl_log_state, goto err; } - ddl_log_create_view(thd, ddl_log_state, &path, old_view_exists ? + ddl_log_create_view(ddl_log_state, &path, old_view_exists ? DDL_CREATE_VIEW_PHASE_DELETE_VIEW_COPY : DDL_CREATE_VIEW_PHASE_NO_OLD_VIEW); @@ -1939,10 +1939,10 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) } if (!view_count++) { - if (ddl_log_drop_view_init(thd, &ddl_log_state, &thd->db)) + if (ddl_log_drop_view_init(&ddl_log_state, &thd->db)) DBUG_RETURN(TRUE); } - if (ddl_log_drop_view(thd, &ddl_log_state, &cpath, &view->db, + if (ddl_log_drop_view(&ddl_log_state, &cpath, &view->db, &view->table_name)) DBUG_RETURN(TRUE); debug_crash_here("ddl_log_drop_before_delete_view"); From 409b8a86de45efc96377c618a99cff1301523150 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:03 +0300 Subject: [PATCH 010/113] MDEV-25292 ha_table_exists() cleanup and improvement Removed default values for arguments, added flags argument to specify filename flags (FN_TO_IS_TMP, FN_FROM_IS_TMP). --- sql/handler.cc | 4 ++-- sql/handler.h | 7 ++++--- sql/sql_acl.cc | 3 ++- sql/sql_base.cc | 5 +++-- sql/sql_db.cc | 3 ++- sql/sql_rename.cc | 4 ++-- sql/sql_show.cc | 2 +- sql/sql_table.cc | 8 +++++--- sql/sql_view.cc | 3 ++- 9 files changed, 23 insertions(+), 16 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 9835d42c8c5d2..6a42643919f05 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6201,7 +6201,7 @@ static my_bool discover_existence(THD *thd, plugin_ref plugin, bool ha_table_exists(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, LEX_CUSTRING *table_id, LEX_CSTRING *partition_engine_name, - handlerton **hton, bool *is_sequence) + handlerton **hton, bool *is_sequence, uint flags) { handlerton *dummy; bool dummy2; @@ -6256,7 +6256,7 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db, #endif char path[FN_REFLEN + 1]; size_t path_len = build_table_filename(path, sizeof(path) - 1, - db->str, table_name->str, "", 0); + db->str, table_name->str, "", flags); st_discover_existence_args args= {path, path_len, db->str, table_name->str, 0, true}; if (file_ext_exists(path, path_len, reg_ext)) diff --git a/sql/handler.h b/sql/handler.h index 027d8351831e5..3c7401a91995a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -5289,9 +5289,10 @@ int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp, Discovered_table_list *result, bool reusable); bool ha_table_exists(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, - LEX_CUSTRING *table_version= 0, - LEX_CSTRING *partition_engine_name= 0, - handlerton **hton= 0, bool *is_sequence= 0); + LEX_CUSTRING *table_version, + LEX_CSTRING *partition_engine_name, + handlerton **hton, bool *is_sequence, + uint flags); bool ha_check_if_updates_are_ignored(THD *thd, handlerton *hton, const char *op); #endif /* MYSQL_SERVER */ diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f75905f07e188..b4120879e830b 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -7111,7 +7111,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, { if (!(rights & CREATE_ACL)) { - if (!ha_table_exists(thd, &table_list->db, &table_list->table_name)) + if (!ha_table_exists(thd, &table_list->db, &table_list->table_name, + NULL, NULL, NULL, NULL, 0)) { my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db.str, table_list->alias.str); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 54296af5a0b6f..9279e2eccde01 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2008,7 +2008,8 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) if (table_list->open_strategy == TABLE_LIST::OPEN_IF_EXISTS) { - if (!ha_table_exists(thd, &table_list->db, &table_list->table_name)) + if (!ha_table_exists(thd, &table_list->db, &table_list->table_name, + NULL, NULL, NULL, NULL, 0)) DBUG_RETURN(FALSE); } else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB) @@ -4223,7 +4224,7 @@ static bool upgrade_lock_if_not_exists(THD *thd, DEBUG_SYNC(thd,"create_table_before_check_if_exists"); if (!create_info.or_replace() && ha_table_exists(thd, &create_table->db, &create_table->table_name, - NULL, NULL, &create_table->db_type)) + NULL, NULL, &create_table->db_type, NULL, 0)) { if (create_info.if_not_exists()) { diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 7be4ba00b8618..765509056b5b1 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1236,7 +1236,8 @@ mysql_rm_db_internal(THD *thd, const LEX_CSTRING *db, bool if_exists, char quoted_name[FN_REFLEN+3]; // Only write drop table to the binlog for tables that no longer exist. - if (ha_table_exists(thd, &tbl->db, &tbl->table_name)) + if (ha_table_exists(thd, &tbl->db, &tbl->table_name, + NULL, NULL, NULL, NULL, 0)) continue; tbl_name_len= my_snprintf(quoted_name, sizeof(quoted_name), "%`s", diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 5b0f77f5bcb99..5ed80d69ff8bc 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -281,7 +281,7 @@ rename_check_preconditions(THD *thd, rename_param *param, if (!ha_table_exists(thd, &ren_table->db, ¶m->old_alias, ¶m->old_version, NULL, - ¶m->from_table_hton) || + ¶m->from_table_hton, NULL, 0) || !param->from_table_hton) { my_error(ER_NO_SUCH_TABLE, MYF(if_exists ? ME_NOTE : 0), @@ -301,7 +301,7 @@ rename_check_preconditions(THD *thd, rename_param *param, DBUG_RETURN(-1); } - if (ha_table_exists(thd, new_db, ¶m->new_alias, NULL, NULL, 0)) + if (ha_table_exists(thd, new_db, ¶m->new_alias, NULL, NULL, NULL, NULL, 0)) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), param->new_alias.str); DBUG_RETURN(1); // This can't be skipped diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6290a47ee3075..ed82e6deae343 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4819,7 +4819,7 @@ static int fill_schema_table_names(THD *thd, TABLE_LIST *tables, bool is_sequence; if (ha_table_exists(thd, db_name, table_name, NULL, NULL, - &hton, &is_sequence)) + &hton, &is_sequence, 0)) { if (hton == view_pseudo_hton) table->field[3]->store(STRING_WITH_LEN("VIEW"), cs); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0d6f7e7a2c068..dd940b24f61a2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4427,8 +4427,9 @@ int create_table_impl(THD *thd, handlerton *db_type; if (!internal_tmp_table && - ha_table_exists(thd, &db, &table_name, - &create_info->org_tabledef_version, NULL, &db_type)) + ha_table_exists(thd, &orig_db, &orig_table_name, + &create_info->org_tabledef_version, + NULL, &db_type, NULL, 0)) { if (ha_check_if_updates_are_ignored(thd, db_type, "CREATE")) { @@ -10080,7 +10081,8 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, on the name, now we can safely try to find out for sure. */ if (!(alter_info->partition_flags & ALTER_PARTITION_CONVERT_IN) && - ha_table_exists(thd, &alter_ctx.new_db, &alter_ctx.new_name)) + ha_table_exists(thd, &alter_ctx.new_db, &alter_ctx.new_name, + NULL, NULL, NULL, NULL, 0)) { /* Table will be closed in do_command() */ my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alter_ctx.new_alias.str); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 166b67b68164c..be82fc166c91b 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1091,7 +1091,8 @@ static int mysql_register_view(THD *thd, DDL_LOG_STATE *ddl_log_state, fn_format(path_buff, file.str, dir.str, "", MY_UNPACK_FILENAME); path.length= strlen(path_buff); - if (ha_table_exists(thd, &view->db, &view->table_name)) + if (ha_table_exists(thd, &view->db, &view->table_name, + NULL, NULL, NULL, NULL, 0)) { old_view_exists= 1; if (lex->create_info.if_not_exists()) From 32d88faec5a8ca4c552a508ac874406fefee3605 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:03 +0300 Subject: [PATCH 011/113] MDEV-25292 Refactoring: removed TABLEOP_HOOKS TABLEOP_HOOKS is a strange interface: proxy interface calls virtual interface. Since it is used only for select_create::prepare() such complexity is overwhelming. --- sql/handler.h | 50 ---------------------- sql/sql_class.h | 4 +- sql/sql_insert.cc | 107 +++++++++++++++++++--------------------------- 3 files changed, 45 insertions(+), 116 deletions(-) diff --git a/sql/handler.h b/sql/handler.h index 3c7401a91995a..65da0e69fcae0 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2658,56 +2658,6 @@ typedef struct st_key_create_information } KEY_CREATE_INFO; -/* - Class for maintaining hooks used inside operations on tables such - as: create table functions, delete table functions, and alter table - functions. - - Class is using the Template Method pattern to separate the public - usage interface from the private inheritance interface. This - imposes no overhead, since the public non-virtual function is small - enough to be inlined. - - The hooks are usually used for functions that does several things, - e.g., create_table_from_items(), which both create a table and lock - it. - */ -class TABLEOP_HOOKS -{ -public: - TABLEOP_HOOKS() {} - virtual ~TABLEOP_HOOKS() {} - - inline void prelock(TABLE **tables, uint count) - { - do_prelock(tables, count); - } - - inline int postlock(TABLE **tables, uint count) - { - return do_postlock(tables, count); - } -private: - /* Function primitive that is called prior to locking tables */ - virtual void do_prelock(TABLE **tables, uint count) - { - /* Default is to do nothing */ - } - - /** - Primitive called after tables are locked. - - If an error is returned, the tables will be unlocked and error - handling start. - - @return Error code or zero. - */ - virtual int do_postlock(TABLE **tables, uint count) - { - return 0; /* Default is to do nothing */ - } -}; - typedef struct st_savepoint SAVEPOINT; extern ulong savepoint_alloc_size; extern KEY_CREATE_INFO default_key_create_info; diff --git a/sql/sql_class.h b/sql/sql_class.h index 0025eeb9a9fcf..6a107fed54d0a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -6162,8 +6162,8 @@ class select_create: public select_insert { private: TABLE *create_table_from_items(THD *thd, List *items, - MYSQL_LOCK **lock, - TABLEOP_HOOKS *hooks); + MYSQL_LOCK **lock); + int postlock(THD *thd, TABLE **tables); }; #include diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d3919a161ed91..059ac8b589371 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4484,8 +4484,7 @@ Field *Item::create_field_for_create_select(MEM_ROOT *root, TABLE *table) */ TABLE *select_create::create_table_from_items(THD *thd, List *items, - MYSQL_LOCK **lock, - TABLEOP_HOOKS *hooks) + MYSQL_LOCK **lock) { TABLE tmp_table; // Used during 'Create_field()' TABLE_SHARE share; @@ -4650,7 +4649,6 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, DEBUG_SYNC(thd,"create_table_select_before_lock"); table->reginfo.lock_type=TL_WRITE; - hooks->prelock(&table, 1); // Call prelock hooks /* Ensure that decide_logging_format(), called by mysql_lock_tables(), works @@ -4665,7 +4663,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, the table) and thus can't get aborted. */ if (unlikely(!((*lock)= mysql_lock_tables(thd, &table, 1, 0)) || - hooks->postlock(&table, 1))) + postlock(thd, &table))) { /* purecov: begin tested */ /* @@ -4704,71 +4702,52 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, } -int -select_create::prepare(List &_values, SELECT_LEX_UNIT *u) +/* + For row-based replication, the CREATE-SELECT statement is written + in two pieces: the first one contain the CREATE TABLE statement + necessary to create the table and the second part contain the rows + that should go into the table. + + For non-temporary tables, the start of the CREATE-SELECT + implicitly commits the previous transaction, and all events + forming the statement will be stored the transaction cache. At end + of the statement, the entire statement is committed as a + transaction, and all events are written to the binary log. + + On the master, the table is locked for the duration of the + statement, but since the CREATE part is replicated as a simple + statement, there is no way to lock the table for accesses on the + slave. Hence, we have to hold on to the CREATE part of the + statement until the statement has finished. +*/ +int select_create::postlock(THD *thd, TABLE **tables) { - List values(_values, thd->mem_root); - MYSQL_LOCK *extra_lock= NULL; - DBUG_ENTER("select_create::prepare"); - - TABLEOP_HOOKS *hook_ptr= NULL; /* - For row-based replication, the CREATE-SELECT statement is written - in two pieces: the first one contain the CREATE TABLE statement - necessary to create the table and the second part contain the rows - that should go into the table. - - For non-temporary tables, the start of the CREATE-SELECT - implicitly commits the previous transaction, and all events - forming the statement will be stored the transaction cache. At end - of the statement, the entire statement is committed as a - transaction, and all events are written to the binary log. - - On the master, the table is locked for the duration of the - statement, but since the CREATE part is replicated as a simple - statement, there is no way to lock the table for accesses on the - slave. Hence, we have to hold on to the CREATE part of the - statement until the statement has finished. - */ - class MY_HOOKS : public TABLEOP_HOOKS { - public: - MY_HOOKS(select_create *x, TABLE_LIST *create_table_arg, - TABLE_LIST *select_tables_arg) - : ptr(x), - create_table(create_table_arg), - select_tables(select_tables_arg) - { - } - - private: - virtual int do_postlock(TABLE **tables, uint count) - { - int error; - THD *thd= const_cast(ptr->get_thd()); - TABLE_LIST *save_next_global= create_table->next_global; - - create_table->next_global= select_tables; - - error= thd->decide_logging_format(create_table); + NOTE: for row format CREATE TABLE must be logged before row data. + */ + int error; + TABLE_LIST *save_next_global= create_table->next_global; + create_table->next_global= select_tables; + error= thd->decide_logging_format(create_table); + create_table->next_global= save_next_global; - create_table->next_global= save_next_global; + if (unlikely(error)) + return error; - if (unlikely(error)) - return error; + TABLE const *const table = *tables; + if (thd->is_current_stmt_binlog_format_row() && + !table->s->tmp_table) + return binlog_show_create_table(thd, *tables, create_info); + return 0; +} - TABLE const *const table = *tables; - if (thd->is_current_stmt_binlog_format_row() && - !table->s->tmp_table) - return binlog_show_create_table(thd, *tables, ptr->create_info); - return 0; - } - select_create *ptr; - TABLE_LIST *create_table; - TABLE_LIST *select_tables; - }; - MY_HOOKS hooks(this, create_table, select_tables); - hook_ptr= &hooks; +int +select_create::prepare(List &_values, SELECT_LEX_UNIT *u) +{ + List values(_values, thd->mem_root); + MYSQL_LOCK *extra_lock= NULL; + DBUG_ENTER("select_create::prepare"); unit= u; @@ -4784,7 +4763,7 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) thd->binlog_start_trans_and_stmt(); } - if (!(table= create_table_from_items(thd, &values, &extra_lock, hook_ptr))) + if (!(table= create_table_from_items(thd, &values, &extra_lock))) { if (create_info->or_replace()) { From d145dda9c7b6db394edf7150cc255343a4a7b116 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:04 +0300 Subject: [PATCH 012/113] MDEV-25292 Table_name class for (db, table_name, alias) TABLE_SHARE, TABLE_LIST inherit Table_name rename_table_and_triggers(), rename_check_preconditions() use Table_name instead TABLE_LIST. TODO: - Table_ident should inherit Table_name too; - Use TABLE_SHARE::alias instead of TABLE::alias. --- sql/sql_rename.cc | 4 ++-- sql/table.h | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 5ed80d69ff8bc..05ebdbf144ab4 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -257,7 +257,7 @@ struct rename_param static int rename_check_preconditions(THD *thd, rename_param *param, - TABLE_LIST *ren_table, + Table_name *ren_table, const LEX_CSTRING *new_db, const LEX_CSTRING *new_table_name, const LEX_CSTRING *new_table_alias, @@ -333,7 +333,7 @@ rename_check_preconditions(THD *thd, rename_param *param, static bool rename_table_and_triggers(THD *thd, rename_param *param, DDL_LOG_STATE *ddl_log_state, - TABLE_LIST *ren_table, const LEX_CSTRING *new_db, + Table_name *ren_table, const LEX_CSTRING *new_db, bool skip_error, bool *force_if_exists) { int rc= 1; diff --git a/sql/table.h b/sql/table.h index cb917594131c3..02e8998adb9e6 100644 --- a/sql/table.h +++ b/sql/table.h @@ -705,12 +705,21 @@ class TABLE_STATISTICS_CB void abort_stats_load() { stats_state.abort_load(); } }; + +struct Table_name +{ + LEX_CSTRING db; + LEX_CSTRING table_name; + LEX_CSTRING alias; +}; + + /** This structure is shared between different table objects. There is one instance of table share per one table in the database. */ -struct TABLE_SHARE +struct TABLE_SHARE: public Table_name { TABLE_SHARE() {} /* Remove gcc warning */ @@ -760,8 +769,6 @@ struct TABLE_SHARE To ensure this one can use set_table_cache() methods. */ LEX_CSTRING table_cache_key; - LEX_CSTRING db; /* Pointer to db */ - LEX_CSTRING table_name; /* Table name (for open) */ LEX_CSTRING path; /* Path to .frm file (from datadir) */ LEX_CSTRING normalized_path; /* unpack_filename(path) */ LEX_CSTRING connect_string; @@ -2192,7 +2199,8 @@ struct TABLE_CHAIN void set_end_pos(TABLE_LIST **pos) { end_pos= pos; } }; -struct TABLE_LIST + +struct TABLE_LIST: public Table_name { TABLE_LIST() {} /* Remove gcc warning */ @@ -2279,10 +2287,7 @@ struct TABLE_LIST TABLE_LIST *next_local; /* link in a global list of all queries tables */ TABLE_LIST *next_global, **prev_global; - LEX_CSTRING db; - LEX_CSTRING table_name; LEX_CSTRING schema_table_name; - LEX_CSTRING alias; const char *option; /* Used by cache index */ Item *on_expr; /* Used with outer join */ Name_resolution_context *on_context; /* For ON expressions */ From 86da0f4ee8381e7543733fae209252ff2b873631 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:04 +0300 Subject: [PATCH 013/113] MDEV-25292 select_create::create_table removed create_table duplicates select_insert::table_list. Since select_create inherits select_insert and the functional role of the members is the same we should remove one to eliminate the need of keeping them in sync. --- sql/sql_class.h | 2 -- sql/sql_insert.cc | 70 +++++++++++++++++++++++------------------------ 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index 6a107fed54d0a..ee51b1828dae2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -6115,7 +6115,6 @@ class select_insert :public select_result_interceptor { class select_create: public select_insert { - TABLE_LIST *create_table; Table_specification_st *create_info; TABLE_LIST *select_tables; Alter_info *alter_info; @@ -6136,7 +6135,6 @@ class select_create: public select_insert { TABLE_LIST *select_tables_arg): select_insert(thd_arg, table_arg, NULL, &select_fields, 0, 0, duplic, ignore, NULL), - create_table(table_arg), create_info(create_info_par), select_tables(select_tables_arg), alter_info(alter_info_arg), diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 059ac8b589371..aa0c38411ba3c 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4507,7 +4507,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, if (!(thd->variables.option_bits & OPTION_EXPLICIT_DEF_TIMESTAMP)) promote_first_timestamp_column(&alter_info->create_list); - if (create_info->fix_create_fields(thd, alter_info, *create_table)) + if (create_info->fix_create_fields(thd, alter_info, *table_list)) DBUG_RETURN(NULL); while ((item=it++)) @@ -4548,20 +4548,20 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, } if (create_info->check_fields(thd, alter_info, - create_table->table_name, - create_table->db)) + table_list->table_name, + table_list->db)) DBUG_RETURN(NULL); DEBUG_SYNC(thd,"create_table_select_before_create"); /* Check if LOCK TABLES + CREATE OR REPLACE of existing normal table*/ - if (thd->locked_tables_mode && create_table->table && + if (thd->locked_tables_mode && table_list->table && !create_info->tmp_table()) { /* Remember information about the locked table */ create_info->pos_in_locked_tables= - create_table->table->pos_in_locked_tables; - create_info->mdl_ticket= create_table->table->mdl_ticket; + table_list->table->pos_in_locked_tables; + create_info->mdl_ticket= table_list->table->mdl_ticket; } /* @@ -4582,10 +4582,10 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, */ if (!mysql_create_table_no_lock(thd, &ddl_log_state_create, &ddl_log_state_rm, - &create_table->db, - &create_table->table_name, + &table_list->db, + &table_list->table_name, create_info, alter_info, NULL, - C_ORDINARY_CREATE, create_table)) + C_ORDINARY_CREATE, table_list)) { DEBUG_SYNC(thd,"create_table_select_before_open"); @@ -4593,7 +4593,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, If we had a temporary table or a table used with LOCK TABLES, it was closed by mysql_create() */ - create_table->table= 0; + table_list->table= 0; if (!create_info->tmp_table()) { @@ -4601,20 +4601,20 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, TABLE_LIST::enum_open_strategy save_open_strategy; /* Force the newly created table to be opened */ - save_open_strategy= create_table->open_strategy; - create_table->open_strategy= TABLE_LIST::OPEN_NORMAL; + save_open_strategy= table_list->open_strategy; + table_list->open_strategy= TABLE_LIST::OPEN_NORMAL; /* Here we open the destination table, on which we already have an exclusive metadata lock. */ - if (open_table(thd, create_table, &ot_ctx)) + if (open_table(thd, table_list, &ot_ctx)) { - quick_rm_table(thd, create_info->db_type, &create_table->db, - table_case_name(create_info, &create_table->table_name), + quick_rm_table(thd, create_info->db_type, &table_list->db, + table_case_name(create_info, &table_list->table_name), 0); } /* Restore */ - create_table->open_strategy= save_open_strategy; + table_list->open_strategy= save_open_strategy; } else { @@ -4622,8 +4622,8 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, The pointer to the newly created temporary table has been stored in table->create_info. */ - create_table->table= create_info->table; - if (!create_table->table) + table_list->table= create_info->table; + if (!table_list->table) { /* This shouldn't happen as creation of temporary table should make @@ -4635,9 +4635,9 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, } } else - create_table->table= 0; // Create failed + table_list->table= 0; // Create failed - if (unlikely(!(table= create_table->table))) + if (unlikely(!(table= table_list->table))) { if (likely(!thd->is_error())) // CREATE ... IF NOT EXISTS my_ok(thd); // succeed, but did nothing @@ -4679,7 +4679,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, mysql_unlock_tables(thd, *lock); *lock= 0; } - drop_open_table(thd, table, &create_table->db, &create_table->table_name); + drop_open_table(thd, table, &table_list->db, &table_list->table_name); ddl_log_complete(&ddl_log_state_rm); ddl_log_complete(&ddl_log_state_create); DBUG_RETURN(NULL); @@ -4726,10 +4726,10 @@ int select_create::postlock(THD *thd, TABLE **tables) NOTE: for row format CREATE TABLE must be logged before row data. */ int error; - TABLE_LIST *save_next_global= create_table->next_global; - create_table->next_global= select_tables; - error= thd->decide_logging_format(create_table); - create_table->next_global= save_next_global; + TABLE_LIST *save_next_global= table_list->next_global; + table_list->next_global= select_tables; + error= thd->decide_logging_format(table_list); + table_list->next_global= save_next_global; if (unlikely(error)) return error; @@ -4768,7 +4768,7 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) if (create_info->or_replace()) { /* Original table was deleted. We have to log it */ - log_drop_table(thd, &create_table->db, &create_table->table_name, + log_drop_table(thd, &table_list->db, &table_list->table_name, &create_info->org_storage_engine_name, create_info->db_type == partition_hton, &create_info->org_tabledef_version, @@ -4788,7 +4788,7 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) list to keep them inaccessible from inner statements. e.g. CREATE TEMPORARY TABLE `t1` AS SELECT * FROM `t1`; */ - saved_tmp_table_share= thd->save_tmp_table_share(create_table->table); + saved_tmp_table_share= thd->save_tmp_table_share(table_list->table); } if (extra_lock) @@ -5087,8 +5087,8 @@ bool select_create::send_eof() */ wsrep_key_arr_t key_arr= {0, 0}; wsrep_prepare_keys_for_isolation(thd, - create_table->db.str, - create_table->table_name.str, + table_list->db.str, + table_list->table_name.str, table_list, &key_arr); int rcode= wsrep_thd_append_key(thd, key_arr.keys, key_arr.keys_len, @@ -5144,8 +5144,8 @@ bool select_create::send_eof() else lex_string_set(&ddl_log.org_storage_engine_name, ha_resolve_storage_engine_name(create_info->db_type)); - ddl_log.org_database= create_table->db; - ddl_log.org_table= create_table->table_name; + ddl_log.org_database= table_list->db; + ddl_log.org_table= table_list->table_name; ddl_log.org_table_id= create_info->tabledef_version; backup_log_ddl(&ddl_log); } @@ -5260,7 +5260,7 @@ void select_create::abort_result_set() m_plock= NULL; } - drop_open_table(thd, table, &create_table->db, &create_table->table_name); + drop_open_table(thd, table, &table_list->db, &table_list->table_name); table=0; // Safety if (thd->log_current_statement()) { @@ -5275,7 +5275,7 @@ void select_create::abort_result_set() ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); debug_crash_here("ddl_log_create_before_binlog"); - log_drop_table(thd, &create_table->db, &create_table->table_name, + log_drop_table(thd, &table_list->db, &table_list->table_name, &create_info->org_storage_engine_name, create_info->db_type == partition_hton, &create_info->tabledef_version, @@ -5291,8 +5291,8 @@ void select_create::abort_result_set() ddl_log.query= { C_STRING_WITH_LEN("DROP_AFTER_CREATE") }; ddl_log.org_partitioned= (create_info->db_type == partition_hton); ddl_log.org_storage_engine_name= create_info->org_storage_engine_name; - ddl_log.org_database= create_table->db; - ddl_log.org_table= create_table->table_name; + ddl_log.org_database= table_list->db; + ddl_log.org_table= table_list->table_name; ddl_log.org_table_id= create_info->tabledef_version; backup_log_ddl(&ddl_log); } From 93c8252f02faa8ad8dc5f005e52f1990c29d4a0d Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:04 +0300 Subject: [PATCH 014/113] MDEV-25292 Atomic CREATE OR REPLACE TABLE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Atomic CREATE OR REPLACE allows to keep an old table intact if the command fails or during the crash. That is done through creating a table with a temporary name and filling it with the data (for CREATE OR REPLACE .. SELECT), then renaming the original table to another temporary (backup) name and renaming the replacement table to original table. The backup table is kept until the last chance of failure and if that happens, the replacement table is thrown off and backup recovered. When the command is complete and logged the backup table is deleted. Atomic replace algorithm Two DDL chains are used for CREATE OR REPLACE: ddl_log_state_create (C) and ddl_log_state_rm (D). 1. (C) Log CREATE_TABLE_ACTION of TMP table (drops TMP table); 2. Create new table as TMP; 3. Do everything with TMP (like insert data); finalize_atomic_replace(): 4. Link chains: (D) is executed only if (C) is closed; 5. (D) Log DROP_ACTION of BACKUP; 6. (C) Log RENAME_TABLE_ACTION from ORIG to BACKUP (replays BACKUP -> ORIG); 7. Rename ORIG to BACKUP; 8. (C) Log CREATE_TABLE_ACTION of ORIG (drops ORIG); 9. Rename TMP to ORIG; finalize_ddl() in case of success: 10. Close (C); 11. Replay (D): BACKUP is dropped. finalize_ddl() in case of error: 10. Close (D); 11. Replay (C): 1) ORIG is dropped (only after finalize_atomic_replace()); 2) BACKUP renamed to ORIG (only after finalize_atomic_replace()); 3) drop TMP. If crash happens (C) or (D) is replayed in reverse order. (C) is replayed if crash happens before it is closed, otherwise (D) is replayed. Temporary table for CREATE OR REPLACE Before dropping "old" table, CREATE OR REPLACE creates "tmp" table. ddl_log_state_create holds the drop of the "tmp" table. When everything is OK (data is inserted, "tmp" is ready) ddl_log_state_rm is written to replace "old" with "tmp". Until ddl_log_state_create is closed ddl_log_state_rm is not executed. After the binlogging is done ddl_log_state_create is closed. At that point ddl_log_state_rm is executed and "tmp" is replaced with "old". That is: final rename is done by the DDL log. With that important role of DDL log for CREATE OR REPLACE operation replay of ddl_log_state_rm must fail at the first hit error and print the error message if possible. F.ex. foreign key error is discovered at this phase: InnoDB rejects to drop the "old" table and returns corresponding foreign key error code. Additional notes - CREATE TABLE without REPLACE is not affected by this commit. - Engines having HTON_EXPENSIVE_RENAME flag set are not affected by this commit. - CREATE TABLE .. SELECT XID usage is fixed and now there is no need to log DROP TABLE via DDL_CREATE_TABLE_PHASE_LOG (see comments in do_postlock()). XID is now correctly updated so it disables DDL_LOG_DROP_TABLE_ACTION. Note that binary log is flushed at the final stage when the table is ready. So if we have XID in the binary log we don't need to drop the table. - Three variations of CREATE OR REPLACE handled: 1. CREATE OR REPLACE TABLE t1 (..); 2. CREATE OR REPLACE TABLE t1 LIKE t2; 3. CREATE OR REPLACE TABLE t1 SELECT ..; - Test case uses 6 combinations for engines (aria, aria_notrans, myisam, ib, lock_tables, expensive_rename) and 2 combinations for binlog types (row, stmt). Combinations help to check differences between the results. Error failures are tested for the above three variations. - expensive_rename tests CREATE OR REPLACE without atomic replace. The effect should be the same as with the old behaviour before this commit. - Triggers mechanism is unaffected by this change. This is tested in create_replace.test. - LOCK TABLES is affected. Lock restoration must be done after "rm" chain is replayed. - Moved ddl_log_complete() from send_eof() to finalize_ddl(). This checkpoint was not executed before for normal CREATE TABLE but is executed now. - CREATE TABLE will now rollback also if writing to the binary logging failed. See rpl_gtid_strict.test Rename and drop via DDL log We replay ddl_log_state_rm to drop the old table and rename the temporary table. In that case we must throw the correct error message if ddl_log_revert() fails (f.ex. on FK error). If table is deleted earlier and not via DDL log and the crash happened, the create chain is not closed. Linked drop chain is not executed and the new table is not installed. But the old table is already deleted. ddl_log.cc changes Now we can place action before DDL_LOG_DROP_INIT_ACTION and it will be replayed after DDL_LOG_DROP_TABLE_ACTION. report_error parameter for ddl_log_revert() allows to fail at first error and print the error message if possible. ddl_log_execute_action() now can print error message. Since we now can handle errors from ddl_log_execute_action() (in case of non-recovery execution) unconditional setting "error= TRUE" is wrong (it was wrong anyway because it was overwritten at the end of the function). On XID usage Like with all other atomic DDL operations XID is used to avoid inconsistency between master and slave in the case of a crash after binary log is written and before ddl_log_state_create is closed. On recovery XIDs are taken from binary log and corresponding DDL log events get disabled. That is done by ddl_log_close_binlogged_events(). On linking two chains together Chains are executed in the ascending order of entry_pos of execute entries. But entry_pos assignment order is undefined: it may assign bigger number for the first chain and then smaller number for the second chain. So the execution order in that case will be reverse: second chain will be executed first. To avoid that we link one chain to another. While the base chain (ddl_log_state_create) is active the secondary chain (ddl_log_state_rm) is not executed. That is: only one chain can be executed in two linked chains. The interface ddl_log_link_chains() was done in "MDEV-22166 ddl_log_write_execute_entry() extension". More on CREATE OR REPLACE .. SELECT We use create_and_open_tmp_table() like in ALTER TABLE to create temporary TABLE object (tmp_table is (NON_)TRANSACTIONAL_TMP_TABLE). After we created such TABLE object we use create_info->tmp_table() instead of table->s->tmp_table when we need to check for parser-requested tmp-table. External locking is required for temporary table created by create_and_open_tmp_table(). F.ex. that disables logging for Aria transactional tables and without that (when no mysql_lock_tables() is done) it cannot work correctly. For making external lock the patch requires Aria table to work in non-transactional mode. That is usually done by ha_enable_transaction(false). But we cannot disable transaction completely because: 1. binlog rollback removes pending row events (binlog_remove_pending_rows_event()). The row events are added during CREATE .. SELECT data insertion phase. 2. replication slave highly depends on transaction and cannot work without it. So we put temporary Aria table into non-transactional mode with "thd->transaction->on hack". See comment for on_save variable. Note that Aria table has internal_table mode. But we cannot use it because: if (!internal_table) { mysql_mutex_lock(&THR_LOCK_myisam); old_info= test_if_reopen(name_buff); } For internal_table test_if_reopen() is not called and we get a new MARIA_SHARE for each file handler. In that case duplicate errors are missed because insert and lookup in CREATE .. SELECT is done via two different handlers (see create_lookup_handler()). For temporary table before dropping TABLE_SHARE by drop_temporary_table() we must do ha_reset(). ha_reset() releases storage share. Without that the share is kept and the second CREATE OR REPLACE .. SELECT fails with: HA_ERR_TABLE_EXIST (156): MyISAM table '#sql-create-b5377-4-t2' is in use (most likely by a MERGE table). Try FLUSH TABLES. HA_EXTRA_PREPARE_FOR_DROP also removes MYISAM_SHARE, but that is not needed as ha_reset() does the job. ha_reset() is usually done by mark_tmp_table_as_free_for_reuse(). But we don't need that mechanism for our temporary table. Atomic_info in HA_CREATE_INFO Many functions in CREATE TABLE pass the same parameters. These parameters are part of table creation info and should be in HA_CREATE_INFO (or whatever). Passing parameters via single structure is much easier for adding new data and refactoring. InnoDB changes (revised by Marko Mäkelä) row_rename_table_for_mysql(): Specify the treatment of FOREIGN KEY constraints in a 4-valued enum parameter. In cases where FOREIGN KEY constraints cannot exist (partitioned tables, or internal tables of FULLTEXT INDEX), we can use the mode RENAME_IGNORE_FK. The mod RENAME_REBUILD is for any DDL operation that rebuilds the table inside InnoDB, such as TRUNCATE and native ALTER TABLE (or OPTIMIZE TABLE). The mode RENAME_ALTER_COPY is used solely during non-native ALTER TABLE in ha_innobase::rename_table(). Normal ha_innobase::rename_table() will use the mode RENAME_FK. CREATE OR REPLACE will rename the old table (if one exists) along with its FOREIGN KEY constraints into a temporary name. The replacement table will be initially created with another temporary name. Unlike in ALTER TABLE, all FOREIGN KEY constraints must be renamed and not inherited as part of these operations, using the mode RENAME_FK. dict_get_referenced_table(): Let the callers convert names when needed. create_table_info_t::create_foreign_keys(): CREATE OR REPLACE creates the replacement table with a temporary name table, so for self-references foreign->referenced_table will be a table with temporary name and charset conversion must be skipped for it. Reviewed by: Michael Widenius --- .../include/binlog_formats.combinations | 8 + mysql-test/include/binlog_formats.inc | 4 + mysql-test/main/backup_log.result | 87 +- mysql-test/main/backup_log_print.inc | 7 + mysql-test/main/create_not_windows.result | 36 + mysql-test/main/create_not_windows.test | 63 ++ mysql-test/main/create_or_replace.result | 306 ++++++- mysql-test/main/create_or_replace.test | 155 +++- mysql-test/main/create_or_replace2.result | 47 ++ mysql-test/main/create_or_replace2.test | 32 + mysql-test/main/default.result | 14 +- mysql-test/main/default.test | 15 +- mysql-test/main/long_unique_bugs.result | 3 +- mysql-test/main/long_unique_bugs.test | 1 - .../create_replace,aria_notrans,row.result | 710 ++++++++++++++++ .../atomic/create_replace,aria_notrans.result | 696 ++++++++++++++++ ...create_replace,expensive_rename,row.result | 584 +++++++++++++ .../create_replace,expensive_rename.result | 561 +++++++++++++ .../suite/atomic/create_replace,ib,row.result | 661 +++++++++++++++ .../suite/atomic/create_replace,ib.result | 648 +++++++++++++++ .../atomic/create_replace,myisam,row.result | 710 ++++++++++++++++ .../suite/atomic/create_replace,row.result | 710 ++++++++++++++++ .../suite/atomic/create_replace.combinations | 6 + mysql-test/suite/atomic/create_replace.result | 696 ++++++++++++++++ mysql-test/suite/atomic/create_replace.test | 211 +++++ mysql-test/suite/atomic/create_table.result | 215 +---- mysql-test/suite/atomic/create_table.test | 9 +- mysql-test/suite/binlog/include/binlog.test | 1 + .../suite/binlog/r/binlog_row_binlog.result | 6 +- .../suite/binlog/r/binlog_stm_binlog.result | 5 +- .../suite/binlog/r/binlog_write_error.result | 2 + .../suite/binlog/t/binlog_write_error.test | 3 + .../binlog_write_error.result | 2 + mysql-test/suite/parts/r/backup_log.result | 107 ++- .../suite/rpl/r/create_or_replace2,stmt.rdiff | 17 + .../suite/rpl/r/create_or_replace2.result | 11 + .../suite/rpl/r/create_or_replace_mix.result | 31 +- .../suite/rpl/r/create_or_replace_row.result | 35 +- .../rpl/r/create_or_replace_statement.result | 31 +- mysql-test/suite/rpl/r/rpl_gtid_strict.result | 5 +- mysql-test/suite/rpl/t/create_or_replace.inc | 11 +- .../suite/rpl/t/create_or_replace2.test | 2 + mysql-test/suite/rpl/t/rpl_gtid_strict.test | 7 +- sql/ddl_log.cc | 226 +++-- sql/ddl_log.h | 13 +- sql/handler.cc | 15 +- sql/handler.h | 93 ++- sql/log.cc | 15 +- sql/sql_alter.cc | 3 +- sql/sql_base.cc | 8 +- sql/sql_class.h | 24 +- sql/sql_insert.cc | 418 +++++++--- sql/sql_parse.cc | 4 +- sql/sql_partition.cc | 2 + sql/sql_rename.cc | 67 +- sql/sql_select.cc | 2 + sql/sql_show.cc | 5 +- sql/sql_table.cc | 780 ++++++++++++++---- sql/sql_table.h | 69 +- sql/sql_trigger.cc | 58 +- sql/sql_trigger.h | 15 +- sql/sql_truncate.cc | 45 +- sql/structs.h | 12 +- sql/table.h | 12 +- storage/innobase/dict/dict0dict.cc | 76 +- storage/innobase/fts/fts0fts.cc | 4 +- storage/innobase/handler/ha_innodb.cc | 206 +++-- storage/innobase/handler/handler0alter.cc | 56 +- storage/innobase/include/dict0dict.h | 12 +- storage/innobase/include/row0mysql.h | 15 +- storage/innobase/row/row0mysql.cc | 12 +- storage/maria/ha_s3.cc | 5 +- storage/maria/ma_check.c | 2 +- 73 files changed, 8639 insertions(+), 1106 deletions(-) create mode 100644 mysql-test/include/binlog_formats.combinations create mode 100644 mysql-test/include/binlog_formats.inc create mode 100644 mysql-test/main/backup_log_print.inc create mode 100644 mysql-test/suite/atomic/create_replace,aria_notrans,row.result create mode 100644 mysql-test/suite/atomic/create_replace,aria_notrans.result create mode 100644 mysql-test/suite/atomic/create_replace,expensive_rename,row.result create mode 100644 mysql-test/suite/atomic/create_replace,expensive_rename.result create mode 100644 mysql-test/suite/atomic/create_replace,ib,row.result create mode 100644 mysql-test/suite/atomic/create_replace,ib.result create mode 100644 mysql-test/suite/atomic/create_replace,myisam,row.result create mode 100644 mysql-test/suite/atomic/create_replace,row.result create mode 100644 mysql-test/suite/atomic/create_replace.combinations create mode 100644 mysql-test/suite/atomic/create_replace.result create mode 100644 mysql-test/suite/atomic/create_replace.test create mode 100644 mysql-test/suite/rpl/r/create_or_replace2,stmt.rdiff diff --git a/mysql-test/include/binlog_formats.combinations b/mysql-test/include/binlog_formats.combinations new file mode 100644 index 0000000000000..07042c2cbecd2 --- /dev/null +++ b/mysql-test/include/binlog_formats.combinations @@ -0,0 +1,8 @@ +[row] +binlog-format=row + +[stmt] +binlog-format=statement + +[mix] +binlog-format=mixed diff --git a/mysql-test/include/binlog_formats.inc b/mysql-test/include/binlog_formats.inc new file mode 100644 index 0000000000000..44d64293102ca --- /dev/null +++ b/mysql-test/include/binlog_formats.inc @@ -0,0 +1,4 @@ +# This file adds combinations for all binlog formats: row, stmt, mix +# Under each combination a corresponding binlog-format option is set. + +--source include/have_log_bin.inc diff --git a/mysql-test/main/backup_log.result b/mysql-test/main/backup_log.result index 94590a220d47d..6338425990c46 100644 --- a/mysql-test/main/backup_log.result +++ b/mysql-test/main/backup_log.result @@ -69,7 +69,7 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' create table t32 (a int) ; drop table if exists t30,t31,t32,tmp_t30; Warnings: -Note 1051 Unknown table 'test.t31,test.tmp_t30' +Note 1051 Unknown table 'test.tmp_t30' # # Testing create LIKE # @@ -182,56 +182,55 @@ CREATE,MyISAM,0,test,t30,id: 8,,0,,, CREATE,MyISAM,0,test,t31,id: 9,,0,,, DROP,MyISAM,0,test,t31,id: 9,,0,,, CREATE,MyISAM,0,test,t31,id: 10,,0,,, -DROP,MyISAM,0,test,t31,id: 10,,0,,, -DROP_AFTER_CREATE,MyISAM,0,test,t31,id: 11,,0,,, -CREATE,MyISAM,0,test,t32,id: 12,,0,,, +CREATE,MyISAM,0,test,t32,id: 11,,0,,, DROP,MyISAM,0,test,t30,id: 8,,0,,, -DROP,MyISAM,0,test,t32,id: 12,,0,,, -CREATE,MyISAM,0,test,t40,id: 13,,0,,, -CREATE,InnoDB,0,test,t41,id: 14,,0,,, -CREATE,MyISAM,0,test,t42,id: 15,,0,,, -DROP,MyISAM,0,test,t42,id: 15,,0,,, -CREATE,InnoDB,0,test,t42,id: 16,,0,,, -DROP,MyISAM,0,test,t40,id: 13,,0,,, -DROP,InnoDB,0,test,t41,id: 14,,0,,, -DROP,InnoDB,0,test,t42,id: 16,,0,,, -CREATE,MyISAM,0,test,t50,id: 17,,0,,, -CREATE,MyISAM,0,test,t51,id: 18,,0,,, -RENAME,MyISAM,0,test,t50,id: 17,MyISAM,0,test,t52,id: 17 -RENAME,MyISAM,0,test,t51,id: 18,MyISAM,0,test,t53,id: 18 -RENAME,MyISAM,0,test,t52,id: 17,MyISAM,0,test,tmp,id: 17 -RENAME,MyISAM,0,test,t53,id: 18,MyISAM,0,test,t52,id: 18 -RENAME,MyISAM,0,test,tmp,id: 17,MyISAM,0,test,t53,id: 17 -DROP,MyISAM,0,test,t52,id: 18,,0,,, -DROP,MyISAM,0,test,t53,id: 17,,0,,, -CREATE,Aria,0,test,t60,id: 19,,0,,, -CHANGE_INDEX,Aria,0,test,t60,id: 19,,0,,, -CHANGE_INDEX,Aria,0,test,t60,id: 19,,0,,, -DROP,Aria,0,test,t60,id: 19,,0,,, -CREATE,Aria,0,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,0,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,0,test,t70,id: 20,,0,,, -CREATE,Aria,0,test,t71,id: 21,,0,,, -BULK_INSERT,Aria,0,test,t71,id: 21,,0,,, -DROP,Aria,0,test,t70,id: 20,,0,,, -DROP,Aria,0,test,t71,id: 21,,0,,, -CREATE,MyISAM,0,test,t@00201,id: 22,,0,,, -DROP,MyISAM,0,test,t@00201,id: 22,,0,,, -CREATE,MyISAM,0,test,t80,id: 23,,0,,, +DROP,MyISAM,0,test,t31,id: 10,,0,,, +DROP,MyISAM,0,test,t32,id: 11,,0,,, +CREATE,MyISAM,0,test,t40,id: 12,,0,,, +CREATE,InnoDB,0,test,t41,id: 13,,0,,, +CREATE,MyISAM,0,test,t42,id: 14,,0,,, +DROP,MyISAM,0,test,t42,id: 14,,0,,, +CREATE,InnoDB,0,test,t42,id: 15,,0,,, +DROP,MyISAM,0,test,t40,id: 12,,0,,, +DROP,InnoDB,0,test,t41,id: 13,,0,,, +DROP,InnoDB,0,test,t42,id: 15,,0,,, +CREATE,MyISAM,0,test,t50,id: 16,,0,,, +CREATE,MyISAM,0,test,t51,id: 17,,0,,, +RENAME,MyISAM,0,test,t50,id: 16,MyISAM,0,test,t52,id: 16 +RENAME,MyISAM,0,test,t51,id: 17,MyISAM,0,test,t53,id: 17 +RENAME,MyISAM,0,test,t52,id: 16,MyISAM,0,test,tmp,id: 16 +RENAME,MyISAM,0,test,t53,id: 17,MyISAM,0,test,t52,id: 17 +RENAME,MyISAM,0,test,tmp,id: 16,MyISAM,0,test,t53,id: 16 +DROP,MyISAM,0,test,t52,id: 17,,0,,, +DROP,MyISAM,0,test,t53,id: 16,,0,,, +CREATE,Aria,0,test,t60,id: 18,,0,,, +CHANGE_INDEX,Aria,0,test,t60,id: 18,,0,,, +CHANGE_INDEX,Aria,0,test,t60,id: 18,,0,,, +DROP,Aria,0,test,t60,id: 18,,0,,, +CREATE,Aria,0,test,t70,id: 19,,0,,, +BULK_INSERT,Aria,0,test,t70,id: 19,,0,,, +BULK_INSERT,Aria,0,test,t70,id: 19,,0,,, +CREATE,Aria,0,test,t71,id: 20,,0,,, +BULK_INSERT,Aria,0,test,t71,id: 20,,0,,, +DROP,Aria,0,test,t70,id: 19,,0,,, +DROP,Aria,0,test,t71,id: 20,,0,,, +CREATE,MyISAM,0,test,t@00201,id: 21,,0,,, +DROP,MyISAM,0,test,t@00201,id: 21,,0,,, +CREATE,MyISAM,0,test,t80,id: 22,,0,,, CREATE,VIEW,0,test,v1,,,0,,, CREATE,TRIGGER,0,test,trg,,,0,,, DROP,TRIGGER,0,test,trg,,,0,,, DROP,VIEW,0,test,v1,,,0,,, -DROP,MyISAM,0,test,t80,id: 23,,0,,, -CREATE,MyISAM,0,test,t85,id: 24,,0,,, -ALTER,MyISAM,0,test,t85,id: 24,InnoDB,0,test,t85,id: 25 -DROP,InnoDB,0,test,t85,id: 25,,0,,, +DROP,MyISAM,0,test,t80,id: 22,,0,,, +CREATE,MyISAM,0,test,t85,id: 23,,0,,, +ALTER,MyISAM,0,test,t85,id: 23,InnoDB,0,test,t85,id: 24 +DROP,InnoDB,0,test,t85,id: 24,,0,,, CREATE,DATABASE,0,mysqltest,,,,0,,, -CREATE,MyISAM,0,mysqltest,t90,id: 26,,0,,, -CREATE,InnoDB,0,mysqltest,t91,id: 27,,0,,, +CREATE,MyISAM,0,mysqltest,t90,id: 25,,0,,, +CREATE,InnoDB,0,mysqltest,t91,id: 26,,0,,, ALTER,DATABASE,0,mysqltest,,,,0,,, -DROP,MyISAM,0,mysqltest,t90,id: 26,,0,,, -DROP,InnoDB,0,mysqltest,t91,id: 27,,0,,, +DROP,MyISAM,0,mysqltest,t90,id: 25,,0,,, +DROP,InnoDB,0,mysqltest,t91,id: 26,,0,,, DROP,DATABASE,0,mysqltest,,,,0,,, # # Cleanup diff --git a/mysql-test/main/backup_log_print.inc b/mysql-test/main/backup_log_print.inc new file mode 100644 index 0000000000000..ad46dde49f938 --- /dev/null +++ b/mysql-test/main/backup_log_print.inc @@ -0,0 +1,7 @@ +--disable_query_log +--source include/print_ddl_log.inc +--connection con1 +backup stage end; +backup stage start; +--connection default +--enable_query_log diff --git a/mysql-test/main/create_not_windows.result b/mysql-test/main/create_not_windows.result index abe76fd3fbec4..1ae0f96b72816 100644 --- a/mysql-test/main/create_not_windows.result +++ b/mysql-test/main/create_not_windows.result @@ -29,3 +29,39 @@ select count(a) from t1; count(a) 0 drop table t1; +# +# MDEV-25292 Atomic CREATE OR REPLACE TABLE +# +# Test multi-byte characters in table name +set names utf8; +# Filename is too long because it is converted to @274e@274e@274e@274e... +# so each '❎' is 5 bytes in filesystem, 51 x 5 = 255 bytes +create table ❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (x int); +ERROR HY000: Can't create table `test`.`❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` (errno: 36 "File name too long") +# Let's find out max length for '❎'... +# Acceptable name length: 50; Filename length: 254 +# OK with 64-characters table name, filesystem name is 40 x 5 + 24 = 224 bytes +create table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (x int); +# Not OK with 65-characters table name +create table ttttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (x int); +ERROR 42000: Incorrect table name 'ttttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎' +show tables; +Tables_in_test +tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ +create or replace table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (y int); +show create table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎; +Table Create Table +tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ CREATE TABLE `tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` ( + `y` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +set @@debug_dbug="+d,ddl_log_create_after_save_backup", @debug_crash_counter=1; +create or replace table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (z int); +ERROR HY000: Lost connection to server during query +#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD +#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI +#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm +#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD +#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI +#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm +drop table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎; +set @@debug_dbug=""; diff --git a/mysql-test/main/create_not_windows.test b/mysql-test/main/create_not_windows.test index b612e31e3aa49..d6dfc0d3fa1db 100644 --- a/mysql-test/main/create_not_windows.test +++ b/mysql-test/main/create_not_windows.test @@ -1,6 +1,8 @@ # Non-windows specific create tests. --source include/not_windows.inc +--source include/have_debug.inc +--source include/not_embedded.inc # # Bug#19479:mysqldump creates invalid dump @@ -41,3 +43,64 @@ create table t1(a int, b int, c int); --echo "Try to select from the table. This should not crash the server" select count(a) from t1; drop table t1; + +--echo # +--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE +--echo # + +# This does not work on Windows because of max path limit 255 +# (actually it does not work for path 254 already) +# Note: on Windows use ER_BAD_DB_ERROR instead of ER_CANT_CREATE_TABLE +# unless MDEV-28746 is fixed. + +--echo # Test multi-byte characters in table name +set names utf8; +let $save_debug=`select @@debug_dbug`; +let $MYSQLD_DATADIR= `SELECT @@datadir`; +--echo # Filename is too long because it is converted to @274e@274e@274e@274e... +--echo # so each '❎' is 5 bytes in filesystem, 51 x 5 = 255 bytes +let $t= `select repeat('❎', 51)`; +--error ER_CANT_CREATE_TABLE +eval create table $t (x int); +# The below case is useful for experimenting on Windows +--echo # Let's find out max length for '❎'... +--disable_query_log +let $i= 50; +while ($i) +{ + let $t= `select repeat('❎', $i)`; + --error 0,ER_CANT_CREATE_TABLE + eval create table $t (x int); + let $good_len= $i; + dec $i; + if (!$mysql_errno) + { + let $i= 0; + } +} +let $fn_len= `select $good_len * 5 + 4`; # 4 is extension length +eval drop table $t; +--enable_query_log +--echo # Acceptable name length: $good_len; Filename length: $fn_len +--echo # OK with 64-characters table name, filesystem name is 40 x 5 + 24 = 224 bytes +let $t= `select concat(repeat('t', 24), repeat('❎', 40))`; +eval create table $t (x int); +--echo # Not OK with 65-characters table name +let $t2= `select concat(repeat('t', 25), repeat('❎', 40))`; +--error ER_WRONG_TABLE_NAME +eval create table $t2 (x int); +show tables; +# Let's try atomic replace with such long name and see what happens +eval create or replace table $t (y int); +eval show create table $t; +set @@debug_dbug="+d,ddl_log_create_after_save_backup", @debug_crash_counter=1; +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--disable_reconnect +--error 2013 +eval create or replace table $t (z int); +--replace_regex /-\w+-\w+-ttt/-PID-TID-ttt/ +--list_files $MYSQLD_DATADIR/test *sql* +--enable_reconnect +--source include/wait_until_connected_again.inc +eval drop table $t; +eval set @@debug_dbug="$save_debug"; diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index 178b7182666ed..46645bb910f4f 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -1,5 +1,3 @@ -SET @save_persistent=@@GLOBAL.innodb_stats_persistent; -SET GLOBAL innodb_stats_persistent=OFF; CREATE TABLE t2 (a int); INSERT INTO t2 VALUES(1),(2),(3); # @@ -260,7 +258,8 @@ Note 1051 Unknown table 'test.t1,mysqltest2.t2' create table test.t1 (i int) engine=myisam; create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -272,24 +271,37 @@ create or replace table test.t1; ERROR 42000: A table must have at least 1 column show tables; Tables_in_test +t1 t2 -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 create or replace table mysqltest2.t2; ERROR 42000: A table must have at least 1 column -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME +# MDL_BACKUP_DDL NULL Backup lock +# MDL_BACKUP_DML NULL Backup lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 +drop table mysqltest2.t2; +drop table t1; create table t1 (i int); drop table t1; create table test.t1 (i int); create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -301,24 +313,37 @@ create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a'; ERROR 42S21: Duplicate column name 'a' show tables; Tables_in_test +t1 t2 -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; ERROR 42S21: Duplicate column name 'a' -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME +# MDL_BACKUP_DDL NULL Backup lock +# MDL_BACKUP_DML NULL Backup lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 +drop table mysqltest2.t2; +drop table t1; create table t1 (i int); drop table t1; create table test.t1 (i int) engine=innodb; create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 @@ -330,7 +355,8 @@ drop table test.t1,mysqltest2.t2; create table test.t1 (i int) engine=aria transactional=1 checksum=1; create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 @@ -347,7 +373,8 @@ drop table test.t1; # create table t1 (i int); lock table t1 write; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -355,10 +382,12 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a; ERROR 22001: Data too long for column 'a' at row 1 +drop table t1; show tables; Tables_in_test t2 -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME create table t1 (i int); drop table t1; @@ -446,7 +475,8 @@ drop view t1; # create table t1 (a int); lock table t1 write, t2 read; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -454,7 +484,8 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 # MDL_SHARED_READ NULL Table metadata lock test t2 create or replace table t1 (i int); -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -462,7 +493,8 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 # MDL_SHARED_READ NULL Table metadata lock test t2 create or replace table t1 like t2; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -470,7 +502,8 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 # MDL_SHARED_READ NULL Table metadata lock test t2 create or replace table t1 select 1 as f1; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -568,4 +601,243 @@ ERROR HY000: Table 't3' was not locked with LOCK TABLES UNLOCK TABLES; DROP TABLE t3; # End of 10.4 tests -SET GLOBAL innodb_stats_persistent=@save_persistent; +# +# MDEV-25292 Atomic CREATE OR REPLACE TABLE +# +create table t1 (a int); +insert t1 values (1), (1); +create table t2 (c int); +create or replace table t2 (a int, b int, key k (a), key k (b)); +ERROR 42000: Duplicate key name 'k' +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create or replace table t2 (a int, b int, key k (a), key k (b)) as select a, a as b from t1; +ERROR 42000: Duplicate key name 'k' +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create or replace table t2 (a int primary key) as select * from t1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +set @old_mode= @@sql_mode; +set @@sql_mode='ALLOW_INVALID_DATES'; +create table t3 (dt datetime default '2008-02-31 00:00:00'); +set @@sql_mode= @old_mode; +create or replace table t2 like t3; +ERROR 42000: Invalid default value for 'dt' +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +# LOCK TABLES +lock tables t2 write, t1 write; +flush tables; +show open tables like 't2'; +Database Table In_use Name_locked +test t2 1 0 +create or replace table t2 (y int); +flush tables; +show open tables like 't2'; +Database Table In_use Name_locked +test t2 1 0 +create or replace table t2 like t1; +flush tables; +show open tables like 't2'; +Database Table In_use Name_locked +test t2 1 0 +create or replace table t2 (y int) as select * from t1; +flush tables; +show open tables like 't2'; +Database Table In_use Name_locked +test t2 1 0 +unlock tables; +# SP +create or replace procedure sp(n int) +begin +select concat('sp call ', n, ':') as ''; +show open tables like 't2'; +create or replace table t2 (y int); +select 'create or replace table t2 (y int);' as ''; +show open tables like 't2'; +insert into t2 values (2); +select 'insert into t2 values (2);' as ''; +show open tables like 't2'; +create or replace table t2 like t1; +select 'create or replace table t2 like t1;' as ''; +show open tables like 't2'; +create or replace table t2 (y int) as select * from t1; +select 'create or replace table t2 (y int) as select * from t1;' as ''; +show open tables like 't2'; +select 'select * from t2;' as ''; +select * from t2; +show open tables like 't2'; +end $ +flush tables; +call sp(1); + +sp call 1: +Database Table In_use Name_locked + +create or replace table t2 (y int); +Database Table In_use Name_locked + +insert into t2 values (2); +Database Table In_use Name_locked +test t2 0 0 + +create or replace table t2 like t1; +Database Table In_use Name_locked + +create or replace table t2 (y int) as select * from t1; +Database Table In_use Name_locked + +select * from t2; +y a +NULL 1 +NULL 1 +Database Table In_use Name_locked +test t2 0 0 +call sp(2); + +sp call 2: +Database Table In_use Name_locked +test t2 0 0 + +create or replace table t2 (y int); +Database Table In_use Name_locked + +insert into t2 values (2); +Database Table In_use Name_locked +test t2 0 0 + +create or replace table t2 like t1; +Database Table In_use Name_locked + +create or replace table t2 (y int) as select * from t1; +Database Table In_use Name_locked + +select * from t2; +y a +NULL 1 +NULL 1 +Database Table In_use Name_locked +test t2 0 0 +# SP under LOCK TABLES +lock tables t2 write, t1 write; +call sp(3); + +sp call 3: +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 (y int); +Database Table In_use Name_locked +test t2 1 0 + +insert into t2 values (2); +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 like t1; +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 (y int) as select * from t1; +Database Table In_use Name_locked +test t2 1 0 + +select * from t2; +y a +NULL 1 +NULL 1 +Database Table In_use Name_locked +test t2 1 0 +call sp(4); + +sp call 4: +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 (y int); +Database Table In_use Name_locked +test t2 1 0 + +insert into t2 values (2); +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 like t1; +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 (y int) as select * from t1; +Database Table In_use Name_locked +test t2 1 0 + +select * from t2; +y a +NULL 1 +NULL 1 +Database Table In_use Name_locked +test t2 1 0 +unlock tables; +drop procedure sp; +drop tables t1, t2, t3; +# Trigger +create table t1 (a int); +create trigger a before insert on t1 for each row set @s= 1; +create or replace table t1 (old int); +show create trigger a; +ERROR HY000: Trigger does not exist +drop table t1; +# Foreign keys +create table t1 (x int primary key, y int) engine innodb; +create table t2 (x int references t1(x)) engine innodb; +create or replace table t1 (x int primary key); +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) +create or replace table t1 (x int primary key); +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) +create table t3 (x int); +create or replace table t1 like t3; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) +create or replace table t1 like t3; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) +create or replace table t1 select * from t3; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) +create or replace table t1 select * from t3; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`x`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop tables t3, t2, t1; +# UNIQUE +create table t1 (pk int auto_increment primary key, a varchar(2300), unique (a)) engine aria; +insert into t1 (a) values ('a'), ('b'), ('c'); +create table t2 (x int); +create or replace table t2 engine aria select * from t1; +select * from t2; +pk a +1 a +2 b +3 c +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `pk` int(11) NOT NULL DEFAULT 0, + `a` varchar(2300) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 +drop tables t2, t1; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 573e0e177c26f..7d783710c17b2 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -5,8 +5,7 @@ --source include/have_innodb.inc --source include/have_metadata_lock_info.inc -SET @save_persistent=@@GLOBAL.innodb_stats_persistent; -SET GLOBAL innodb_stats_persistent=OFF; +let $MYSQLD_DATADIR= `SELECT @@datadir`; # # Create help table @@ -215,18 +214,23 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; --error ER_TABLE_MUST_HAVE_COLUMNS create or replace table test.t1; show tables; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; --error ER_TABLE_MUST_HAVE_COLUMNS create or replace table mysqltest2.t2; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +drop table mysqltest2.t2; +drop table t1; create table t1 (i int); drop table t1; @@ -235,18 +239,23 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; --error ER_DUP_FIELDNAME create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a'; show tables; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; --error ER_DUP_FIELDNAME create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +drop table mysqltest2.t2; +drop table t1; create table t1 (i int); drop table t1; @@ -255,7 +264,8 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; unlock tables; drop table test.t1,mysqltest2.t2; @@ -264,7 +274,8 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; unlock tables; drop table t1; @@ -280,13 +291,16 @@ create table t1 (i int); lock table t1 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; --error ER_DATA_TOO_LONG create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a; +drop table t1; show tables; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; create table t1 (i int); drop table t1; @@ -364,20 +378,24 @@ create table t1 (a int); lock table t1 write, t2 read; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; create or replace table t1 (i int); --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; create or replace table t1 like t2; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; create or replace table t1 select 1 as f1; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; drop table t1; unlock tables; @@ -510,4 +528,107 @@ DROP TABLE t3; --echo # End of 10.4 tests -SET GLOBAL innodb_stats_persistent=@save_persistent; +--echo # +--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE +--echo # +create table t1 (a int); +insert t1 values (1), (1); +create table t2 (c int); +--error ER_DUP_KEYNAME +create or replace table t2 (a int, b int, key k (a), key k (b)); +show create table t2; +--error ER_DUP_KEYNAME +create or replace table t2 (a int, b int, key k (a), key k (b)) as select a, a as b from t1; +show create table t2; +--error ER_DUP_ENTRY +create or replace table t2 (a int primary key) as select * from t1; +show create table t2; +set @old_mode= @@sql_mode; +set @@sql_mode='ALLOW_INVALID_DATES'; +create table t3 (dt datetime default '2008-02-31 00:00:00'); +set @@sql_mode= @old_mode; +--error ER_INVALID_DEFAULT +create or replace table t2 like t3; +show create table t2; +--echo # LOCK TABLES +lock tables t2 write, t1 write; +flush tables; +show open tables like 't2'; +create or replace table t2 (y int); +flush tables; +show open tables like 't2'; +create or replace table t2 like t1; +flush tables; +show open tables like 't2'; +create or replace table t2 (y int) as select * from t1; +flush tables; +show open tables like 't2'; +unlock tables; +--echo # SP +--delimiter $ +create or replace procedure sp(n int) +begin + select concat('sp call ', n, ':') as ''; + show open tables like 't2'; + create or replace table t2 (y int); + select 'create or replace table t2 (y int);' as ''; + show open tables like 't2'; + insert into t2 values (2); + select 'insert into t2 values (2);' as ''; + show open tables like 't2'; + create or replace table t2 like t1; + select 'create or replace table t2 like t1;' as ''; + show open tables like 't2'; + create or replace table t2 (y int) as select * from t1; + select 'create or replace table t2 (y int) as select * from t1;' as ''; + show open tables like 't2'; + select 'select * from t2;' as ''; + select * from t2; + show open tables like 't2'; +end $ +--delimiter ; +flush tables; +call sp(1); call sp(2); +--echo # SP under LOCK TABLES +lock tables t2 write, t1 write; +call sp(3); call sp(4); +unlock tables; +drop procedure sp; +drop tables t1, t2, t3; +--echo # Trigger +create table t1 (a int); +create trigger a before insert on t1 for each row set @s= 1; +create or replace table t1 (old int); +--error ER_TRG_DOES_NOT_EXIST +show create trigger a; +drop table t1; +--echo # Foreign keys +--list_files $MYSQLD_DATADIR/test *sql* +create table t1 (x int primary key, y int) engine innodb; +create table t2 (x int references t1(x)) engine innodb; +--error ER_ROW_IS_REFERENCED_2 +create or replace table t1 (x int primary key); +--list_files $MYSQLD_DATADIR/test *sql* +--error ER_ROW_IS_REFERENCED_2 +create or replace table t1 (x int primary key); +create table t3 (x int); +--error ER_ROW_IS_REFERENCED_2 +create or replace table t1 like t3; +--list_files $MYSQLD_DATADIR/test *sql* +--error ER_ROW_IS_REFERENCED_2 +create or replace table t1 like t3; +--error ER_ROW_IS_REFERENCED_2 +create or replace table t1 select * from t3; +--error ER_ROW_IS_REFERENCED_2 +create or replace table t1 select * from t3; +--list_files $MYSQLD_DATADIR/test *sql* +show create table t1; +drop tables t3, t2, t1; +--echo # UNIQUE +create table t1 (pk int auto_increment primary key, a varchar(2300), unique (a)) engine aria; +insert into t1 (a) values ('a'), ('b'), ('c'); +create table t2 (x int); +create or replace table t2 engine aria select * from t1; +select * from t2; +show create table t2; +drop tables t2, t1; diff --git a/mysql-test/main/create_or_replace2.result b/mysql-test/main/create_or_replace2.result index 6be0d46bdc11b..f7bbb7417e6e1 100644 --- a/mysql-test/main/create_or_replace2.result +++ b/mysql-test/main/create_or_replace2.result @@ -21,7 +21,54 @@ connection slave; SHOW TABLES; Tables_in_test t1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 connection master; drop temporary table if exists tmp; drop table t1; include/rpl_end.inc +# +# MDEV-25292 Atomic CREATE OR REPLACE TABLE +# +set @saved_debug_dbug= @@session.debug_dbug; +create table t1 (a int primary key) engine innodb; +insert t1 values (1), (2); +create table t2 (c int, a int constraint t1_a references t1 (a)) engine innodb; +insert into t2 values (2, 2); +lock tables t2 write, t1 write; +set session debug_dbug= '+d,atomic_replace_external_lock_fail'; +create or replace table t2 (y int) as select * from t1; +ERROR HY000: The total number of locks exceeds the lock table size +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL, + `a` int(11) DEFAULT NULL, + KEY `t1_a` (`a`), + CONSTRAINT `t1_a` FOREIGN KEY (`a`) REFERENCES `t1` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +select * from t2; +c a +2 2 +unlock tables; +drop tables t2, t1; +set session debug_dbug= @saved_debug_dbug; +# Test entry_pos in higher position, so drop chain executes before create chain +# (see commit message: On linking two chains together) +create table t1 (c int); +create or replace table t1 (a int, b int, key k (a), key k (b)); +ERROR 42000: Duplicate key name 'k' +create or replace table t1 (a int, b int, key k (a), key k (b)); +ERROR 42000: Duplicate key name 'k' +drop table t1; diff --git a/mysql-test/main/create_or_replace2.test b/mysql-test/main/create_or_replace2.test index 80c8b635d8d5d..227aff226d53c 100644 --- a/mysql-test/main/create_or_replace2.test +++ b/mysql-test/main/create_or_replace2.test @@ -26,6 +26,7 @@ SHOW TABLES; show create table t1; --sync_slave_with_master SHOW TABLES; +show create table t1; --connection master --disable_warnings @@ -33,3 +34,34 @@ drop temporary table if exists tmp; --enable_warnings drop table t1; --source include/rpl_end.inc + + +--echo # +--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE +--echo # +set @saved_debug_dbug= @@session.debug_dbug; +create table t1 (a int primary key) engine innodb; +insert t1 values (1), (2); +create table t2 (c int, a int constraint t1_a references t1 (a)) engine innodb; +insert into t2 values (2, 2); +lock tables t2 write, t1 write; +set session debug_dbug= '+d,atomic_replace_external_lock_fail'; +--error ER_LOCK_TABLE_FULL +create or replace table t2 (y int) as select * from t1; +let $MYSQLD_DATADIR= `SELECT @@datadir`; +--list_files $MYSQLD_DATADIR/test *sql* +show create table t1; +show create table t2; +select * from t2; +unlock tables; +drop tables t2, t1; +set session debug_dbug= @saved_debug_dbug; + +--echo # Test entry_pos in higher position, so drop chain executes before create chain +--echo # (see commit message: On linking two chains together) +create table t1 (c int); +--error ER_DUP_KEYNAME +create or replace table t1 (a int, b int, key k (a), key k (b)); +--error ER_DUP_KEYNAME +create or replace table t1 (a int, b int, key k (a), key k (b)); +drop table t1; diff --git a/mysql-test/main/default.result b/mysql-test/main/default.result index 2d94c0695a040..5285169456859 100644 --- a/mysql-test/main/default.result +++ b/mysql-test/main/default.result @@ -428,14 +428,6 @@ a b c e 2 -1 1 1 drop table t1; # -# Create or replace can delete a table on error -# -create table t1 (a int); -create or replace table t1 (a int default b, b int default a); -ERROR 01000: Expression for field `a` is referring to uninitialized field `b` -show create table t1; -ERROR 42S02: Table 'test.t1' doesn't exist -# # Refering to other columns # create or replace table t1 (a int default 1, b int default a); @@ -453,11 +445,11 @@ ERROR 01000: Expression for field `a` is referring to uninitialized field `a` create or replace table t1 (a int default b, b int default (1+1)); create or replace table t1 (a int default 1, b int as (c), c int as (a+1)); ERROR 01000: Expression for field `b` is referring to uninitialized field `c` -CREATE TABLE t1 (a INT DEFAULT (DEFAULT(a))); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT (DEFAULT(a))); ERROR 01000: Expression for field `a` is referring to uninitialized field `a` -CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); ERROR 01000: Expression for field `a` is referring to uninitialized field `b` -CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); ERROR 01000: Expression for field `a` is referring to uninitialized field `b` # # Allow defaults to refer to not default fields diff --git a/mysql-test/main/default.test b/mysql-test/main/default.test index 26fc218653313..36a616551d734 100644 --- a/mysql-test/main/default.test +++ b/mysql-test/main/default.test @@ -307,15 +307,6 @@ insert into t1 values(); select * from t1; drop table t1; ---echo # ---echo # Create or replace can delete a table on error ---echo # -create table t1 (a int); ---error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -create or replace table t1 (a int default b, b int default a); ---error ER_NO_SUCH_TABLE -show create table t1; - --echo # --echo # Refering to other columns --echo # @@ -338,11 +329,11 @@ create or replace table t1 (a int default b, b int default (1+1)); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD create or replace table t1 (a int default 1, b int as (c), c int as (a+1)); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -CREATE TABLE t1 (a INT DEFAULT (DEFAULT(a))); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT (DEFAULT(a))); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); --echo # --echo # Allow defaults to refer to not default fields diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 30c6aaf0f2041..19d1f462aa025 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -397,7 +397,8 @@ c d create or replace table t2 (a int, b blob, unique(b)) as select * from t1; ERROR 23000: Duplicate entry 'bar' for key 'b' select * from t2; -ERROR 42S02: Table 'test.t2' doesn't exist +c d +3 bar create or replace table t2 (a int, b blob, unique(b)) ignore as select * from t1; Warnings: Warning 1062 Duplicate entry 'bar' for key 'b' diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 18e430858b05a..e522f5140bae9 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -480,7 +480,6 @@ delete from t2 using t1, t2 where t1.a=t2.c and t1.b='foo'; # CREATE...SELECT --error ER_DUP_ENTRY create or replace table t2 (a int, b blob, unique(b)) as select * from t1; ---error ER_NO_SUCH_TABLE select * from t2; create or replace table t2 (a int, b blob, unique(b)) ignore as select * from t1; select * from t2; diff --git a/mysql-test/suite/atomic/create_replace,aria_notrans,row.result b/mysql-test/suite/atomic/create_replace,aria_notrans,row.result new file mode 100644 index 0000000000000..0006c405608c5 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace,aria_notrans,row.result @@ -0,0 +1,710 @@ +# Crash recovery +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,aria_notrans.result b/mysql-test/suite/atomic/create_replace,aria_notrans.result new file mode 100644 index 0000000000000..a6ce2c40c7ee9 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace,aria_notrans.result @@ -0,0 +1,696 @@ +# Crash recovery +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,expensive_rename,row.result b/mysql-test/suite/atomic/create_replace,expensive_rename,row.result new file mode 100644 index 0000000000000..dd8ba62643f54 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace,expensive_rename,row.result @@ -0,0 +1,584 @@ +# Crash recovery +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_create_before_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_drop_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_rename_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_create_before_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_drop_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_rename_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_create_before_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_drop_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_rename_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,expensive_rename.result b/mysql-test/suite/atomic/create_replace,expensive_rename.result new file mode 100644 index 0000000000000..8d64a6cd950f8 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace,expensive_rename.result @@ -0,0 +1,561 @@ +# Crash recovery +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_create_before_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_drop_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_rename_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_create_before_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_drop_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_rename_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_create_before_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_drop_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_log_rename_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_install_new +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,ib,row.result b/mysql-test/suite/atomic/create_replace,ib,row.result new file mode 100644 index 0000000000000..84c0ccefcd9d0 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace,ib,row.result @@ -0,0 +1,661 @@ +# Crash recovery +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_create_before_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_save_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.TRG +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete2 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,ib.result b/mysql-test/suite/atomic/create_replace,ib.result new file mode 100644 index 0000000000000..18b88211e06b8 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace,ib.result @@ -0,0 +1,648 @@ +# Crash recovery +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_create_before_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_save_backup +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,myisam,row.result b/mysql-test/suite/atomic/create_replace,myisam,row.result new file mode 100644 index 0000000000000..cf4d48c436b5e --- /dev/null +++ b/mysql-test/suite/atomic/create_replace,myisam,row.result @@ -0,0 +1,710 @@ +# Crash recovery +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,row.result b/mysql-test/suite/atomic/create_replace,row.result new file mode 100644 index 0000000000000..7d0a1888fc244 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace,row.result @@ -0,0 +1,710 @@ +# Crash recovery +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace.combinations b/mysql-test/suite/atomic/create_replace.combinations new file mode 100644 index 0000000000000..09eb352b1cdf3 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace.combinations @@ -0,0 +1,6 @@ +[ib] +[myisam] +[aria] +[aria_notrans] +[expensive_rename] +[lock_tables] diff --git a/mysql-test/suite/atomic/create_replace.result b/mysql-test/suite/atomic/create_replace.result new file mode 100644 index 0000000000000..0bac8d8bb92fd --- /dev/null +++ b/mysql-test/suite/atomic/create_replace.result @@ -0,0 +1,696 @@ +# Crash recovery +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_create_before_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_drop_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_log_rename_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_drop +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_save_backup +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_install_new +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_fk_fail +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail2 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_fk_fail3 +t1.TRG +t1.frm +t1.ibd +t2.frm +t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) NOT NULL, + `y` int(11) DEFAULT NULL, + PRIMARY KEY (`old`) +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +old y +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_log_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete2 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_log_complete3 +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace.test b/mysql-test/suite/atomic/create_replace.test new file mode 100644 index 0000000000000..7cb6d3494445a --- /dev/null +++ b/mysql-test/suite/atomic/create_replace.test @@ -0,0 +1,211 @@ +--source include/have_debug.inc +--source include/have_sequence.inc +--source include/have_innodb.inc +--source include/binlog_formats.inc +--source include/not_valgrind.inc + +--disable_query_log +let $default_engine=InnoDB; +let $extra_option= ''; +let $save_debug=`select @@debug_dbug`; +let $show_error=0; +let $drop_error=0; + +if ($MTR_COMBINATION_MYISAM) +{ + let $default_engine=MyISAM; +} +if ($MTR_COMBINATION_ARIA) +{ + let $default_engine=Aria; + call mtr.add_suppression("Checking table"); + call mtr.add_suppression("marked as crashed"); +} +if ($MTR_COMBINATION_ARIA_NOTRANS) +{ + let $default_engine=Aria; + let $extra_option=' engine=aria,transactional=0'; + call mtr.add_suppression("Checking table"); + call mtr.add_suppression("marked as crashed"); +} +if ($MTR_COMBINATION_EXPENSIVE_RENAME) +{ + # Disable atomic CREATE OR REPLACE (emulates HTON_EXPENSIVE_RENAME flag) + let $default_engine=MyISAM; + let $show_error=0, ER_NO_SUCH_TABLE; + let $drop_error=0, ER_BAD_TABLE_ERROR; + set @@debug_dbug="+d,ddl_log_expensive_rename"; +} +if ($MTR_COMBINATION_LOCK_TABLES) +{ + let $default_engine=Aria; + call mtr.add_suppression("Checking table"); + call mtr.add_suppression("marked as crashed"); +} + +if ($MTR_COMBINATION_STMT) +{ + let $binlog_format=include/set_binlog_format_statement.sql; +} +if ($MTR_COMBINATION_ROW) +{ + let $binlog_format=include/set_binlog_format_row.sql; +} +if ($MTR_COMBINATION_MIX) +{ + --skip same as stmt +} + +--eval set @@default_storage_engine=$default_engine +--enable_query_log + +--echo # Crash recovery + +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +let $crash_count=19; +let $crash_points='ddl_log_create_before_install_new', + 'ddl_log_create_after_log_drop_backup', + 'ddl_log_create_after_log_rename_backup', + 'ddl_log_create_before_create_frm', + 'ddl_log_create_before_create_table', + 'ddl_log_create_after_create_table', + 'ddl_log_create_after_drop', + 'ddl_log_create_after_send_data', + 'ddl_log_create_after_save_backup', + 'ddl_log_create_after_install_new', + 'ddl_log_create_before_binlog', + 'ddl_log_create_after_prepare_eof', + 'ddl_log_create_after_binlog', + 'ddl_log_create_fk_fail', + 'ddl_log_create_fk_fail2', + 'ddl_log_create_fk_fail3', + 'ddl_log_create_log_complete', + 'ddl_log_create_log_complete2', + 'ddl_log_create_log_complete3'; + +#let $crash_count=1; +#let $crash_points='ddl_log_create_fk_fail'; +# 'ddl_log_create_before_binlog3', +# 'ddl_log_create_before_binlog4'; + +let $statement_count=3; +let $statements='CREATE OR REPLACE TABLE t1 (new int) EXTRA_OPTION', + 'CREATE OR REPLACE TABLE t1 LIKE const_table', + 'CREATE OR REPLACE TABLE t1 EXTRA_OPTION SELECT * from const_table'; + +#let $statement_count=1; +#let $statements='CREATE OR REPLACE TABLE t1 EXTRA_OPTION SELECT * from const_table'; + +--disable_query_log +let create_const=`select REPLACE('create table const_table (new int, b int) EXTRA_OPTION', ' EXTRA_OPTION', $extra_option)`; +eval $create_const; +--replace_result $default_engine ENGINE ' PAGE_CHECKSUM=1' '' ' TRANSACTIONAL=0' '' +show create table const_table; +--enable_query_log +insert into const_table values (1, 1), (2, 2); +flush tables; + +let $old_debug=`select @@debug_dbug`; + +let $keep_include_silent=1; +let $grep_script=CREATE|DROP; +--disable_query_log + +let $r=0; +while ($r < $statement_count) +{ + inc $r; + let $STATEMENT=`select REPLACE(ELT($r, $statements), ' EXTRA_OPTION', $extra_option)`; + --echo # QUERY: $STATEMENT + + let $c=0; + while ($c < $crash_count) + { + inc $c; + let $crash= `select ELT($c, $crash_points)`; + let $fk_error= `select '$crash' like 'ddl_log_create_fk_fail%'`; + + --eval set @@default_storage_engine=$default_engine + create or replace table t1 (old int); + if ($fk_error) + { + create or replace table t1 (old int primary key, y int) engine innodb; + create table t2 (x int references t1(old)) engine innodb; + } + create trigger a before insert on t1 for each row set @s= 1; + flush tables; + if ($MTR_COMBINATION_LOCK_TABLES) + { + lock tables t1 write, const_table read; + } + + --source $binlog_format + + RESET MASTER; + --echo # CRASH POINT: $crash + --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + --disable_reconnect + --eval set @@debug_dbug="+d,$crash",@debug_crash_counter=1 + let $errno=0; + --error 0,2013 + eval $STATEMENT; + let $error=$errno; + --enable_reconnect + --source include/wait_until_connected_again.inc + --disable_query_log + --eval set @@debug_dbug="$old_debug" + + if ($error == 0) + { + --echo # No crash! + if ($MTR_COMBINATION_LOCK_TABLES) + { + unlock tables; + } + } + # Check which tables still exists + --replace_result .MAD .DATA1 .MYD .DATA1 .MAI .DATA2 .MYI .DATA2 + --list_files $MYSQLD_DATADIR/test t* + --list_files $MYSQLD_DATADIR/test *sql* + + --let $binlog_file=master-bin.000001 + --source include/show_binlog_events.inc + if ($error) + { + --let $binlog_file=master-bin.000002 + --source include/show_binlog_events.inc + } + + if ($default_engine == Aria) + { + # Again we suppress 'marked as crashed', it works differently in --ps + --disable_warnings + } + --replace_result $default_engine ENGINE InnoDB ENGINE ' PAGE_CHECKSUM=1' '' ' TRANSACTIONAL=0' '' + --error $show_error + show create table t1; + --enable_warnings + if (`select locate('SELECT', '$STATEMENT')`) + { + --error $show_error + select * from t1; + } + --enable_warnings + --replace_column 6 '' 7 '' 8 '' 9 '' 10 '' 11 '' + show triggers; + # Drop the tables. The warnings will show what was dropped + if ($fk_error) + { + drop table t2; + } + --disable_warnings + --error $drop_error + drop table t1; + --enable_warnings + } +} +drop table if exists t1,const_table; +--eval set @@debug_dbug="$save_debug" + +--enable_query_log diff --git a/mysql-test/suite/atomic/create_table.result b/mysql-test/suite/atomic/create_table.result index acc78c76d254c..aa22e3cb0ed55 100644 --- a/mysql-test/suite/atomic/create_table.result +++ b/mysql-test/suite/atomic/create_table.result @@ -55,7 +55,6 @@ t2.MYI t2.frm master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) crash point: ddl_log_create_log_complete -"No crash!" t1.MYD t1.MYI t1.frm @@ -63,40 +62,6 @@ t2.MYD t2.MYI t2.frm master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) -query: CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_after_binlog -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_log_complete -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) query: CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_before_create_frm t2.MYD @@ -150,7 +115,6 @@ t2.MYI t2.frm master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_log_complete -"No crash!" t1.MYD t1.MYI t1.frm @@ -158,40 +122,6 @@ t2.MYD t2.MYI t2.frm master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table -query: CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_after_binlog -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_log_complete -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table query: CREATE TABLE t1 SELECT * from t2 crash point: ddl_log_create_before_create_frm t2.MYD @@ -238,16 +168,9 @@ t2.MYD t2.MYI t2.frm crash point: ddl_log_create_after_binlog -t1.MYD -t1.MYI -t1.frm t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` ( - `seq` bigint(20) unsigned NOT NULL -) -master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT * from t2 crash point: ddl_log_create_log_complete t1.MYD t1.MYI @@ -259,47 +182,6 @@ master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` ( `seq` bigint(20) unsigned NOT NULL ) master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT * from t2 -query: CREATE OR REPLACE TABLE t2 SELECT * from const_table -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_binlog -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table -crash point: ddl_log_create_log_complete -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table engine: innodb query: CREATE TABLE t1 (a int) crash point: ddl_log_create_before_create_frm @@ -342,42 +224,11 @@ t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) crash point: ddl_log_create_log_complete -"No crash!" t1.frm t1.ibd t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) -query: CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -"No crash!" -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_after_binlog -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_log_complete -"No crash!" -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) query: CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_before_create_frm t2.frm @@ -423,47 +274,12 @@ t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_log_complete -"No crash!" t1.MYD t1.MYI t1.frm t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table -query: CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_after_binlog -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_log_complete -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table query: CREATE TABLE t1 SELECT * from t2 crash point: ddl_log_create_before_create_frm t2.frm @@ -494,44 +310,17 @@ t2.ibd crash point: ddl_log_create_after_prepare_eof t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 -master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t1` /* generated by ddl recovery */ crash point: ddl_log_create_after_binlog +t1.frm +t1.ibd t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 -master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t1` /* generated by ddl recovery */ crash point: ddl_log_create_log_complete t1.frm t1.ibd t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 -query: CREATE OR REPLACE TABLE t2 SELECT * from const_table -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table -master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_binlog -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table -master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t2` /* generated by ddl recovery */ -crash point: ddl_log_create_log_complete -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table Warnings: Note 1051 Unknown table 'test.t1,test.t2' diff --git a/mysql-test/suite/atomic/create_table.test b/mysql-test/suite/atomic/create_table.test index ff53a12ebabc0..d2b63de877d1c 100644 --- a/mysql-test/suite/atomic/create_table.test +++ b/mysql-test/suite/atomic/create_table.test @@ -30,13 +30,10 @@ if ($engine_count == "") let $crash_count=9; let $crash_points='ddl_log_create_before_create_frm', 'storage_engine_middle_of_create', 'ddl_log_create_before_create_table', 'ddl_log_create_after_create_table', 'ddl_log_create_after_drop', 'ddl_log_create_before_binlog', 'ddl_log_create_after_prepare_eof', 'ddl_log_create_after_binlog', 'ddl_log_create_log_complete'; -let $statement_count=6; +let $statement_count=3; let $statements='CREATE TABLE t1 (a int)', - 'CREATE OR REPLACE TABLE t2 (a int)', 'CREATE TABLE t1 LIKE const_table', - 'CREATE OR REPLACE TABLE t2 LIKE const_table', - 'CREATE TABLE t1 SELECT * from t2', - 'CREATE OR REPLACE TABLE t2 SELECT * from const_table'; + 'CREATE TABLE t1 SELECT * from t2'; create table const_table (a int, b int) engine=myisam; insert into const_table values (1,1),(2,2); @@ -54,6 +51,8 @@ while ($e < $engine_count) inc $e; let $engine=`select ELT($e, $engines)`; let $default_engine=$engine; + # Note: $extra_option is not used. This dead code here is for conformity with + # other tests. let $extra_option=; if ($engine == "aria") diff --git a/mysql-test/suite/binlog/include/binlog.test b/mysql-test/suite/binlog/include/binlog.test index 9f3288b52f07a..1061cf5101822 100644 --- a/mysql-test/suite/binlog/include/binlog.test +++ b/mysql-test/suite/binlog/include/binlog.test @@ -419,6 +419,7 @@ create table t (old_table_field int); create or replace table t as select 1 as b, 2 as b; --error ER_DUP_FIELDNAME create or replace temporary table t as select 1 as b, 2 as b; +drop table t; create table t (new_table_field int); --source include/show_binlog_events.inc diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result index fa111106cd663..c0e4e6f46be3d 100644 --- a/mysql-test/suite/binlog/r/binlog_row_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result @@ -1085,14 +1085,14 @@ create or replace table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' create or replace temporary table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' +drop table t; create table t (new_table_field int); 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 t (old_table_field int) -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t (new_table_field int) drop table t; diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result index f48b624ec2152..dc0b3c2b4a104 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result @@ -682,15 +682,16 @@ create or replace table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' create or replace temporary table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' +drop table t; create table t (new_table_field int); 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 t (old_table_field int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t (new_table_field int) drop table t; diff --git a/mysql-test/suite/binlog/r/binlog_write_error.result b/mysql-test/suite/binlog/r/binlog_write_error.result index 46a233718d982..eb83a1805e61e 100644 --- a/mysql-test/suite/binlog/r/binlog_write_error.result +++ b/mysql-test/suite/binlog/r/binlog_write_error.result @@ -9,6 +9,8 @@ CREATE TABLE t1 (a INT); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; INSERT INTO t1 VALUES (1),(2),(3); +ERROR 42S02: Table 'test.t1' doesn't exist +CREATE TABLE t1 (a INT); set @saved_dbug = @@global.debug_dbug; SET GLOBAL debug_dbug='d,injecting_fault_writing'; INSERT INTO t1 VALUES (4),(5),(6); diff --git a/mysql-test/suite/binlog/t/binlog_write_error.test b/mysql-test/suite/binlog/t/binlog_write_error.test index bd1cb5301b3d4..f62d1f1fd494a 100644 --- a/mysql-test/suite/binlog/t/binlog_write_error.test +++ b/mysql-test/suite/binlog/t/binlog_write_error.test @@ -30,8 +30,11 @@ call mtr.add_suppression("Write to binary log failed: Error writing file*"); let $query= CREATE TABLE t1 (a INT); source include/binlog_inject_error.inc; +--error ER_NO_SUCH_TABLE INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t1 (a INT); + let $query= INSERT INTO t1 VALUES (4),(5),(6); source include/binlog_inject_error.inc; diff --git a/mysql-test/suite/binlog_encryption/binlog_write_error.result b/mysql-test/suite/binlog_encryption/binlog_write_error.result index 46a233718d982..eb83a1805e61e 100644 --- a/mysql-test/suite/binlog_encryption/binlog_write_error.result +++ b/mysql-test/suite/binlog_encryption/binlog_write_error.result @@ -9,6 +9,8 @@ CREATE TABLE t1 (a INT); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; INSERT INTO t1 VALUES (1),(2),(3); +ERROR 42S02: Table 'test.t1' doesn't exist +CREATE TABLE t1 (a INT); set @saved_dbug = @@global.debug_dbug; SET GLOBAL debug_dbug='d,injecting_fault_writing'; INSERT INTO t1 VALUES (4),(5),(6); diff --git a/mysql-test/suite/parts/r/backup_log.result b/mysql-test/suite/parts/r/backup_log.result index 3a22049102708..9b745eb8fa02d 100644 --- a/mysql-test/suite/parts/r/backup_log.result +++ b/mysql-test/suite/parts/r/backup_log.result @@ -67,7 +67,7 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' create table t32 (a int) PARTITION BY HASH(a) PARTITIONS 2; drop table if exists t30,t31,t32,tmp_t30; Warnings: -Note 1051 Unknown table 'test.t31,test.tmp_t30' +Note 1051 Unknown table 'test.tmp_t30' # # Testing create LIKE # @@ -208,70 +208,69 @@ CREATE,MyISAM,1,test,t30,id: 8,,0,,, CREATE,MyISAM,1,test,t31,id: 9,,0,,, DROP,MyISAM,1,test,t31,id: 9,,0,,, CREATE,MyISAM,0,test,t31,id: 10,,0,,, -DROP,MyISAM,0,test,t31,id: 10,,0,,, -DROP_AFTER_CREATE,MyISAM,1,test,t31,id: 11,,0,,, -CREATE,MyISAM,1,test,t32,id: 12,,0,,, +CREATE,MyISAM,1,test,t32,id: 11,,0,,, DROP,MyISAM,1,test,t30,id: 8,,0,,, -DROP,MyISAM,1,test,t32,id: 12,,0,,, -CREATE,MyISAM,1,test,t40,id: 13,,0,,, -CREATE,InnoDB,1,test,t41,id: 14,,0,,, +DROP,MyISAM,0,test,t31,id: 10,,0,,, +DROP,MyISAM,1,test,t32,id: 11,,0,,, +CREATE,MyISAM,1,test,t40,id: 12,,0,,, +CREATE,InnoDB,1,test,t41,id: 13,,0,,, +CREATE,partition,0,test,t42,id: 14,,0,,, +DROP,MyISAM,1,test,t42,id: 14,,0,,, CREATE,partition,0,test,t42,id: 15,,0,,, -DROP,MyISAM,1,test,t42,id: 15,,0,,, -CREATE,partition,0,test,t42,id: 16,,0,,, -DROP,MyISAM,1,test,t40,id: 13,,0,,, -DROP,InnoDB,1,test,t41,id: 14,,0,,, -DROP,InnoDB,1,test,t42,id: 16,,0,,, -CREATE,MyISAM,1,test,t50,id: 17,,0,,, -CREATE,MyISAM,1,test,t51,id: 18,,0,,, -RENAME,MyISAM,1,test,t50,id: 17,MyISAM,1,test,t52,id: 17 -RENAME,MyISAM,1,test,t51,id: 18,MyISAM,1,test,t53,id: 18 -RENAME,MyISAM,1,test,t52,id: 17,MyISAM,1,test,tmp,id: 17 -RENAME,MyISAM,1,test,t53,id: 18,MyISAM,1,test,t52,id: 18 -RENAME,MyISAM,1,test,tmp,id: 17,MyISAM,1,test,t53,id: 17 -DROP,MyISAM,1,test,t52,id: 18,,0,,, -DROP,MyISAM,1,test,t53,id: 17,,0,,, -CREATE,Aria,1,test,t60,id: 19,,0,,, -CHANGE_INDEX,Aria,1,test,t60,id: 19,,0,,, -CHANGE_INDEX,Aria,1,test,t60,id: 19,,0,,, -DROP,Aria,1,test,t60,id: 19,,0,,, -CREATE,Aria,1,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, -TRUNCATE,Aria,1,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, -CREATE,Aria,1,test,t71,id: 21,,0,,, -BULK_INSERT,Aria,1,test,t71,id: 21,,0,,, -BULK_INSERT,Aria,1,test,t71,id: 21,,0,,, -DROP,Aria,1,test,t70,id: 20,,0,,, -DROP,Aria,1,test,t71,id: 21,,0,,, -CREATE,MyISAM,1,test,t@00201,id: 22,,0,,, -DROP,MyISAM,1,test,t@00201,id: 22,,0,,, -CREATE,MyISAM,1,test,t80,id: 23,,0,,, +DROP,MyISAM,1,test,t40,id: 12,,0,,, +DROP,InnoDB,1,test,t41,id: 13,,0,,, +DROP,InnoDB,1,test,t42,id: 15,,0,,, +CREATE,MyISAM,1,test,t50,id: 16,,0,,, +CREATE,MyISAM,1,test,t51,id: 17,,0,,, +RENAME,MyISAM,1,test,t50,id: 16,MyISAM,1,test,t52,id: 16 +RENAME,MyISAM,1,test,t51,id: 17,MyISAM,1,test,t53,id: 17 +RENAME,MyISAM,1,test,t52,id: 16,MyISAM,1,test,tmp,id: 16 +RENAME,MyISAM,1,test,t53,id: 17,MyISAM,1,test,t52,id: 17 +RENAME,MyISAM,1,test,tmp,id: 16,MyISAM,1,test,t53,id: 16 +DROP,MyISAM,1,test,t52,id: 17,,0,,, +DROP,MyISAM,1,test,t53,id: 16,,0,,, +CREATE,Aria,1,test,t60,id: 18,,0,,, +CHANGE_INDEX,Aria,1,test,t60,id: 18,,0,,, +CHANGE_INDEX,Aria,1,test,t60,id: 18,,0,,, +DROP,Aria,1,test,t60,id: 18,,0,,, +CREATE,Aria,1,test,t70,id: 19,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 19,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 19,,0,,, +TRUNCATE,Aria,1,test,t70,id: 19,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 19,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 19,,0,,, +CREATE,Aria,1,test,t71,id: 20,,0,,, +BULK_INSERT,Aria,1,test,t71,id: 20,,0,,, +BULK_INSERT,Aria,1,test,t71,id: 20,,0,,, +DROP,Aria,1,test,t70,id: 19,,0,,, +DROP,Aria,1,test,t71,id: 20,,0,,, +CREATE,MyISAM,1,test,t@00201,id: 21,,0,,, +DROP,MyISAM,1,test,t@00201,id: 21,,0,,, +CREATE,MyISAM,1,test,t80,id: 22,,0,,, CREATE,VIEW,0,test,v1,,,0,,, CREATE,TRIGGER,0,test,trg,,,0,,, DROP,TRIGGER,0,test,trg,,,0,,, DROP,VIEW,0,test,v1,,,0,,, -DROP,MyISAM,1,test,t80,id: 23,,0,,, -CREATE,MyISAM,1,test,t85,id: 24,,0,,, -ALTER,MyISAM,1,test,t85,id: 24,InnoDB,1,test,t85,id: 25 -DROP,InnoDB,1,test,t85,id: 25,,0,,, -CREATE,Aria,0,test,t200,id: 26,,0,,, -ALTER,Aria,0,test,t200,id: 26,Aria,1,test,t200,id: 27 -CREATE,Aria,0,test,t210,id: 28,,0,,, -EXCHANGE_PARTITION,Aria,1,test,t200,id: 27,Aria,0,test,t210,id: 28 -ALTER,Aria,1,test,t200,id: 27,Aria,1,test,t200,id: 29 +DROP,MyISAM,1,test,t80,id: 22,,0,,, +CREATE,MyISAM,1,test,t85,id: 23,,0,,, +ALTER,MyISAM,1,test,t85,id: 23,InnoDB,1,test,t85,id: 24 +DROP,InnoDB,1,test,t85,id: 24,,0,,, +CREATE,Aria,0,test,t200,id: 25,,0,,, +ALTER,Aria,0,test,t200,id: 25,Aria,1,test,t200,id: 26 +CREATE,Aria,0,test,t210,id: 27,,0,,, +EXCHANGE_PARTITION,Aria,1,test,t200,id: 26,Aria,0,test,t210,id: 27 +ALTER,Aria,1,test,t200,id: 26,Aria,1,test,t200,id: 28 +ALTER,Aria,1,test,t200,id: 28,Aria,1,test,t200,id: 29 ALTER,Aria,1,test,t200,id: 29,Aria,1,test,t200,id: 30 ALTER,Aria,1,test,t200,id: 30,Aria,1,test,t200,id: 31 ALTER,Aria,1,test,t200,id: 31,Aria,1,test,t200,id: 32 ALTER,Aria,1,test,t200,id: 32,Aria,1,test,t200,id: 33 ALTER,Aria,1,test,t200,id: 33,Aria,1,test,t200,id: 34 -ALTER,Aria,1,test,t200,id: 34,Aria,1,test,t200,id: 35 -ALTER,Aria,1,test,t200,id: 35,Aria,0,test,t200,id: 36 -DROP,Aria,0,test,t200,id: 36,,0,,, -DROP,Aria,0,test,t210,id: 28,,0,,, -CREATE,Aria,1,test,t220,id: 37,,0,,, -DROP,Aria,1,test,t220,id: 37,,0,,, +ALTER,Aria,1,test,t200,id: 34,Aria,0,test,t200,id: 35 +DROP,Aria,0,test,t200,id: 35,,0,,, +DROP,Aria,0,test,t210,id: 27,,0,,, +CREATE,Aria,1,test,t220,id: 36,,0,,, +DROP,Aria,1,test,t220,id: 36,,0,,, # # Cleanup # diff --git a/mysql-test/suite/rpl/r/create_or_replace2,stmt.rdiff b/mysql-test/suite/rpl/r/create_or_replace2,stmt.rdiff new file mode 100644 index 0000000000000..52dd3828b3848 --- /dev/null +++ b/mysql-test/suite/rpl/r/create_or_replace2,stmt.rdiff @@ -0,0 +1,17 @@ +--- create_or_replace2.result ++++ create_or_replace2,stmt.reject +@@ -34,9 +34,11 @@ + master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) + RETURN ( SELECT MAX(a) FROM t1 ) + master-bin.000001 # Gtid # # GTID #-#-# +-master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( +- `b` int(11) DEFAULT NULL +-) ENGINE=InnoDB ++master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp (b INT) ENGINE=InnoDB ++master-bin.000001 # Gtid # # GTID #-#-# ++master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE tmp ++master-bin.000001 # Gtid # # GTID #-#-# ++master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `tmp` + drop function f1; + drop table t1; + include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/create_or_replace2.result b/mysql-test/suite/rpl/r/create_or_replace2.result index b96a0f8ae134b..a179c26128171 100644 --- a/mysql-test/suite/rpl/r/create_or_replace2.result +++ b/mysql-test/suite/rpl/r/create_or_replace2.result @@ -26,6 +26,17 @@ unlock tables; connection default; ERROR 42S22: Unknown column 'a' in 'field list' disconnect con1; +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 t1 (a INT) ENGINE=InnoDB +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) +RETURN ( SELECT MAX(a) FROM t1 ) +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `b` int(11) DEFAULT NULL +) ENGINE=InnoDB drop function f1; drop table t1; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/create_or_replace_mix.result b/mysql-test/suite/rpl/r/create_or_replace_mix.result index 9036ab425ae06..75f7ca2a82868 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_mix.result +++ b/mysql-test/suite/rpl/r/create_or_replace_mix.result @@ -64,13 +64,12 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -Warnings: -Note 1051 Unknown table 'test.t1' -create or replace table t1 (a int primary key) select a from t2; +create or replace table t1 (b int primary key) select a as b from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -create table t1 (a int); -create or replace table t1 (a int primary key) select a from t2; +create table t1 (c int); +create or replace table t1 (d int primary key) select a as d from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +drop table t1; create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' @@ -80,34 +79,26 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create or replace table t1 -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Query # # use `test`; create table t1 (c int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create temporary table t9 (a int) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t9`/* Generated to handle failed CREATE OR REPLACE */ connection server_2; show tables; Tables_in_test t2 connection server_1; -create table t1 (a int); +create table t1 (e int); create or replace table t1 (a int, a int) select * from t2; ERROR 42S21: Duplicate column name 'a' 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 t1 (a int) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # use `test`; create table t1 (e int) drop table if exists t1,t2; -Warnings: -Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' @@ -159,7 +150,7 @@ slave-bin.000001 # Query # # use `test`; create table t4 (server_2_to_be_delete slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; create table t1 (new_table int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# -slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( +slave-bin.000001 # Query # # use `test`; CREATE TABLE `t2` ( `a` int(11) DEFAULT NULL ) slave-bin.000001 # Annotate_rows # # create table t2 select * from t9 @@ -217,7 +208,7 @@ drop table t1; # connection server_2; connection server_1; -create table t1 (a int); +create table t1 (f int); insert into t1 values (0),(1),(2); create table t2 engine=myisam select * from t1; create or replace table t2 engine=innodb select * from t1; @@ -226,7 +217,7 @@ binlog from server 2 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Gtid # # GTID #-#-# -slave-bin.000001 # Query # # use `test`; create table t1 (a int) +slave-bin.000001 # Query # # use `test`; create table t1 (f int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; insert into t1 values (0),(1),(2) slave-bin.000001 # Query # # COMMIT diff --git a/mysql-test/suite/rpl/r/create_or_replace_row.result b/mysql-test/suite/rpl/r/create_or_replace_row.result index 16f92b5e4b6cd..9b3ffb6777e6b 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_row.result +++ b/mysql-test/suite/rpl/r/create_or_replace_row.result @@ -92,13 +92,12 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -Warnings: -Note 1051 Unknown table 'test.t1' -create or replace table t1 (a int primary key) select a from t2; +create or replace table t1 (b int primary key) select a as b from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -create table t1 (a int); -create or replace table t1 (a int primary key) select a from t2; +create table t1 (c int); +create or replace table t1 (d int primary key) select a as d from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +drop table t1; create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' @@ -108,32 +107,24 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create or replace table t1 -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create table t1 (a int) -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # use `test`; create table t1 (c int) +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ connection server_2; show tables; Tables_in_test t2 connection server_1; -create table t1 (a int); +create table t1 (e int); create or replace table t1 (a int, a int) select * from t2; ERROR 42S21: Duplicate column name 'a' 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 t1 (a int) -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # use `test`; create table t1 (e int) drop table if exists t1,t2; -Warnings: -Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' @@ -243,7 +234,7 @@ drop table t1; # connection server_2; connection server_1; -create table t1 (a int); +create table t1 (f int); insert into t1 values (0),(1),(2); create table t2 engine=myisam select * from t1; create or replace table t2 engine=innodb select * from t1; @@ -252,7 +243,7 @@ binlog from server 2 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Gtid # # GTID #-#-# -slave-bin.000001 # Query # # use `test`; create table t1 (a int) +slave-bin.000001 # Query # # use `test`; create table t1 (f int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Annotate_rows # # insert into t1 values (0),(1),(2) slave-bin.000001 # Table_map # # table_id: # (test.t1) @@ -260,7 +251,7 @@ slave-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F slave-bin.000001 # Query # # COMMIT slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL + `f` int(11) DEFAULT NULL ) ENGINE=MyISAM slave-bin.000001 # Annotate_rows # # create table t2 engine=myisam select * from t1 slave-bin.000001 # Table_map # # table_id: # (test.t2) @@ -268,7 +259,7 @@ slave-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F slave-bin.000001 # Query # # COMMIT slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( - `a` int(11) DEFAULT NULL + `f` int(11) DEFAULT NULL ) ENGINE=InnoDB slave-bin.000001 # Annotate_rows # # create or replace table t2 engine=innodb select * from t1 slave-bin.000001 # Table_map # # table_id: # (test.t2) diff --git a/mysql-test/suite/rpl/r/create_or_replace_statement.result b/mysql-test/suite/rpl/r/create_or_replace_statement.result index 9036ab425ae06..75f7ca2a82868 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_statement.result +++ b/mysql-test/suite/rpl/r/create_or_replace_statement.result @@ -64,13 +64,12 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -Warnings: -Note 1051 Unknown table 'test.t1' -create or replace table t1 (a int primary key) select a from t2; +create or replace table t1 (b int primary key) select a as b from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -create table t1 (a int); -create or replace table t1 (a int primary key) select a from t2; +create table t1 (c int); +create or replace table t1 (d int primary key) select a as d from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +drop table t1; create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' @@ -80,34 +79,26 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create or replace table t1 -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Query # # use `test`; create table t1 (c int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create temporary table t9 (a int) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t9`/* Generated to handle failed CREATE OR REPLACE */ connection server_2; show tables; Tables_in_test t2 connection server_1; -create table t1 (a int); +create table t1 (e int); create or replace table t1 (a int, a int) select * from t2; ERROR 42S21: Duplicate column name 'a' 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 t1 (a int) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # use `test`; create table t1 (e int) drop table if exists t1,t2; -Warnings: -Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' @@ -159,7 +150,7 @@ slave-bin.000001 # Query # # use `test`; create table t4 (server_2_to_be_delete slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; create table t1 (new_table int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# -slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( +slave-bin.000001 # Query # # use `test`; CREATE TABLE `t2` ( `a` int(11) DEFAULT NULL ) slave-bin.000001 # Annotate_rows # # create table t2 select * from t9 @@ -217,7 +208,7 @@ drop table t1; # connection server_2; connection server_1; -create table t1 (a int); +create table t1 (f int); insert into t1 values (0),(1),(2); create table t2 engine=myisam select * from t1; create or replace table t2 engine=innodb select * from t1; @@ -226,7 +217,7 @@ binlog from server 2 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Gtid # # GTID #-#-# -slave-bin.000001 # Query # # use `test`; create table t1 (a int) +slave-bin.000001 # Query # # use `test`; create table t1 (f int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; insert into t1 values (0),(1),(2) slave-bin.000001 # Query # # COMMIT diff --git a/mysql-test/suite/rpl/r/rpl_gtid_strict.result b/mysql-test/suite/rpl/r/rpl_gtid_strict.result index 27e7d1051257f..8cbc917a1a8eb 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_strict.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_strict.result @@ -59,7 +59,7 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4) master-bin.000001 # Xid # # COMMIT /* XID */ -*** Test non-transactional GTID error (cannot be rolled back). *** +*** Test non-transactional GTID error. *** SET server_id= 3; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled @@ -68,9 +68,6 @@ SET gtid_seq_no= 1; SET SESSION debug_dbug=@old_dbug; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled -SET sql_log_bin= 0; -DROP TABLE t2; -SET sql_log_bin= 1; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-3-5, and gtid strict mode is enabled diff --git a/mysql-test/suite/rpl/t/create_or_replace.inc b/mysql-test/suite/rpl/t/create_or_replace.inc index df46cc36e9788..bdde953f7dce7 100644 --- a/mysql-test/suite/rpl/t/create_or_replace.inc +++ b/mysql-test/suite/rpl/t/create_or_replace.inc @@ -47,12 +47,13 @@ create or replace table t1; drop table if exists t1; # The following is not logged as t1 does not exists; --error ER_DUP_ENTRY -create or replace table t1 (a int primary key) select a from t2; +create or replace table t1 (b int primary key) select a as b from t2; -create table t1 (a int); +create table t1 (c int); # This should as a delete as we will delete t1 --error ER_DUP_ENTRY -create or replace table t1 (a int primary key) select a from t2; +create or replace table t1 (d int primary key) select a as d from t2; +drop table t1; # Same with temporary table create temporary table t9 (a int); @@ -69,7 +70,7 @@ show tables; connection server_1; --let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1) -create table t1 (a int); +create table t1 (e int); --error ER_DUP_FIELDNAME create or replace table t1 (a int, a int) select * from t2; --source include/show_binlog_events.inc @@ -169,7 +170,7 @@ sync_with_master; --let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1) connection server_1; -create table t1 (a int); +create table t1 (f int); insert into t1 values (0),(1),(2); create table t2 engine=myisam select * from t1; create or replace table t2 engine=innodb select * from t1; diff --git a/mysql-test/suite/rpl/t/create_or_replace2.test b/mysql-test/suite/rpl/t/create_or_replace2.test index f0091db7fb909..0208be577a7f4 100644 --- a/mysql-test/suite/rpl/t/create_or_replace2.test +++ b/mysql-test/suite/rpl/t/create_or_replace2.test @@ -36,6 +36,8 @@ unlock tables; --reap --disconnect con1 +--source include/show_binlog_events.inc + # Cleanup drop function f1; drop table t1; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_strict.test b/mysql-test/suite/rpl/t/rpl_gtid_strict.test index 56ebba824c481..7cbd6304c1045 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_strict.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_strict.test @@ -49,7 +49,7 @@ INSERT INTO t1 VALUES (4); SELECT * FROM t1 ORDER BY 1; --source include/show_binlog_events.inc ---echo *** Test non-transactional GTID error (cannot be rolled back). *** +--echo *** Test non-transactional GTID error. *** SET server_id= 3; --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 1; @@ -58,11 +58,6 @@ SET gtid_seq_no= 1; SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; -# The table is still created, DDL cannot be rolled back. -# Fix it up for replication. -SET sql_log_bin= 0; -DROP TABLE t2; -SET sql_log_bin= 1; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; --error ER_GTID_STRICT_OUT_OF_ORDER diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index 35a3f54e61f11..afcf2e6497eff 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2021, MariaDB + Copyright (c) 2010, 2022, 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 @@ -135,6 +135,13 @@ class st_ddl_recovery { char current_db[NAME_LEN]; uint execute_entry_pos; ulonglong xid; + void free() + { + drop_table.free(); + drop_view.free(); + query.free(); + db.free(); + } }; static st_global_ddl_log global_ddl_log; @@ -455,7 +462,7 @@ bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry) static bool is_execute_entry_active(uint entry_pos) { uchar buff[1]; - DBUG_ENTER("disable_execute_entry"); + DBUG_ENTER("is_execute_entry_active"); if (mysql_file_pread(global_ddl_log.file_id, buff, sizeof(buff), global_ddl_log.io_size * entry_pos + @@ -963,11 +970,12 @@ static bool build_filename_and_delete_tmp_file(char *path, size_t path_length, const LEX_CSTRING *db, const LEX_CSTRING *name, const char *ext, - PSI_file_key psi_key) + PSI_file_key psi_key, + uint flags) { bool deleted; uint length= build_table_filename(path, path_length-1, - db->str, name->str, ext, 0); + db->str, name->str, ext, flags); path[length]= '~'; path[length+1]= 0; deleted= mysql_file_delete(psi_key, path, MYF(0)) != 0; @@ -1081,15 +1089,15 @@ static handler *create_handler(THD *thd, MEM_ROOT *mem_root, like connect, needs the .frm file to exists to be able to do an rename. */ -static void execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, - const LEX_CSTRING *from_db, - const LEX_CSTRING *from_table, - const LEX_CSTRING *to_db, - const LEX_CSTRING *to_table, - uint flags, - char *from_path, char *to_path) +static int execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, + const LEX_CSTRING *from_db, + const LEX_CSTRING *from_table, + const LEX_CSTRING *to_db, + const LEX_CSTRING *to_table, uint flags, + char *from_path, char *to_path) { uint to_length=0, fr_length=0; + int error; DBUG_ENTER("execute_rename_table"); if (file->needs_lower_case_filenames()) @@ -1104,12 +1112,12 @@ static void execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, { fr_length= build_table_filename(from_path, FN_REFLEN, from_db->str, from_table->str, "", - flags & FN_TO_IS_TMP); + flags & FN_FROM_IS_TMP); to_length= build_table_filename(to_path, FN_REFLEN, to_db->str, to_table->str, "", flags & FN_TO_IS_TMP); } - file->ha_rename_table(from_path, to_path); + error= file->ha_rename_table(from_path, to_path); if (file->needs_lower_case_filenames()) { /* @@ -1130,7 +1138,7 @@ static void execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, } if (!access(from_path, F_OK)) (void) mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)); - DBUG_VOID_RETURN; + DBUG_RETURN(error); } @@ -1144,7 +1152,7 @@ static void execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, */ static void rename_triggers(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, - bool swap_tables) + bool swap_tables, uint flags) { LEX_CSTRING to_table, from_table, to_db, from_db, from_converted_name; char to_path[FN_REFLEN+1], from_path[FN_REFLEN+1], conv_path[FN_REFLEN+1]; @@ -1166,10 +1174,10 @@ static void rename_triggers(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, build_filename_and_delete_tmp_file(from_path, sizeof(from_path), &from_db, &from_table, - TRG_EXT, key_file_trg); + TRG_EXT, key_file_trg, flags & FN_FROM_IS_TMP); build_filename_and_delete_tmp_file(to_path, sizeof(to_path), &to_db, &to_table, - TRG_EXT, key_file_trg); + TRG_EXT, key_file_trg, flags & FN_TO_IS_TMP); if (lower_case_table_names) { uint errors; @@ -1295,15 +1303,15 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, handlerton *hton= 0; ddl_log_error_handler no_such_table_handler; uint entry_pos= ddl_log_entry->entry_pos; - int error; + int error= 0; + uint fn_flags= 0; bool frm_action= FALSE; DBUG_ENTER("ddl_log_execute_action"); mysql_mutex_assert_owner(&LOCK_gdl); DBUG_PRINT("ddl_log", - ("pos: %u=>%u->%u type: %u action: %u (%s) phase: %u " + ("pos: %u->%u type: %u action: %u (%s) phase: %u " "handler: '%s' name: '%s' from_name: '%s' tmp_name: '%s'", - recovery_state.execute_entry_pos, ddl_log_entry->entry_pos, ddl_log_entry->next_entry, (uint) ddl_log_entry->entry_type, @@ -1331,6 +1339,11 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, hton= file->ht; } + if (ddl_log_entry->flags & DDL_LOG_FLAG_FROM_IS_TMP) + fn_flags|= FN_FROM_IS_TMP; + if (ddl_log_entry->flags & DDL_LOG_FLAG_TO_IS_TMP) + fn_flags|= FN_TO_IS_TMP; + switch (ddl_log_entry->action_type) { case DDL_LOG_REPLACE_ACTION: case DDL_LOG_DELETE_ACTION: @@ -1374,24 +1387,28 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, /* fall through */ case DDL_LOG_RENAME_ACTION: { - error= TRUE; if (frm_action) { strxmov(to_path, ddl_log_entry->name.str, reg_ext, NullS); strxmov(from_path, ddl_log_entry->from_name.str, reg_ext, NullS); - (void) mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)); + error= mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)); #ifdef WITH_PARTITION_STORAGE_ENGINE strxmov(to_path, ddl_log_entry->name.str, PAR_EXT, NullS); strxmov(from_path, ddl_log_entry->from_name.str, PAR_EXT, NullS); - (void) mysql_file_rename(key_file_partition_ddl_log, from_path, to_path, - MYF(MY_WME)); + int err2= mysql_file_rename(key_file_partition_ddl_log, from_path, + to_path, MYF(MY_WME)); + if (!error) + error= err2; #endif } else - (void) file->ha_rename_table(ddl_log_entry->from_name.str, + error= file->ha_rename_table(ddl_log_entry->from_name.str, ddl_log_entry->name.str); if (increment_phase(entry_pos)) + { + error= -1; break; + } break; } case DDL_LOG_EXCHANGE_ACTION: @@ -1445,25 +1462,40 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, */ switch (ddl_log_entry->phase) { case DDL_RENAME_PHASE_TRIGGER: - rename_triggers(thd, ddl_log_entry, 0); + rename_triggers(thd, ddl_log_entry, 0, fn_flags); if (increment_phase(entry_pos)) break; /* fall through */ case DDL_RENAME_PHASE_STAT: - /* - Stat tables must be updated last so that we can handle a rename of - a stat table. For now we just rememeber that we have to update it - */ - update_flags(ddl_log_entry->entry_pos, DDL_LOG_FLAG_UPDATE_STAT); - ddl_log_entry->flags|= DDL_LOG_FLAG_UPDATE_STAT; + if (fn_flags & FN_TO_IS_TMP) + { + /* + Only executed in case of CREATE OR REPLACE table when renaming + the orignal table to a temporary name. + + If new code is added here please finish this block like this: + + if (increment_phase(entry_pos)) + break; + */ + } + else + { + /* + Stat tables must be updated last so that we can handle a rename of + a stat table. For now we just remember that we have to update it. + */ + update_flags(ddl_log_entry->entry_pos, DDL_LOG_FLAG_UPDATE_STAT); + ddl_log_entry->flags|= DDL_LOG_FLAG_UPDATE_STAT; + } /* fall through */ case DDL_RENAME_PHASE_TABLE: /* Restore frm and table to original names */ - execute_rename_table(ddl_log_entry, file, - &ddl_log_entry->db, &ddl_log_entry->name, - &ddl_log_entry->from_db, &ddl_log_entry->from_name, - 0, - from_path, to_path); + error= execute_rename_table(ddl_log_entry, file, + &ddl_log_entry->db, &ddl_log_entry->name, + &ddl_log_entry->from_db, + &ddl_log_entry->from_name, + fn_flags, from_path, to_path); if (ddl_log_entry->flags & DDL_LOG_FLAG_UPDATE_STAT) { @@ -1491,11 +1523,11 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, &ddl_log_entry->db, &ddl_log_entry->name, reg_ext, - key_file_fileparser); + key_file_fileparser, 0); build_filename_and_delete_tmp_file(from_path, sizeof(from_path) - 1, &ddl_log_entry->from_db, &ddl_log_entry->from_name, - reg_ext, key_file_fileparser); + reg_ext, key_file_fileparser, 0); /* Rename view back if the original rename did succeed */ if (!access(to_path, F_OK)) @@ -1570,25 +1602,39 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, /* Fall through */ case DDL_DROP_PHASE_TRIGGER: Table_triggers_list::drop_all_triggers(thd, &db, &table, + fn_flags, MYF(MY_WME | MY_IGNORE_ENOENT)); if (increment_phase(entry_pos)) break; /* Fall through */ case DDL_DROP_PHASE_BINLOG: - if (strcmp(recovery_state.current_db, db.str)) + if (fn_flags & FN_IS_TMP) { - append_identifier(thd, &recovery_state.drop_table, &db); - recovery_state.drop_table.append('.'); - } - append_identifier(thd, &recovery_state.drop_table, &table); - recovery_state.drop_table.append(','); - /* We don't increment phase as we want to retry this in case of crash */ + /* + If new code is added here please finish this block like this: - if (ddl_log_drop_to_binary_log(thd, ddl_log_entry, - &recovery_state.drop_table)) + if (increment_phase(entry_pos)) + break; + */ + } + else { - if (increment_phase(entry_pos)) - break; + if (strcmp(recovery_state.current_db, db.str)) + { + append_identifier(thd, &recovery_state.drop_table, &db); + recovery_state.drop_table.append('.'); + } + append_identifier(thd, &recovery_state.drop_table, &table); + recovery_state.drop_table.append(','); + /* + We don't increment phase as we want to retry this in case of crash. + */ + if (ddl_log_drop_to_binary_log(thd, ddl_log_entry, + &recovery_state.drop_table)) + { + if (increment_phase(entry_pos)) + break; + } } break; case DDL_DROP_PHASE_RESET: @@ -1644,7 +1690,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, &ddl_log_entry->db, &ddl_log_entry->name, TRG_EXT, - key_file_fileparser)) + key_file_fileparser, 0)) { /* Temporary file existed and was deleted, nothing left to do */ (void) update_phase(entry_pos, DDL_LOG_FINAL_PHASE); @@ -1869,11 +1915,11 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, (void) build_filename_and_delete_tmp_file(to_path, sizeof(to_path) - 1, &db, &table, TRG_EXT, - key_file_fileparser); + key_file_fileparser, 0); (void) build_filename_and_delete_tmp_file(to_path, sizeof(to_path) - 1, &db, &trigger, TRN_EXT, - key_file_fileparser); + key_file_fileparser, 0); switch (ddl_log_entry->phase) { case DDL_CREATE_TRIGGER_PHASE_DELETE_COPY: { @@ -2182,7 +2228,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, if (is_renamed) { // rename_triggers will rename from: from_db.from_name -> db.extra_name - rename_triggers(thd, ddl_log_entry, 1); + rename_triggers(thd, ddl_log_entry, 1, 0); (void) update_phase(entry_pos, DDL_ALTER_TABLE_PHASE_UPDATE_STATS); } } @@ -2858,6 +2904,7 @@ void ddl_log_release() } my_free(global_ddl_log.file_entry_buf); global_ddl_log.file_entry_buf= 0; + recovery_state.free(); close_ddl_log(); create_ddl_log_file_name(file_name, 0); @@ -3041,7 +3088,8 @@ static bool ddl_log_write(DDL_LOG_STATE *ddl_state, mysql_mutex_lock(&LOCK_gdl); error= ((ddl_log_write_entry(ddl_log_entry, &log_entry)) || - ddl_log_write_execute_entry(log_entry->entry_pos, 0, + ddl_log_write_execute_entry(log_entry->entry_pos, + ddl_state->master_chain_pos, &ddl_state->execute_entry)); mysql_mutex_unlock(&LOCK_gdl); if (error) @@ -3057,7 +3105,10 @@ static bool ddl_log_write(DDL_LOG_STATE *ddl_state, /** - Logging of rename table + Logging of rename + + @param phase Starting phase (usually DDL_RENAME_PHASE_TABLE) + @param flags Rename flags (FN_FROM_IS_TMP, FN_TO_IS_TMP) */ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, @@ -3065,7 +3116,9 @@ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, const LEX_CSTRING *new_db, - const LEX_CSTRING *new_alias) + const LEX_CSTRING *new_alias, + enum_ddl_log_rename_table_phase phase, + uint16 flags) { DDL_LOG_ENTRY ddl_log_entry; DBUG_ENTER("ddl_log_rename_file"); @@ -3080,7 +3133,8 @@ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, ddl_log_entry.name= *const_cast(new_alias); ddl_log_entry.from_db= *const_cast(org_db); ddl_log_entry.from_name= *const_cast(org_alias); - ddl_log_entry.phase= DDL_RENAME_PHASE_TABLE; + ddl_log_entry.phase= (uchar) phase; + ddl_log_entry.flags= flags; DBUG_RETURN(ddl_log_write(ddl_state, &ddl_log_entry)); } @@ -3126,7 +3180,7 @@ static bool ddl_log_drop_init(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *comment) { DDL_LOG_ENTRY ddl_log_entry; - DBUG_ENTER("ddl_log_drop_file"); + DBUG_ENTER("ddl_log_drop_init"); bzero(&ddl_log_entry, sizeof(ddl_log_entry)); @@ -3161,6 +3215,15 @@ bool ddl_log_drop_view_init(DDL_LOG_STATE *ddl_state, be stored in call order instead of reverse order, which is the normal case for all other events. See also comment before ddl_log_drop_init(). + + @param ddl_state DDL log chain + @param action_code DDL_LOG_DROP_TABLE_ACTION or DDL_LOG_DROP_VIEW_ACTION + @param phase Starting phase (for table DDL_DROP_PHASE_TABLE) + @param hton Handlerton + @param path Table filepath without extension + @param db DB name + @param table Table name + @param flags DDL_LOG_FLAG_FROM_IS_TMP or DDL_LOG_FLAG_TO_IS_TMP */ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, @@ -3169,13 +3232,16 @@ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, - const LEX_CSTRING *table) + const LEX_CSTRING *table, + uint16 flags) { DDL_LOG_ENTRY ddl_log_entry; DDL_LOG_MEMORY_ENTRY *log_entry; DBUG_ENTER("ddl_log_drop"); DBUG_ASSERT(ddl_state->list); + DBUG_ASSERT(action_code == DDL_LOG_DROP_TABLE_ACTION || + action_code == DDL_LOG_DROP_VIEW_ACTION); bzero(&ddl_log_entry, sizeof(ddl_log_entry)); ddl_log_entry.action_type= action_code; @@ -3186,6 +3252,7 @@ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, ddl_log_entry.name= *const_cast(table); ddl_log_entry.tmp_name= *const_cast(path); ddl_log_entry.phase= (uchar) phase; + ddl_log_entry.flags= flags; mysql_mutex_lock(&LOCK_gdl); if (ddl_log_write_entry(&ddl_log_entry, &log_entry)) @@ -3209,19 +3276,36 @@ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, } +/** + @param ddl_state DDL log chain + @param hton Handlerton + @param path Table filepath without extension + @param db DB name + @param table Table name + @param flags DDL_LOG_FLAG_FROM_IS_TMP or DDL_LOG_FLAG_TO_IS_TMP +*/ + bool ddl_log_drop_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, - const LEX_CSTRING *table) + const LEX_CSTRING *table, + uint16 flags) { DBUG_ENTER("ddl_log_drop_table"); DBUG_RETURN(ddl_log_drop(ddl_state, DDL_LOG_DROP_TABLE_ACTION, DDL_DROP_PHASE_TABLE, - hton, path, db, table)); + hton, path, db, table, flags)); } +/** + @param ddl_state DDL log chain + @param path Table filepath without extension + @param db DB name + @param table Table name +*/ + bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, const LEX_CSTRING *db, @@ -3230,7 +3314,7 @@ bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, DBUG_ENTER("ddl_log_drop_view"); DBUG_RETURN(ddl_log_drop(ddl_state, DDL_LOG_DROP_VIEW_ACTION, 0, - (handlerton*) 0, path, db, table)); + (handlerton*) 0, path, db, table, 0)); } @@ -3324,6 +3408,8 @@ bool ddl_log_create_table(DDL_LOG_STATE *ddl_state, ddl_log_entry.name= *const_cast(table); ddl_log_entry.tmp_name= *const_cast(path); ddl_log_entry.flags= only_frm ? DDL_LOG_FLAG_ONLY_FRM : 0; + /* Needed for finalize_atomic_replace() which logs 2 events. */ + ddl_log_entry.next_entry= ddl_state->list ? ddl_state->list->entry_pos : 0; DBUG_RETURN(ddl_log_write(ddl_state, &ddl_log_entry)); } @@ -3576,3 +3662,17 @@ bool ddl_log_delete_frm(DDL_LOG_STATE *ddl_state, const char *to_path) ddl_log_add_entry(ddl_state, log_entry); DBUG_RETURN(0); } + +/* + Link the ddl_log_state to another (master) chain. If the master + chain is active during DDL recovery, this event will not be executed. + + This is used for DROP TABLE of the original table when + CREATE OR REPLACE ... is used. +*/ + +void ddl_log_link_chains(DDL_LOG_STATE *state, DDL_LOG_STATE *master_state) +{ + DBUG_ASSERT(master_state->execute_entry); + state->master_chain_pos= master_state->execute_entry->entry_pos; +} diff --git a/sql/ddl_log.h b/sql/ddl_log.h index 87b7af57102ee..809b51a0e10ac 100644 --- a/sql/ddl_log.h +++ b/sql/ddl_log.h @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2021, MariaDB + Copyright (c) 2010, 2022, 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 @@ -173,6 +173,8 @@ enum enum_ddl_log_alter_table_phase { engine is not changed */ #define DDL_LOG_FLAG_ALTER_PARTITION (1 << 4) +#define DDL_LOG_FLAG_FROM_IS_TMP (1 << 5) +#define DDL_LOG_FLAG_TO_IS_TMP (1 << 6) /* Setting ddl_log_entry.phase to this has the same effect as setting @@ -248,6 +250,7 @@ typedef struct st_ddl_log_state */ DDL_LOG_MEMORY_ENTRY *main_entry; uint16 flags; /* Cache for flags */ + uint master_chain_pos; bool is_active() { return list != 0; } } DDL_LOG_STATE; @@ -286,7 +289,9 @@ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, const LEX_CSTRING *new_db, - const LEX_CSTRING *new_alias); + const LEX_CSTRING *new_alias, + enum_ddl_log_rename_table_phase phase, + uint16 flags); bool ddl_log_rename_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, @@ -301,7 +306,8 @@ bool ddl_log_drop_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, - const LEX_CSTRING *table); + const LEX_CSTRING *table, + uint16 flags); bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, const LEX_CSTRING *db, @@ -348,5 +354,6 @@ bool ddl_log_alter_table(DDL_LOG_STATE *ddl_state, bool ddl_log_store_query(THD *thd, DDL_LOG_STATE *ddl_log_state, const char *query, size_t length); bool ddl_log_delete_frm(DDL_LOG_STATE *ddl_state, const char *to_path); +void ddl_log_link_chains(DDL_LOG_STATE *state, DDL_LOG_STATE *master_state); extern mysql_mutex_t LOCK_gdl; #endif /* DDL_LOG_INCLUDED */ diff --git a/sql/handler.cc b/sql/handler.cc index 6a42643919f05..4d7c2eb228ff0 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4993,7 +4993,7 @@ void handler::mark_trx_read_write_internal() table_share can be NULL, for example, in ha_delete_table() or ha_rename_table(). */ - if (table_share == NULL || table_share->tmp_table == NO_TMP_TABLE) + if (table_share == NULL || table_share->tmp_table <= NO_TMP_TABLE) ha_info->set_trx_read_write(); } } @@ -7037,8 +7037,7 @@ int handler::binlog_log_row(TABLE *table, THD *thd= table->in_use; DBUG_ENTER("binlog_log_row"); - if (!thd->binlog_table_maps && - thd->binlog_write_table_maps()) + if (!thd->binlog_table_maps && thd->binlog_write_table_maps(table)) DBUG_RETURN(HA_ERR_RBR_LOGGING_FAILED); error= (*log_func)(thd, table, row_logging_has_trans, @@ -7587,7 +7586,7 @@ int handler::ha_write_row(const uchar *buf) error= binlog_log_row(table, 0, buf, log_func); } #ifdef WITH_WSREP - if (WSREP_NNULL(ha_thd()) && table_share->tmp_table == NO_TMP_TABLE && + if (WSREP_NNULL(ha_thd()) && table_share->tmp_table <= NO_TMP_TABLE && ht->flags & HTON_WSREP_REPLICATION && !error && (error= wsrep_after_row(ha_thd()))) { @@ -7661,7 +7660,7 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data) " can not mark as PA unsafe"); } - if (!error && table_share->tmp_table == NO_TMP_TABLE && + if (!error && table_share->tmp_table <= NO_TMP_TABLE && ht->flags & HTON_WSREP_REPLICATION) error= wsrep_after_row(thd); } @@ -7739,7 +7738,7 @@ int handler::ha_delete_row(const uchar *buf) " can not mark as PA unsafe"); } - if (!error && table_share->tmp_table == NO_TMP_TABLE && + if (!error && table_share->tmp_table <= NO_TMP_TABLE && ht->flags & HTON_WSREP_REPLICATION) error= wsrep_after_row(thd); } @@ -8615,8 +8614,8 @@ bool Table_period_info::check_field(const Create_field* f, } bool Table_scope_and_contents_source_st::check_fields( - THD *thd, Alter_info *alter_info, - const Lex_table_name &table_name, const Lex_table_name &db) + THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, + const Lex_table_name &db) { return (vers_check_system_fields(thd, alter_info, table_name, db) || check_period_fields(thd, alter_info)); diff --git a/sql/handler.h b/sql/handler.h index 65da0e69fcae0..b6124765b6b6b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -35,6 +35,7 @@ #include "sql_array.h" /* Dynamic_array<> */ #include "mdl.h" #include "vers_string.h" +#include "backup.h" #include "sql_analyze_stmt.h" // for Exec_time_tracker @@ -1780,6 +1781,12 @@ handlerton *ha_default_tmp_handlerton(THD *thd); */ #define HTON_REQUIRES_NOTIFY_TABLEDEF_CHANGED_AFTER_COMMIT (1 << 20) +/* + Indicates that rename table is expensive operation. + When set atomic CREATE OR REPLACE TABLE is not used. +*/ +#define HTON_EXPENSIVE_RENAME (1 << 21) + class Ha_trx_info; struct THD_TRANS @@ -2225,6 +2232,11 @@ struct Table_scope_and_contents_source_pod_st // For trivial members { bzero(this, sizeof(*this)); } + /* + NOTE: share->tmp_table (tmp_table_type) is superset of this + HA_LEX_CREATE_TMP_TABLE which means TEMPORARY keyword in + CREATE TEMPORARY TABLE statement. + */ bool tmp_table() const { return options & HA_LEX_CREATE_TMP_TABLE; } void use_default_db_type(THD *thd) { @@ -2266,17 +2278,81 @@ struct Table_scope_and_contents_source_st: bool vers_check_system_fields(THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, const Lex_table_name &db); +}; + +typedef struct st_ddl_log_state DDL_LOG_STATE; + +struct Atomic_info +{ + Table_name tmp_name; + Table_name backup_name; + DDL_LOG_STATE *ddl_log_state_create; + DDL_LOG_STATE *ddl_log_state_rm; + handlerton *old_hton; + backup_log_info drop_entry; + + Atomic_info() + { + bzero(this, sizeof(*this)); + } + Atomic_info(DDL_LOG_STATE *ddl_log_state_rm) + { + bzero(this, sizeof(*this)); + Atomic_info::ddl_log_state_rm= ddl_log_state_rm; + } + + bool is_atomic_replace() const + { + return tmp_name.table_name.str != NULL; + } }; +/* + mysql_create_table_no_lock can be called in one of the following + mutually exclusive situations: + + - Just a normal ordinary CREATE TABLE statement that explicitly + defines the table structure. + + - CREATE TABLE ... SELECT. It is special, because only in this case, + the list of fields is allowed to have duplicates, as long as one of the + duplicates comes from the select list, and the other doesn't. For + example in + + CREATE TABLE t1 (a int(5) NOT NUL) SELECT b+10 as a FROM t2; + + the list in alter_info->create_list will have two fields `a`. + + - ALTER TABLE, that creates a temporary table #sql-xxx, which will be later + renamed to replace the original table. + + - ALTER TABLE as above, but which only modifies the frm file, it only + creates an frm file for the #sql-xxx, the table in the engine is not + created. + + - Assisted discovery, CREATE TABLE statement without the table structure. + + These situations are distinguished by the following "create table mode" + values, except CREATE ... SELECT which is denoted by non-zero + Alter_info::select_field_count. +*/ + +#define C_ORDINARY_CREATE 0 +#define C_ALTER_TABLE 1 +#define C_ALTER_TABLE_FRM_ONLY 2 +#define C_ASSISTED_DISCOVERY 4 + + /** This struct is passed to handler table routines, e.g. ha_create(). It does not include the "OR REPLACE" and "IF NOT EXISTS" parts, as these parts are handled on the SQL level and are not needed on the handler level. */ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, - public Schema_specification_st + public Schema_specification_st, + public Atomic_info { /* TODO: remove after MDEV-20865 */ Alter_info *alter_info; @@ -2298,6 +2374,17 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, const Lex_table_charset_collation_attrs_st &default_cscl, const Lex_table_charset_collation_attrs_st &convert_cscl, const Charset_collation_context &ctx); + bool is_atomic_replace_usable() const + { + return !tmp_table() && !sequence && + !(db_type->flags & HTON_EXPENSIVE_RENAME) && + !DBUG_IF("ddl_log_expensive_rename"); + } + bool finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table); + void finalize_ddl(THD *thd, bool roll_back); + bool finalize_locked_tables(THD *thd); + bool make_tmp_table_list(THD *thd, TABLE_LIST **create_table, + int *create_table_mode); }; @@ -2377,6 +2464,10 @@ struct Table_specification_st: public HA_CREATE_INFO, convert_charset_collation, ctx); } + bool is_atomic_replace() const + { + return or_replace() && is_atomic_replace_usable(); + } }; diff --git a/sql/log.cc b/sql/log.cc index 06bb073134dd2..850b79998a1bb 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -6101,9 +6101,12 @@ bool THD::binlog_write_annotated_row(Log_event_writer *writer) Also write annotate events and start transactions. This is using the "tables_with_row_logging" list prepared by THD::binlog_prepare_for_row_logging + + Atomic CREATE OR REPLACE .. SELECT logs row events via temporary table, + so it is missed in locks. We write table map for that specially via cur_table. */ -bool THD::binlog_write_table_maps() +bool THD::binlog_write_table_maps(TABLE *cur_table) { bool with_annotate; MYSQL_LOCK *locks[2], **locks_end= locks; @@ -6156,6 +6159,16 @@ bool THD::binlog_write_table_maps() } } } + if (cur_table->s->tmp_table && cur_table->file->row_logging) + { + /* + This is a temporary table created with CREATE OR REPLACE ... SELECT. + As these types of tables are not locked, we have to write the bitmap + separately. + */ + if (binlog_write_table_map(cur_table, with_annotate)) + DBUG_RETURN(1); + } binlog_table_maps= 1; // Table maps written DBUG_RETURN(0); } diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index 1d5875733ac12..5ec576bec5632 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2016, 2020, MariaDB Corporation + Copyright (c) 2016, 2022, 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 @@ -30,6 +30,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root) key_list(rhs.key_list, mem_root), alter_rename_key_list(rhs.alter_rename_key_list, mem_root), create_list(rhs.create_list, mem_root), + select_field_count(rhs.select_field_count), alter_index_ignorability_list(rhs.alter_index_ignorability_list, mem_root), check_constraint_list(rhs.check_constraint_list, mem_root), flags(rhs.flags), partition_flags(rhs.partition_flags), diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9279e2eccde01..8b987914697c7 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1950,8 +1950,9 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) DBUG_PRINT("info",("Using locked table")); #ifdef WITH_PARTITION_STORAGE_ENGINE part_names_error= set_partitions_as_used(table_list, table); - if (!part_names_error - && table->vers_switch_partition(thd, table_list, ot_ctx)) + if (!part_names_error && + table_list->lock_type >= TL_WRITE_ALLOW_WRITE && + table->vers_switch_partition(thd, table_list, ot_ctx)) DBUG_RETURN(true); #endif goto reset; @@ -2212,6 +2213,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) #ifdef WITH_PARTITION_STORAGE_ENGINE if (!part_names_error && + table_list->lock_type >= TL_WRITE_ALLOW_WRITE && table->vers_switch_partition(thd, table_list, ot_ctx)) { MYSQL_UNBIND_TABLE(table->file); @@ -3152,7 +3154,7 @@ bool tdc_open_view(THD *thd, TABLE_LIST *table_list, uint flags) static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry) { if (Table_triggers_list::check_n_load(thd, &share->db, - &share->table_name, entry, 0)) + &share->table_name, entry, false, 0)) return TRUE; /* diff --git a/sql/sql_class.h b/sql/sql_class.h index ee51b1828dae2..01e180a6cceb1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2909,7 +2909,7 @@ class THD: public THD_count, /* this must be first */ bool prepare_handlers_for_update(uint flag); bool binlog_write_annotated_row(Log_event_writer *writer); void binlog_prepare_for_row_logging(); - bool binlog_write_table_maps(); + bool binlog_write_table_maps(TABLE *cur_table); bool binlog_write_table_map(TABLE *table, bool with_annotate); static void binlog_prepare_row_images(TABLE* table); @@ -6095,6 +6095,11 @@ class select_insert :public select_result_interceptor { ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not COPY_INFO info; bool insert_into_view; + bool binary_logged; // true if query was binlogged + bool atomic_replace; // true for atomic create or replace + bool tmp_table; + Table_specification_st *create_info; + select_insert(THD *thd_arg, TABLE_LIST *table_list_par, TABLE *table_par, List *fields_par, List *update_fields, List *update_values, enum_duplicates duplic, @@ -6106,6 +6111,7 @@ class select_insert :public select_result_interceptor { virtual void store_values(List &values); virtual bool can_rollback_data() { return 0; } bool prepare_eof(); + bool binlog_query(); bool send_ok_packet(); bool send_eof(); virtual void abort_result_set(); @@ -6115,7 +6121,7 @@ class select_insert :public select_result_interceptor { class select_create: public select_insert { - Table_specification_st *create_info; + TABLE_LIST *orig_table; TABLE_LIST *select_tables; Alter_info *alter_info; Field **field; @@ -6132,19 +6138,7 @@ class select_create: public select_insert { Table_specification_st *create_info_par, Alter_info *alter_info_arg, List &select_fields,enum_duplicates duplic, bool ignore, - TABLE_LIST *select_tables_arg): - select_insert(thd_arg, table_arg, NULL, &select_fields, 0, 0, duplic, - ignore, NULL), - create_info(create_info_par), - select_tables(select_tables_arg), - alter_info(alter_info_arg), - m_plock(NULL), exit_done(0), - saved_tmp_table_share(0) - { - DBUG_ASSERT(create_info->default_table_charset); - bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); - bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); - } + TABLE_LIST *select_tables_arg); int prepare(List &list, SELECT_LEX_UNIT *u); void store_values(List &values); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index aa0c38411ba3c..6fc46e5818c89 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3877,7 +3877,8 @@ select_insert::select_insert(THD *thd_arg, TABLE_LIST *table_list_par, sel_result(result), table_list(table_list_par), table(table_par), fields(fields_par), autoinc_value_of_last_inserted_row(0), - insert_into_view(table_list_par && table_list_par->view != 0) + insert_into_view(table_list_par && table_list_par->view != 0), + binary_logged(false), atomic_replace(false), create_info(NULL) { bzero((char*) &info,sizeof(info)); info.handle_duplicates= duplic; @@ -3886,6 +3887,37 @@ select_insert::select_insert(THD *thd_arg, TABLE_LIST *table_list_par, info.update_values= update_values; info.view= (table_list_par->view ? table_list_par : 0); info.table_list= table_list_par; + tmp_table= table ? table->s->tmp_table != NO_TMP_TABLE : false; +} + + +select_create::select_create(THD *thd, TABLE_LIST *table_arg, + Table_specification_st *create_info_par, + Alter_info *alter_info_arg, + List &select_fields, + enum_duplicates duplic, bool ignore, + TABLE_LIST *select_tables_arg): + select_insert(thd, table_arg, NULL, &select_fields, 0, 0, duplic, + ignore, NULL), + orig_table(table_arg), + select_tables(select_tables_arg), + alter_info(alter_info_arg), + m_plock(NULL), exit_done(0), + saved_tmp_table_share(0) +{ + DBUG_ASSERT(create_info_par->default_table_charset); + bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); + bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); + create_info= create_info_par; + if (!thd->is_current_stmt_binlog_format_row() || + !ha_check_storage_engine_flag(create_info->db_type, + HTON_NO_BINLOG_ROW_OPT)) + atomic_replace= create_info->is_atomic_replace(); + else + DBUG_ASSERT(!atomic_replace); + create_info->ddl_log_state_create= &ddl_log_state_create; + create_info->ddl_log_state_rm= &ddl_log_state_rm; + tmp_table= create_info->tmp_table(); } @@ -4226,10 +4258,10 @@ void select_insert::store_values(List &values) bool select_insert::prepare_eof() { int error; +#ifndef DBUG_OFF bool const trans_table= table->file->has_transactions_and_rollback(); +#endif bool changed; - bool binary_logged= 0; - killed_state killed_status= thd->killed; DBUG_ENTER("select_insert::prepare_eof"); DBUG_PRINT("enter", ("trans_table: %d, table_type: '%s'", @@ -4247,12 +4279,31 @@ bool select_insert::prepare_eof() error= thd->get_stmt_da()->sql_errno(); if (info.ignore || info.handle_duplicates != DUP_ERROR) - if (table->file->ha_table_flags() & HA_DUPLICATE_POS) - table->file->ha_rnd_end(); + if (table->file->ha_table_flags() & HA_DUPLICATE_POS) + table->file->ha_rnd_end(); table->file->extra(HA_EXTRA_END_ALTER_COPY); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); + if (atomic_replace) + { + DBUG_ASSERT(table->s->tmp_table); + + /* + Note: InnoDB does autocommit on external unlock. + We cannot do commit twice and we must commit after binlog + (flush row events is done at commit), so we cannot do it here. + Test: rpl.create_or_replace_row + */ + ulonglong save_options_bits= thd->variables.option_bits; + thd->variables.option_bits|= OPTION_NOT_AUTOCOMMIT; + int lock_error= table->file->ha_external_lock(thd, F_UNLCK); + thd->variables.option_bits= save_options_bits; + + if (lock_error) + DBUG_RETURN(true); /* purecov: inspected */ + } + if (likely((changed= (info.copied || info.deleted || info.updated)))) { /* @@ -4270,19 +4321,54 @@ bool select_insert::prepare_eof() DBUG_ASSERT(trans_table || !changed || thd->transaction->stmt.modified_non_trans_table); + if (unlikely(error)) + { + if ((thd->transaction->stmt.modified_non_trans_table || + thd->log_current_statement()) && !atomic_replace) + { + if (binlog_query()) + table->file->print_error(error,MYF(0)); + } + else + table->file->ha_release_auto_increment(); + DBUG_RETURN(true); + } + + DBUG_RETURN(false); +} + +bool select_insert::binlog_query() +{ + /* For atomic_replace table was already closed in send_eof(). */ + DBUG_ASSERT(table || atomic_replace); + const bool trans_table= table ? table->file->has_transactions_and_rollback() : + false; + killed_state killed_status= thd->killed; + DBUG_ENTER("select_insert::binlog_query"); + /* Write to binlog before commiting transaction. No statement will be written by the binlog_query() below in RBR mode. All the events are in the transaction cache and will be written when ha_autocommit_or_rollback() is issued below. */ - if ((WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) && - (likely(!error) || thd->transaction->stmt.modified_non_trans_table || - thd->log_current_statement())) + if ((WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open())) { + + debug_crash_here("ddl_log_create_before_binlog"); + + if (create_info && !create_info->tmp_table()) + { + thd->binlog_xid= thd->query_id; + /* Remember xid's for the case of row based logging */ + ddl_log_update_xid(create_info->ddl_log_state_create, thd->binlog_xid); + if (create_info->ddl_log_state_rm->is_active() && !atomic_replace) + ddl_log_update_xid(create_info->ddl_log_state_rm, thd->binlog_xid); + } + int errcode= 0; int res; - if (likely(!error)) + if (thd->is_error()) thd->clear_error(); else errcode= query_error_code(thd, killed_status == NOT_KILLED); @@ -4291,20 +4377,24 @@ bool select_insert::prepare_eof() res= thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), trans_table, FALSE, FALSE, errcode); + /* + NOTE: binlog_xid must be cleared after commit because pending row events + are written at commit phase. + */ if (res > 0) { - table->file->ha_release_auto_increment(); + thd->binlog_xid= 0; + if (table) + table->file->ha_release_auto_increment(); DBUG_RETURN(true); } - binary_logged= res == 0 || !table->s->tmp_table; + binary_logged= res == 0 || !tmp_table; } - table->s->table_creation_was_logged|= binary_logged; - table->file->ha_release_auto_increment(); - - if (unlikely(error)) + if (table) { - table->file->print_error(error,MYF(0)); - DBUG_RETURN(true); + /* NOTE: used in binlog_drop_table(), not needed for atomic_replace */ + table->s->table_creation_was_logged|= binary_logged; + table->file->ha_release_auto_increment(); } DBUG_RETURN(false); @@ -4351,7 +4441,8 @@ bool select_insert::send_eof() { bool res; DBUG_ENTER("select_insert::send_eof"); - res= (prepare_eof() || (!suppress_my_ok && send_ok_packet())); + res= (prepare_eof() || binlog_query() || + (!suppress_my_ok && send_ok_packet())); DBUG_RETURN(res); } @@ -4416,7 +4507,11 @@ void select_insert::abort_result_set() res= thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), transactional_table, FALSE, FALSE, errcode); - binary_logged= res == 0 || !table->s->tmp_table; + + /* TODO: Update binary_logged in do_postlock() for RBR? */ + const bool tmp_table= create_info ? create_info->tmp_table() : + (bool) table->s->tmp_table; + binary_logged= res == 0 || !tmp_table; } if (changed) query_cache_invalidate3(thd, table, 1); @@ -4494,6 +4589,8 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, List_iterator_fast it(*items); Item *item; bool save_table_creation_was_logged; + int create_table_mode= C_ORDINARY_CREATE; + LEX_CUSTRING frm= {0, 0}; DBUG_ENTER("select_create::create_table_from_items"); tmp_table.s= &share; @@ -4564,6 +4661,13 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, create_info->mdl_ticket= table_list->table->mdl_ticket; } + if (atomic_replace) + { + if (create_info->make_tmp_table_list(thd, &table_list, + &create_table_mode)) + DBUG_RETURN(NULL); + } + /* Create and lock table. @@ -4581,11 +4685,14 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, open_table(). */ - if (!mysql_create_table_no_lock(thd, &ddl_log_state_create, &ddl_log_state_rm, + if (!mysql_create_table_no_lock(thd, + &orig_table->db, + &orig_table->table_name, &table_list->db, &table_list->table_name, create_info, alter_info, NULL, - C_ORDINARY_CREATE, table_list)) + create_table_mode, table_list, + atomic_replace ? &frm : NULL)) { DEBUG_SYNC(thd,"create_table_select_before_open"); @@ -4595,7 +4702,58 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, */ table_list->table= 0; - if (!create_info->tmp_table()) + if (atomic_replace) + { + char tmp_path[FN_REFLEN + 1]; + build_table_filename(tmp_path, sizeof(tmp_path) - 1, table_list->db.str, + table_list->table_name.str, "", FN_IS_TMP); + + table_list->table= + thd->create_and_open_tmp_table(&frm, tmp_path, orig_table->db.str, + orig_table->table_name.str, false); + /* + NOTE: if create_and_open_tmp_table() fails the table is dropped by + ddl_log_state_create + */ + if (table_list->table) + { + table_list->table->s->tmp_table= TMP_TABLE_ATOMIC_REPLACE; + /* + NOTE: Aria tables require table locking to work in transactional + mode. Since we don't lock our temporary table we get problems with + unproperly initialized transactional mode: seg-fault while accessing + uninitialized trn member (reproduced by + atomic.create_replace,aria,stmt). + + This hack disables logging for Aria table (that is not needed anyway + for a temporary table). + */ + TABLE *table= table_list->table; + int error; + + /* Disable logging of inserted rows */ + mysql_trans_prepare_alter_copy_data(thd); + + if ((DBUG_IF("atomic_replace_external_lock_fail") && + (error= HA_ERR_LOCK_TABLE_FULL)) || + (error= table->file->ha_external_lock(thd, F_WRLCK))) + { + table->file->print_error(error, MYF(0)); + /* + Enable transaction logging. We cannot call ha_enable_transaction() + as this would write the transaction to the binary log + */ + thd->transaction->on= true; + table->file->ha_reset(); + thd->drop_temporary_table(table, NULL, false); + table_list->table= 0; + goto err; + } + + table_list->table->s->can_do_row_logging= 1; + } + } + else if (!create_info->tmp_table()) { Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); TABLE_LIST::enum_open_strategy save_open_strategy; @@ -4636,13 +4794,18 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, } else table_list->table= 0; // Create failed - + +err: + DBUG_ASSERT(!table_list->table || frm.str || !atomic_replace); + my_free(const_cast(frm.str)); + if (unlikely(!(table= table_list->table))) { - if (likely(!thd->is_error())) // CREATE ... IF NOT EXISTS - my_ok(thd); // succeed, but did nothing - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); + const bool error= thd->is_error(); + /* CREATE ... IF NOT EXISTS succeed, but did nothing */ + if (likely(!error)) + my_ok(thd); + create_info->finalize_ddl(thd, error); DBUG_RETURN(NULL); } @@ -4661,9 +4824,13 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, mysql_lock_tables() below should never fail with request to reopen table since it won't wait for the table lock (we have exclusive metadata lock on the table) and thus can't get aborted. + + In case of atomic_replace we have already called ha_external_lock() above + on the newly created temporary table. */ - if (unlikely(!((*lock)= mysql_lock_tables(thd, &table, 1, 0)) || - postlock(thd, &table))) + if ((!atomic_replace && + unlikely(!((*lock)= mysql_lock_tables(thd, &table, 1, 0)))) || + postlock(thd, &table)) { /* purecov: begin tested */ /* @@ -4680,13 +4847,24 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, *lock= 0; } drop_open_table(thd, table, &table_list->db, &table_list->table_name); - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); + if (atomic_replace) + create_info->finalize_ddl(thd, 1); + else + { + debug_crash_here("ddl_log_create_log_complete"); + ddl_log_complete(&ddl_log_state_create); + debug_crash_here("ddl_log_create_log_complete2"); + } + thd->transaction->on= true; DBUG_RETURN(NULL); /* purecov: end */ } + DBUG_ASSERT( + create_info->tmp_table() || + thd->mdl_context.is_lock_owner(MDL_key::TABLE, orig_table->db.str, + orig_table->table_name.str, MDL_SHARED)); table->s->table_creation_was_logged= save_table_creation_was_logged; - if (!table->s->tmp_table) + if (!create_info->tmp_table()) table->file->prepare_for_row_logging(); /* @@ -4734,11 +4912,10 @@ int select_create::postlock(THD *thd, TABLE **tables) if (unlikely(error)) return error; - TABLE const *const table = *tables; - if (thd->is_current_stmt_binlog_format_row() && - !table->s->tmp_table) - return binlog_show_create_table(thd, *tables, create_info); - return 0; + if (thd->is_current_stmt_binlog_format_row() && !create_info->tmp_table()) + error= binlog_show_create_table(thd, *tables, create_info); + + return error; } @@ -4765,7 +4942,11 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) if (!(table= create_table_from_items(thd, &values, &extra_lock))) { - if (create_info->or_replace()) + /* + TODO: Use create_info->table_was_deleted + (now binlog.binlog_stm_binlog fails). + */ + if (create_info->or_replace() && !atomic_replace) { /* Original table was deleted. We have to log it */ log_drop_table(thd, &table_list->db, &table_list->table_name, @@ -4779,6 +4960,8 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) DBUG_RETURN(-1); } + DBUG_ASSERT(table == table_list->table); + if (create_info->tmp_table()) { /* @@ -4788,17 +4971,26 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) list to keep them inaccessible from inner statements. e.g. CREATE TEMPORARY TABLE `t1` AS SELECT * FROM `t1`; */ - saved_tmp_table_share= thd->save_tmp_table_share(table_list->table); + saved_tmp_table_share= thd->save_tmp_table_share(table); } if (extra_lock) { DBUG_ASSERT(m_plock == NULL); - if (create_info->tmp_table()) + if (table->s->tmp_table) + { + /* Table is a temporary table, don't write table map to binary log */ m_plock= &m_lock; + } else + { + /* + Table is a normal table. Inform binlog_write_table_maps() that + it should write the table map for the current table. + */ m_plock= &thd->extra_lock; + } *m_plock= extra_lock; } @@ -4890,6 +5082,14 @@ static int binlog_show_create_table(THD *thd, TABLE *table, create_info, WITH_DB_NAME); DBUG_ASSERT(result == 0); /* show_create_table() always return 0 */ + /* + NOTE: why it does show_create_table() even if !mysql_bin_log.is_open()? + + Because Galera needs it even if there is no binlog. + (I assume Galera will hijack the binlog information and use it itself + if there is no binlog). That is the the only thing that makes sence + looking at the if statement... Monty + */ if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) { int errcode= query_error_code(thd, thd->killed == NOT_KILLED); @@ -5011,30 +5211,12 @@ bool select_create::send_eof() is in select_insert::prepare_eof(). For that reason, we mark the flag at this point. */ - if (table->s->tmp_table) + if (create_info->tmp_table()) thd->transaction->stmt.mark_created_temp_table(); if (thd->slave_thread) thd->variables.binlog_annotate_row_events= 0; - debug_crash_here("ddl_log_create_before_binlog"); - - /* - In case of crash, we have to add DROP TABLE to the binary log as - the CREATE TABLE will already be logged if we are not using row based - replication. - */ - if (!thd->is_current_stmt_binlog_format_row()) - { - if (ddl_log_state_create.is_active()) // Not temporary table - ddl_log_update_phase(&ddl_log_state_create, DDL_CREATE_TABLE_PHASE_LOG); - /* - We can ignore if we replaced an old table as ddl_log_state_create will - now handle the logging of the drop if needed. - */ - ddl_log_complete(&ddl_log_state_rm); - } - if (prepare_eof()) { abort_result_set(); @@ -5042,7 +5224,7 @@ bool select_create::send_eof() } debug_crash_here("ddl_log_create_after_prepare_eof"); - if (table->s->tmp_table) + if (create_info->tmp_table()) { /* Now is good time to add the new table to THD temporary tables list. @@ -5068,11 +5250,11 @@ bool select_create::send_eof() tables. This can fail, but we should unlock the table nevertheless. */ - if (!table->s->tmp_table) + if (!create_info->tmp_table()) { #ifdef WITH_WSREP if (WSREP(thd) && - table->file->ht->db_type == DB_TYPE_INNODB) + create_info->db_type->db_type == DB_TYPE_INNODB) { if (thd->wsrep_trx_id() == WSREP_UNDEFINED_TRX_ID) { @@ -5107,15 +5289,46 @@ bool select_create::send_eof() thd->get_stmt_da()->set_overwrite_status(true); } #endif /* WITH_WSREP */ - thd->binlog_xid= thd->query_id; - /* Remember xid's for the case of row based logging */ - ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); + if (atomic_replace) + { + table_list= orig_table; + create_info->table= orig_table->table; + thd->transaction->on= true; + table->file->ha_reset(); + /* + Remove the temporary table structures from memory but keep the table + files. + */ + thd->drop_temporary_table(table, NULL, false); + table= NULL; + + if (create_info->finalize_atomic_replace(thd, orig_table)) + { + abort_result_set(); + DBUG_RETURN(true); + } + } + + if (binlog_query()) + { + abort_result_set(); + DBUG_RETURN(true); + } + + debug_crash_here("ddl_log_create_after_binlog"); trans_commit_stmt(thd); if (!(thd->variables.option_bits & OPTION_GTID_BEGIN)) trans_commit_implicit(thd); thd->binlog_xid= 0; + /* + If are using statement based replication the table will be deleted here + in case of a crash as we can't use xid to check if the query was logged + (as the query was logged before commit!) + */ + create_info->finalize_ddl(thd, false); + + #ifdef WITH_WSREP if (WSREP(thd)) { @@ -5147,17 +5360,22 @@ bool select_create::send_eof() ddl_log.org_database= table_list->db; ddl_log.org_table= table_list->table_name; ddl_log.org_table_id= create_info->tabledef_version; + /* + Since atomic replace doesn't do mysql_rm_table_no_locks() we have + to log DROP entry now. It was already prepared in create_table_impl(). + */ + if (create_info->drop_entry.query.length) + { + DBUG_ASSERT(atomic_replace); + backup_log_ddl(&create_info->drop_entry); + } backup_log_ddl(&ddl_log); } - /* - If are using statement based replication the table will be deleted here - in case of a crash as we can't use xid to check if the query was logged - (as the query was logged before commit!) - */ - debug_crash_here("ddl_log_create_after_binlog"); - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); - debug_crash_here("ddl_log_create_log_complete"); + else if (binlog_query()) + { + abort_result_set(); + DBUG_RETURN(true); + } /* exit_done must only be set after last potential call to @@ -5165,10 +5383,9 @@ bool select_create::send_eof() */ exit_done= 1; // Avoid double calls - send_ok_packet(); - if (m_plock) { + DBUG_ASSERT(!atomic_replace); MYSQL_LOCK *lock= *m_plock; *m_plock= NULL; m_plock= NULL; @@ -5187,11 +5404,20 @@ bool select_create::send_eof() create_info-> pos_in_locked_tables, table, lock)) + { + send_ok_packet(); DBUG_RETURN(false); // ok + } /* Fail. Continue without locking the table */ + thd->clear_error(); } mysql_unlock_tables(thd, lock); } + else if (atomic_replace && create_info->pos_in_locked_tables && + create_info->finalize_locked_tables(thd)) + DBUG_RETURN(true); + + send_ok_packet(); DBUG_RETURN(false); } @@ -5229,6 +5455,7 @@ void select_create::abort_result_set() thd->variables.option_bits&= ~OPTION_BIN_LOG; select_insert::abort_result_set(); thd->transaction->stmt.modified_non_trans_table= FALSE; + thd->transaction->on= true; thd->variables.option_bits= save_option_bits; /* possible error of writing binary log is ignored deliberately */ @@ -5236,9 +5463,7 @@ void select_create::abort_result_set() if (table) { - bool tmp_table= table->s->tmp_table; - bool table_creation_was_logged= (!tmp_table || - table->s->table_creation_was_logged); + bool tmp_table= create_info->tmp_table(); if (tmp_table) { DBUG_ASSERT(saved_tmp_table_share); @@ -5260,7 +5485,14 @@ void select_create::abort_result_set() m_plock= NULL; } - drop_open_table(thd, table, &table_list->db, &table_list->table_name); + if (atomic_replace) + { + (void) table->file->ha_external_lock(thd, F_UNLCK); + (void) thd->drop_temporary_table(table, NULL, true); + } + else + drop_open_table(thd, table, &table_list->db, + &table_list->table_name); table=0; // Safety if (thd->log_current_statement()) { @@ -5268,23 +5500,8 @@ void select_create::abort_result_set() { /* Remove logging of drop, create + insert rows */ binlog_reset_cache(thd); - /* Original table was deleted. We have to log it */ - if (table_creation_was_logged) - { - thd->binlog_xid= thd->query_id; - ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); - debug_crash_here("ddl_log_create_before_binlog"); - log_drop_table(thd, &table_list->db, &table_list->table_name, - &create_info->org_storage_engine_name, - create_info->db_type == partition_hton, - &create_info->tabledef_version, - tmp_table); - debug_crash_here("ddl_log_create_after_binlog"); - thd->binlog_xid= 0; - } } - else if (!tmp_table) + else if (!tmp_table && !atomic_replace) { backup_log_info ddl_log; bzero(&ddl_log, sizeof(ddl_log)); @@ -5299,8 +5516,8 @@ void select_create::abort_result_set() } } - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); + create_info->finalize_ddl(thd, !binary_logged); + DBUG_ASSERT(!thd->binlog_xid); if (create_info->table_was_deleted) { @@ -5308,6 +5525,7 @@ void select_create::abort_result_set() (void) trans_rollback_stmt(thd); thd->locked_tables_list.unlock_locked_table(thd, create_info->mdl_ticket); } - + else if (atomic_replace && create_info->pos_in_locked_tables) + (void) create_info->finalize_locked_tables(thd); DBUG_VOID_RETURN; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8b8ab430308af..3219116c89102 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7526,9 +7526,11 @@ void THD::reset_for_next_command(bool do_clear_error) DBUG_ENTER("THD::reset_for_next_command"); DBUG_ASSERT(!spcont); /* not for substatements of routines */ DBUG_ASSERT(!in_sub_stmt); + DBUG_ASSERT(transaction->on); + /* Table maps should have been reset after previous statement except in the - case where we have locked tables + case where we have locked ables */ DBUG_ASSERT(binlog_table_maps == 0 || locked_tables_mode == LTM_LOCK_TABLES); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 3eb78b2439b85..500f2affd192e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -7079,6 +7079,8 @@ static void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, { THD *thd= lpt->thd; partition_info *part_info= lpt->part_info->get_clone(thd); + /* TABLE is going to be released, we should not access old part_info anymore */ + lpt->part_info= part_info; TABLE *table= lpt->table; DBUG_ENTER("handle_alter_part_error"); DBUG_ASSERT(table->needs_reopen()); diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 05ebdbf144ab4..658afd57f9b1b 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -199,7 +199,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent, else { /* Revert the renames of normal tables with the help of the ddl log */ - ddl_log_revert(thd, &ddl_log_state); + error|= ddl_log_revert(thd, &ddl_log_state); } err: @@ -227,18 +227,6 @@ rename_temporary_table(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table) } -/** - Parameters for rename_table_and_triggers() -*/ - -struct rename_param -{ - LEX_CSTRING old_alias, new_alias; - LEX_CUSTRING old_version; - handlerton *from_table_hton; -}; - - /** Check pre-conditions for rename - From table should exists @@ -255,7 +243,7 @@ struct rename_param @retval <0 Can't do rename, but no error */ -static int +int rename_check_preconditions(THD *thd, rename_param *param, Table_name *ren_table, const LEX_CSTRING *new_db, @@ -281,7 +269,8 @@ rename_check_preconditions(THD *thd, rename_param *param, if (!ha_table_exists(thd, &ren_table->db, ¶m->old_alias, ¶m->old_version, NULL, - ¶m->from_table_hton, NULL, 0) || + ¶m->from_table_hton, NULL, + (param->rename_flags & FN_FROM_IS_TMP)) || !param->from_table_hton) { my_error(ER_NO_SUCH_TABLE, MYF(if_exists ? ME_NOTE : 0), @@ -301,7 +290,8 @@ rename_check_preconditions(THD *thd, rename_param *param, DBUG_RETURN(-1); } - if (ha_table_exists(thd, new_db, ¶m->new_alias, NULL, NULL, NULL, NULL, 0)) + if (ha_table_exists(thd, new_db, ¶m->new_alias, NULL, NULL, NULL, NULL, + (param->rename_flags & FN_TO_IS_TMP))) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), param->new_alias.str); DBUG_RETURN(1); // This can't be skipped @@ -325,12 +315,17 @@ rename_check_preconditions(THD *thd, rename_param *param, Rename a single table or a view. In case of failure, all changes will be reverted + Even if mysql_rename_tables() cannot be used with LOCK TABLES, + the table can still be locked if we come here from CREATE ... REPLACE. + + If ddl_log_state is NULL then we will not log the rename to the ddl log. + RETURN false Ok true rename failed */ -static bool +bool rename_table_and_triggers(THD *thd, rename_param *param, DDL_LOG_STATE *ddl_log_state, Table_name *ren_table, const LEX_CSTRING *new_db, @@ -340,6 +335,7 @@ rename_table_and_triggers(THD *thd, rename_param *param, handlerton *hton; LEX_CSTRING *old_alias, *new_alias; TRIGGER_RENAME_PARAM rename_param; + rename_param.rename_flags= param->rename_flags; DBUG_ENTER("rename_table_and_triggers"); DBUG_PRINT("enter", ("skip_error: %d", (int) skip_error)); @@ -347,15 +343,19 @@ rename_table_and_triggers(THD *thd, rename_param *param, new_alias= ¶m->new_alias; hton= param->from_table_hton; - DBUG_ASSERT(!thd->locked_tables_mode); - #ifdef WITH_WSREP if (WSREP(thd) && hton && hton != view_pseudo_hton && !wsrep_should_replicate_ddl(thd, hton)) DBUG_RETURN(1); #endif - tdc_remove_table(thd, ren_table->db.str, ren_table->table_name.str); + if (!(param->rename_flags & FN_FROM_IS_TMP)) + tdc_remove_table(thd, ren_table->db.str, ren_table->table_name.str); + + /* + In case of CREATE..REPLACE the temporary table does not have a + MDL lock + */ if (hton != view_pseudo_hton) { @@ -373,19 +373,23 @@ rename_table_and_triggers(THD *thd, rename_param *param, thd->replication_flags= 0; - if (ddl_log_rename_table(ddl_log_state, hton, - &ren_table->db, old_alias, new_db, new_alias)) + if (ddl_log_state && + ddl_log_rename_table(ddl_log_state, hton, + &ren_table->db, old_alias, new_db, new_alias, + DDL_RENAME_PHASE_TABLE, 0)) DBUG_RETURN(1); debug_crash_here("ddl_log_rename_before_rename_table"); if (!(rc= mysql_rename_table(hton, &ren_table->db, old_alias, - new_db, new_alias, ¶m->old_version, 0))) + new_db, new_alias, ¶m->old_version, + param->rename_flags))) { /* Table rename succeded. It's safe to start recovery at rename trigger phase */ debug_crash_here("ddl_log_rename_before_phase_trigger"); - ddl_log_update_phase(ddl_log_state, DDL_RENAME_PHASE_TRIGGER); + if (ddl_log_state) + ddl_log_update_phase(ddl_log_state, DDL_RENAME_PHASE_TRIGGER); debug_crash_here("ddl_log_rename_before_rename_trigger"); @@ -398,10 +402,13 @@ rename_table_and_triggers(THD *thd, rename_param *param, new_alias))) { debug_crash_here("ddl_log_rename_before_stat_tables"); - (void) rename_table_in_stat_tables(thd, &ren_table->db, - &ren_table->table_name, - new_db, new_alias); - debug_crash_here("ddl_log_rename_after_stat_tables"); + if (!(param->rename_flags & FN_IS_TMP)) + { + (void) rename_table_in_stat_tables(thd, &ren_table->db, + &ren_table->table_name, + new_db, new_alias); + debug_crash_here("ddl_log_rename_after_stat_tables"); + } } else { @@ -416,7 +423,8 @@ rename_table_and_triggers(THD *thd, rename_param *param, &ren_table->db, old_alias, ¶m->old_version, NO_FK_CHECKS); debug_crash_here("ddl_log_rename_after_revert_rename_table"); - ddl_log_disable_entry(ddl_log_state); + if (ddl_log_state) + ddl_log_disable_entry(ddl_log_state); debug_crash_here("ddl_log_rename_after_disable_entry"); } } @@ -437,6 +445,7 @@ rename_table_and_triggers(THD *thd, rename_param *param, DBUG_RETURN(1); } + DBUG_ASSERT(ddl_log_state); ddl_log_rename_view(ddl_log_state, &ren_table->db, &ren_table->table_name, new_db, new_alias); debug_crash_here("ddl_log_rename_before_rename_view"); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b76ec6d14f3b8..45fed46e37590 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -55,6 +55,7 @@ #include "sql_window.h" #include "tztime.h" +#include "debug.h" #include "debug_sync.h" // DEBUG_SYNC #include #include @@ -23005,6 +23006,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) // error < 0 => duplicate row join->duplicate_rows++; } + debug_crash_here("ddl_log_create_after_send_data"); } join->send_records++; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index ed82e6deae343..0dee0beae76af 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2107,7 +2107,8 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, !create_info_arg->or_replace_slave_generated()) || create_info_arg->table_was_deleted)) packet->append(STRING_WITH_LEN("OR REPLACE ")); - if (share->tmp_table) + if (share->tmp_table && + !(create_info_arg && create_info_arg->is_atomic_replace())) packet->append(STRING_WITH_LEN("TEMPORARY ")); packet->append(STRING_WITH_LEN("TABLE ")); if (create_info_arg && create_info_arg->if_not_exists()) @@ -5049,7 +5050,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table, init_sql_alloc(key_memory_table_triggers_list, &tbl.mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0)); if (!Table_triggers_list::check_n_load(thd, db_name, - table_name, &tbl, 1)) + table_name, &tbl, true, 0)) { table_list.table= &tbl; res= schema_table->process_table(thd, &table_list, table, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dd940b24f61a2..48761ee194570 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1242,6 +1242,69 @@ static uint32 get_comment(THD *thd, uint32 comment_pos, return 0; } + +static +bool make_tmp_name(THD *thd, const char *prefix, const Table_name *orig, + Table_name *res) +{ + char res_name[NAME_LEN + 1]; + char file_name[NAME_LEN + 1]; + LEX_CSTRING table_name; + + size_t len= my_snprintf(res_name, sizeof(res_name) - 1, + tmp_file_prefix "-%s-%lx-%llx-", prefix, + current_pid, thd->thread_id); + + uint len2= tablename_to_filename(orig->table_name.str, file_name, + sizeof(res_name) - len - 1); + + DBUG_ASSERT(len + len2 < sizeof(res_name) - 1); + memcpy(res_name + len, file_name, len2 + 1); + len+= len2; + + table_name.str= strmake_root(thd->mem_root, res_name, len); + if (!table_name.str) + return true; + + table_name.length= len; + res->db= orig->db; + res->table_name= table_name; + res->alias= table_name; + return false; +} + + +/** + Helper for making utility table names for atomic CREATE OR REPLACE. + + Creates two temporary names: "create" (used for new table) + and "backup" (used for saving old table). + + @param create_table[in/out] Original table name, on output holds new name + @param create_table_mode[out] Create flags or-ed with C_ALTER_TABLE +*/ + +bool HA_CREATE_INFO::make_tmp_table_list(THD *thd, TABLE_LIST **create_table, + int *create_table_mode) +{ + TABLE_LIST *new_table; + if (make_tmp_name(thd, "create", *create_table, &tmp_name) || + make_tmp_name(thd, "backup", *create_table, &backup_name) || + !(new_table= (TABLE_LIST *)thd->alloc(sizeof(TABLE_LIST)))) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + return true; + } + (*create_table_mode)|= C_ALTER_TABLE; + DBUG_ASSERT(!(options & HA_CREATE_TMP_ALTER)); + options|= HA_CREATE_TMP_ALTER; + new_table->init_one_table(&tmp_name.db, &tmp_name.table_name, + &tmp_name.alias, (*create_table)->lock_type); + *create_table= new_table; + return false; +} + + /** Execute the drop of a sequence, view or table (normal or temporary). @@ -1494,12 +1557,13 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)); + /* NOTE: alias holds original table name, table_name holds lowercase name */ alias= (lower_case_table_names == 2) ? table->alias : table_name; /* remove .frm file and engine files */ path_length= build_table_filename(path, sizeof(path) - 1, db.str, alias.str, reg_ext, 0); path_end= path + path_length - reg_ext_length; - } + } /* if (!drop_temporary) */ DEBUG_SYNC(thd, "rm_table_no_locks_before_delete_table"); if (drop_temporary) @@ -1598,7 +1662,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, &table_name); else res= ddl_log_drop_table(ddl_log_state, hton, &cpath, &db, - &table_name); + &table_name, 0); if (res) { error= -1; @@ -1675,8 +1739,17 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, int ferror= 0; DBUG_ASSERT(!was_view); + /* + We where not able to drop the table for the engine. We will now try + to drop the table for any engines (to handle the case where we don't have + an .frm file or when the the information in the .frm does not match the + engine type). + We start by discarding the previous drop attempt, as we have tried + this drop already and it failed. + */ + ddl_log_disable_entry(ddl_log_state); if (ddl_log_drop_table(ddl_log_state, 0, &cpath, &db, - &table_name)) + &table_name, 0)) { error= -1; goto err; @@ -1715,17 +1788,24 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, if (!was_view) { - debug_crash_here("ddl_log_drop_before_drop_trigger"); - ddl_log_update_phase(ddl_log_state, DDL_DROP_PHASE_TRIGGER); - debug_crash_here("ddl_log_drop_before_drop_trigger2"); + if (likely(!error) || non_existing_table_error(error)) + { + debug_crash_here("ddl_log_drop_before_drop_trigger"); + ddl_log_update_phase(ddl_log_state, DDL_DROP_PHASE_TRIGGER); + debug_crash_here("ddl_log_drop_before_drop_trigger2"); + if (Table_triggers_list::drop_all_triggers(thd, &db, &table_name, 0, + MYF(MY_WME | + MY_IGNORE_ENOENT))) + error= error ? error : -1; + } + else + { + /* NOTE: table may not be dropped due to FK error */ + DBUG_ASSERT(error); + ddl_log_update_phase(ddl_log_state, DDL_DROP_PHASE_END); + } } - if (likely(!error) || non_existing_table_error(error)) - { - if (Table_triggers_list::drop_all_triggers(thd, &db, &table_name, - MYF(MY_WME | MY_IGNORE_ENOENT))) - error= error ? error : -1; - } debug_crash_here("ddl_log_drop_after_drop_trigger"); report_error: @@ -1792,7 +1872,12 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, backup_log_ddl(&ddl_log); } } - if (!was_view) + /* + Foreign key check may fail and we didn't drop the table. + We are already at DDL_DROP_PHASE_END in this case and we + must not binlog DROP query. + */ + if (!was_view && table_dropped) ddl_log_update_phase(ddl_log_state, DDL_DROP_PHASE_BINLOG); if (!dont_log_query && @@ -2741,7 +2826,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, List_iterator_fast it(alter_info->create_list); List_iterator it2(alter_info->create_list); uint total_uneven_bit_length= 0; - bool tmp_table= create_table_mode == C_ALTER_TABLE; + bool tmp_table= (create_table_mode & C_ALTER_TABLE); const bool create_simple= thd->lex->create_simple(); bool is_hash_field_needed= false; const Column_derived_attributes dattr(create_info->default_table_charset); @@ -2994,6 +3079,18 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, } else fk_key->ref_columns.append(&fk_key->columns); + /* + If this is a self refering table from CREATE ... SELECT, + update the foreign key table name to the used (temporary) table name. + */ + if (create_info->tmp_name.is_set() && + (!fk_key->ref_db.str || + !lex_string_cmp(table_alias_charset, &db, &fk_key->ref_db)) && + !lex_string_cmp(table_alias_charset, &table_name, + &fk_key->ref_table)) + { + fk_key->ref_table= create_info->tmp_name.table_name; + } continue; } (*key_count)++; @@ -4274,12 +4371,171 @@ handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db, } +/** + Finalize atomic CREATE OR REPLACE. + + Renames old table to backup table (in case it exists), rename tmp table to + new table. These operations are covered with DDL logging in two chains: + + ddl_log_state_create: rolls back the tables to the original state before + the command was started. + + ddl_log_state_rm: keep the new table and drop the backup table. + + finalize_ddl() executes one of the above chains depending on error or success + state. + + @return true in case of error +*/ + +bool HA_CREATE_INFO::finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table) +{ + rename_param param; + bool dummy; + const LEX_CSTRING db= orig_table->db; + const LEX_CSTRING table_name= orig_table->table_name; + LEX_CSTRING cpath; + char path[FN_REFLEN + 1]; + cpath.str= path; + + debug_crash_here("ddl_log_create_before_install_new"); + if (old_hton) + { + /* Old table exists, rename it to backup_name */ + ddl_log_link_chains(ddl_log_state_rm, ddl_log_state_create); + + cpath.length= build_table_filename(path, sizeof(path) - 1, + backup_name.db.str, + backup_name.table_name.str, + "", FN_IS_TMP); + + if (ddl_log_drop_table_init(ddl_log_state_rm, &backup_name.db, + &empty_clex_str) || + ddl_log_drop_table(ddl_log_state_rm, old_hton, &cpath, + &backup_name.db, &backup_name.table_name, + DDL_LOG_FLAG_FROM_IS_TMP)) + return true; + + debug_crash_here("ddl_log_create_after_log_drop_backup"); + if (ddl_log_rename_table(ddl_log_state_create, old_hton, + &db, &table_name, + &backup_name.db, &backup_name.table_name, + DDL_RENAME_PHASE_TRIGGER, + DDL_LOG_FLAG_FROM_IS_TMP)) + return true; + + debug_crash_here("ddl_log_create_after_log_rename_backup"); + + if (thd->locked_tables_mode == LTM_LOCK_TABLES || + thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES) + { + DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, + table_name.str, + MDL_EXCLUSIVE)); + + close_all_tables_for_name(thd, table->s, + HA_EXTRA_PREPARE_FOR_DROP, NULL); + table= NULL; + orig_table->table= NULL; + } + + param.rename_flags= FN_TO_IS_TMP; + param.from_table_hton= old_hton; + param.old_version= org_tabledef_version; + param.old_alias= lower_case_table_names == 2 ? orig_table->alias : + table_name; + param.new_alias= backup_name.table_name; + if (rename_table_and_triggers(thd, ¶m, NULL, orig_table, + &backup_name.db, false, &dummy)) + return true; + debug_crash_here("ddl_log_create_after_save_backup"); + } + + cpath.length= build_table_filename(path, sizeof(path) - 1, db.str, + table_name.str, "", 0); + param.rename_flags= FN_FROM_IS_TMP; + param.from_table_hton= db_type; + param.old_version= tabledef_version; + param.old_alias= tmp_name.table_name; + param.new_alias= table_name; + if (ddl_log_create_table(ddl_log_state_create, param.from_table_hton, + &cpath, &db, &table_name, false) || + rename_table_and_triggers(thd, ¶m, NULL, &tmp_name, &db, false, + &dummy)) + return true; + debug_crash_here("ddl_log_create_after_install_new"); + return false; +} + + +/** + Execute ddl_log_state_rm or ddl_log_state_create depending on error or success + state. +*/ + +void HA_CREATE_INFO::finalize_ddl(THD *thd, bool roll_back) +{ + if (roll_back) + { + /* + Statement failed + - Forget drop of backup table + - Rollback create (drop temporary table, rename backup to original) + */ + debug_crash_here("ddl_log_create_fk_fail"); + ddl_log_complete(ddl_log_state_rm); + debug_crash_here("ddl_log_create_fk_fail2"); + (void) ddl_log_revert(thd, ddl_log_state_create); + debug_crash_here("ddl_log_create_fk_fail3"); + } + else + { + /* + Statement succeded + - Forget revert of create table + - Drop backup table + */ + debug_crash_here("ddl_log_create_log_complete"); + ddl_log_complete(ddl_log_state_create); + debug_crash_here("ddl_log_create_log_complete2"); + (void) ddl_log_revert(thd, ddl_log_state_rm); + debug_crash_here("ddl_log_create_log_complete3"); + } +} + + +bool HA_CREATE_INFO::finalize_locked_tables(THD *thd) +{ + DBUG_ASSERT(pos_in_locked_tables); + DBUG_ASSERT(thd->locked_tables_mode); + DBUG_ASSERT(thd->variables.option_bits & OPTION_TABLE_LOCK); + /* + Add back the deleted table and re-created table as a locked 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, false)) + { + thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); + return true; + } + /* + The lock was made exclusive in create_table_impl(). We have now + to bring it back to it's orginal state + */ + TABLE *table= pos_in_locked_tables->table; + table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); + + return false; +} + + /** Create a table @param thd Thread object - @param orig_db Database for error messages - @param orig_table_name Table name for error messages + @param orig_db Database for error messages or atomic replace + @param orig_table_name Table name for error messages or atomic replace (it's different from table_name for ALTER TABLE) @param db Database @param table_name Table name @@ -4314,8 +4570,6 @@ handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db, static int create_table_impl(THD *thd, - DDL_LOG_STATE *ddl_log_state_create, - DDL_LOG_STATE *ddl_log_state_rm, const LEX_CSTRING &orig_db, const LEX_CSTRING &orig_table_name, const LEX_CSTRING &db, const LEX_CSTRING &table_name, @@ -4324,24 +4578,23 @@ int create_table_impl(THD *thd, int create_table_mode, bool *is_trans, KEY **key_info, uint *key_count, LEX_CUSTRING *frm) { - LEX_CSTRING *alias; + LEX_CSTRING *alias= const_cast(table_case_name(create_info, &table_name)); handler *file= 0; int error= 1; - bool frm_only= create_table_mode == C_ALTER_TABLE_FRM_ONLY; - bool internal_tmp_table= create_table_mode == C_ALTER_TABLE || frm_only; + bool frm_only= (create_table_mode & C_ALTER_TABLE_FRM_ONLY); + bool atomic_replace= create_info->is_atomic_replace(); + bool internal_tmp_table= (!atomic_replace && + (create_table_mode & C_ALTER_TABLE)) || + frm_only; + /* Easy check for ddl logging if we are creating a temporary table */ + DDL_LOG_STATE *ddl_log_state_create= + create_info->tmp_table() ? 0 : create_info->ddl_log_state_create; DBUG_ENTER("create_table_impl"); DBUG_PRINT("enter", ("db: '%s' table: '%s' tmp: %d path: %s", db.str, table_name.str, internal_tmp_table, path.str)); DBUG_ASSERT(create_info->default_table_charset); - /* Easy check for ddl logging if we are creating a temporary table */ - if (create_info->tmp_table()) - { - ddl_log_state_create= 0; - ddl_log_state_rm= 0; - } - if (fix_constraints_names(thd, &alter_info->check_constraint_list, create_info)) DBUG_RETURN(1); @@ -4370,8 +4623,6 @@ int create_table_impl(THD *thd, goto err; } - alias= const_cast(table_case_name(create_info, &table_name)); - /* Check if table exists */ if (create_info->tmp_table()) { @@ -4425,12 +4676,16 @@ int create_table_impl(THD *thd, goto err; } - handlerton *db_type; + handlerton *db_type= NULL; + LEX_CSTRING partition_engine_name= {NULL, 0}; + if (!internal_tmp_table && ha_table_exists(thd, &orig_db, &orig_table_name, &create_info->org_tabledef_version, - NULL, &db_type, NULL, 0)) + &partition_engine_name, &db_type, NULL, 0)) { + create_info->old_hton= db_type; + if (ha_check_if_updates_are_ignored(thd, db_type, "CREATE")) { /* Don't create table. CREATE will still be logged in binary log */ @@ -4440,44 +4695,115 @@ int create_table_impl(THD *thd, if (options.or_replace()) { - (void) delete_statistics_for_table(thd, &db, &table_name); + (void) delete_statistics_for_table(thd, &orig_db, &orig_table_name); TABLE_LIST table_list; - table_list.init_one_table(&db, &table_name, 0, TL_WRITE_ALLOW_WRITE); - table_list.table= create_info->table; + TABLE *table= create_info->table; + table_list.init_one_table(&orig_db, &orig_table_name, 0, TL_READ); + table_list.table= table; if (check_if_log_table(&table_list, TRUE, "CREATE OR REPLACE")) goto err; - - /* - Rollback the empty transaction started in mysql_create_table() - call to open_and_lock_tables() when we are using LOCK TABLES. - */ - (void) trans_rollback_stmt(thd); - /* Remove normal table without logging. Keep tables locked */ - if (mysql_rm_table_no_locks(thd, &table_list, &thd->db, - ddl_log_state_rm, - 0, 0, 0, 0, 1, 1)) - goto err; - debug_crash_here("ddl_log_create_after_drop"); - - /* - We have to log this query, even if it failed later to ensure the - drop is done. - */ - thd->variables.option_bits|= OPTION_BINLOG_THIS; - create_info->table_was_deleted= 1; lex_string_set(&create_info->org_storage_engine_name, - ha_resolve_storage_engine_name(db_type)); - DBUG_EXECUTE_IF("send_kill_after_delete", - thd->set_killed(KILL_QUERY);); - /* - Restart statement transactions for the case of CREATE ... SELECT. - */ - if (thd->lex->first_select_lex()->item_list.elements && - restart_trans_for_tables(thd, thd->lex->query_tables)) - goto err; + ha_resolve_storage_engine_name(db_type)); + + if (db_type == view_pseudo_hton) + atomic_replace= false; + + if (atomic_replace) + { + /* NOTE: here FK referencing is checked */ + if (!(thd->variables.option_bits & OPTION_NO_FOREIGN_KEY_CHECKS)) + { + Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); + if (!create_info->table) + { + if (open_table(thd, &table_list, &ot_ctx)) + goto err; + table= table_list.table; + } + FOREIGN_KEY_INFO *fk; + bool res= table->referenced_by_foreign_table(thd, &fk); + if (!create_info->table) + { + (void) close_thread_table(thd, &thd->open_tables); + table= NULL; + } + if (res) + { + if (fk) + my_error(ER_ROW_IS_REFERENCED_2, MYF(0), fk->foreign_table->str); + goto err; + } + } + + if (thd->locked_tables_mode == LTM_LOCK_TABLES || + thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES) + { + if (wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED)) + goto err; + } + else + { + DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, + orig_db.str, + orig_table_name.str, + MDL_EXCLUSIVE)); + } + + /* + Prepare DROP entry for backup log. It will be logged before logging + the CREATE entry when the command succeeds. + */ + backup_log_info *drop_entry= &create_info->drop_entry; + drop_entry->query= { C_STRING_WITH_LEN("DROP") }; + if ((drop_entry->org_partitioned= (partition_engine_name.str != 0))) + drop_entry->org_storage_engine_name= partition_engine_name; + else + lex_string_set(&drop_entry->org_storage_engine_name, + ha_resolve_storage_engine_name(db_type)); + drop_entry->org_database= orig_db; + drop_entry->org_table= orig_table_name; + drop_entry->org_table_id= create_info->org_tabledef_version; + + DBUG_EXECUTE_IF("send_kill_after_delete", thd->set_killed(KILL_QUERY);); + } + else + { + /* + Rollback the empty transaction started in mysql_create_table() + call to open_and_lock_tables() when we are using LOCK TABLES. + */ + (void) trans_rollback_stmt(thd); + + /* Remove normal table without logging. Keep tables locked */ + if (mysql_rm_table_no_locks(thd, &table_list, &thd->db, + create_info->ddl_log_state_rm, + 0, 0, 0, 0, 1, 1)) + goto err; + + /* Locked table was closed */ + create_info->table= table_list.table; + + debug_crash_here("ddl_log_create_after_drop"); + + /* + We have to log this query, even if it failed later to ensure the + drop is done. + */ + thd->variables.option_bits|= OPTION_BINLOG_THIS; + create_info->table_was_deleted= 1; + + DBUG_EXECUTE_IF("send_kill_after_delete", thd->set_killed(KILL_QUERY);); + + /* + Restart statement transactions for the case of CREATE ... SELECT. + */ + if (thd->lex->first_select_lex()->item_list.elements && + restart_trans_for_tables(thd, thd->lex->query_tables)) + goto err; + } } else if (options.if_not_exists()) { @@ -4496,18 +4822,19 @@ int create_table_impl(THD *thd, } else { - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name.str); + DBUG_ASSERT(!atomic_replace); + my_error(ER_TABLE_EXISTS_ERROR, MYF(0), orig_table_name.str); goto err; } - } - } + } /* ha_table_exists() */ + } /* else (!create_info->tmp_table()) */ THD_STAGE_INFO(thd, stage_creating_table); if (check_engine(thd, orig_db.str, orig_table_name.str, create_info)) goto err; - if (create_table_mode == C_ASSISTED_DISCOVERY) + if (create_table_mode & C_ASSISTED_DISCOVERY) { /* check that it's used correctly */ DBUG_ASSERT(alter_info->create_list.elements == 0); @@ -4593,8 +4920,8 @@ int create_table_impl(THD *thd, if (!frm_only) { debug_crash_here("ddl_log_create_before_create_table"); - if (ha_create_table(thd, path.str, db.str, table_name.str, create_info, - frm, 0)) + if (ha_create_table(thd, path.str, orig_db.str, orig_table_name.str, + create_info, frm, 0)) { file->ha_create_partitioning_metadata(path.str, NULL, CHF_DELETE_FLAG); deletefrm(path.str); @@ -4650,21 +4977,40 @@ int create_table_impl(THD *thd, Simple wrapper around create_table_impl() to be used in various version of CREATE TABLE statement. + @param thd Thread object + @param orig_db Database for error messages or atomic replace + @param orig_table_name Table name for error messages or atomic replace + (it's different from table_name for ALTER TABLE) + @param db Database + @param table_name Table name + @param create_info Create information (like MAX_ROWS) + @param alter_info Description of fields and keys for new table + @param[out] is_trans Identifies the type of engine where the table + was created: either trans or non-trans. + @param create_table_mode C_ORDINARY_CREATE, C_ALTER_TABLE, + C_ASSISTED_DISCOVERY or C_ALTER_TABLE_FRM_ONLY. + or any positive number (for C_CREATE_SELECT). + If set to C_ALTER_TABLE_FRM_ONY then no frm or + table is created, only the frm image in memory. + @param[out] frm The frm image. + @result 1 unspecifed error 2 error; Don't log create statement 0 ok -1 Table was used with IF NOT EXISTS and table existed (warning, not error) + + TODO: orig_db, orig_table_name, db, table_name should be moved to create_info */ -int mysql_create_table_no_lock(THD *thd, - DDL_LOG_STATE *ddl_log_state_create, - DDL_LOG_STATE *ddl_log_state_rm, +int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *orig_db, + const LEX_CSTRING *orig_table_name, const LEX_CSTRING *db, const LEX_CSTRING *table_name, Table_specification_st *create_info, Alter_info *alter_info, bool *is_trans, - int create_table_mode, TABLE_LIST *table_list) + int create_table_mode, TABLE_LIST *table_list, + LEX_CUSTRING *frm) { KEY *not_used_1; uint not_used_2; @@ -4672,7 +5018,14 @@ int mysql_create_table_no_lock(THD *thd, uint path_length; char path[FN_REFLEN + 1]; LEX_CSTRING cpath; - LEX_CUSTRING frm= {0,0}; + LEX_CUSTRING frm_local; + + if (!frm) + { + /* Used in atomic replace */ + frm_local= {0, 0}; + frm= &frm_local; + } DBUG_ASSERT(create_info->default_table_charset); @@ -4681,9 +5034,9 @@ int mysql_create_table_no_lock(THD *thd, else { const LEX_CSTRING *alias= table_case_name(create_info, table_name); + uint flags= (create_info->options & HA_CREATE_TMP_ALTER) ? FN_IS_TMP : 0; path_length= build_table_filename(path, sizeof(path) - 1, db->str, - alias->str, - "", 0); + alias->str, "", flags); // Check if we hit FN_REFLEN bytes along with file extension. if (path_length+reg_ext_length > FN_REFLEN) { @@ -4694,12 +5047,12 @@ int mysql_create_table_no_lock(THD *thd, } lex_string_set3(&cpath, path, path_length); - res= create_table_impl(thd, ddl_log_state_create, ddl_log_state_rm, - *db, *table_name, *db, *table_name, cpath, - *create_info, create_info, - alter_info, create_table_mode, - is_trans, ¬_used_1, ¬_used_2, &frm); - my_free(const_cast(frm.str)); + res= create_table_impl(thd, *orig_db, *orig_table_name, *db, *table_name, + cpath, *create_info, create_info, alter_info, + create_table_mode, is_trans, ¬_used_1, ¬_used_2, + frm); + if (frm == &frm_local) + my_free(const_cast(frm_local.str)); if (!res && create_info->sequence) { @@ -4714,8 +5067,7 @@ int mysql_create_table_no_lock(THD *thd, DBUG_ASSERT(thd->is_error()); /* Drop the table as it wasn't completely done */ if (!mysql_rm_table_no_locks(thd, table_list, &thd->db, - (DDL_LOG_STATE*) 0, - 1, + NULL, 1, create_info->tmp_table(), false, true /* Sequence*/, true /* Don't log_query */, @@ -4756,7 +5108,9 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, int create_table_mode; uint save_thd_create_info_options; bool is_trans= FALSE; - bool result; + int result; + TABLE_LIST *orig_table= create_table; + const bool atomic_replace= create_info->is_atomic_replace(); DBUG_ENTER("mysql_create_table"); DBUG_ASSERT(create_info->default_table_charset); @@ -4765,6 +5119,8 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); + create_info->ddl_log_state_create= &ddl_log_state_create; + create_info->ddl_log_state_rm= &ddl_log_state_rm; /* Copy temporarily the statement flags to thd for lock_table_names() */ save_thd_create_info_options= thd->lex->create_info.options; @@ -4793,6 +5149,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, if ((create_info->table= create_table->table)) { pos_in_locked_tables= create_info->table->pos_in_locked_tables; + create_info->pos_in_locked_tables= pos_in_locked_tables; mdl_ticket= create_table->table->mdl_ticket; } @@ -4810,42 +5167,33 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, /* We can abort create table for any table type */ thd->abort_on_warning= thd->is_strict_mode(); - if (mysql_create_table_no_lock(thd, &ddl_log_state_create, &ddl_log_state_rm, - &create_table->db, &create_table->table_name, - create_info, alter_info, &is_trans, - create_table_mode, create_table) > 0) + if (atomic_replace && + create_info->make_tmp_table_list(thd, &create_table, &create_table_mode)) { result= 1; goto err; } - /* - Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES - on a non temporary table - */ - if (thd->locked_tables_mode && pos_in_locked_tables && - create_info->or_replace()) + if (mysql_create_table_no_lock(thd, + &orig_table->db, + &orig_table->table_name, + &create_table->db, + &create_table->table_name, create_info, + alter_info, + &is_trans, create_table_mode, + create_table) > 0) { - DBUG_ASSERT(thd->variables.option_bits & OPTION_TABLE_LOCK); - /* - Add back the deleted table and re-created table as a locked 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, false)) - { - thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); - result= 1; - goto err; - } - else - { - TABLE *table= pos_in_locked_tables->table; - table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); - } + result= 1; + goto err; } err: + if (atomic_replace) + { + create_table= orig_table; + create_info->table= orig_table->table; + } + thd->abort_on_warning= 0; /* In RBR or readonly server we don't need to log CREATE TEMPORARY TABLE */ @@ -4858,6 +5206,8 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, if (create_info->tmp_table()) thd->transaction->stmt.mark_created_temp_table(); + else if (!result && atomic_replace) + result= create_info->finalize_atomic_replace(thd, orig_table); /* Write log if no error or if we already deleted a table */ if (!result || thd->log_current_statement()) @@ -4878,12 +5228,16 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, we should log a delete of it. If create_info->table was not set, it's a normal table and table_creation_was_logged will be set when the share is created. + + NOTE: this is only needed for non-atomic CREATE OR REPLACE and + CREATE TEMPORARY TABLE. */ + DBUG_ASSERT(!atomic_replace); create_info->table->s->table_creation_was_logged= 1; } thd->binlog_xid= thd->query_id; ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - if (ddl_log_state_rm.is_active()) + if (ddl_log_state_rm.is_active() && !atomic_replace) ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); debug_crash_here("ddl_log_create_before_binlog"); if (unlikely(write_bin_log(thd, result ? FALSE : TRUE, thd->query(), @@ -4902,11 +5256,25 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, ddl_log.org_database= create_table->db; ddl_log.org_table= create_table->table_name; ddl_log.org_table_id= create_info->tabledef_version; + if (create_info->drop_entry.query.length) + { + DBUG_ASSERT(atomic_replace); + backup_log_ddl(&create_info->drop_entry); + } backup_log_ddl(&ddl_log); } } - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); + + create_info->finalize_ddl(thd, result); + + /* + Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES + on a non temporary table + */ + if (thd->locked_tables_mode && pos_in_locked_tables && + create_info->or_replace()) + result|= (int) create_info->finalize_locked_tables(thd); + DBUG_RETURN(result); } @@ -5214,10 +5582,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, bool src_table_exists= FALSE; uint not_used; int create_res; + TABLE_LIST *orig_table= table; + const bool atomic_replace= create_info->is_atomic_replace(); + int create_table_mode= C_ORDINARY_CREATE; DBUG_ENTER("mysql_create_like_table"); bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); + local_create_info.ddl_log_state_create= &ddl_log_state_create; + local_create_info.ddl_log_state_rm= &ddl_log_state_rm; #ifdef WITH_WSREP if (WSREP(thd) && !thd->wsrep_applier && @@ -5325,14 +5698,22 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, /* The following is needed only in case of lock tables */ if ((local_create_info.table= thd->lex->query_tables->table)) - pos_in_locked_tables= local_create_info.table->pos_in_locked_tables; + { + pos_in_locked_tables= local_create_info.table->pos_in_locked_tables; + local_create_info.pos_in_locked_tables= pos_in_locked_tables; + } + + if (atomic_replace && + local_create_info.make_tmp_table_list(thd, &table, &create_table_mode)) + goto err; res= ((create_res= mysql_create_table_no_lock(thd, - &ddl_log_state_create, &ddl_log_state_rm, + &orig_table->db, + &orig_table->table_name, &table->db, &table->table_name, &local_create_info, &local_alter_info, - &is_trans, C_ORDINARY_CREATE, + &is_trans, create_table_mode, table)) > 0); /* Remember to log if we deleted something */ do_logging= thd->log_current_statement(); @@ -5340,46 +5721,18 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, goto err; /* - Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES - on a non temporary table + Ensure that we have an exclusive lock on target table if we are creating + non-temporary table. We don't have or need the lock if the create failed + because of existing table when using "if exists". */ - if (thd->locked_tables_mode && pos_in_locked_tables && - create_info->or_replace()) - { - /* - Add back the deleted table and re-created table as a locked 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, false)) - { - thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); - res= 1; // We got an error - } - else - { - /* - Get pointer to the newly opened table. We need this to ensure we - don't reopen the table when doing statment logging below. - */ - table->table= pos_in_locked_tables->table; - table->table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); - } - } - else - { - /* - Ensure that we have an exclusive lock on target table if we are creating - non-temporary table. We don't have or need the lock if the create failed - because of existing table when using "if exists". - */ - DBUG_ASSERT((create_info->tmp_table()) || create_res < 0 || - thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str, - table->table_name.str, - MDL_EXCLUSIVE) || - (thd->locked_tables_mode && pos_in_locked_tables && - create_info->if_not_exists())); - } + DBUG_ASSERT((thd->locked_tables_mode && pos_in_locked_tables && + create_info->or_replace()) || atomic_replace || + (create_info->tmp_table()) || create_res < 0 || + thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str, + table->table_name.str, + MDL_EXCLUSIVE) || + (thd->locked_tables_mode && pos_in_locked_tables && + create_info->if_not_exists())); DEBUG_SYNC(thd, "create_table_like_before_binlog"); @@ -5404,10 +5757,20 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, if (thd->is_current_stmt_binlog_format_row() || force_generated_create) { /* - Since temporary tables are not replicated under row-based - replication, CREATE TABLE ... LIKE ... needs special - treatement. We have some cases to consider, according to the - following decision table: + The logging for CREATE .. LIKE is a bit different from normal + create as we want in statement-based logging use the original statement. + + Generated statement means the CREATE TABLE statement without LIKE. Same + thing we do with CREATE .. SELECT in row based logging. It is needed to + get replication working if the original table didn't exists. + + However as an engine can change a table definition, it is probly better to + use CREATE TABLE instead of LIKE to ensure the table definition will be + same on both side. (This is just a guess). + + Since temporary tables are not replicated under row-based replication, + CREATE TABLE .. LIKE needs special treatment. We have some cases to + consider, according to the following decision table: ==== ========= ========= ============================== Case Target Source Write to binary log @@ -5431,7 +5794,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, query.length(0); // Have to zero it since constructor doesn't Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN | MYSQL_OPEN_IGNORE_KILLED); - bool new_table= FALSE; // Whether newly created table is open. + bool opened_new_table= FALSE; // Whether newly created table is open. if (create_res != 0) { @@ -5450,6 +5813,22 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, save_open_strategy= table->open_strategy; table->open_strategy= TABLE_LIST::OPEN_NORMAL; + if (atomic_replace) + { + /* + NOTE: We acquire explicit lock for temporary table just to make + close_thread_table() happy. We open it like a normal table + because it's too complex to open it like tmp_table here. + */ + table->mdl_request.duration= MDL_EXPLICIT; + if (thd->mdl_context.acquire_lock(&table->mdl_request, + thd->variables.lock_wait_timeout)) + { + res= 1; + goto err; + } + } + /* In order for show_create_table() to work we need to open destination table if it is not already open (i.e. if it @@ -5466,7 +5845,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, res= 1; goto err; } - new_table= TRUE; + opened_new_table= TRUE; } /* We have to re-test if the table was a view as the view may not @@ -5489,26 +5868,52 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, */ create_info->used_fields|= HA_CREATE_USED_ENGINE; + const LEX_CSTRING *const db= + table->schema_table ? &INFORMATION_SCHEMA_NAME : &orig_table->db; + const char *force_db= NULL; + if (!thd->db.str || cmp(db, &thd->db)) + force_db= db->str; + int result __attribute__((unused))= - show_create_table(thd, table, &query, create_info, WITH_DB_NAME); + show_create_table_ex(thd, table, + force_db, orig_table->table_name.str, + &query, create_info, WITH_DB_NAME); DBUG_ASSERT(result == 0); // show_create_table() always return 0 do_logging= FALSE; + + thd->binlog_xid= thd->query_id; + ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); + if (ddl_log_state_rm.is_active() && !atomic_replace) + ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); + debug_crash_here("ddl_log_create_before_binlog"); + if (write_bin_log(thd, TRUE, query.ptr(), query.length())) { res= 1; + thd->binlog_xid= 0; goto err; } - if (new_table) + debug_crash_here("ddl_log_create_after_binlog"); + thd->binlog_xid= 0; + + if (opened_new_table) { DBUG_ASSERT(thd->open_tables == table->table); /* When opening the table, we ignored the locked tables (MYSQL_OPEN_GET_NEW_TABLE). Now we can close the table without risking to close some locked table. + + For atomic_replace we must remove TABLE and TABLE_SHARE + from cache since they are the objects for temporary table. */ + if (atomic_replace) + table->table->s->tdc->flushed= true; close_thread_table(thd, &thd->open_tables); + if (atomic_replace) + thd->mdl_context.release_lock(table->mdl_request.ticket); } } } @@ -5532,7 +5937,11 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, /* Remember that tmp table creation was logged so that we know if we should log a delete of it. + + NOTE: this is only needed for non-atomic CREATE OR REPLACE and + CREATE TEMPORARY TABLE. */ + DBUG_ASSERT(!atomic_replace); local_create_info.table->s->table_creation_was_logged= 1; } } @@ -5540,13 +5949,26 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, } err: + if (atomic_replace) + { + table= orig_table; + local_create_info.table= orig_table->table; + + if (!res) + { + res= local_create_info.finalize_atomic_replace(thd, orig_table); + if (res) + do_logging= false; + } + } + if (do_logging) { thd->binlog_xid= thd->query_id; ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - if (ddl_log_state_rm.is_active()) + if (ddl_log_state_rm.is_active() && !atomic_replace) ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); - debug_crash_here("ddl_log_create_before_binlog"); + debug_crash_here("ddl_log_create_before_binlog"); if (res && create_info->table_was_deleted) { /* @@ -5554,6 +5976,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, We have to log it. */ DBUG_ASSERT(ddl_log_state_rm.is_active()); + DBUG_ASSERT(!atomic_replace); log_drop_table(thd, &table->db, &table->table_name, &create_info->org_storage_engine_name, create_info->db_type == partition_hton, @@ -5579,11 +6002,24 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ddl_log.org_database= table->db; ddl_log.org_table= table->table_name; ddl_log.org_table_id= local_create_info.tabledef_version; + if (local_create_info.drop_entry.query.length) + { + DBUG_ASSERT(atomic_replace); + backup_log_ddl(&local_create_info.drop_entry); + } backup_log_ddl(&ddl_log); } - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); + local_create_info.finalize_ddl(thd, res); + + /* + Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES + on a non temporary table + */ + if (thd->locked_tables_mode && pos_in_locked_tables && + create_info->or_replace()) + res|= (int) local_create_info.finalize_locked_tables(thd); + DBUG_RETURN(res != 0); } @@ -9449,7 +9885,8 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list, (void) ddl_log_rename_table(&ddl_log_state, old_db_type, &alter_ctx->db, &alter_ctx->table_name, - &alter_ctx->new_db, &alter_ctx->new_alias); + &alter_ctx->new_db, &alter_ctx->new_alias, + DDL_RENAME_PHASE_TABLE, 0); if (mysql_rename_table(old_db_type, &alter_ctx->db, &alter_ctx->table_name, &alter_ctx->new_db, &alter_ctx->new_alias, &table_version, 0)) @@ -10543,8 +10980,7 @@ do_continue:; No ddl logging needed as ddl_log_alter_query will take care of failed table creations. */ - error= create_table_impl(thd, (DDL_LOG_STATE*) 0, (DDL_LOG_STATE*) 0, - alter_ctx.db, alter_ctx.table_name, + error= create_table_impl(thd, alter_ctx.db, alter_ctx.table_name, alter_ctx.new_db, alter_ctx.tmp_name, alter_ctx.get_tmp_cstring_path(), thd->lex->create_info, create_info, alter_info, diff --git a/sql/sql_table.h b/sql/sql_table.h index 4d74aadc02a4b..2cead6fa68387 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -27,8 +27,10 @@ class Alter_info; class Alter_table_ctx; +struct Atomic_info; class Column_definition; class Create_field; +struct Table_name; struct TABLE_LIST; class THD; struct TABLE; @@ -94,49 +96,15 @@ uint build_tmptable_filename(THD* thd, char *buff, size_t bufflen); bool add_keyword_to_query(THD *thd, String *result, const LEX_CSTRING *keyword, const LEX_CSTRING *add); -/* - mysql_create_table_no_lock can be called in one of the following - mutually exclusive situations: - - - Just a normal ordinary CREATE TABLE statement that explicitly - defines the table structure. - - - CREATE TABLE ... SELECT. It is special, because only in this case, - the list of fields is allowed to have duplicates, as long as one of the - duplicates comes from the select list, and the other doesn't. For - example in - - CREATE TABLE t1 (a int(5) NOT NUL) SELECT b+10 as a FROM t2; - - the list in alter_info->create_list will have two fields `a`. - - - ALTER TABLE, that creates a temporary table #sql-xxx, which will be later - renamed to replace the original table. - - - ALTER TABLE as above, but which only modifies the frm file, it only - creates an frm file for the #sql-xxx, the table in the engine is not - created. - - - Assisted discovery, CREATE TABLE statement without the table structure. - - These situations are distinguished by the following "create table mode" - values, where a CREATE ... SELECT is denoted by any non-negative number - (which should be the number of fields in the SELECT ... part), and other - cases use constants as defined below. -*/ -#define C_ORDINARY_CREATE 0 -#define C_ALTER_TABLE 1 -#define C_ALTER_TABLE_FRM_ONLY 2 -#define C_ASSISTED_DISCOVERY 3 - int mysql_create_table_no_lock(THD *thd, - DDL_LOG_STATE *ddl_log_state, - DDL_LOG_STATE *ddl_log_state_rm, + const LEX_CSTRING *orig_db, + const LEX_CSTRING *orig_table_name, const LEX_CSTRING *db, const LEX_CSTRING *table_name, Table_specification_st *create_info, Alter_info *alter_info, bool *is_trans, - int create_table_mode, TABLE_LIST *table); + int create_table_mode, TABLE_LIST *table, + LEX_CUSTRING *frm= NULL); handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db, @@ -170,6 +138,31 @@ bool mysql_compare_tables(TABLE *table, HA_CREATE_INFO *create_info, bool *metadata_equal); bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy); +/** + Parameters for rename_table_and_triggers() +*/ +struct rename_param +{ + LEX_CSTRING old_alias, new_alias; + LEX_CUSTRING old_version; + handlerton *from_table_hton; + int rename_flags; /* FN_FROM_IS_TMP, FN_TO_IS_TMP, etc */ + rename_param() : + from_table_hton(NULL), + rename_flags(0) {} +}; +bool +rename_table_and_triggers(THD *thd, rename_param *param, + DDL_LOG_STATE *ddl_log_state, + Table_name *ren_table, const LEX_CSTRING *new_db, + bool skip_error, bool *force_if_exists); +int +rename_check_preconditions(THD *thd, rename_param *param, + Table_name *ren_table, + const LEX_CSTRING *new_db, + const LEX_CSTRING *new_table_name, + const LEX_CSTRING *new_table_alias, + bool if_exists); bool mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db, const LEX_CSTRING *old_name, const LEX_CSTRING *new_db, const LEX_CSTRING *new_name, LEX_CUSTRING *id, diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 77035219d2f2e..6fe0d5384a9f3 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1195,9 +1195,11 @@ bool Trigger::add_to_file_list(void* param_arg) */ static bool rm_trigger_file(char *path, const LEX_CSTRING *db, - const LEX_CSTRING *table_name, myf MyFlags) + const LEX_CSTRING *table_name, uint flags, + myf MyFlags) { - build_table_filename(path, FN_REFLEN-1, db->str, table_name->str, TRG_EXT, 0); + build_table_filename(path, FN_REFLEN - 1, db->str, table_name->str, TRG_EXT, + flags); return mysql_file_delete(key_file_trg, path, MyFlags); } @@ -1239,7 +1241,8 @@ bool rm_trigname_file(char *path, const LEX_CSTRING *db, */ bool Table_triggers_list::save_trigger_file(THD *thd, const LEX_CSTRING *db, - const LEX_CSTRING *table_name) + const LEX_CSTRING *table_name, + uint flags) { char file_buff[FN_REFLEN]; LEX_CSTRING file; @@ -1249,7 +1252,7 @@ bool Table_triggers_list::save_trigger_file(THD *thd, const LEX_CSTRING *db, DBUG_RETURN(true); file.length= build_table_filename(file_buff, FN_REFLEN - 1, db->str, table_name->str, - TRG_EXT, 0); + TRG_EXT, flags); file.str= file_buff; DBUG_RETURN(sql_create_definition_file(NULL, &file, &triggers_file_type, (uchar*) this, @@ -1359,12 +1362,12 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables, drop or create ddl_log recovery will ensure that all related trigger files are deleted or the original ones are restored. */ - if (rm_trigger_file(path, &tables->db, &tables->table_name, MYF(MY_WME))) + if (rm_trigger_file(path, &tables->db, &tables->table_name, 0, MYF(MY_WME))) goto err; } else { - if (save_trigger_file(thd, &tables->db, &tables->table_name)) + if (save_trigger_file(thd, &tables->db, &tables->table_name, 0)) goto err; } @@ -1523,7 +1526,8 @@ bool Table_triggers_list::prepare_record_accessors(TABLE *table) bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, TABLE *table, - bool names_only) + bool names_only, + uint flags) { char path_buff[FN_REFLEN]; LEX_CSTRING path; @@ -1532,7 +1536,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, DBUG_ENTER("Table_triggers_list::check_n_load"); path.length= build_table_filename(path_buff, FN_REFLEN - 1, - db->str, table_name->str, TRG_EXT, 0); + db->str, table_name->str, TRG_EXT, flags); path.str= path_buff; // QQ: should we analyze errno somehow ? @@ -2022,7 +2026,7 @@ bool add_table_for_trigger(THD *thd, bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *name, - myf MyFlags) + uint flags, myf MyFlags) { TABLE table; char path[FN_REFLEN]; @@ -2033,11 +2037,11 @@ bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db, init_sql_alloc(key_memory_Table_trigger_dispatcher, &table.mem_root, 8192, 0, MYF(MY_WME)); - if (Table_triggers_list::check_n_load(thd, db, name, &table, 1)) + if (Table_triggers_list::check_n_load(thd, db, name, &table, true, flags)) { result= 1; /* We couldn't parse trigger file, best to just remove it */ - rm_trigger_file(path, db, name, MyFlags); + rm_trigger_file(path, db, name, flags, MyFlags); goto end; } if (table.triggers) @@ -2071,7 +2075,7 @@ bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db, } } } - if (rm_trigger_file(path, db, name, MyFlags)) + if (rm_trigger_file(path, db, name, flags, MyFlags)) result= 1; delete table.triggers; } @@ -2113,7 +2117,8 @@ change_table_name_in_triggers(THD *thd, const LEX_CSTRING *old_db_name, const LEX_CSTRING *new_db_name, const LEX_CSTRING *old_table_name, - const LEX_CSTRING *new_table_name) + const LEX_CSTRING *new_table_name, + uint flags) { struct change_table_name_param param; sql_mode_t save_sql_mode= thd->variables.sql_mode; @@ -2129,13 +2134,15 @@ change_table_name_in_triggers(THD *thd, if (unlikely(thd->is_fatal_error)) return TRUE; /* OOM */ - if (save_trigger_file(thd, new_db_name, new_table_name)) + if (save_trigger_file(thd, new_db_name, new_table_name, + (flags & FN_TO_IS_TMP))) return TRUE; - if (rm_trigger_file(path_buff, old_db_name, old_table_name, MYF(MY_WME))) + if (rm_trigger_file(path_buff, old_db_name, old_table_name, + (flags & FN_FROM_IS_TMP), MYF(MY_WME))) { (void) rm_trigger_file(path_buff, new_db_name, new_table_name, - MYF(MY_WME)); + (flags & FN_TO_IS_TMP), MYF(MY_WME)); return TRUE; } return FALSE; @@ -2285,7 +2292,8 @@ Table_triggers_list::prepare_for_rename(THD *thd, my_strcasecmp(table_alias_charset, old_alias->str, new_table->str)); - if (Table_triggers_list::check_n_load(thd, db, old_table, table, TRUE)) + if (Table_triggers_list::check_n_load(thd, db, old_table, table, TRUE, + param->rename_flags)) { result= 1; goto end; @@ -2372,15 +2380,17 @@ bool Table_triggers_list::change_table_name(THD *thd, This method interfaces the mysql server code protected by an exclusive metadata lock. */ - DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db->str, + DBUG_ASSERT((param->rename_flags & FN_FROM_IS_TMP) || + thd->mdl_context.is_lock_owner(MDL_key::TABLE, db->str, old_table->str, MDL_EXCLUSIVE)); if (table->triggers) { - if (unlikely(table->triggers->change_table_name_in_triggers(thd, db, new_db, - old_alias, - new_table))) + if (unlikely(table->triggers-> + change_table_name_in_triggers(thd, db, new_db, old_alias, + new_table, + param->rename_flags))) { result= 1; goto end; @@ -2398,9 +2408,9 @@ bool Table_triggers_list::change_table_name(THD *thd, (void) table->triggers->change_table_name_in_trignames( upgrading50to51 ? new_db : NULL, db, old_alias, err_trigger); - (void) table->triggers->change_table_name_in_triggers( - thd, db, new_db, - new_table, old_alias); + (void) table->triggers-> + change_table_name_in_triggers(thd, db, new_db, new_table, old_alias, + (param->rename_flags ^ FN_IS_TMP)); result= 1; goto end; } diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 739669c86a575..e3782500421d4 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -3,7 +3,7 @@ /* Copyright (c) 2004, 2011, Oracle and/or its affiliates. - Copyright (c) 2017, MariaDB Corporation. + Copyright (c) 2017, 2022, 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 @@ -89,10 +89,12 @@ class TRIGGER_RENAME_PARAM TABLE table; bool upgrading50to51; bool got_error; + int rename_flags; TRIGGER_RENAME_PARAM() { upgrading50to51= got_error= 0; + rename_flags= 0; table.reset(); } ~TRIGGER_RENAME_PARAM() @@ -255,12 +257,14 @@ class Table_triggers_list: public Sql_alloc bool old_row_is_record1); void empty_lists(); bool create_lists_needed_for_files(MEM_ROOT *root); - bool save_trigger_file(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name); + bool save_trigger_file(THD *thd, const LEX_CSTRING *db, + const LEX_CSTRING *table_name, uint flags); static bool check_n_load(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, - TABLE *table, bool names_only); + TABLE *table, bool names_only, uint flags); static bool drop_all_triggers(THD *thd, const LEX_CSTRING *db, - const LEX_CSTRING *table_name, myf MyFlags); + const LEX_CSTRING *table_name, uint flags, + myf MyFlags); static bool prepare_for_rename(THD *thd, TRIGGER_RENAME_PARAM *param, const LEX_CSTRING *db, const LEX_CSTRING *old_alias, @@ -333,7 +337,8 @@ class Table_triggers_list: public Sql_alloc const LEX_CSTRING *old_db_name, const LEX_CSTRING *new_db_name, const LEX_CSTRING *old_table_name, - const LEX_CSTRING *new_table_name); + const LEX_CSTRING *new_table_name, + uint flags); bool check_for_broken_triggers() { diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index a0ef89ff0f5fc..283714bdd1b4e 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) 2012, 2018, MariaDB + Copyright (c) 2012, 2022, 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 @@ -116,18 +116,18 @@ static const char *fk_info_str(THD *thd, FOREIGN_KEY_INFO *fk_info) error was emitted. */ -static bool -fk_truncate_illegal_if_parent(THD *thd, TABLE *table) +bool +TABLE::referenced_by_foreign_table(THD *thd, FOREIGN_KEY_INFO **fk_info) const { - FOREIGN_KEY_INFO *fk_info; List fk_list; List_iterator_fast it; + *fk_info= NULL; /* Bail out early if the table is not referenced by a foreign key. In this case, the table could only be, if at all, a child table. */ - if (! table->file->referenced_by_foreign_key()) + if (! file->referenced_by_foreign_key()) return FALSE; /* @@ -136,7 +136,7 @@ fk_truncate_illegal_if_parent(THD *thd, TABLE *table) of foreign keys referencing this table in order to check the name of the child (dependent) tables. */ - table->file->get_parent_foreign_key_list(thd, &fk_list); + file->get_parent_foreign_key_list(thd, &fk_list); /* Out of memory when building list. */ if (unlikely(thd->is_error())) @@ -145,25 +145,22 @@ fk_truncate_illegal_if_parent(THD *thd, TABLE *table) it.init(fk_list); /* Loop over the set of foreign keys for which this table is a parent. */ - while ((fk_info= it++)) + while ((*fk_info= it++)) { - if (lex_string_cmp(system_charset_info, fk_info->referenced_db, - &table->s->db) || - lex_string_cmp(system_charset_info, fk_info->referenced_table, - &table->s->table_name) || - lex_string_cmp(system_charset_info, fk_info->foreign_db, - &table->s->db) || - lex_string_cmp(system_charset_info, fk_info->foreign_table, - &table->s->table_name)) + if (lex_string_cmp(system_charset_info, (*fk_info)->referenced_db, + &s->db) || + lex_string_cmp(system_charset_info, (*fk_info)->referenced_table, + &s->table_name) || + lex_string_cmp(system_charset_info, (*fk_info)->foreign_db, + &s->db) || + lex_string_cmp(system_charset_info, (*fk_info)->foreign_table, + &s->table_name)) break; } /* Table is parent in a non-self-referencing foreign key. */ - if (fk_info) - { - my_error(ER_TRUNCATE_ILLEGAL_FK, MYF(0), fk_info_str(thd, fk_info)); - return TRUE; - } + if (*fk_info) + return TRUE; /* tested by main.trigger-trans */ return FALSE; } @@ -193,6 +190,7 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref, int error= 0; uint flags= 0; TABLE *table; + FOREIGN_KEY_INFO *fk_info; DBUG_ENTER("Sql_cmd_truncate_table::handler_truncate"); /* @@ -233,8 +231,13 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref, /* Whether to truncate regardless of foreign keys. */ if (! (thd->variables.option_bits & OPTION_NO_FOREIGN_KEY_CHECKS)) - if (fk_truncate_illegal_if_parent(thd, table_ref->table)) + if (table_ref->table->referenced_by_foreign_table(thd, &fk_info)) + { + /* Table is parent in a non-self-referencing foreign key. */ + if (fk_info) + my_error(ER_TRUNCATE_ILLEGAL_FK, MYF(0), fk_info_str(thd, fk_info)); DBUG_RETURN(TRUNCATE_FAILED_SKIP_BINLOG); + } table= table_ref->table; diff --git a/sql/structs.h b/sql/structs.h index b36f8e6a1a01a..1c3873196da94 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -2,7 +2,7 @@ #define STRUCTS_INCLUDED /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2022, 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 @@ -1016,4 +1016,14 @@ class Timeval: public timeval }; +struct Table_name +{ + LEX_CSTRING db; + LEX_CSTRING table_name; + LEX_CSTRING alias; + bool is_set() const + { + return table_name.str; + } +}; #endif /* STRUCTS_INCLUDED */ diff --git a/sql/table.h b/sql/table.h index 02e8998adb9e6..b8087bd056d01 100644 --- a/sql/table.h +++ b/sql/table.h @@ -35,6 +35,7 @@ #include "sql_i_s.h" #include "sql_type.h" /* vers_kind_t */ #include "privilege.h" /* privilege_t */ +#include "structs.h" /* Structs that defines the TABLE */ @@ -76,6 +77,7 @@ typedef ulonglong nested_join_map; #define tmp_file_prefix "#sql" /**< Prefix for tmp tables */ #define tmp_file_prefix_length 4 +#define backup_file_prefix tmp_file_prefix "-backup-" #define TMP_TABLE_KEY_EXTRA 8 /** @@ -336,6 +338,7 @@ typedef struct st_grant_info enum tmp_table_type { + TMP_TABLE_ATOMIC_REPLACE= -1, NO_TMP_TABLE= 0, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE, INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE }; @@ -706,14 +709,6 @@ class TABLE_STATISTICS_CB }; -struct Table_name -{ - LEX_CSTRING db; - LEX_CSTRING table_name; - LEX_CSTRING alias; -}; - - /** This structure is shared between different table objects. There is one instance of table share per one table in the database. @@ -1834,6 +1829,7 @@ struct TABLE /* Used in DELETE, DUP REPLACE and insert history row */ void vers_update_end(); void find_constraint_correlated_indexes(); + bool referenced_by_foreign_table(THD *thd, FOREIGN_KEY_INFO **fk_info) const; /** Number of additional fields used in versioned tables */ #define VERSIONING_FIELDS 2 diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 8c2d720f62e9f..98490ded18ff3 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -3297,66 +3297,18 @@ foreign constraint parser to get the referenced table. heap memory passed in */ char* dict_get_referenced_table( - const char* name, /*!< in: foreign key table name */ - const char* database_name, /*!< in: table db name */ - ulint database_name_len, /*!< in: db name length */ - const char* table_name, /*!< in: table name */ - ulint table_name_len, /*!< in: table name length */ - dict_table_t** table, /*!< out: table object or NULL */ - mem_heap_t* heap, /*!< in/out: heap memory */ - CHARSET_INFO* from_cs) /*!< in: table name charset */ + LEX_CSTRING database_name, /*!< in: table db name */ + LEX_CSTRING table_name, /*!< in: table name */ + dict_table_t** table, /*!< out: table object or NULL */ + mem_heap_t* heap) /*!< in/out: heap memory */ { - char* ref; - char db_name[MAX_DATABASE_NAME_LEN]; - char tbl_name[MAX_TABLE_NAME_LEN]; - CHARSET_INFO* to_cs = &my_charset_filename; - uint errors; - ut_ad(database_name || name); - ut_ad(table_name); - - if (!strncmp(table_name, srv_mysql50_table_name_prefix, - sizeof(srv_mysql50_table_name_prefix) - 1)) { - /* This is a pre-5.1 table name - containing chars other than [A-Za-z0-9]. - Discard the prefix and use raw UTF-8 encoding. */ - table_name += sizeof(srv_mysql50_table_name_prefix) - 1; - table_name_len -= sizeof(srv_mysql50_table_name_prefix) - 1; - - to_cs = system_charset_info; - } - - table_name_len = strconvert(from_cs, table_name, table_name_len, to_cs, - tbl_name, MAX_TABLE_NAME_LEN, &errors); - table_name = tbl_name; - - if (database_name) { - to_cs = &my_charset_filename; - if (!strncmp(database_name, srv_mysql50_table_name_prefix, - sizeof(srv_mysql50_table_name_prefix) - 1)) { - database_name - += sizeof(srv_mysql50_table_name_prefix) - 1; - database_name_len - -= sizeof(srv_mysql50_table_name_prefix) - 1; - to_cs = system_charset_info; - } - - database_name_len = strconvert( - from_cs, database_name, database_name_len, to_cs, - db_name, MAX_DATABASE_NAME_LEN, &errors); - database_name = db_name; - } else { - /* Use the database name of the foreign key table */ - - database_name = name; - database_name_len = dict_get_db_name_len(name); - } - /* Copy database_name, '/', table_name, '\0' */ - const size_t len = database_name_len + table_name_len + 1; - ref = static_cast(mem_heap_alloc(heap, len + 1)); - memcpy(ref, database_name, database_name_len); - ref[database_name_len] = '/'; - memcpy(ref + database_name_len + 1, table_name, table_name_len + 1); + const size_t len = database_name.length + table_name.length + 1; + char* ref = static_cast(mem_heap_alloc(heap, len + 1)); + memcpy(ref, database_name.str, database_name.length); + ref[database_name.length] = '/'; + memcpy(ref + database_name.length + 1, table_name.str, + table_name.length + 1); /* Values; 0 = Store and compare as given; case sensitive 1 = Store and compare in lower; case insensitive @@ -3364,10 +3316,10 @@ dict_get_referenced_table( if (lower_case_table_names == 2) { innobase_casedn_str(ref); *table = dict_sys.load_table({ref, len}); - memcpy(ref, database_name, database_name_len); - ref[database_name_len] = '/'; - memcpy(ref + database_name_len + 1, table_name, table_name_len + 1); - + memcpy(ref, database_name.str, database_name.length); + ref[database_name.length] = '/'; + memcpy(ref + database_name.length + 1, + table_name.str, table_name.length + 1); } else { #ifndef _WIN32 if (lower_case_table_names == 1) { diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 3cb487657913a..2aa92371c2d2f 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1359,7 +1359,7 @@ static dberr_t fts_drop_table(trx_t *trx, const char *table_name, bool rename) char *tmp= dict_mem_create_temporary_tablename(heap, table->name.m_name, table->id); dberr_t err= row_rename_table_for_mysql(table->name.m_name, tmp, trx, - false); + RENAME_IGNORE_FK); mem_heap_free(heap); if (err != DB_SUCCESS) { @@ -1410,7 +1410,7 @@ fts_rename_one_aux_table( fts_table_new_name[table_new_name_len] = 0; return row_rename_table_for_mysql( - fts_table_old_name, fts_table_new_name, trx, false); + fts_table_old_name, fts_table_new_name, trx, RENAME_IGNORE_FK); } /****************************************************************//** diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index ee63d4950d825..3d798ca2e00b5 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -12202,6 +12202,8 @@ create_table_info_t::create_foreign_keys() const char* ref_column_names[MAX_COLS_PER_FK]; char create_name[MAX_DATABASE_NAME_LEN + 1 + MAX_TABLE_NAME_LEN + 1]; + char db_name[MAX_DATABASE_NAME_LEN + 1]; + char t_name[MAX_TABLE_NAME_LEN + 1]; dict_index_t* index = NULL; fkerr_t index_error = FK_SUCCESS; dict_index_t* err_index = NULL; @@ -12209,18 +12211,50 @@ create_table_info_t::create_foreign_keys() const bool tmp_table = m_flags2 & DICT_TF2_TEMPORARY; const CHARSET_INFO* cs = thd_charset(m_thd); const char* operation = "Create "; - const char* name = m_table_name; + const char* basename; enum_sql_command sqlcom = enum_sql_command(thd_sql_command(m_thd)); + LEX_CSTRING name= {m_table_name, strlen(m_table_name)}; if (sqlcom == SQLCOM_ALTER_TABLE) { - dict_table_t* table_to_alter; - mem_heap_t* heap = mem_heap_create(10000); - ulint highest_id_so_far; - char* n = dict_get_referenced_table( - name, LEX_STRING_WITH_LEN(m_form->s->db), - LEX_STRING_WITH_LEN(m_form->s->table_name), - &table_to_alter, heap, cs); + dict_table_t* alter_table; + mem_heap_t* heap = mem_heap_create(10000); + DBUG_ASSERT(!m_create_info->is_atomic_replace()); + LEX_CSTRING table_name = m_form->s->table_name; + CHARSET_INFO* to_cs = &my_charset_filename; + + if (!strncmp(table_name.str, srv_mysql50_table_name_prefix, + sizeof srv_mysql50_table_name_prefix - 1)) { + table_name.str + += sizeof srv_mysql50_table_name_prefix - 1; + table_name.length + -= sizeof srv_mysql50_table_name_prefix - 1; + to_cs = system_charset_info; + } + + uint errors; + LEX_CSTRING t; + t.str = t_name; + t.length = strconvert(cs, LEX_STRING_WITH_LEN(table_name), + to_cs, t_name, MAX_TABLE_NAME_LEN, + &errors); + LEX_CSTRING d = m_form->s->db; + + if (!strncmp(d.str, srv_mysql50_table_name_prefix, + sizeof srv_mysql50_table_name_prefix - 1)) { + d.str += sizeof srv_mysql50_table_name_prefix - 1; + d.length -= sizeof srv_mysql50_table_name_prefix - 1; + to_cs = system_charset_info; + } else { + to_cs = &my_charset_filename; + } + + d.length = strconvert(cs, LEX_STRING_WITH_LEN(d), to_cs, + db_name, MAX_DATABASE_NAME_LEN, + &errors); + d.str = db_name; + + char* n = dict_get_referenced_table(d, t, &alter_table, heap); /* Starting from 4.0.18 and 4.1.2, we generate foreign key id's in the format databasename/tablename_ibfk_[number], where @@ -12230,38 +12264,33 @@ create_table_info_t::create_foreign_keys() /* If we are altering a temporary table, the table name after ALTER TABLE does not correspond to the internal table name, and - table_to_alter is NULL. TODO: should we fix this somehow? */ + alter_table=nullptr. But, we do not support FOREIGN KEY + constraints for temporary tables. */ - if (table_to_alter) { - n = table_to_alter->name.m_name; - highest_id_so_far = dict_table_get_highest_foreign_id( - table_to_alter); - } else { - highest_id_so_far = 0; + if (alter_table) { + n = alter_table->name.m_name; + number = 1 + dict_table_get_highest_foreign_id( + alter_table); } - char* bufend = innobase_convert_name( - create_name, sizeof create_name, n, strlen(n), m_thd); - create_name[bufend - create_name] = '\0'; - number = highest_id_so_far + 1; + *innobase_convert_name(create_name, sizeof create_name, + n, strlen(n), m_thd) = '\0'; mem_heap_free(heap); operation = "Alter "; - } else if (strstr(name, "#P#") || strstr(name, "#p#")) { + } else if (strstr(m_table_name, "#P#") + || strstr(m_table_name, "#p#")) { /* Partitioned table */ create_name[0] = '\0'; } else { - char* bufend = innobase_convert_name(create_name, - sizeof create_name, - name, - strlen(name), m_thd); - create_name[bufend - create_name] = '\0'; + *innobase_convert_name(create_name, sizeof create_name, + LEX_STRING_WITH_LEN(name), m_thd)= '\0'; } Alter_info* alter_info = m_create_info->alter_info; ut_ad(alter_info); List_iterator_fast key_it(alter_info->key_list); - dict_table_t* table = dict_sys.find_table({name,strlen(name)}); + dict_table_t* table = dict_sys.find_table({name.str, name.length}); if (!table) { ib_foreign_warn(m_trx, DB_CANNOT_ADD_CONSTRAINT, create_name, "%s table %s foreign key constraint" @@ -12271,6 +12300,8 @@ create_table_info_t::create_foreign_keys() return (DB_CANNOT_ADD_CONSTRAINT); } + basename = table->name.basename(); + while (Key* key = key_it++) { if (key->type != Key::FOREIGN_KEY) continue; @@ -12308,27 +12339,27 @@ create_table_info_t::create_foreign_keys() col->field_name.length); success = find_col(table, column_names + i); if (!success) { - key_text k(fk); ib_foreign_warn( m_trx, DB_CANNOT_ADD_CONSTRAINT, create_name, "%s table %s foreign key %s constraint" " failed. Column %s was not found.", - operation, create_name, k.str(), + operation, create_name, + key_text(fk).str(), column_names[i]); dict_foreign_free(foreign); return (DB_CANNOT_ADD_CONSTRAINT); } ++i; if (i >= MAX_COLS_PER_FK) { - key_text k(fk); ib_foreign_warn( m_trx, DB_CANNOT_ADD_CONSTRAINT, create_name, "%s table %s foreign key %s constraint" " failed. Too many columns: %u (%u " "allowed).", - operation, create_name, k.str(), i, + operation, create_name, + key_text(fk).str(), i, MAX_COLS_PER_FK); dict_foreign_free(foreign); return (DB_CANNOT_ADD_CONSTRAINT); @@ -12340,9 +12371,9 @@ create_table_info_t::create_foreign_keys() &index_error, &err_col, &err_index); if (!index) { - key_text k(fk); foreign_push_index_error(m_trx, operation, create_name, - k.str(), column_names, + key_text(fk).str(), + column_names, index_error, err_col, err_index, table); dict_foreign_free(foreign); @@ -12408,32 +12439,79 @@ create_table_info_t::create_foreign_keys() memcpy(foreign->foreign_col_names, column_names, i * sizeof(void*)); - foreign->referenced_table_name = dict_get_referenced_table( - name, LEX_STRING_WITH_LEN(fk->ref_db), - LEX_STRING_WITH_LEN(fk->ref_table), - &foreign->referenced_table, foreign->heap, cs); + LEX_CSTRING table_name = fk->ref_table; + CHARSET_INFO* to_cs = &my_charset_filename; + uint errors; + LEX_CSTRING t = table_name; + LEX_CSTRING d = fk->ref_db; + + if (!d.str) { + d.str = table->name.m_name; + d.length = size_t(basename - table->name.m_name - 1); + } + + if (m_create_info->is_atomic_replace() + && basename == &table->name.m_name[d.length + 1] + && !memcmp(d.str, table->name.m_name, d.length) + && !strcmp(basename, table_name.str)) { + /* Do not convert names when encountering + self-referential constraints during + CREATE OR REPLACE TABLE. */ + goto name_converted; + } + + if (!strncmp(table_name.str, srv_mysql50_table_name_prefix, + sizeof srv_mysql50_table_name_prefix - 1)) { + table_name.str + += sizeof srv_mysql50_table_name_prefix - 1; + table_name.length + -= sizeof srv_mysql50_table_name_prefix - 1; + to_cs = system_charset_info; + } + + t.str = t_name; + t.length = strconvert(cs, LEX_STRING_WITH_LEN(table_name), + to_cs, t_name, + MAX_TABLE_NAME_LEN, &errors); + + if (!strncmp(d.str, srv_mysql50_table_name_prefix, + sizeof srv_mysql50_table_name_prefix - 1)) { + d.str += sizeof srv_mysql50_table_name_prefix - 1; + d.length -= sizeof srv_mysql50_table_name_prefix - 1; + to_cs = system_charset_info; + } else if (d.str == table->name.m_name) { + goto name_converted; + } else { + to_cs = &my_charset_filename; + } - if (!foreign->referenced_table_name) { - return (DB_OUT_OF_MEMORY); + if (d.str != table->name.m_name) { + d.length = strconvert(cs, LEX_STRING_WITH_LEN(d), + to_cs, db_name, + MAX_DATABASE_NAME_LEN, + &errors); + d.str = db_name; } +name_converted: + foreign->referenced_table_name = dict_get_referenced_table( + d, t, &foreign->referenced_table, foreign->heap); if (!foreign->referenced_table && m_trx->check_foreigns) { char buf[MAX_TABLE_NAME_LEN + 1] = ""; - char* bufend; - bufend = innobase_convert_name( + *innobase_convert_name( buf, MAX_TABLE_NAME_LEN, foreign->referenced_table_name, - strlen(foreign->referenced_table_name), m_thd); - buf[bufend - buf] = '\0'; - key_text k(fk); + strlen(foreign->referenced_table_name), m_thd) + = '\0'; ib_foreign_warn(m_trx, DB_CANNOT_ADD_CONSTRAINT, create_name, "%s table %s with foreign key %s " "constraint failed. Referenced table " "%s not found in the data dictionary.", - operation, create_name, k.str(), buf); - return (DB_CANNOT_ADD_CONSTRAINT); + operation, create_name, + key_text(fk).str(), buf); + return DB_CANNOT_ADD_CONSTRAINT; } /* Don't allow foreign keys on partitioned tables yet. */ @@ -12456,7 +12534,6 @@ create_table_info_t::create_foreign_keys() success = find_col(foreign->referenced_table, ref_column_names + j); if (!success) { - key_text k(fk); ib_foreign_warn( m_trx, DB_CANNOT_ADD_CONSTRAINT, @@ -12465,9 +12542,9 @@ create_table_info_t::create_foreign_keys() "constraint failed. " "Column %s was not found.", operation, create_name, - k.str(), ref_column_names[j]); - - return (DB_CANNOT_ADD_CONSTRAINT); + key_text(fk).str(), + ref_column_names[j]); + return DB_CANNOT_ADD_CONSTRAINT; } } ++j; @@ -12487,16 +12564,15 @@ create_table_info_t::create_foreign_keys() &err_index); if (!index) { - key_text k(fk); foreign_push_index_error( - m_trx, operation, create_name, k.str(), + m_trx, operation, create_name, + key_text(fk).str(), column_names, index_error, err_col, err_index, foreign->referenced_table); - - return (DB_CANNOT_ADD_CONSTRAINT); + return DB_CANNOT_ADD_CONSTRAINT; } } else { - ut_a(m_trx->check_foreigns == FALSE); + ut_a(!m_trx->check_foreigns); index = NULL; } @@ -12533,7 +12609,6 @@ create_table_info_t::create_foreign_keys() NULL if the column is not allowed to be NULL! */ - key_text k(fk); ib_foreign_warn( m_trx, DB_CANNOT_ADD_CONSTRAINT, @@ -12544,9 +12619,9 @@ create_table_info_t::create_foreign_keys() "but column '%s' is defined as " "NOT NULL.", operation, create_name, - k.str(), col_name); + key_text(fk).str(), col_name); - return (DB_CANNOT_ADD_CONSTRAINT); + return DB_CANNOT_ADD_CONSTRAINT; } } } @@ -13687,10 +13762,10 @@ int ha_innobase::delete_table(const char *name) @param[in,out] trx InnoDB data dictionary transaction @param[in] from old table name @param[in] to new table name -@param[in] use_fk whether to enforce FOREIGN KEY +@param[in] fk how to handle FOREIGN KEY @return DB_SUCCESS or error code */ static dberr_t innobase_rename_table(trx_t *trx, const char *from, - const char *to, bool use_fk) + const char *to, rename_fk fk) { dberr_t error; char norm_to[FN_REFLEN]; @@ -13708,7 +13783,7 @@ static dberr_t innobase_rename_table(trx_t *trx, const char *from, ut_ad(trx->will_lock); - error = row_rename_table_for_mysql(norm_from, norm_to, trx, use_fk); + error = row_rename_table_for_mysql(norm_from, norm_to, trx, fk); if (error != DB_SUCCESS) { if (error == DB_TABLE_NOT_FOUND @@ -13733,7 +13808,8 @@ static dberr_t innobase_rename_table(trx_t *trx, const char *from, #endif /* _WIN32 */ trx_start_if_not_started(trx, true); error = row_rename_table_for_mysql( - par_case_name, norm_to, trx, false); + par_case_name, norm_to, trx, + RENAME_IGNORE_FK); } } @@ -13914,7 +13990,7 @@ int ha_innobase::truncate() if (error == DB_SUCCESS) { error = innobase_rename_table(trx, ib_table->name.m_name, - temp_name, false); + temp_name, RENAME_REBUILD); if (error == DB_SUCCESS) { error = trx->drop_table(*ib_table); @@ -14107,7 +14183,11 @@ ha_innobase::rename_table( row_mysql_lock_data_dictionary(trx); if (error == DB_SUCCESS) { - error = innobase_rename_table(trx, from, to, true); + error = innobase_rename_table(trx, from, to, + thd_sql_command(thd) + == SQLCOM_ALTER_TABLE + ? RENAME_ALTER_COPY + : RENAME_FK); } DEBUG_SYNC(thd, "after_innobase_rename_table"); diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 0babd37251e34..1d23a52fa1caa 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -30,6 +30,7 @@ Smart ALTER TABLE #include #include #include +#include /* Include necessary InnoDB headers */ #include "btr0sea.h" @@ -3186,6 +3187,8 @@ innobase_get_foreign_key_info( ulint num_fk = 0; Alter_info* alter_info = ha_alter_info->alter_info; const CHARSET_INFO* cs = thd_charset(trx->mysql_thd); + char db_name[MAX_DATABASE_NAME_LEN + 1]; + char t_name[MAX_TABLE_NAME_LEN + 1]; DBUG_ENTER("innobase_get_foreign_key_info"); @@ -3250,14 +3253,51 @@ innobase_get_foreign_key_info( add_fk[num_fk] = dict_mem_foreign_create(); + LEX_CSTRING table_name = fk_key->ref_table; + CHARSET_INFO* to_cs = &my_charset_filename; + + if (!strncmp(table_name.str, srv_mysql50_table_name_prefix, + sizeof srv_mysql50_table_name_prefix - 1)) { + table_name.str + += sizeof srv_mysql50_table_name_prefix - 1; + table_name.length + -= sizeof srv_mysql50_table_name_prefix - 1; + to_cs = system_charset_info; + } + + uint errors; + LEX_CSTRING t; + t.str = t_name; + t.length = strconvert(cs, LEX_STRING_WITH_LEN(table_name), + to_cs, t_name, MAX_TABLE_NAME_LEN, + &errors); + LEX_CSTRING d = fk_key->ref_db; + if (!d.str) { + d.str = table->name.m_name; + d.length = table->name.dblen(); + } + + if (!strncmp(d.str, srv_mysql50_table_name_prefix, + sizeof srv_mysql50_table_name_prefix - 1)) { + d.str += sizeof srv_mysql50_table_name_prefix - 1; + d.length -= sizeof srv_mysql50_table_name_prefix - 1; + to_cs = system_charset_info; + } else if (d.str == table->name.m_name) { + goto name_converted; + } else { + to_cs = &my_charset_filename; + } + + d.length = strconvert(cs, LEX_STRING_WITH_LEN(d), to_cs, + db_name, MAX_DATABASE_NAME_LEN, + &errors); + d.str = db_name; + +name_converted: dict_sys.lock(SRW_LOCK_CALL); referenced_table_name = dict_get_referenced_table( - table->name.m_name, - LEX_STRING_WITH_LEN(fk_key->ref_db), - LEX_STRING_WITH_LEN(fk_key->ref_table), - &referenced_table, - add_fk[num_fk]->heap, cs); + d, t, &referenced_table, add_fk[num_fk]->heap); /* Test the case when referenced_table failed to open, if trx->check_foreigns is not set, we should @@ -10168,10 +10208,12 @@ commit_try_rebuild( char* old_name= mem_heap_strdup(ctx->heap, user_table->name.m_name); dberr_t error = row_rename_table_for_mysql(user_table->name.m_name, - ctx->tmp_name, trx, false); + ctx->tmp_name, trx, + RENAME_REBUILD); if (error == DB_SUCCESS) { error = row_rename_table_for_mysql( - rebuilt_table->name.m_name, old_name, trx, false); + rebuilt_table->name.m_name, old_name, trx, + RENAME_REBUILD); if (error == DB_SUCCESS) { /* The statistics for the surviving indexes will be re-inserted in alter_stats_rebuild(). */ diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index d867d2f297a7c..fef0e4f9857d9 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -61,15 +61,11 @@ foreign constraint parser to get the referenced table. heap memory passed in */ char* dict_get_referenced_table( -/*======================*/ - const char* name, /*!< in: foreign key table name */ - const char* database_name, /*!< in: table db name */ - ulint database_name_len,/*!< in: db name length */ - const char* table_name, /*!< in: table name */ - ulint table_name_len, /*!< in: table name length */ + LEX_CSTRING database_name, /*!< in: table db name */ + LEX_CSTRING table_name, /*!< in: table name */ dict_table_t** table, /*!< out: table object or NULL */ - mem_heap_t* heap, /*!< in: heap memory */ - CHARSET_INFO* from_cs); /*!< in: table name charset */ + mem_heap_t* heap) /*!< in/out: heap memory */ + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Frees a foreign key struct. */ void diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index c4a94a9b5ef01..e74bdb09db90a 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2021, MariaDB Corporation. +Copyright (c) 2017, 2022, 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 @@ -369,6 +369,17 @@ row_import_tablespace_for_mysql( row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in MySQL */ MY_ATTRIBUTE((nonnull, warn_unused_result)); +enum rename_fk { + /** ignore FOREIGN KEY constraints */ + RENAME_IGNORE_FK= 0, + /** parse and enforce FOREIGN KEY constaints */ + RENAME_FK, + /** Rename a table as part of a native table-rebuilding DDL operation */ + RENAME_REBUILD, + /** Rename as part of ALTER TABLE...ALGORITHM=COPY */ + RENAME_ALTER_COPY +}; + /*********************************************************************//** Renames a table for MySQL. @return error code or DB_SUCCESS */ @@ -378,7 +389,7 @@ row_rename_table_for_mysql( const char* old_name, /*!< in: old table name */ const char* new_name, /*!< in: new table name */ trx_t* trx, /*!< in/out: transaction */ - bool use_fk) /*!< in: whether to parse and enforce + rename_fk fk) /*!< in: how to handle FOREIGN KEY constraints */ MY_ATTRIBUTE((nonnull, warn_unused_result)); diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 483e10b628336..b20d0cddf5bb4 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -2549,7 +2549,7 @@ row_rename_table_for_mysql( const char* old_name, /*!< in: old table name */ const char* new_name, /*!< in: new table name */ trx_t* trx, /*!< in/out: transaction */ - bool use_fk) /*!< in: whether to parse and enforce + rename_fk fk) /*!< in: how to handle FOREIGN KEY constraints */ { dict_table_t* table = NULL; @@ -2634,9 +2634,9 @@ row_rename_table_for_mysql( goto funct_exit; - } else if (use_fk && !old_is_tmp && new_is_tmp) { - /* MySQL is doing an ALTER TABLE command and it renames the - original table to a temporary table name. We want to preserve + } else if (fk == RENAME_ALTER_COPY && !old_is_tmp && new_is_tmp) { + /* Non-native ALTER TABLE is renaming the + original table to a temporary name. We want to preserve the original foreign key constraint definitions despite the name change. An exception is those constraints for which the ALTER TABLE contained DROP FOREIGN KEY .*/ @@ -2680,7 +2680,7 @@ row_rename_table_for_mysql( goto rollback_and_exit; } - if (!new_is_tmp) { + if (fk == RENAME_IGNORE_FK || fk == RENAME_FK || !new_is_tmp) { /* Rename all constraints. */ char new_table_name[MAX_TABLE_NAME_LEN + 1]; char old_table_utf8[MAX_TABLE_NAME_LEN + 1]; @@ -2854,7 +2854,7 @@ row_rename_table_for_mysql( err = dict_load_foreigns( new_name, nullptr, trx->id, !old_is_tmp || trx->check_foreigns, - use_fk + fk == RENAME_FK || fk == RENAME_ALTER_COPY ? DICT_ERR_IGNORE_NONE : DICT_ERR_IGNORE_FK_NOKEY, fk_tables); diff --git a/storage/maria/ha_s3.cc b/storage/maria/ha_s3.cc index c00f42d74c1fa..f432c15820485 100644 --- a/storage/maria/ha_s3.cc +++ b/storage/maria/ha_s3.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2019, 2021 MariaDB Corporation Ab +/* Copyright (C) 2019, 2022, 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 @@ -1031,7 +1031,8 @@ static int ha_s3_init(void *p) s3_hton->show_status= 0; s3_hton->prepare_for_backup= 0; s3_hton->end_backup= 0; - s3_hton->flags= ((s3_slave_ignore_updates ? HTON_IGNORE_UPDATES : 0) | + s3_hton->flags= HTON_EXPENSIVE_RENAME | + ((s3_slave_ignore_updates ? HTON_IGNORE_UPDATES : 0) | (s3_replicate_alter_as_create_select ? HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE : 0)); /* Copy global arguments to s3_access_key and s3_secret_key */ diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index f66b6ae61868c..71b2561360a51 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -2881,7 +2881,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info, if (param->testflag & T_SAFE_REPAIR) { - /* Don't repair if we loosed more than one row */ + /* Don't repair if we lost more than one row */ if (sort_info.new_info->s->state.state.records+1 < start_records) { share->state.state.records= start_records; From 34398a20b5829f0508c78bc8f765f7bef6e0ad48 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:05 +0300 Subject: [PATCH 015/113] MDEV-25292 backup_log improved Separate backup_log_print per each test case group. --- mysql-test/main/backup_log.inc | 26 ++- mysql-test/main/backup_log.result | 192 ++++++++++++------- mysql-test/main/backup_log.test | 3 + mysql-test/suite/parts/r/backup_log.result | 212 ++++++++++++--------- 4 files changed, 270 insertions(+), 163 deletions(-) diff --git a/mysql-test/main/backup_log.inc b/mysql-test/main/backup_log.inc index f553a3b952743..4ad6b9122cd23 100644 --- a/mysql-test/main/backup_log.inc +++ b/mysql-test/main/backup_log.inc @@ -7,7 +7,7 @@ # non-partitioned testing --echo # ---echo # Testing with normal tables +--echo # Testing normal tables --echo # eval create table t1 (a int) engine=myisam $part_int; @@ -20,6 +20,8 @@ repair table t1; optimize table t1; drop table t1; +--source backup_log_print.inc + eval create table t1_innodb (a int) engine=innodb $part_int; insert into t1_innodb values (1),(2); alter table t1_innodb add column b int; @@ -30,6 +32,8 @@ repair table t1_innodb; optimize table t1_innodb; drop table t1_innodb; +--source backup_log_print.inc + --echo # --echo # Testing with temporary tables (should not be logged) --echo # @@ -41,6 +45,8 @@ rename table tmp_t11 to tmp_t10; truncate table tmp_t10; drop table tmp_t10; +--source backup_log_print.inc + --echo # --echo # Testing with mix of normal and temporary tables --echo # @@ -54,6 +60,8 @@ eval create table t21 (a int) $part_int; drop temporary table if exists tmp_t21,t21; drop table if exists tmp_t21,t21; +--source backup_log_print.inc + --echo # --echo # Testing create select --echo # @@ -68,6 +76,8 @@ eval create or replace table t31 (a int primary key) $part_int select * from t30 eval create table t32 (a int) $part_int; drop table if exists t30,t31,t32,tmp_t30; +--source backup_log_print.inc + --echo # --echo # Testing create LIKE --echo # @@ -81,6 +91,8 @@ create or replace table t42 like t41; show create table t42; drop table t40, t41, t42; +--source backup_log_print.inc + --echo # --echo # Testing rename --echo # @@ -91,6 +103,8 @@ rename table t50 to t52, t51 to t53; rename table t52 to tmp, t53 to t52, tmp to t53; drop table t52,t53; +--source backup_log_print.inc + --echo # --echo # Testing enable/disable keys --echo # @@ -107,6 +121,8 @@ INSERT INTO t61 VALUES(1),(2),(3); ALTER TABLE t61 DISABLE KEYS; DROP TABLE t61; +--source backup_log_print.inc + --echo # --echo # Testing load data --echo # @@ -128,6 +144,8 @@ insert into t71 select * from t70; unlock tables; drop table t70,t71; +--source backup_log_print.inc + --echo # --echo # Testing strange table names --echo # @@ -135,6 +153,8 @@ drop table t70,t71; eval create table `t 1` (a int) $part_int; drop table `t 1`; +--source backup_log_print.inc + --echo # --echo # Testing views and triggers --echo # @@ -146,6 +166,8 @@ drop trigger trg; drop view v1; drop table t80; +--source backup_log_print.inc + --echo # --echo # Testing alter to a new storage engine --echo # @@ -153,3 +175,5 @@ drop table t80; eval create table t85 (a int primary key, b int) engine=myisam $part_int; alter table t85 engine=innodb; drop table t85; + +--source backup_log_print.inc diff --git a/mysql-test/main/backup_log.result b/mysql-test/main/backup_log.result index 6338425990c46..ce4db48a4f010 100644 --- a/mysql-test/main/backup_log.result +++ b/mysql-test/main/backup_log.result @@ -4,7 +4,7 @@ connect con1,localhost,root,,; BACKUP STAGE START; connection default; # -# Testing with normal tables +# Testing normal tables # create table t1 (a int) engine=myisam ; insert into t1 values (1),(2); @@ -19,6 +19,16 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK drop table t1; +# +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t1,id: 1,,0,,, +ALTER,MyISAM,0,test,t1,id: 1,MyISAM,0,test,t1,id: 2 +RENAME,MyISAM,0,test,t1,id: 2,MyISAM,0,test,t2,id: 2 +RENAME,MyISAM,0,test,t2,id: 2,MyISAM,0,test,t1,id: 2 +repair,MyISAM,0,test,t1,id: 2,,0,,, +optimize,MyISAM,0,test,t1,id: 2,,0,,, +DROP,MyISAM,0,test,t1,id: 2,,0,,, create table t1_innodb (a int) engine=innodb ; insert into t1_innodb values (1),(2); alter table t1_innodb add column b int; @@ -34,6 +44,17 @@ test.t1_innodb optimize note Table does not support optimize, doing recreate + a test.t1_innodb optimize status OK drop table t1_innodb; # +# Reading backup ddl log file +# +CREATE,InnoDB,0,test,t1_innodb,id: 1,,0,,, +ALTER,InnoDB,0,test,t1_innodb,id: 1,InnoDB,0,test,t1_innodb,id: 2 +RENAME,InnoDB,0,test,t1_innodb,id: 2,InnoDB,0,test,t2_innodb,id: 2 +RENAME,InnoDB,0,test,t2_innodb,id: 2,InnoDB,0,test,t1_innodb,id: 2 +TRUNCATE,InnoDB,0,test,t1_innodb,id: 2,,0,,, +repair,InnoDB,0,test,t1_innodb,id: 2,,0,,, +ALTER,InnoDB,0,test,t1_innodb,id: 2,InnoDB,0,test,t1_innodb,id: 3 +DROP,InnoDB,0,test,t1_innodb,id: 3,,0,,, +# # Testing with temporary tables (should not be logged) # create temporary table tmp_t10 (a int) engine=myisam; @@ -43,6 +64,9 @@ rename table tmp_t11 to tmp_t10; truncate table tmp_t10; drop table tmp_t10; # +# Reading backup ddl log file +# +# # Testing with mix of normal and temporary tables # create temporary table tmp_t20 (a int); @@ -57,6 +81,13 @@ drop table if exists tmp_t21,t21; Warnings: Note 1051 Unknown table 'test.tmp_t21' # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t20,id: 1,,0,,, +DROP,MyISAM,0,test,t20,id: 1,,0,,, +CREATE,MyISAM,0,test,t21,id: 2,,0,,, +DROP,MyISAM,0,test,t21,id: 2,,0,,, +# # Testing create select # create table t30 (a int) ; @@ -71,6 +102,17 @@ drop table if exists t30,t31,t32,tmp_t30; Warnings: Note 1051 Unknown table 'test.tmp_t30' # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t30,id: 1,,0,,, +CREATE,MyISAM,0,test,t31,id: 2,,0,,, +DROP,MyISAM,0,test,t31,id: 2,,0,,, +CREATE,MyISAM,0,test,t31,id: 3,,0,,, +CREATE,MyISAM,0,test,t32,id: 4,,0,,, +DROP,MyISAM,0,test,t30,id: 1,,0,,, +DROP,MyISAM,0,test,t31,id: 3,,0,,, +DROP,MyISAM,0,test,t32,id: 4,,0,,, +# # Testing create LIKE # create table t40 (a int) engine=myisam ; @@ -86,6 +128,17 @@ t42 CREATE TABLE `t42` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t40, t41, t42; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t40,id: 1,,0,,, +CREATE,InnoDB,0,test,t41,id: 2,,0,,, +CREATE,MyISAM,0,test,t42,id: 3,,0,,, +DROP,MyISAM,0,test,t42,id: 3,,0,,, +CREATE,InnoDB,0,test,t42,id: 4,,0,,, +DROP,MyISAM,0,test,t40,id: 1,,0,,, +DROP,InnoDB,0,test,t41,id: 2,,0,,, +DROP,InnoDB,0,test,t42,id: 4,,0,,, +# # Testing rename # create table t50 (a int) ; @@ -94,6 +147,18 @@ rename table t50 to t52, t51 to t53; rename table t52 to tmp, t53 to t52, tmp to t53; drop table t52,t53; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t50,id: 1,,0,,, +CREATE,MyISAM,0,test,t51,id: 2,,0,,, +RENAME,MyISAM,0,test,t50,id: 1,MyISAM,0,test,t52,id: 1 +RENAME,MyISAM,0,test,t51,id: 2,MyISAM,0,test,t53,id: 2 +RENAME,MyISAM,0,test,t52,id: 1,MyISAM,0,test,tmp,id: 1 +RENAME,MyISAM,0,test,t53,id: 2,MyISAM,0,test,t52,id: 2 +RENAME,MyISAM,0,test,tmp,id: 1,MyISAM,0,test,t53,id: 1 +DROP,MyISAM,0,test,t52,id: 2,,0,,, +DROP,MyISAM,0,test,t53,id: 1,,0,,, +# # Testing enable/disable keys # CREATE TABLE t60 (a int(10), index(a) ) ENGINE=Aria ; @@ -107,6 +172,13 @@ INSERT INTO t61 VALUES(1),(2),(3); ALTER TABLE t61 DISABLE KEYS; DROP TABLE t61; # +# Reading backup ddl log file +# +CREATE,Aria,0,test,t60,id: 1,,0,,, +CHANGE_INDEX,Aria,0,test,t60,id: 1,,0,,, +CHANGE_INDEX,Aria,0,test,t60,id: 1,,0,,, +DROP,Aria,0,test,t60,id: 1,,0,,, +# # Testing load data # create table t70 (a date, b date, c date not null, d date) engine=aria ; @@ -123,11 +195,26 @@ insert into t71 select * from t70; unlock tables; drop table t70,t71; # +# Reading backup ddl log file +# +CREATE,Aria,0,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,0,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,0,test,t70,id: 1,,0,,, +CREATE,Aria,0,test,t71,id: 2,,0,,, +BULK_INSERT,Aria,0,test,t71,id: 2,,0,,, +DROP,Aria,0,test,t70,id: 1,,0,,, +DROP,Aria,0,test,t71,id: 2,,0,,, +# # Testing strange table names # create table `t 1` (a int) ; drop table `t 1`; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t@00201,id: 1,,0,,, +DROP,MyISAM,0,test,t@00201,id: 1,,0,,, +# # Testing views and triggers # create table t80 (a int, b int) engine=myisam ; @@ -137,12 +224,27 @@ drop trigger trg; drop view v1; drop table t80; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t80,id: 1,,0,,, +CREATE,VIEW,0,test,v1,,,0,,, +CREATE,TRIGGER,0,test,trg,,,0,,, +DROP,TRIGGER,0,test,trg,,,0,,, +DROP,VIEW,0,test,v1,,,0,,, +DROP,MyISAM,0,test,t80,id: 1,,0,,, +# # Testing alter to a new storage engine # create table t85 (a int primary key, b int) engine=myisam ; alter table t85 engine=innodb; drop table t85; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t85,id: 1,,0,,, +ALTER,MyISAM,0,test,t85,id: 1,InnoDB,0,test,t85,id: 2 +DROP,InnoDB,0,test,t85,id: 2,,0,,, +# # Testing create/drop/alter database # create database mysqltest; @@ -151,6 +253,16 @@ create table mysqltest.t91 (a int primary key, b int) engine=innodb; alter database mysqltest character set utf8; drop database mysqltest; # +# Reading backup ddl log file +# +CREATE,DATABASE,0,mysqltest,,,,0,,, +CREATE,MyISAM,0,mysqltest,t90,id: 1,,0,,, +CREATE,InnoDB,0,mysqltest,t91,id: 2,,0,,, +ALTER,DATABASE,0,mysqltest,,,,0,,, +DROP,MyISAM,0,mysqltest,t90,id: 1,,0,,, +DROP,InnoDB,0,mysqltest,t91,id: 2,,0,,, +DROP,DATABASE,0,mysqltest,,,,0,,, +# # MENT-222 bug testing # CREATE TABLE IF NOT EXISTS t_exists LIKE t_exists_template; @@ -159,82 +271,14 @@ Note 1050 Table 't_exists' already exists # # Reading backup ddl log file # -CREATE,MyISAM,0,test,t1,id: 1,,0,,, -ALTER,MyISAM,0,test,t1,id: 1,MyISAM,0,test,t1,id: 2 -RENAME,MyISAM,0,test,t1,id: 2,MyISAM,0,test,t2,id: 2 -RENAME,MyISAM,0,test,t2,id: 2,MyISAM,0,test,t1,id: 2 -repair,MyISAM,0,test,t1,id: 2,,0,,, -optimize,MyISAM,0,test,t1,id: 2,,0,,, -DROP,MyISAM,0,test,t1,id: 2,,0,,, -CREATE,InnoDB,0,test,t1_innodb,id: 3,,0,,, -ALTER,InnoDB,0,test,t1_innodb,id: 3,InnoDB,0,test,t1_innodb,id: 4 -RENAME,InnoDB,0,test,t1_innodb,id: 4,InnoDB,0,test,t2_innodb,id: 4 -RENAME,InnoDB,0,test,t2_innodb,id: 4,InnoDB,0,test,t1_innodb,id: 4 -TRUNCATE,InnoDB,0,test,t1_innodb,id: 4,,0,,, -repair,InnoDB,0,test,t1_innodb,id: 4,,0,,, -ALTER,InnoDB,0,test,t1_innodb,id: 4,InnoDB,0,test,t1_innodb,id: 5 -DROP,InnoDB,0,test,t1_innodb,id: 5,,0,,, -CREATE,MyISAM,0,test,t20,id: 6,,0,,, -DROP,MyISAM,0,test,t20,id: 6,,0,,, -CREATE,MyISAM,0,test,t21,id: 7,,0,,, -DROP,MyISAM,0,test,t21,id: 7,,0,,, -CREATE,MyISAM,0,test,t30,id: 8,,0,,, -CREATE,MyISAM,0,test,t31,id: 9,,0,,, -DROP,MyISAM,0,test,t31,id: 9,,0,,, -CREATE,MyISAM,0,test,t31,id: 10,,0,,, -CREATE,MyISAM,0,test,t32,id: 11,,0,,, -DROP,MyISAM,0,test,t30,id: 8,,0,,, -DROP,MyISAM,0,test,t31,id: 10,,0,,, -DROP,MyISAM,0,test,t32,id: 11,,0,,, -CREATE,MyISAM,0,test,t40,id: 12,,0,,, -CREATE,InnoDB,0,test,t41,id: 13,,0,,, -CREATE,MyISAM,0,test,t42,id: 14,,0,,, -DROP,MyISAM,0,test,t42,id: 14,,0,,, -CREATE,InnoDB,0,test,t42,id: 15,,0,,, -DROP,MyISAM,0,test,t40,id: 12,,0,,, -DROP,InnoDB,0,test,t41,id: 13,,0,,, -DROP,InnoDB,0,test,t42,id: 15,,0,,, -CREATE,MyISAM,0,test,t50,id: 16,,0,,, -CREATE,MyISAM,0,test,t51,id: 17,,0,,, -RENAME,MyISAM,0,test,t50,id: 16,MyISAM,0,test,t52,id: 16 -RENAME,MyISAM,0,test,t51,id: 17,MyISAM,0,test,t53,id: 17 -RENAME,MyISAM,0,test,t52,id: 16,MyISAM,0,test,tmp,id: 16 -RENAME,MyISAM,0,test,t53,id: 17,MyISAM,0,test,t52,id: 17 -RENAME,MyISAM,0,test,tmp,id: 16,MyISAM,0,test,t53,id: 16 -DROP,MyISAM,0,test,t52,id: 17,,0,,, -DROP,MyISAM,0,test,t53,id: 16,,0,,, -CREATE,Aria,0,test,t60,id: 18,,0,,, -CHANGE_INDEX,Aria,0,test,t60,id: 18,,0,,, -CHANGE_INDEX,Aria,0,test,t60,id: 18,,0,,, -DROP,Aria,0,test,t60,id: 18,,0,,, -CREATE,Aria,0,test,t70,id: 19,,0,,, -BULK_INSERT,Aria,0,test,t70,id: 19,,0,,, -BULK_INSERT,Aria,0,test,t70,id: 19,,0,,, -CREATE,Aria,0,test,t71,id: 20,,0,,, -BULK_INSERT,Aria,0,test,t71,id: 20,,0,,, -DROP,Aria,0,test,t70,id: 19,,0,,, -DROP,Aria,0,test,t71,id: 20,,0,,, -CREATE,MyISAM,0,test,t@00201,id: 21,,0,,, -DROP,MyISAM,0,test,t@00201,id: 21,,0,,, -CREATE,MyISAM,0,test,t80,id: 22,,0,,, -CREATE,VIEW,0,test,v1,,,0,,, -CREATE,TRIGGER,0,test,trg,,,0,,, -DROP,TRIGGER,0,test,trg,,,0,,, -DROP,VIEW,0,test,v1,,,0,,, -DROP,MyISAM,0,test,t80,id: 22,,0,,, -CREATE,MyISAM,0,test,t85,id: 23,,0,,, -ALTER,MyISAM,0,test,t85,id: 23,InnoDB,0,test,t85,id: 24 -DROP,InnoDB,0,test,t85,id: 24,,0,,, -CREATE,DATABASE,0,mysqltest,,,,0,,, -CREATE,MyISAM,0,mysqltest,t90,id: 25,,0,,, -CREATE,InnoDB,0,mysqltest,t91,id: 26,,0,,, -ALTER,DATABASE,0,mysqltest,,,,0,,, -DROP,MyISAM,0,mysqltest,t90,id: 25,,0,,, -DROP,InnoDB,0,mysqltest,t91,id: 26,,0,,, -DROP,DATABASE,0,mysqltest,,,,0,,, # # Cleanup # DROP TABLE t_exists; DROP TABLE t_exists_template; +# +# Reading backup ddl log file +# +DROP,MyISAM,0,test,t_exists,id: 1,,0,,, +DROP,MyISAM,0,test,t_exists_template,id: 2,,0,,, disconnect con1; diff --git a/mysql-test/main/backup_log.test b/mysql-test/main/backup_log.test index ee34484e92bf9..d2f5d4616bd75 100644 --- a/mysql-test/main/backup_log.test +++ b/mysql-test/main/backup_log.test @@ -24,6 +24,8 @@ create table mysqltest.t91 (a int primary key, b int) engine=innodb; alter database mysqltest character set utf8; drop database mysqltest; +--source backup_log_print.inc + --echo # --echo # MENT-222 bug testing --echo # @@ -36,4 +38,5 @@ CREATE TABLE IF NOT EXISTS t_exists LIKE t_exists_template; --echo # DROP TABLE t_exists; DROP TABLE t_exists_template; +--source backup_log_print.inc disconnect con1; diff --git a/mysql-test/suite/parts/r/backup_log.result b/mysql-test/suite/parts/r/backup_log.result index 9b745eb8fa02d..4664d611f1fac 100644 --- a/mysql-test/suite/parts/r/backup_log.result +++ b/mysql-test/suite/parts/r/backup_log.result @@ -2,7 +2,7 @@ connect con1,localhost,root,,; BACKUP STAGE START; connection default; # -# Testing with normal tables +# Testing normal tables # create table t1 (a int) engine=myisam PARTITION BY HASH(a) PARTITIONS 2; insert into t1 values (1),(2); @@ -17,6 +17,17 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK drop table t1; +# +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t1,id: 1,,0,,, +ALTER,MyISAM,1,test,t1,id: 1,MyISAM,1,test,t1,id: 2 +RENAME,MyISAM,1,test,t1,id: 2,MyISAM,1,test,t2,id: 2 +RENAME,MyISAM,1,test,t2,id: 2,MyISAM,1,test,t1,id: 2 +TRUNCATE,MyISAM,1,test,t1,id: 2,,0,,, +repair,MyISAM,1,test,t1,id: 2,,0,,, +optimize,MyISAM,1,test,t1,id: 2,,0,,, +DROP,MyISAM,1,test,t1,id: 2,,0,,, create table t1_innodb (a int) engine=innodb PARTITION BY HASH(a) PARTITIONS 2; insert into t1_innodb values (1),(2); alter table t1_innodb add column b int; @@ -32,6 +43,17 @@ test.t1_innodb optimize note Table does not support optimize, doing recreate + a test.t1_innodb optimize status OK drop table t1_innodb; # +# Reading backup ddl log file +# +CREATE,InnoDB,1,test,t1_innodb,id: 1,,0,,, +ALTER,InnoDB,1,test,t1_innodb,id: 1,InnoDB,1,test,t1_innodb,id: 2 +RENAME,InnoDB,1,test,t1_innodb,id: 2,InnoDB,1,test,t2_innodb,id: 2 +RENAME,InnoDB,1,test,t2_innodb,id: 2,InnoDB,1,test,t1_innodb,id: 2 +TRUNCATE,InnoDB,1,test,t1_innodb,id: 2,,0,,, +repair,InnoDB,1,test,t1_innodb,id: 2,,0,,, +ALTER,InnoDB,1,test,t1_innodb,id: 2,InnoDB,1,test,t1_innodb,id: 3 +DROP,InnoDB,1,test,t1_innodb,id: 3,,0,,, +# # Testing with temporary tables (should not be logged) # create temporary table tmp_t10 (a int) engine=myisam; @@ -41,6 +63,9 @@ rename table tmp_t11 to tmp_t10; truncate table tmp_t10; drop table tmp_t10; # +# Reading backup ddl log file +# +# # Testing with mix of normal and temporary tables # create temporary table tmp_t20 (a int); @@ -55,6 +80,13 @@ drop table if exists tmp_t21,t21; Warnings: Note 1051 Unknown table 'test.tmp_t21' # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t20,id: 1,,0,,, +DROP,MyISAM,1,test,t20,id: 1,,0,,, +CREATE,MyISAM,1,test,t21,id: 2,,0,,, +DROP,MyISAM,1,test,t21,id: 2,,0,,, +# # Testing create select # create table t30 (a int) PARTITION BY HASH(a) PARTITIONS 2; @@ -69,6 +101,17 @@ drop table if exists t30,t31,t32,tmp_t30; Warnings: Note 1051 Unknown table 'test.tmp_t30' # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t30,id: 1,,0,,, +CREATE,MyISAM,1,test,t31,id: 2,,0,,, +DROP,MyISAM,1,test,t31,id: 2,,0,,, +CREATE,MyISAM,0,test,t31,id: 3,,0,,, +CREATE,MyISAM,1,test,t32,id: 4,,0,,, +DROP,MyISAM,1,test,t30,id: 1,,0,,, +DROP,MyISAM,0,test,t31,id: 3,,0,,, +DROP,MyISAM,1,test,t32,id: 4,,0,,, +# # Testing create LIKE # create table t40 (a int) engine=myisam PARTITION BY HASH(a) PARTITIONS 2; @@ -85,6 +128,17 @@ t42 CREATE TABLE `t42` ( PARTITIONS 2 drop table t40, t41, t42; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t40,id: 1,,0,,, +CREATE,InnoDB,1,test,t41,id: 2,,0,,, +CREATE,partition,0,test,t42,id: 3,,0,,, +DROP,MyISAM,1,test,t42,id: 3,,0,,, +CREATE,partition,0,test,t42,id: 4,,0,,, +DROP,MyISAM,1,test,t40,id: 1,,0,,, +DROP,InnoDB,1,test,t41,id: 2,,0,,, +DROP,InnoDB,1,test,t42,id: 4,,0,,, +# # Testing rename # create table t50 (a int) PARTITION BY HASH(a) PARTITIONS 2; @@ -93,6 +147,18 @@ rename table t50 to t52, t51 to t53; rename table t52 to tmp, t53 to t52, tmp to t53; drop table t52,t53; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t50,id: 1,,0,,, +CREATE,MyISAM,1,test,t51,id: 2,,0,,, +RENAME,MyISAM,1,test,t50,id: 1,MyISAM,1,test,t52,id: 1 +RENAME,MyISAM,1,test,t51,id: 2,MyISAM,1,test,t53,id: 2 +RENAME,MyISAM,1,test,t52,id: 1,MyISAM,1,test,tmp,id: 1 +RENAME,MyISAM,1,test,t53,id: 2,MyISAM,1,test,t52,id: 2 +RENAME,MyISAM,1,test,tmp,id: 1,MyISAM,1,test,t53,id: 1 +DROP,MyISAM,1,test,t52,id: 2,,0,,, +DROP,MyISAM,1,test,t53,id: 1,,0,,, +# # Testing enable/disable keys # CREATE TABLE t60 (a int(10), index(a) ) ENGINE=Aria PARTITION BY HASH(a) PARTITIONS 2; @@ -106,6 +172,13 @@ INSERT INTO t61 VALUES(1),(2),(3); ALTER TABLE t61 DISABLE KEYS; DROP TABLE t61; # +# Reading backup ddl log file +# +CREATE,Aria,1,test,t60,id: 1,,0,,, +CHANGE_INDEX,Aria,1,test,t60,id: 1,,0,,, +CHANGE_INDEX,Aria,1,test,t60,id: 1,,0,,, +DROP,Aria,1,test,t60,id: 1,,0,,, +# # Testing load data # create table t70 (a date, b date, c date not null, d date) engine=aria PARTITION BY HASH(YEAR(a)) PARTITIONS 2; @@ -122,11 +195,30 @@ insert into t71 select * from t70; unlock tables; drop table t70,t71; # +# Reading backup ddl log file +# +CREATE,Aria,1,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, +TRUNCATE,Aria,1,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, +CREATE,Aria,1,test,t71,id: 2,,0,,, +BULK_INSERT,Aria,1,test,t71,id: 2,,0,,, +BULK_INSERT,Aria,1,test,t71,id: 2,,0,,, +DROP,Aria,1,test,t70,id: 1,,0,,, +DROP,Aria,1,test,t71,id: 2,,0,,, +# # Testing strange table names # create table `t 1` (a int) PARTITION BY HASH(a) PARTITIONS 2; drop table `t 1`; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t@00201,id: 1,,0,,, +DROP,MyISAM,1,test,t@00201,id: 1,,0,,, +# # Testing views and triggers # create table t80 (a int, b int) engine=myisam PARTITION BY HASH(a) PARTITIONS 2; @@ -136,12 +228,27 @@ drop trigger trg; drop view v1; drop table t80; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t80,id: 1,,0,,, +CREATE,VIEW,0,test,v1,,,0,,, +CREATE,TRIGGER,0,test,trg,,,0,,, +DROP,TRIGGER,0,test,trg,,,0,,, +DROP,VIEW,0,test,v1,,,0,,, +DROP,MyISAM,1,test,t80,id: 1,,0,,, +# # Testing alter to a new storage engine # create table t85 (a int primary key, b int) engine=myisam PARTITION BY HASH(a) PARTITIONS 2; alter table t85 engine=innodb; drop table t85; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t85,id: 1,,0,,, +ALTER,MyISAM,1,test,t85,id: 1,InnoDB,1,test,t85,id: 2 +DROP,InnoDB,1,test,t85,id: 2,,0,,, +# # Testing backup ddl log for partitioned tables # CREATE TABLE t200(a INT, b INT) ENGINE ARIA TRANSACTIONAL = 1 PAGE_CHECKSUM = 1; @@ -184,93 +291,22 @@ DROP TABLE t220; # # Reading backup ddl log file # -CREATE,MyISAM,1,test,t1,id: 1,,0,,, -ALTER,MyISAM,1,test,t1,id: 1,MyISAM,1,test,t1,id: 2 -RENAME,MyISAM,1,test,t1,id: 2,MyISAM,1,test,t2,id: 2 -RENAME,MyISAM,1,test,t2,id: 2,MyISAM,1,test,t1,id: 2 -TRUNCATE,MyISAM,1,test,t1,id: 2,,0,,, -repair,MyISAM,1,test,t1,id: 2,,0,,, -optimize,MyISAM,1,test,t1,id: 2,,0,,, -DROP,MyISAM,1,test,t1,id: 2,,0,,, -CREATE,InnoDB,1,test,t1_innodb,id: 3,,0,,, -ALTER,InnoDB,1,test,t1_innodb,id: 3,InnoDB,1,test,t1_innodb,id: 4 -RENAME,InnoDB,1,test,t1_innodb,id: 4,InnoDB,1,test,t2_innodb,id: 4 -RENAME,InnoDB,1,test,t2_innodb,id: 4,InnoDB,1,test,t1_innodb,id: 4 -TRUNCATE,InnoDB,1,test,t1_innodb,id: 4,,0,,, -repair,InnoDB,1,test,t1_innodb,id: 4,,0,,, -ALTER,InnoDB,1,test,t1_innodb,id: 4,InnoDB,1,test,t1_innodb,id: 5 -DROP,InnoDB,1,test,t1_innodb,id: 5,,0,,, -CREATE,MyISAM,1,test,t20,id: 6,,0,,, -DROP,MyISAM,1,test,t20,id: 6,,0,,, -CREATE,MyISAM,1,test,t21,id: 7,,0,,, -DROP,MyISAM,1,test,t21,id: 7,,0,,, -CREATE,MyISAM,1,test,t30,id: 8,,0,,, -CREATE,MyISAM,1,test,t31,id: 9,,0,,, -DROP,MyISAM,1,test,t31,id: 9,,0,,, -CREATE,MyISAM,0,test,t31,id: 10,,0,,, -CREATE,MyISAM,1,test,t32,id: 11,,0,,, -DROP,MyISAM,1,test,t30,id: 8,,0,,, -DROP,MyISAM,0,test,t31,id: 10,,0,,, -DROP,MyISAM,1,test,t32,id: 11,,0,,, -CREATE,MyISAM,1,test,t40,id: 12,,0,,, -CREATE,InnoDB,1,test,t41,id: 13,,0,,, -CREATE,partition,0,test,t42,id: 14,,0,,, -DROP,MyISAM,1,test,t42,id: 14,,0,,, -CREATE,partition,0,test,t42,id: 15,,0,,, -DROP,MyISAM,1,test,t40,id: 12,,0,,, -DROP,InnoDB,1,test,t41,id: 13,,0,,, -DROP,InnoDB,1,test,t42,id: 15,,0,,, -CREATE,MyISAM,1,test,t50,id: 16,,0,,, -CREATE,MyISAM,1,test,t51,id: 17,,0,,, -RENAME,MyISAM,1,test,t50,id: 16,MyISAM,1,test,t52,id: 16 -RENAME,MyISAM,1,test,t51,id: 17,MyISAM,1,test,t53,id: 17 -RENAME,MyISAM,1,test,t52,id: 16,MyISAM,1,test,tmp,id: 16 -RENAME,MyISAM,1,test,t53,id: 17,MyISAM,1,test,t52,id: 17 -RENAME,MyISAM,1,test,tmp,id: 16,MyISAM,1,test,t53,id: 16 -DROP,MyISAM,1,test,t52,id: 17,,0,,, -DROP,MyISAM,1,test,t53,id: 16,,0,,, -CREATE,Aria,1,test,t60,id: 18,,0,,, -CHANGE_INDEX,Aria,1,test,t60,id: 18,,0,,, -CHANGE_INDEX,Aria,1,test,t60,id: 18,,0,,, -DROP,Aria,1,test,t60,id: 18,,0,,, -CREATE,Aria,1,test,t70,id: 19,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 19,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 19,,0,,, -TRUNCATE,Aria,1,test,t70,id: 19,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 19,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 19,,0,,, -CREATE,Aria,1,test,t71,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t71,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t71,id: 20,,0,,, -DROP,Aria,1,test,t70,id: 19,,0,,, -DROP,Aria,1,test,t71,id: 20,,0,,, -CREATE,MyISAM,1,test,t@00201,id: 21,,0,,, -DROP,MyISAM,1,test,t@00201,id: 21,,0,,, -CREATE,MyISAM,1,test,t80,id: 22,,0,,, -CREATE,VIEW,0,test,v1,,,0,,, -CREATE,TRIGGER,0,test,trg,,,0,,, -DROP,TRIGGER,0,test,trg,,,0,,, -DROP,VIEW,0,test,v1,,,0,,, -DROP,MyISAM,1,test,t80,id: 22,,0,,, -CREATE,MyISAM,1,test,t85,id: 23,,0,,, -ALTER,MyISAM,1,test,t85,id: 23,InnoDB,1,test,t85,id: 24 -DROP,InnoDB,1,test,t85,id: 24,,0,,, -CREATE,Aria,0,test,t200,id: 25,,0,,, -ALTER,Aria,0,test,t200,id: 25,Aria,1,test,t200,id: 26 -CREATE,Aria,0,test,t210,id: 27,,0,,, -EXCHANGE_PARTITION,Aria,1,test,t200,id: 26,Aria,0,test,t210,id: 27 -ALTER,Aria,1,test,t200,id: 26,Aria,1,test,t200,id: 28 -ALTER,Aria,1,test,t200,id: 28,Aria,1,test,t200,id: 29 -ALTER,Aria,1,test,t200,id: 29,Aria,1,test,t200,id: 30 -ALTER,Aria,1,test,t200,id: 30,Aria,1,test,t200,id: 31 -ALTER,Aria,1,test,t200,id: 31,Aria,1,test,t200,id: 32 -ALTER,Aria,1,test,t200,id: 32,Aria,1,test,t200,id: 33 -ALTER,Aria,1,test,t200,id: 33,Aria,1,test,t200,id: 34 -ALTER,Aria,1,test,t200,id: 34,Aria,0,test,t200,id: 35 -DROP,Aria,0,test,t200,id: 35,,0,,, -DROP,Aria,0,test,t210,id: 27,,0,,, -CREATE,Aria,1,test,t220,id: 36,,0,,, -DROP,Aria,1,test,t220,id: 36,,0,,, +CREATE,Aria,0,test,t200,id: 1,,0,,, +ALTER,Aria,0,test,t200,id: 1,Aria,1,test,t200,id: 2 +CREATE,Aria,0,test,t210,id: 3,,0,,, +EXCHANGE_PARTITION,Aria,1,test,t200,id: 2,Aria,0,test,t210,id: 3 +ALTER,Aria,1,test,t200,id: 2,Aria,1,test,t200,id: 4 +ALTER,Aria,1,test,t200,id: 4,Aria,1,test,t200,id: 5 +ALTER,Aria,1,test,t200,id: 5,Aria,1,test,t200,id: 6 +ALTER,Aria,1,test,t200,id: 6,Aria,1,test,t200,id: 7 +ALTER,Aria,1,test,t200,id: 7,Aria,1,test,t200,id: 8 +ALTER,Aria,1,test,t200,id: 8,Aria,1,test,t200,id: 9 +ALTER,Aria,1,test,t200,id: 9,Aria,1,test,t200,id: 10 +ALTER,Aria,1,test,t200,id: 10,Aria,0,test,t200,id: 11 +DROP,Aria,0,test,t200,id: 11,,0,,, +DROP,Aria,0,test,t210,id: 3,,0,,, +CREATE,Aria,1,test,t220,id: 12,,0,,, +DROP,Aria,1,test,t220,id: 12,,0,,, # # Cleanup # From 2af15914cb3ae204d3b413995a96c7722ad60d93 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:05 +0300 Subject: [PATCH 016/113] MDEV-25292 Disable atomic replace for slave-generated or-replace Also fixes wrong rollback of ddl_log_state_rm in case of non-atomic replace. There is no backup to remove in that case. --- mysql-test/suite/rpl/r/create_or_replace_mix.result | 2 +- mysql-test/suite/rpl/r/create_or_replace_statement.result | 2 +- sql/handler.h | 3 ++- sql/sql_table.cc | 7 ++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/rpl/r/create_or_replace_mix.result b/mysql-test/suite/rpl/r/create_or_replace_mix.result index 75f7ca2a82868..2a82e747b351b 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_mix.result +++ b/mysql-test/suite/rpl/r/create_or_replace_mix.result @@ -150,7 +150,7 @@ slave-bin.000001 # Query # # use `test`; create table t4 (server_2_to_be_delete slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; create table t1 (new_table int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# -slave-bin.000001 # Query # # use `test`; CREATE TABLE `t2` ( +slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( `a` int(11) DEFAULT NULL ) slave-bin.000001 # Annotate_rows # # create table t2 select * from t9 diff --git a/mysql-test/suite/rpl/r/create_or_replace_statement.result b/mysql-test/suite/rpl/r/create_or_replace_statement.result index 75f7ca2a82868..2a82e747b351b 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_statement.result +++ b/mysql-test/suite/rpl/r/create_or_replace_statement.result @@ -150,7 +150,7 @@ slave-bin.000001 # Query # # use `test`; create table t4 (server_2_to_be_delete slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; create table t1 (new_table int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# -slave-bin.000001 # Query # # use `test`; CREATE TABLE `t2` ( +slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( `a` int(11) DEFAULT NULL ) slave-bin.000001 # Annotate_rows # # create table t2 select * from t9 diff --git a/sql/handler.h b/sql/handler.h index b6124765b6b6b..1abe66448aa37 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2466,7 +2466,8 @@ struct Table_specification_st: public HA_CREATE_INFO, } bool is_atomic_replace() const { - return or_replace() && is_atomic_replace_usable(); + return or_replace() && !or_replace_slave_generated() && + is_atomic_replace_usable(); } }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 48761ee194570..0d76a50f4ce27 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4398,6 +4398,8 @@ bool HA_CREATE_INFO::finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table) char path[FN_REFLEN + 1]; cpath.str= path; + DBUG_ASSERT(is_atomic_replace()); + debug_crash_here("ddl_log_create_before_install_new"); if (old_hton) { @@ -4498,7 +4500,10 @@ void HA_CREATE_INFO::finalize_ddl(THD *thd, bool roll_back) debug_crash_here("ddl_log_create_log_complete"); ddl_log_complete(ddl_log_state_create); debug_crash_here("ddl_log_create_log_complete2"); - (void) ddl_log_revert(thd, ddl_log_state_rm); + if (is_atomic_replace()) + (void) ddl_log_revert(thd, ddl_log_state_rm); + else + ddl_log_complete(ddl_log_state_rm); debug_crash_here("ddl_log_create_log_complete3"); } } From 24fff8267d0722b20ca780cf144ce27560df1394 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:05 +0300 Subject: [PATCH 017/113] MDEV-25292 gcol.gcol_bugfixes --ps fix Related to MDEV-24176. 1. vcol_fix_expr() generates new tree changes: Type_std_attributes::agg_item_set_converter() does change_item_tree(). The changes are allocated on expr_arena (via Vcol_expr_context as per MDEV-24176). 2. vcol_cleanup_expr() doesn't remove these changes (can be a bug of Type_std_attributes or per design). 3. Atomic CREATE OR REPLACE renames old table to backup (finalize_atomic_replace()). It does that via rename_table_and_triggers() and that closes table share and releases expr_arena root. Hence now we have Item corpses in thd->change_list. 4. PS cleanup phase tries to rollback thd->change_list and accesses already freed item corpses. The fix saves and restores change_list on vcol_fix_expr()/vcol_cleanup_expr(). --- mysql-test/main/create_or_replace.result | 6 ++++++ mysql-test/main/create_or_replace.test | 6 ++++++ sql/table.cc | 21 +++++++++++++++++++++ sql/table.h | 2 ++ 4 files changed, 35 insertions(+) diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index 46645bb910f4f..142856d603f14 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -800,6 +800,12 @@ create or replace table t1 (old int); show create trigger a; ERROR HY000: Trigger does not exist drop table t1; +# PS: check thd->change_list sanity +create table t1 (a int not null, b char(10) as (concat('', dayname('2020-02-02')))) collate utf8_bin; +prepare stmt from 'insert into t1 (b) values (2)'; +create or replace table t1 (x int); +drop table t1; +drop prepare stmt; # Foreign keys create table t1 (x int primary key, y int) engine innodb; create table t2 (x int references t1(x)) engine innodb; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 7d783710c17b2..c18c8b9eb7cef 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -602,6 +602,12 @@ create or replace table t1 (old int); --error ER_TRG_DOES_NOT_EXIST show create trigger a; drop table t1; +--echo # PS: check thd->change_list sanity +create table t1 (a int not null, b char(10) as (concat('', dayname('2020-02-02')))) collate utf8_bin; +prepare stmt from 'insert into t1 (b) values (2)'; +create or replace table t1 (x int); +drop table t1; +drop prepare stmt; --echo # Foreign keys --list_files $MYSQLD_DATADIR/test *sql* create table t1 (x int primary key, y int) engine innodb; diff --git a/sql/table.cc b/sql/table.cc index 5e17eb60b30ce..e1161fd98c36f 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3723,6 +3723,13 @@ bool TABLE::vcol_fix_expr(THD *thd) return false; } + if (!thd->Item_change_list::is_empty()) + { + DBUG_ASSERT(!saved_change_list); + saved_change_list= new Item_change_list; + thd->move_elements_to(saved_change_list); + } + Vcol_expr_context expr_ctx(thd, this); if (expr_ctx.init()) return true; @@ -3743,7 +3750,12 @@ bool TABLE::vcol_fix_expr(THD *thd) bool TABLE::vcol_cleanup_expr(THD *thd) { if (vcol_refix_list.is_empty()) + { + DBUG_ASSERT(!saved_change_list); return false; + } + + thd->rollback_item_tree_changes(); List_iterator it(vcol_refix_list); bool result= false; @@ -3751,6 +3763,15 @@ bool TABLE::vcol_cleanup_expr(THD *thd) while (Virtual_column_info *vcol= it++) result|= vcol->cleanup_session_expr(); + if (saved_change_list) + { + DBUG_ASSERT(!vcol_refix_list.is_empty()); + DBUG_ASSERT(!saved_change_list->is_empty()); + saved_change_list->move_elements_to(thd); + delete saved_change_list; + saved_change_list= NULL; + } + DBUG_ASSERT(!result || thd->get_stmt_da()->is_error()); return result; } diff --git a/sql/table.h b/sql/table.h index b8087bd056d01..72db38a82f229 100644 --- a/sql/table.h +++ b/sql/table.h @@ -41,6 +41,7 @@ class Item; /* Needed by ORDER */ typedef Item (*Item_ptr); +class Item_change_list; class Item_subselect; class Item_field; class GRANT_TABLE; @@ -1511,6 +1512,7 @@ struct TABLE bool get_fields_in_item_tree; /* Signal to fix_field */ List vcol_refix_list; private: + Item_change_list *saved_change_list; bool m_needs_reopen; bool created; /* For tmp tables. TRUE <=> tmp table was actually created.*/ public: From a228ec80e30cae59c2057b786fd3559171ce794f Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:05 +0300 Subject: [PATCH 018/113] MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES add_back_last_deleted_lock() was called when the lock was never removed. Lock is removed in finalize_atomic_replace() in close_all_tables_for_name(). finalize_atomic_replace() is done only for successful operation. In non-atomic codepath it drops the table first, if anything fails later we don't need to return back the lock since there is no table now. So the fix is required as well. --- mysql-test/main/create_or_replace.result | 16 ++++++++ mysql-test/main/create_or_replace.test | 17 ++++++++ mysql-test/main/create_or_replace2.result | 19 +++++++++ mysql-test/main/create_or_replace2.test | 21 ++++++++++ sql/handler.h | 2 +- sql/sql_insert.cc | 6 ++- sql/sql_table.cc | 48 ++++++++++++++++------- 7 files changed, 112 insertions(+), 17 deletions(-) diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index 142856d603f14..d9ca4102b069b 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -847,3 +847,19 @@ t2 CREATE TABLE `t2` ( `a` varchar(2300) DEFAULT NULL ) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 drop tables t2, t1; +# +# MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES +# +# Atomic CREATE OR REPLACE part: +# +create table t1 (pk int primary key) engine=innodb; +create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; +lock tables t1 write, t2 write; +create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +select * from t1; +pk +select * from t2; +a +unlock tables; +drop tables t2, t1; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index c18c8b9eb7cef..316d904e59140 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -638,3 +638,20 @@ create or replace table t2 engine aria select * from t1; select * from t2; show create table t2; drop tables t2, t1; + +--echo # +--echo # MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES +--echo # +--echo # Atomic CREATE OR REPLACE part: +--echo # +create table t1 (pk int primary key) engine=innodb; +create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; + +lock tables t1 write, t2 write; +--error ER_DUP_FIELDNAME +create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; +select * from t1; +select * from t2; +unlock tables; + +drop tables t2, t1; diff --git a/mysql-test/main/create_or_replace2.result b/mysql-test/main/create_or_replace2.result index f7bbb7417e6e1..dd183441e42c9 100644 --- a/mysql-test/main/create_or_replace2.result +++ b/mysql-test/main/create_or_replace2.result @@ -72,3 +72,22 @@ ERROR 42000: Duplicate key name 'k' create or replace table t1 (a int, b int, key k (a), key k (b)); ERROR 42000: Duplicate key name 'k' drop table t1; +# +# MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES +# +# Non-atomic CREATE OR REPLACE part: +# +set @saved_debug_dbug= @@session.debug_dbug; +set @@debug_dbug="+d,ddl_log_expensive_rename"; +create table t1 (pk int primary key) engine=innodb; +create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; +lock tables t1 write, t2 write; +create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +select * from t1; +pk +select * from t2; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +drop tables t1; +set @@debug_dbug= @saved_debug_dbug; diff --git a/mysql-test/main/create_or_replace2.test b/mysql-test/main/create_or_replace2.test index 227aff226d53c..bd82d13f1d1ae 100644 --- a/mysql-test/main/create_or_replace2.test +++ b/mysql-test/main/create_or_replace2.test @@ -65,3 +65,24 @@ create or replace table t1 (a int, b int, key k (a), key k (b)); --error ER_DUP_KEYNAME create or replace table t1 (a int, b int, key k (a), key k (b)); drop table t1; + +--echo # +--echo # MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES +--echo # +--echo # Non-atomic CREATE OR REPLACE part: +--echo # +set @saved_debug_dbug= @@session.debug_dbug; +set @@debug_dbug="+d,ddl_log_expensive_rename"; +create table t1 (pk int primary key) engine=innodb; +create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; + +lock tables t1 write, t2 write; +--error ER_DUP_FIELDNAME +create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; +select * from t1; +--error ER_TABLE_NOT_LOCKED +select * from t2; +unlock tables; + +drop tables t1; +set @@debug_dbug= @saved_debug_dbug; diff --git a/sql/handler.h b/sql/handler.h index 1abe66448aa37..d4ea7687f150b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2382,7 +2382,7 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, } bool finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table); void finalize_ddl(THD *thd, bool roll_back); - bool finalize_locked_tables(THD *thd); + bool finalize_locked_tables(THD *thd, bool operation_failed); bool make_tmp_table_list(THD *thd, TABLE_LIST **create_table, int *create_table_mode); }; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 6fc46e5818c89..163dd45f50c1e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -5414,7 +5414,8 @@ bool select_create::send_eof() mysql_unlock_tables(thd, lock); } else if (atomic_replace && create_info->pos_in_locked_tables && - create_info->finalize_locked_tables(thd)) + /* send_eof() is done on success, passing false here */ + create_info->finalize_locked_tables(thd, false)) DBUG_RETURN(true); send_ok_packet(); @@ -5526,6 +5527,7 @@ void select_create::abort_result_set() thd->locked_tables_list.unlock_locked_table(thd, create_info->mdl_ticket); } else if (atomic_replace && create_info->pos_in_locked_tables) - (void) create_info->finalize_locked_tables(thd); + /* abort_result_set() is done on error, passing true here */ + (void) create_info->finalize_locked_tables(thd, true); DBUG_VOID_RETURN; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0d76a50f4ce27..5855c21bbb34b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4509,27 +4509,47 @@ void HA_CREATE_INFO::finalize_ddl(THD *thd, bool roll_back) } -bool HA_CREATE_INFO::finalize_locked_tables(THD *thd) +/** + Finalize operation of LOCK TABLES mode for CREATE TABLE family of commands. + + @param operation_failed Notify if the callee CREATE fails the operation + @return true on error, false on success +*/ +bool HA_CREATE_INFO::finalize_locked_tables(THD *thd, bool operation_failed) { DBUG_ASSERT(pos_in_locked_tables); DBUG_ASSERT(thd->locked_tables_mode); DBUG_ASSERT(thd->variables.option_bits & OPTION_TABLE_LOCK); - /* - Add back the deleted table and re-created table as a locked 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 (!operation_failed) + { + /* + Add back the deleted table and re-created table as a locked 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, false)) { thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); return true; } - /* - The lock was made exclusive in create_table_impl(). We have now - to bring it back to it's orginal state - */ - TABLE *table= pos_in_locked_tables->table; - table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); + if (is_atomic_replace() || !operation_failed) + { + /* + The lock was made exclusive in create_table_impl(). We have now + to bring it back to it's orginal state. + */ + TABLE *table= pos_in_locked_tables->table; + table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); + } + else + { + /* + In failed non-atomic we have nothing to downgrade: + original table was deleted and the lock was already removed. + */ + DBUG_ASSERT(!pos_in_locked_tables->table); + } return false; } @@ -5278,7 +5298,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, */ if (thd->locked_tables_mode && pos_in_locked_tables && create_info->or_replace()) - result|= (int) create_info->finalize_locked_tables(thd); + result|= (int) create_info->finalize_locked_tables(thd, result); DBUG_RETURN(result); } @@ -6023,7 +6043,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, */ if (thd->locked_tables_mode && pos_in_locked_tables && create_info->or_replace()) - res|= (int) local_create_info.finalize_locked_tables(thd); + res|= (int) local_create_info.finalize_locked_tables(thd, res); DBUG_RETURN(res != 0); } From f1e1c1335b506905244502ee8584736a17a6ecd0 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:05 +0300 Subject: [PATCH 019/113] MDEV-28933 Moved RENAME_CONSTRAINT_IDS to include/sql_funcs.h All InnoDB internal SQL functions should be moved to sql_funcs.h --- storage/innobase/CMakeLists.txt | 1 + storage/innobase/include/sql_funcs.h | 92 ++++++++++++++++++++++++++++ storage/innobase/row/row0mysql.cc | 69 +-------------------- 3 files changed, 96 insertions(+), 66 deletions(-) create mode 100644 storage/innobase/include/sql_funcs.h diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index f5f8ad342424e..f9af2715aea6e 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -231,6 +231,7 @@ SET(INNOBASE_SOURCES include/srv0start.h include/srw_lock.h include/sux_lock.h + include/sql_funcs.h include/trx0i_s.h include/trx0purge.h include/trx0rec.h diff --git a/storage/innobase/include/sql_funcs.h b/storage/innobase/include/sql_funcs.h new file mode 100644 index 0000000000000..307756196b18c --- /dev/null +++ b/storage/innobase/include/sql_funcs.h @@ -0,0 +1,92 @@ +/***************************************************************************** + +Copyright (c) 2022, 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 +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-1335 USA + +*****************************************************************************/ + +/** + @file include/sql_funcs.h + + SQL procedures for InnoDB system tables operation +*/ + +/** + Rename foreign keys for rename table + + @see row_rename_table_for_mysql() +*/ +constexpr const char *rename_constraint_ids= +R"===(PROCEDURE RENAME_CONSTRAINT_IDS () IS + gen_constr_prefix CHAR; + new_db_name CHAR; + foreign_id CHAR; + new_foreign_id CHAR; + old_db_name_len INT; + old_t_name_len INT; + new_db_name_len INT; + id_len INT; + offset INT; + found INT; + BEGIN + found := 1; + old_db_name_len := INSTR(:old_table_name, '/') - 1; + new_db_name_len := INSTR(:new_table_name, '/') - 1; + new_db_name := SUBSTR(:new_table_name, 0, + new_db_name_len); + old_t_name_len := LENGTH(:old_table_name); + gen_constr_prefix := CONCAT(:old_table_name_utf8, + '_ibfk_'); + WHILE found = 1 LOOP + SELECT ID INTO foreign_id + FROM SYS_FOREIGN + WHERE FOR_NAME = :old_table_name + AND TO_BINARY(FOR_NAME) + = TO_BINARY(:old_table_name) + LOCK IN SHARE MODE; + IF (SQL % NOTFOUND) THEN + found := 0; + ELSE + UPDATE SYS_FOREIGN + SET FOR_NAME = :new_table_name + WHERE ID = foreign_id; + id_len := LENGTH(foreign_id); + IF (INSTR(foreign_id, '/') > 0) THEN + IF (INSTR(foreign_id, + gen_constr_prefix) > 0) + THEN + offset := INSTR(foreign_id, '_ibfk_') - 1; + new_foreign_id := + CONCAT(:new_table_utf8, + SUBSTR(foreign_id, offset, id_len - offset)); + ELSE + new_foreign_id := + CONCAT(new_db_name, + SUBSTR(foreign_id, old_db_name_len, + id_len - old_db_name_len)); + END IF; + UPDATE SYS_FOREIGN + SET ID = new_foreign_id + WHERE ID = foreign_id; + UPDATE SYS_FOREIGN_COLS + SET ID = new_foreign_id + WHERE ID = foreign_id; + END IF; + END IF; + END LOOP; + UPDATE SYS_FOREIGN SET REF_NAME = :new_table_name + WHERE REF_NAME = :old_table_name + AND TO_BINARY(REF_NAME) + = TO_BINARY(:old_table_name); +END;)==="; diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index b20d0cddf5bb4..5e6fb8b5488a1 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -72,6 +72,8 @@ Created 9/17/2000 Heikki Tuuri #include "wsrep_mysqld.h" #endif +#include "sql_funcs.h" + /*******************************************************************//** Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */ static @@ -2725,72 +2727,7 @@ row_rename_table_for_mysql( pars_info_add_str_literal(info, "new_table_utf8", new_table_name); - err = que_eval_sql( - info, - "PROCEDURE RENAME_CONSTRAINT_IDS () IS\n" - "gen_constr_prefix CHAR;\n" - "new_db_name CHAR;\n" - "foreign_id CHAR;\n" - "new_foreign_id CHAR;\n" - "old_db_name_len INT;\n" - "old_t_name_len INT;\n" - "new_db_name_len INT;\n" - "id_len INT;\n" - "offset INT;\n" - "found INT;\n" - "BEGIN\n" - "found := 1;\n" - "old_db_name_len := INSTR(:old_table_name, '/')-1;\n" - "new_db_name_len := INSTR(:new_table_name, '/')-1;\n" - "new_db_name := SUBSTR(:new_table_name, 0,\n" - " new_db_name_len);\n" - "old_t_name_len := LENGTH(:old_table_name);\n" - "gen_constr_prefix := CONCAT(:old_table_name_utf8,\n" - " '_ibfk_');\n" - "WHILE found = 1 LOOP\n" - " SELECT ID INTO foreign_id\n" - " FROM SYS_FOREIGN\n" - " WHERE FOR_NAME = :old_table_name\n" - " AND TO_BINARY(FOR_NAME)\n" - " = TO_BINARY(:old_table_name)\n" - " LOCK IN SHARE MODE;\n" - " IF (SQL % NOTFOUND) THEN\n" - " found := 0;\n" - " ELSE\n" - " UPDATE SYS_FOREIGN\n" - " SET FOR_NAME = :new_table_name\n" - " WHERE ID = foreign_id;\n" - " id_len := LENGTH(foreign_id);\n" - " IF (INSTR(foreign_id, '/') > 0) THEN\n" - " IF (INSTR(foreign_id,\n" - " gen_constr_prefix) > 0)\n" - " THEN\n" - " offset := INSTR(foreign_id, '_ibfk_') - 1;\n" - " new_foreign_id :=\n" - " CONCAT(:new_table_utf8,\n" - " SUBSTR(foreign_id, offset,\n" - " id_len - offset));\n" - " ELSE\n" - " new_foreign_id :=\n" - " CONCAT(new_db_name,\n" - " SUBSTR(foreign_id,\n" - " old_db_name_len,\n" - " id_len - old_db_name_len));\n" - " END IF;\n" - " UPDATE SYS_FOREIGN\n" - " SET ID = new_foreign_id\n" - " WHERE ID = foreign_id;\n" - " UPDATE SYS_FOREIGN_COLS\n" - " SET ID = new_foreign_id\n" - " WHERE ID = foreign_id;\n" - " END IF;\n" - " END IF;\n" - "END LOOP;\n" - "UPDATE SYS_FOREIGN SET REF_NAME = :new_table_name\n" - "WHERE REF_NAME = :old_table_name\n" - " AND TO_BINARY(REF_NAME)\n" - " = TO_BINARY(:old_table_name);\n" - "END;\n", trx); + err = que_eval_sql(info, rename_constraint_ids, trx); } else if (n_constraints_to_drop > 0) { /* Drop some constraints of tmp tables. */ From cf6c5176328c8fbfadac80f337ef285732cc8d06 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 31 Aug 2022 11:55:06 +0300 Subject: [PATCH 020/113] MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name Use temporary constraint names for temporary tables. The constraints are not added to cache (skipped in dict_table_rename_in_cache()). The scheme for temporary constraint names is as follows: for old table: db_name/\xFFconstraint_name for new table: db_name/\xFF\xFFconstraint_name normalize_table_name_c_low(): wrong comparison "less than FN_REFLEN - 1". Somewhere array of FN_REFLEN includes the trailing 0, somewhere array of FN_REFLEN + 1 includes trailing 0, but nowhere array of FN_REFLEN - 1 must include trailing 0. --- mysql-test/main/create_or_replace.result | 28 +++++++++++ mysql-test/main/create_or_replace.test | 22 +++++++++ .../innodb/r/foreign_key_not_windows.result | 43 +++++++++++++++++ .../innodb/t/foreign_key_not_windows.test | 47 ++++++++++++++++++- mysql-test/suite/versioning/r/foreign.result | 17 +++++++ mysql-test/suite/versioning/t/foreign.test | 6 +++ storage/innobase/dict/dict0dict.cc | 14 ++++-- storage/innobase/dict/dict0load.cc | 4 +- storage/innobase/handler/ha_innodb.cc | 21 +++++---- storage/innobase/include/sql_funcs.h | 35 ++++++++++---- storage/innobase/row/row0mysql.cc | 8 ++++ 11 files changed, 222 insertions(+), 23 deletions(-) diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index d9ca4102b069b..c243dcecb8547 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -863,3 +863,31 @@ select * from t2; a unlock tables; drop tables t2, t1; +# +# MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name +# +use test; +create table t (a int primary key) engine=innodb; +create or replace table u ( +a int primary key, +constraint c foreign key d (a) references t (a)) engine=innodb; +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +test/c test/u test/t 1 0 +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS +test/c a a 0 +create or replace table u ( +a int primary key, +constraint c foreign key d (a) references t (a)) engine=innodb; +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +test/c test/u test/t 1 0 +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS +test/c a a 0 +drop tables u, t; +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 316d904e59140..c5dc01de84fd8 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -655,3 +655,25 @@ select * from t2; unlock tables; drop tables t2, t1; + +--echo # +--echo # MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name +--echo # +use test; +create table t (a int primary key) engine=innodb; +create or replace table u ( + a int primary key, + constraint c foreign key d (a) references t (a)) engine=innodb; + +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; + +create or replace table u ( + a int primary key, + constraint c foreign key d (a) references t (a)) engine=innodb; + +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; +drop tables u, t; +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; diff --git a/mysql-test/suite/innodb/r/foreign_key_not_windows.result b/mysql-test/suite/innodb/r/foreign_key_not_windows.result index aaff06f8d6866..f7b31a140cfbe 100644 --- a/mysql-test/suite/innodb/r/foreign_key_not_windows.result +++ b/mysql-test/suite/innodb/r/foreign_key_not_windows.result @@ -6,11 +6,20 @@ CREATE DATABASE `d255`; CREATE TABLE `d255`.`d255` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; ERROR HY000: Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023/@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@ +CREATE OR REPLACE TABLE `d255`.`d255` +(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; +ERROR HY000: Long database name and identifier for object resulted in path length exceeding 511 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023/@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@ CREATE TABLE `d255`.`_##################################################` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; ERROR HY000: Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023/_@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023 +CREATE OR REPLACE TABLE `d255`.`_##################################################` +(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; +ERROR HY000: Long database name and identifier for object resulted in path length exceeding 511 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023/_@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023 CREATE TABLE `d255`.`##################################################` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; +CREATE OR REPLACE TABLE `d255`.`d245` +(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; +DROP TABLE `d255`.`d245`; # # MDEV-29258 Failing assertion for name length on RENAME TABLE # @@ -29,3 +38,37 @@ RENAME TABLE `d255`.u TO u; DROP TABLE u; DROP DATABASE `d255`; # End of 10.3 tests +# +# MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name +# +set names utf8; +create database `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎`; +use `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎`; +create table t (a int primary key) engine=innodb; +create table u ( +a int primary key, +constraint `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` foreign key d (a) references t (a)) engine=innodb; +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 @274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 @274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 1 0 +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS +@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 a a 0 +create or replace table u ( +a int primary key, +constraint `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` foreign key d (a) references t (a)) engine=innodb; +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 @274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 @274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 1 0 +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS +@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 a a 0 +show create table u; +Table Create Table +u CREATE TABLE `u` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`), + CONSTRAINT `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` FOREIGN KEY (`a`) REFERENCES `t` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +use test; +drop database `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎`; diff --git a/mysql-test/suite/innodb/t/foreign_key_not_windows.test b/mysql-test/suite/innodb/t/foreign_key_not_windows.test index e5f42a0ddab03..67e8935c66001 100644 --- a/mysql-test/suite/innodb/t/foreign_key_not_windows.test +++ b/mysql-test/suite/innodb/t/foreign_key_not_windows.test @@ -25,20 +25,43 @@ CREATE TABLE t (a INT PRIMARY KEY) ENGINE=InnoDB; # corresponding to the 51 characters below: 5*51=255. let $d255=###################################################; let $d250=##################################################; +let $d245=#####################; +# FIXME: MDEV-29258 +# let $d245=#################################################; --replace_result $d255 d255 eval CREATE DATABASE `$d255`; + --replace_result $d255 d255 --error ER_IDENT_CAUSES_TOO_LONG_PATH eval CREATE TABLE `$d255`.`$d255` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; + +--replace_result $d255 d255 +--error ER_IDENT_CAUSES_TOO_LONG_PATH +eval CREATE OR REPLACE TABLE `$d255`.`$d255` +(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; + --replace_result $d255 d255 --error ER_IDENT_CAUSES_TOO_LONG_PATH eval CREATE TABLE `$d255`.`_$d250` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; + +--replace_result $d255 d255 +--error ER_IDENT_CAUSES_TOO_LONG_PATH +eval CREATE OR REPLACE TABLE `$d255`.`_$d250` +(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; + --replace_result $d255 d255 eval CREATE TABLE `$d255`.`$d250` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; +--replace_result $d255 d255 $d245 d245 +eval CREATE OR REPLACE TABLE `$d255`.`$d245` +(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; + +--replace_result $d255 d255 $d245 d245 +eval DROP TABLE `$d255`.`$d245`; + --echo # --echo # MDEV-29258 Failing assertion for name length on RENAME TABLE --echo # @@ -53,7 +76,6 @@ eval DROP TABLE `$d255`.`$d250`; eval RENAME TABLE `$d255`.`$d245` TO `$d255`.`$d250`; --replace_result $d250 d250 $d255 d255 eval RENAME TABLE `$d255`.`$d250` TO a; ---replace_result $d255 d255 DROP TABLE a,t; --echo # @@ -75,3 +97,26 @@ DROP TABLE u; eval DROP DATABASE `$d255`; --echo # End of 10.3 tests + +--echo # +--echo # MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name +--echo # +set names utf8; +let $d= `select repeat('❎', 45)`; +let $t= `select repeat('❎', 64)`; +eval create database `$d`; +eval use `$d`; +create table t (a int primary key) engine=innodb; +eval create table u ( + a int primary key, + constraint `$t` foreign key d (a) references t (a)) engine=innodb; +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; +eval create or replace table u ( + a int primary key, + constraint `$t` foreign key d (a) references t (a)) engine=innodb; +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; +show create table u; +use test; +eval drop database `$d`; diff --git a/mysql-test/suite/versioning/r/foreign.result b/mysql-test/suite/versioning/r/foreign.result index 3c8508507fd5a..8df5a042275b4 100644 --- a/mysql-test/suite/versioning/r/foreign.result +++ b/mysql-test/suite/versioning/r/foreign.result @@ -263,6 +263,13 @@ constraint `fk_child_parent` on delete cascade on update cascade ) engine = innodb with system versioning; +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_child_parent test/child test/parent 2 5 +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_child_parent parent_id id 0 +test/fk_child_parent parent_value value 1 create or replace table subchild ( id int not null auto_increment primary key, parent_id smallint unsigned not null, @@ -272,6 +279,16 @@ constraint `fk_subchild_child_parent` on delete cascade on update cascade ) engine=innodb; +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_child_parent test/child test/parent 2 5 +test/fk_subchild_child_parent test/subchild test/child 2 5 +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_child_parent parent_id id 0 +test/fk_child_parent parent_value value 1 +test/fk_subchild_child_parent parent_id parent_id 0 +test/fk_subchild_child_parent parent_value parent_value 1 insert into parent (value) values (23); select id, value from parent into @id, @value; Warnings: diff --git a/mysql-test/suite/versioning/t/foreign.test b/mysql-test/suite/versioning/t/foreign.test index 934053f83ba70..acd6dde2e4b59 100644 --- a/mysql-test/suite/versioning/t/foreign.test +++ b/mysql-test/suite/versioning/t/foreign.test @@ -303,6 +303,9 @@ eval create or replace table child ( on update cascade ) engine = innodb with system versioning; +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; + create or replace table subchild ( id int not null auto_increment primary key, parent_id smallint unsigned not null, @@ -313,6 +316,9 @@ create or replace table subchild ( on update cascade ) engine=innodb; +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; + insert into parent (value) values (23); --enable_prepare_warnings select id, value from parent into @id, @value; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 98490ded18ff3..90c2d786eb92e 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1650,7 +1650,9 @@ dict_table_rename_in_cache( table->name.m_name); dict_mem_foreign_table_name_lookup_set(foreign, FALSE); } - if (strchr(foreign->id, '/')) { + + const bool tmp_id = (strchr(foreign->id, '\xFF') != NULL); + if (!tmp_id && strchr(foreign->id, '/')) { /* This is a >= 4.0.18 format id */ ulint db_len; @@ -1794,10 +1796,14 @@ dict_table_rename_in_cache( } table->foreign_set.erase(it); - fk_set.insert(foreign); - if (foreign->referenced_table) { - foreign->referenced_table->referenced_set.insert(foreign); + if (!tmp_id) { + fk_set.insert(foreign); + + if (foreign->referenced_table) { + foreign->referenced_table + ->referenced_set.insert(foreign); + } } } diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 2e453b56f0e96..17591752300f6 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -3089,8 +3089,8 @@ dict_load_foreigns( rec, DICT_FLD__SYS_FOREIGN_FOR_NAME__ID, &len); /* Copy the string because the page may be modified or evicted - after mtr.commit() below. */ - char fk_id[MAX_TABLE_NAME_LEN + NAME_LEN]; + after mtr.commit() below (-2 is for \xFF\xFF in tmp constraints). */ + char fk_id[MAX_TABLE_NAME_LEN + NAME_LEN - 2]; err = DB_SUCCESS; if (UNIV_LIKELY(len < sizeof fk_id)) { memcpy(fk_id, field, len); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 3d798ca2e00b5..df1b960374651 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5250,7 +5250,7 @@ normalize_table_name_c_low( db_ptr = ptr + 1; norm_len = db_len + name_len + sizeof "/"; - ut_a(norm_len < FN_REFLEN - 1); + ut_a(norm_len < FN_REFLEN); memcpy(norm_name, db_ptr, db_len); @@ -12382,6 +12382,7 @@ create_table_info_t::create_foreign_keys() if (fk->constraint_name.str) { ulint db_len; + const bool tmp= m_create_info->is_atomic_replace(); /* Catenate 'databasename/' to the constraint name specified by the user: we conceive the constraint as @@ -12391,13 +12392,17 @@ create_table_info_t::create_foreign_keys() db_len = dict_get_db_name_len(table->name.m_name); foreign->id = static_cast(mem_heap_alloc( - foreign->heap, - db_len + fk->constraint_name.length + 2)); - - memcpy(foreign->id, table->name.m_name, db_len); - foreign->id[db_len] = '/'; - strcpy(foreign->id + db_len + 1, - fk->constraint_name.str); + foreign->heap, (tmp ? 3 : 2) + + db_len + fk->constraint_name.length)); + + char *pos = foreign->id; + memcpy(pos, table->name.m_name, db_len); + pos += db_len; + *(pos++) = '/'; + if (tmp) { + *(pos++) = '\xFF'; + } + strcpy(pos, fk->constraint_name.str); } if (foreign->id == NULL) { diff --git a/storage/innobase/include/sql_funcs.h b/storage/innobase/include/sql_funcs.h index 307756196b18c..1506a2a5a4813 100644 --- a/storage/innobase/include/sql_funcs.h +++ b/storage/innobase/include/sql_funcs.h @@ -32,12 +32,15 @@ R"===(PROCEDURE RENAME_CONSTRAINT_IDS () IS gen_constr_prefix CHAR; new_db_name CHAR; foreign_id CHAR; + foreign_id2 CHAR; + constr_name CHAR; new_foreign_id CHAR; old_db_name_len INT; - old_t_name_len INT; new_db_name_len INT; id_len INT; offset INT; + offset2 INT; + constr_name_len INT; found INT; BEGIN found := 1; @@ -45,7 +48,6 @@ R"===(PROCEDURE RENAME_CONSTRAINT_IDS () IS new_db_name_len := INSTR(:new_table_name, '/') - 1; new_db_name := SUBSTR(:new_table_name, 0, new_db_name_len); - old_t_name_len := LENGTH(:old_table_name); gen_constr_prefix := CONCAT(:old_table_name_utf8, '_ibfk_'); WHILE found = 1 LOOP @@ -62,6 +64,18 @@ R"===(PROCEDURE RENAME_CONSTRAINT_IDS () IS SET FOR_NAME = :new_table_name WHERE ID = foreign_id; id_len := LENGTH(foreign_id); + foreign_id2 := foreign_id; + offset := INSTR(foreign_id, ')===" "\xFF" R"===('); + IF (SUBSTR(foreign_id, offset, 1) = ')===" "\xFF" R"===(') THEN + offset2 := offset + 1; + ELSE + offset2 := offset; + END IF; + IF (:old_is_tmp > 0 AND offset > 0) THEN + foreign_id := CONCAT(SUBSTR(foreign_id2, 0, offset - 1), + SUBSTR(foreign_id2, offset2, id_len - offset2)); + id_len := id_len - 1; + END IF; IF (INSTR(foreign_id, '/') > 0) THEN IF (INSTR(foreign_id, gen_constr_prefix) > 0) @@ -71,17 +85,22 @@ R"===(PROCEDURE RENAME_CONSTRAINT_IDS () IS CONCAT(:new_table_utf8, SUBSTR(foreign_id, offset, id_len - offset)); ELSE - new_foreign_id := - CONCAT(new_db_name, - SUBSTR(foreign_id, old_db_name_len, - id_len - old_db_name_len)); + constr_name_len := id_len - old_db_name_len; + constr_name := SUBSTR(foreign_id, old_db_name_len, + constr_name_len); + IF (:new_is_tmp > 0) THEN + new_foreign_id := CONCAT(new_db_name, ')===" "/\xFF\xFF" R"===(', + SUBSTR(constr_name, 1, constr_name_len - 1)); + ELSE + new_foreign_id := CONCAT(new_db_name, constr_name); + END IF; END IF; UPDATE SYS_FOREIGN SET ID = new_foreign_id - WHERE ID = foreign_id; + WHERE ID = foreign_id2; UPDATE SYS_FOREIGN_COLS SET ID = new_foreign_id - WHERE ID = foreign_id; + WHERE ID = foreign_id2; END IF; END IF; END LOOP; diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 5e6fb8b5488a1..d26c2bbc04101 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -2726,6 +2726,14 @@ row_rename_table_for_mysql( } pars_info_add_str_literal(info, "new_table_utf8", new_table_name); + /* Old foreign ID for temporary constraint was written like this: + db_name/\xFFconstraint_name */ + pars_info_add_int4_literal(info, "old_is_tmp", + (fk == RENAME_FK) && old_is_tmp); + /* New foreign ID for temporary constraint is written like this: + db_name/\xFF\xFFconstraint_name */ + pars_info_add_int4_literal(info, "new_is_tmp", + (fk == RENAME_FK) && new_is_tmp); err = que_eval_sql(info, rename_constraint_ids, trx); From 12c236415930c789a422b313c3bd9b9b5fe494af Mon Sep 17 00:00:00 2001 From: sawasa Date: Wed, 31 Aug 2022 22:05:02 +0900 Subject: [PATCH 021/113] MDEV-28890 Spider: remove #ifdef SPIDER_XID_USES_xid_cache_iterate Reviewed by: Nayuta Yanagisawa --- storage/spider/spd_include.h | 1 - storage/spider/spd_table.cc | 19 ---------- storage/spider/spd_trx.cc | 70 ------------------------------------ 3 files changed, 90 deletions(-) diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 897721d3c2e38..26acaaa86ec18 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -87,7 +87,6 @@ #define SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR #define SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON -#define SPIDER_XID_USES_xid_cache_iterate #define SPIDER_Item_args_arg_count_IS_PROTECTED diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 8569027f09c40..03624d475dc23 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -110,14 +110,6 @@ inline void spider_destroy_thd(MYSQL_THD thd) delete thd; } -#ifdef SPIDER_XID_USES_xid_cache_iterate -#else -#ifdef XID_CACHE_IS_SPLITTED -uint *spd_db_att_xid_cache_split_num; -#endif -pthread_mutex_t *spd_db_att_LOCK_xid_cache; -HASH *spd_db_att_xid_cache; -#endif struct charset_info_st *spd_charset_utf8mb3_bin; const char **spd_defaults_extra_file; const char **spd_defaults_file; @@ -6593,17 +6585,6 @@ int spider_db_init( #ifndef SPIDER_HAS_NEXT_THREAD_ID spd_db_att_thread_id = &thread_id; -#endif -#ifdef SPIDER_XID_USES_xid_cache_iterate -#else -#ifdef XID_CACHE_IS_SPLITTED - spd_db_att_xid_cache_split_num = &opt_xid_cache_split_num; - spd_db_att_LOCK_xid_cache = LOCK_xid_cache; - spd_db_att_xid_cache = xid_cache; -#else - spd_db_att_LOCK_xid_cache = &LOCK_xid_cache; - spd_db_att_xid_cache = &xid_cache; -#endif #endif spd_charset_utf8mb3_bin = &my_charset_utf8mb3_bin; spd_defaults_extra_file = &my_defaults_extra_file; diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index 2f5b8ca356a3e..954754ea6b5c9 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -36,14 +36,6 @@ #include "spd_ping_table.h" #include "spd_malloc.h" -#ifdef SPIDER_XID_USES_xid_cache_iterate -#else -#ifdef XID_CACHE_IS_SPLITTED -extern uint *spd_db_att_xid_cache_split_num; -#endif -extern pthread_mutex_t *spd_db_att_LOCK_xid_cache; -extern HASH *spd_db_att_xid_cache; -#endif extern struct charset_info_st *spd_charset_utf8mb3_bin; extern handlerton *spider_hton_ptr; @@ -1600,62 +1592,17 @@ static int spider_xa_lock( int error_num; const char *old_proc_info; DBUG_ENTER("spider_xa_lock"); -#ifdef SPIDER_XID_USES_xid_cache_iterate -#else - my_hash_value_type hash_value = my_calc_hash(spd_db_att_xid_cache, - (uchar*) xid_state->xid.key(), xid_state->xid.key_length()); -#ifdef XID_CACHE_IS_SPLITTED - uint idx = hash_value % *spd_db_att_xid_cache_split_num; -#endif -#endif old_proc_info = thd_proc_info(thd, "Locking xid by Spider"); -#ifdef SPIDER_XID_USES_xid_cache_iterate if (xid_cache_insert(thd, xid_state, xid)) { error_num = (spider_stmt_da_sql_errno(thd) == ER_XAER_DUPID ? ER_SPIDER_XA_LOCKED_NUM : HA_ERR_OUT_OF_MEM); goto error; } -#else -#ifdef XID_CACHE_IS_SPLITTED - pthread_mutex_lock(&spd_db_att_LOCK_xid_cache[idx]); -#else - pthread_mutex_lock(spd_db_att_LOCK_xid_cache); -#endif -#ifdef XID_CACHE_IS_SPLITTED - if (my_hash_search_using_hash_value(&spd_db_att_xid_cache[idx], hash_value, - xid_state->xid.key(), xid_state->xid.key_length())) -#else - if (my_hash_search_using_hash_value(spd_db_att_xid_cache, hash_value, - xid_state->xid.key(), xid_state->xid.key_length())) -#endif - { - error_num = ER_SPIDER_XA_LOCKED_NUM; - goto error; - } - if (my_hash_insert(spd_db_att_xid_cache, (uchar*)xid_state)) - { - error_num = HA_ERR_OUT_OF_MEM; - goto error; - } -#ifdef XID_CACHE_IS_SPLITTED - pthread_mutex_unlock(&spd_db_att_LOCK_xid_cache[idx]); -#else - pthread_mutex_unlock(spd_db_att_LOCK_xid_cache); -#endif -#endif thd_proc_info(thd, old_proc_info); DBUG_RETURN(0); error: -#ifdef SPIDER_XID_USES_xid_cache_iterate -#else -#ifdef XID_CACHE_IS_SPLITTED - pthread_mutex_unlock(&spd_db_att_LOCK_xid_cache[idx]); -#else - pthread_mutex_unlock(spd_db_att_LOCK_xid_cache); -#endif -#endif thd_proc_info(thd, old_proc_info); DBUG_RETURN(error_num); } @@ -1666,25 +1613,8 @@ static int spider_xa_unlock( THD *thd = current_thd; const char *old_proc_info; DBUG_ENTER("spider_xa_unlock"); -#ifdef SPIDER_XID_USES_xid_cache_iterate -#else -#endif old_proc_info = thd_proc_info(thd, "Unlocking xid by Spider"); -#ifdef SPIDER_XID_USES_xid_cache_iterate xid_cache_delete(thd, xid_state); -#else -#ifdef XID_CACHE_IS_SPLITTED - pthread_mutex_lock(&spd_db_att_LOCK_xid_cache[idx]); -#else - pthread_mutex_lock(spd_db_att_LOCK_xid_cache); -#endif - my_hash_delete(spd_db_att_xid_cache, (uchar *)xid_state); -#ifdef XID_CACHE_IS_SPLITTED - pthread_mutex_unlock(&spd_db_att_LOCK_xid_cache[idx]); -#else - pthread_mutex_unlock(spd_db_att_LOCK_xid_cache); -#endif -#endif thd_proc_info(thd, old_proc_info); DBUG_RETURN(0); } From 16c9718758cb3bbff76672405d4ce1bce6da6c6f Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 12 Aug 2022 19:03:12 +1000 Subject: [PATCH 022/113] MDEV-25341: innodb buffer pool soft decommit of memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When InnoDB isn't using memory its polite to other system processes to allow that memory to be used. Create buf_page_t::set_os_unused, to madvise(MADV_FREE)/ DiscardVirtualMemory innodb buffer pool pages to keep virtual mapping but allow kernel to reclaim memory. set_os_unused is called by buf_LRU_block_free_non_file_page for flushing deallocations to free up memory. set_os_used is called by buf_block_t::initialise (used by buf_page_create_low and buf_LRU_get_free_only. Move MSan (memory sanitizer) directive to be associated with set_os_{un,}used so that the correctness can be determined by instrumentation and test cases rather than relying on OS behaviour at specific times. Remove existing page information poisoning in buf_LRU_block_free_non_file_page. Tested by: Matthias Leich Reviewer: Marko Mäkelä Windows Review: Vladislav Vaintroub --- storage/innobase/buf/buf0buf.cc | 1 + storage/innobase/buf/buf0lru.cc | 11 ++--------- storage/innobase/include/buf0buf.h | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 3f5145b955642..6be891ec2cb2d 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -3091,6 +3091,7 @@ void buf_block_t::initialise(const page_id_t page_id, ulint zip_size, ut_ad(!page.in_file()); buf_block_init_low(this); page.init(fix, page_id); + page.set_os_used(); page_zip_set_size(&page.zip, zip_size); } diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 33264bc88a168..46ff350812981 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -297,7 +297,7 @@ buf_block_t* buf_LRU_get_free_only() assert_block_ahi_empty(block); block->page.set_state(buf_page_t::MEMORY); - MEM_MAKE_ADDRESSABLE(block->page.frame, srv_page_size); + block->page.set_os_used(); break; } @@ -989,13 +989,6 @@ buf_LRU_block_free_non_file_page( block->page.set_state(buf_page_t::NOT_USED); MEM_UNDEFINED(block->page.frame, srv_page_size); - /* Wipe page_no and space_id */ - static_assert(FIL_PAGE_OFFSET % 4 == 0, "alignment"); - memset_aligned<4>(block->page.frame + FIL_PAGE_OFFSET, 0xfe, 4); - static_assert(FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID % 4 == 2, - "not perfect alignment"); - memset_aligned<2>(block->page.frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, - 0xfe, 4); data = block->page.zip.data; if (data != NULL) { @@ -1024,7 +1017,7 @@ buf_LRU_block_free_non_file_page( pthread_cond_signal(&buf_pool.done_free); } - MEM_NOACCESS(block->page.frame, srv_page_size); + block->page.set_os_unused(); } /** Release a memory block to the buffer pool. */ diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 24571483d05c5..2dd6935241e32 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -657,6 +657,20 @@ class buf_page_t access_time= 0; } + void set_os_unused() + { + MEM_NOACCESS(frame, srv_page_size); +#ifdef MADV_FREE + madvise(frame, srv_page_size, MADV_FREE); +#elif defined(_WIN32) + DiscardVirtualMemory(frame, srv_page_size); +#endif + } + + void set_os_used() const + { + MEM_MAKE_ADDRESSABLE(frame, srv_page_size); + } public: const page_id_t &id() const { return id_; } uint32_t state() const { return zip.fix; } From 8f9df08f02294f4828d40ef0a298dc0e72b01f60 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 9 Sep 2022 12:02:16 +0400 Subject: [PATCH 023/113] MDEV-19246 Change database and table used for Mariabackup's history Changing the mariabackup history table from PERCONA_SCHEMA.xtrabackup_history to mysql.mariabackup_history. Additionally, extending xb_history.test for better coverage: - Recording the fact that the history table is created during "mariabackup --history" invocation when it does not exist. - Recording the history table structure (adding SHOW CREATE TABLE) - Recording how --history vs --history=foo affect the "name" column of the history table. - Recording the fact that two consequent executions of "mariabackup --history[=foo]" insert into the history table incrementally, without truncating it on every execution. --- extra/mariabackup/backup_mysql.cc | 12 +++--- extra/mariabackup/innobackupex.cc | 6 +-- extra/mariabackup/xtrabackup.cc | 6 +-- extra/mariabackup/xtrabackup.h | 2 + .../suite/mariabackup/xb_history.result | 38 +++++++++++++++++-- mysql-test/suite/mariabackup/xb_history.test | 22 +++++++++-- 6 files changed, 67 insertions(+), 19 deletions(-) diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 9a09da21d74d8..10ca894e7f9e4 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -554,7 +554,7 @@ select_incremental_lsn_from_history(lsn_t *incremental_lsn) (unsigned long)strlen(opt_incremental_history_name)); snprintf(query, sizeof(query), "SELECT innodb_to_lsn " - "FROM PERCONA_SCHEMA.xtrabackup_history " + "FROM " XB_HISTORY_TABLE " " "WHERE name = '%s' " "AND innodb_to_lsn IS NOT NULL " "ORDER BY innodb_to_lsn DESC LIMIT 1", @@ -567,7 +567,7 @@ select_incremental_lsn_from_history(lsn_t *incremental_lsn) (unsigned long)strlen(opt_incremental_history_uuid)); snprintf(query, sizeof(query), "SELECT innodb_to_lsn " - "FROM PERCONA_SCHEMA.xtrabackup_history " + "FROM " XB_HISTORY_TABLE " " "WHERE uuid = '%s' " "AND innodb_to_lsn IS NOT NULL " "ORDER BY innodb_to_lsn DESC LIMIT 1", @@ -1568,7 +1568,7 @@ operator<<(std::ostream& s, const escape_and_quote& eq) /*********************************************************************//** Writes xtrabackup_info file and if backup_history is enable creates -PERCONA_SCHEMA.xtrabackup_history and writes a new history record to the +mysql.mariabackup_history and writes a new history record to the table containing all the history info particular to the just completed backup. */ bool @@ -1668,9 +1668,7 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history, } xb_mysql_query(connection, - "CREATE DATABASE IF NOT EXISTS PERCONA_SCHEMA", false); - xb_mysql_query(connection, - "CREATE TABLE IF NOT EXISTS PERCONA_SCHEMA.xtrabackup_history(" + "CREATE TABLE IF NOT EXISTS " XB_HISTORY_TABLE "(" "uuid VARCHAR(40) NOT NULL PRIMARY KEY," "name VARCHAR(255) DEFAULT NULL," "tool_name VARCHAR(255) DEFAULT NULL," @@ -1693,7 +1691,7 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history, #define ESCAPE_BOOL(expr) ((expr)?"'Y'":"'N'") - oss << "insert into PERCONA_SCHEMA.xtrabackup_history(" + oss << "insert into " XB_HISTORY_TABLE "(" << "uuid, name, tool_name, tool_command, tool_version," << "ibbackup_version, server_version, start_time, end_time," << "lock_time, binlog_pos, innodb_from_lsn, innodb_to_lsn," diff --git a/extra/mariabackup/innobackupex.cc b/extra/mariabackup/innobackupex.cc index 20f87354fd079..b925b41552d2a 100644 --- a/extra/mariabackup/innobackupex.cc +++ b/extra/mariabackup/innobackupex.cc @@ -377,7 +377,7 @@ static struct my_option ibx_long_options[] = {"incremental-history-name", OPT_INCREMENTAL_HISTORY_NAME, "This option specifies the name of the backup series stored in the " - "PERCONA_SCHEMA.xtrabackup_history history record to base an " + XB_HISTORY_TABLE " history record to base an " "incremental backup on. Backup will search the history table " "looking for the most recent (highest innodb_to_lsn), successful " "backup in the series and take the to_lsn value to use as the " @@ -392,7 +392,7 @@ static struct my_option ibx_long_options[] = {"incremental-history-uuid", OPT_INCREMENTAL_HISTORY_UUID, "This option specifies the UUID of the specific history record " - "stored in the PERCONA_SCHEMA.xtrabackup_history to base an " + "stored in the " XB_HISTORY_TABLE " table to base an " "incremental backup on. --incremental-history-name, " "--incremental-basedir and --incremental-lsn. If no valid lsn can be " "found (no success record with that uuid), an error will be returned." @@ -417,7 +417,7 @@ static struct my_option ibx_long_options[] = {"history", OPT_HISTORY, "This option enables the tracking of backup history in the " - "PERCONA_SCHEMA.xtrabackup_history table. An optional history " + XB_HISTORY_TABLE " table. An optional history " "series name may be specified that will be placed with the history " "record for the current backup being taken.", NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 9b6a0561552cc..2d343a4dc65c7 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1352,7 +1352,7 @@ struct my_option xb_client_options[]= { {"incremental-history-name", OPT_INCREMENTAL_HISTORY_NAME, "This option specifies the name of the backup series stored in the " - "PERCONA_SCHEMA.xtrabackup_history history record to base an " + XB_HISTORY_TABLE " history record to base an " "incremental backup on. Xtrabackup will search the history table " "looking for the most recent (highest innodb_to_lsn), successful " "backup in the series and take the to_lsn value to use as the " @@ -1367,7 +1367,7 @@ struct my_option xb_client_options[]= { {"incremental-history-uuid", OPT_INCREMENTAL_HISTORY_UUID, "This option specifies the UUID of the specific history record " - "stored in the PERCONA_SCHEMA.xtrabackup_history to base an " + "stored in the " XB_HISTORY_TABLE " table to base an " "incremental backup on. --incremental-history-name, " "--incremental-basedir and --incremental-lsn. If no valid lsn can be " "found (no success record with that uuid), an error will be returned." @@ -1396,7 +1396,7 @@ struct my_option xb_client_options[]= { {"history", OPT_HISTORY, "This option enables the tracking of backup history in the " - "PERCONA_SCHEMA.xtrabackup_history table. An optional history " + XB_HISTORY_TABLE " table. An optional history " "series name may be specified that will be placed with the history " "record for the current backup being taken.", NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h index 11de9eeaf489d..3796c9ec698f4 100644 --- a/extra/mariabackup/xtrabackup.h +++ b/extra/mariabackup/xtrabackup.h @@ -27,6 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA #include "changed_page_bitmap.h" #include +#define XB_HISTORY_TABLE "mysql.mariadb_backup_history" + struct xb_delta_info_t { xb_delta_info_t(ulint page_size, ulint zip_size, uint32_t space_id) diff --git a/mysql-test/suite/mariabackup/xb_history.result b/mysql-test/suite/mariabackup/xb_history.result index b6a1ac211477b..be2d31e50121a 100644 --- a/mysql-test/suite/mariabackup/xb_history.result +++ b/mysql-test/suite/mariabackup/xb_history.result @@ -1,5 +1,37 @@ -SELECT COUNT(*) FROM PERCONA_SCHEMA.xtrabackup_history; +DROP TABLE IF EXISTS mysql.mariadb_backup_history; +SHOW CREATE TABLE mysql.mariadb_backup_history; +Table Create Table +mariadb_backup_history CREATE TABLE `mariadb_backup_history` ( + `uuid` varchar(40) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `tool_name` varchar(255) DEFAULT NULL, + `tool_command` text DEFAULT NULL, + `tool_version` varchar(255) DEFAULT NULL, + `ibbackup_version` varchar(255) DEFAULT NULL, + `server_version` varchar(255) DEFAULT NULL, + `start_time` timestamp NULL DEFAULT NULL, + `end_time` timestamp NULL DEFAULT NULL, + `lock_time` bigint(20) unsigned DEFAULT NULL, + `binlog_pos` varchar(128) DEFAULT NULL, + `innodb_from_lsn` bigint(20) unsigned DEFAULT NULL, + `innodb_to_lsn` bigint(20) unsigned DEFAULT NULL, + `partial` enum('Y','N') DEFAULT NULL, + `incremental` enum('Y','N') DEFAULT NULL, + `format` enum('file','tar','xbstream') DEFAULT NULL, + `compressed` enum('Y','N') DEFAULT NULL, + PRIMARY KEY (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +SELECT COUNT(*) FROM mysql.mariadb_backup_history; COUNT(*) 1 -DROP TABLE PERCONA_SCHEMA.xtrabackup_history; -DROP DATABASE PERCONA_SCHEMA; +SELECT name FROM mysql.mariadb_backup_history; +name +foo +SELECT COUNT(*) FROM mysql.mariadb_backup_history; +COUNT(*) +2 +SELECT name FROM mysql.mariadb_backup_history; +name +foo + +DROP TABLE mysql.mariadb_backup_history; diff --git a/mysql-test/suite/mariabackup/xb_history.test b/mysql-test/suite/mariabackup/xb_history.test index 54ec5f2e729c4..6fac8f04c8535 100644 --- a/mysql-test/suite/mariabackup/xb_history.test +++ b/mysql-test/suite/mariabackup/xb_history.test @@ -1,10 +1,26 @@ #--source include/innodb_page_size.inc +--disable_warnings +DROP TABLE IF EXISTS mysql.mariadb_backup_history; +--enable_warnings + let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; --disable_result_log exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --history=foo --backup --target-dir=$targetdir; --enable_result_log -SELECT COUNT(*) FROM PERCONA_SCHEMA.xtrabackup_history; -DROP TABLE PERCONA_SCHEMA.xtrabackup_history; -DROP DATABASE PERCONA_SCHEMA; rmdir $targetdir; + +SHOW CREATE TABLE mysql.mariadb_backup_history; +SELECT COUNT(*) FROM mysql.mariadb_backup_history; +SELECT name FROM mysql.mariadb_backup_history; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --history --backup --target-dir=$targetdir; +--enable_result_log +rmdir $targetdir; + +SELECT COUNT(*) FROM mysql.mariadb_backup_history; +SELECT name FROM mysql.mariadb_backup_history; + +DROP TABLE mysql.mariadb_backup_history; From 47dccace135f1353386f681aafabcd2d65ef9d56 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 21 Sep 2022 19:16:33 +0300 Subject: [PATCH 024/113] MDEV-29596 Separate SUPER and READ ONLY ADMIN privileges The benefit of this is that one can remove the READ ONLY ADMIN privilege from all users and this way ensure that no one can do any changes on any non-temporary tables. This is good option to use on slaves when one wants to ensure that the slave is kept identical to the master. --- mysql-test/main/grant_read_only.result | 8 +++++++- mysql-test/main/grant_read_only.test | 8 +++++++- mysql-test/main/mysqld--help.result | 2 +- sql/privilege.h | 4 ++-- sql/sys_vars.cc | 3 ++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/mysql-test/main/grant_read_only.result b/mysql-test/main/grant_read_only.result index 185325f03a697..e7855dc941164 100644 --- a/mysql-test/main/grant_read_only.result +++ b/mysql-test/main/grant_read_only.result @@ -46,7 +46,7 @@ SET @@GLOBAL.read_only=0; DROP USER user1@localhost; DROP TABLE t1; # -# Test that @@read_only is ignored with SUPER +# Test that @@read_only is not ignored with SUPER # CREATE TABLE t1 (a INT); CREATE USER user1@localhost IDENTIFIED BY ''; @@ -61,7 +61,13 @@ SELECT @@read_only; @@read_only 1 UPDATE t1 SET a=11 WHERE a=10; +ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement DELETE FROM t1 WHERE a=11; +ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement +connection default; +grant read only admin on *.* to user1@localhost; +disconnect con1; +connect con1,localhost,user1,,; INSERT INTO t1 VALUES (20); disconnect con1; connection default; diff --git a/mysql-test/main/grant_read_only.test b/mysql-test/main/grant_read_only.test index 25ffa3767ba32..a951987fa7f30 100644 --- a/mysql-test/main/grant_read_only.test +++ b/mysql-test/main/grant_read_only.test @@ -55,7 +55,7 @@ DROP TABLE t1; --echo # ---echo # Test that @@read_only is ignored with SUPER +--echo # Test that @@read_only is not ignored with SUPER --echo # CREATE TABLE t1 (a INT); @@ -68,8 +68,14 @@ SET @@GLOBAL.read_only=1; connect (con1,localhost,user1,,); connection con1; SELECT @@read_only; +--error ER_OPTION_PREVENTS_STATEMENT UPDATE t1 SET a=11 WHERE a=10; +--error ER_OPTION_PREVENTS_STATEMENT DELETE FROM t1 WHERE a=11; +connection default; +grant read only admin on *.* to user1@localhost; +disconnect con1; +connect (con1,localhost,user1,,); INSERT INTO t1 VALUES (20); disconnect con1; diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index c92c1cd3cd225..4053f75e35f31 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -1003,7 +1003,7 @@ The following specify which files/extra groups are read (specified before remain value --read-only Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with - the SUPER privilege + the 'READ ONLY ADMIN' privilege --read-rnd-buffer-size=# When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks diff --git a/sql/privilege.h b/sql/privilege.h index 5bcf34a14fe38..57bbc95840e86 100644 --- a/sql/privilege.h +++ b/sql/privilege.h @@ -390,10 +390,10 @@ constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_SYNC_BINLOG= /* Privileges related to --read-only */ // Was super prior to 10.5.2 -constexpr privilege_t PRIV_IGNORE_READ_ONLY= READ_ONLY_ADMIN_ACL | SUPER_ACL; +constexpr privilege_t PRIV_IGNORE_READ_ONLY= READ_ONLY_ADMIN_ACL; // Was super prior to 10.5.2 constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_READ_ONLY= - READ_ONLY_ADMIN_ACL | SUPER_ACL; + READ_ONLY_ADMIN_ACL; /* Privileges related to connection handling. diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index f82727c4349ef..63f4268c89d0d 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3030,7 +3030,8 @@ static Sys_var_on_access_global Date: Thu, 22 Sep 2022 00:06:30 +0200 Subject: [PATCH 025/113] read_only failures --- .../suite/sys_vars/r/read_only_func.result | 2 +- .../suite/sys_vars/r/read_only_grant.result | 19 +++---------------- .../sys_vars/r/sysvars_server_embedded.result | 2 +- .../r/sysvars_server_notembedded.result | 2 +- .../suite/sys_vars/t/read_only_grant.test | 19 ++----------------- 5 files changed, 8 insertions(+), 36 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/read_only_func.result b/mysql-test/suite/sys_vars/r/read_only_func.result index e93f280dbb578..88a7b33420467 100644 --- a/mysql-test/suite/sys_vars/r/read_only_func.result +++ b/mysql-test/suite/sys_vars/r/read_only_func.result @@ -20,7 +20,7 @@ id name CREATE user sameea; CONNECT connn,localhost,sameea,,; SET Global read_ONLY=ON; -ERROR 42000: Access denied; you need (at least one of) the SUPER, READ_ONLY ADMIN privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the READ_ONLY ADMIN privilege(s) for this operation CREATE TABLE t2 ( id INT NOT NULL auto_increment, diff --git a/mysql-test/suite/sys_vars/r/read_only_grant.result b/mysql-test/suite/sys_vars/r/read_only_grant.result index 8884546e92d64..81554183c1312 100644 --- a/mysql-test/suite/sys_vars/r/read_only_grant.result +++ b/mysql-test/suite/sys_vars/r/read_only_grant.result @@ -1,14 +1,14 @@ # # MDEV-21960 Bind READ_ONLY ADMIN to @@read_only # -# Test that "SET read_only" is not allowed without READ_ONLY ADMIN or SUPER +# Test that "SET read_only" is not allowed without READ_ONLY ADMIN CREATE USER user1@localhost; GRANT ALL PRIVILEGES ON *.* TO user1@localhost; -REVOKE READ_ONLY ADMIN, SUPER ON *.* FROM user1@localhost; +REVOKE READ_ONLY ADMIN ON *.* FROM user1@localhost; connect user1,localhost,user1,,; connection user1; SET GLOBAL read_only=0; -ERROR 42000: Access denied; you need (at least one of) the SUPER, READ_ONLY ADMIN privilege(s) for this operation +ERROR 42000: Access denied; you need (at least one of) the READ_ONLY ADMIN privilege(s) for this operation SET read_only=0; ERROR HY000: Variable 'read_only' is a GLOBAL variable and should be set with SET GLOBAL SET SESSION read_only=0; @@ -29,16 +29,3 @@ ERROR HY000: Variable 'read_only' is a GLOBAL variable and should be set with SE disconnect user1; connection default; DROP USER user1@localhost; -# Test that "SET read_only" is allowed with SUPER -CREATE USER user1@localhost; -GRANT SUPER ON *.* TO user1@localhost; -connect user1,localhost,user1,,; -connection user1; -SET GLOBAL read_only=0; -SET read_only=0; -ERROR HY000: Variable 'read_only' is a GLOBAL variable and should be set with SET GLOBAL -SET SESSION read_only=0; -ERROR HY000: Variable 'read_only' is a GLOBAL variable and should be set with SET GLOBAL -disconnect user1; -connection default; -DROP USER user1@localhost; 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 6d0d147a9db67..157c50a78c700 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -3015,7 +3015,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME READ_ONLY VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege +VARIABLE_COMMENT Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the 'READ ONLY ADMIN' privilege NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE 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 1b4e49f55be96..fc006a0013e32 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -3195,7 +3195,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME READ_ONLY VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege +VARIABLE_COMMENT Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the 'READ ONLY ADMIN' privilege NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/mysql-test/suite/sys_vars/t/read_only_grant.test b/mysql-test/suite/sys_vars/t/read_only_grant.test index d6abef93aed50..ccdd0f4636200 100644 --- a/mysql-test/suite/sys_vars/t/read_only_grant.test +++ b/mysql-test/suite/sys_vars/t/read_only_grant.test @@ -4,11 +4,11 @@ --echo # MDEV-21960 Bind READ_ONLY ADMIN to @@read_only --echo # ---echo # Test that "SET read_only" is not allowed without READ_ONLY ADMIN or SUPER +--echo # Test that "SET read_only" is not allowed without READ_ONLY ADMIN CREATE USER user1@localhost; GRANT ALL PRIVILEGES ON *.* TO user1@localhost; -REVOKE READ_ONLY ADMIN, SUPER ON *.* FROM user1@localhost; +REVOKE READ_ONLY ADMIN ON *.* FROM user1@localhost; --connect(user1,localhost,user1,,) --connection user1 --error ER_SPECIFIC_ACCESS_DENIED_ERROR @@ -35,18 +35,3 @@ SET SESSION read_only=0; --disconnect user1 --connection default DROP USER user1@localhost; - ---echo # Test that "SET read_only" is allowed with SUPER - -CREATE USER user1@localhost; -GRANT SUPER ON *.* TO user1@localhost; ---connect(user1,localhost,user1,,) ---connection user1 -SET GLOBAL read_only=0; ---error ER_GLOBAL_VARIABLE -SET read_only=0; ---error ER_GLOBAL_VARIABLE -SET SESSION read_only=0; ---disconnect user1 ---connection default -DROP USER user1@localhost; From 07581249e925c7bbb8562a91a8284b0bd48c4660 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 26 Sep 2022 20:26:29 +0200 Subject: [PATCH 026/113] MDEV-29632 SUPER users created before 10.11 should retain READ_ONLY ADMIN privilege upon upgrade --- mysql-test/suite/sys_vars/r/read_only_grant.result | 9 +++++++++ mysql-test/suite/sys_vars/t/read_only_grant.test | 8 ++++++++ sql/sql_acl.cc | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/mysql-test/suite/sys_vars/r/read_only_grant.result b/mysql-test/suite/sys_vars/r/read_only_grant.result index 81554183c1312..455390eb4fce9 100644 --- a/mysql-test/suite/sys_vars/r/read_only_grant.result +++ b/mysql-test/suite/sys_vars/r/read_only_grant.result @@ -29,3 +29,12 @@ ERROR HY000: Variable 'read_only' is a GLOBAL variable and should be set with SE disconnect user1; connection default; DROP USER user1@localhost; +# +# MDEV-29632 SUPER users created before 10.11 should retain READ_ONLY ADMIN privilege upon upgrade +# +insert mysql.global_priv values ('bar', 'foo', '{"access":32768,"version_id":101000,"plugin":"mysql_native_password","authentication_string":""}'); +flush privileges; +show grants for foo@bar; +Grants for foo@bar +GRANT SUPER, READ_ONLY ADMIN ON *.* TO `foo`@`bar` +drop user foo@bar; diff --git a/mysql-test/suite/sys_vars/t/read_only_grant.test b/mysql-test/suite/sys_vars/t/read_only_grant.test index ccdd0f4636200..9e82f30c9259c 100644 --- a/mysql-test/suite/sys_vars/t/read_only_grant.test +++ b/mysql-test/suite/sys_vars/t/read_only_grant.test @@ -35,3 +35,11 @@ SET SESSION read_only=0; --disconnect user1 --connection default DROP USER user1@localhost; + +--echo # +--echo # MDEV-29632 SUPER users created before 10.11 should retain READ_ONLY ADMIN privilege upon upgrade +--echo # +insert mysql.global_priv values ('bar', 'foo', '{"access":32768,"version_id":101000,"plugin":"mysql_native_password","authentication_string":""}'); +flush privileges; +show grants for foo@bar; +drop user foo@bar; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 32cb77f7db4ed..4e9e642d9d926 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1532,6 +1532,11 @@ class User_table_json: public User_table { privilege_t mask= ALL_KNOWN_ACL_100304; ulonglong orig_access= access; + if (version_id < 101100) + { + if (access & SUPER_ACL) + access|= READ_ONLY_ADMIN_ACL; + } if (version_id >= 100509) { mask= ALL_KNOWN_ACL_100509; From 336dbe55f3efb01eb2110e56b9e1e75c3b21c106 Mon Sep 17 00:00:00 2001 From: Lena Startseva Date: Wed, 28 Sep 2022 16:07:21 +0700 Subject: [PATCH 027/113] MDEV-27691: make working view-protocol Update tests for version 10.11 --- mysql-test/main/create_or_replace.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index e38067b4f531c..933f72e82387d 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -648,6 +648,7 @@ drop tables t2, t1; --echo # --echo # Atomic CREATE OR REPLACE part: --echo # +--disable_service_connection create table t1 (pk int primary key) engine=innodb; create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; @@ -659,6 +660,7 @@ select * from t2; unlock tables; drop tables t2, t1; +--enable_service_connection --echo # --echo # MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name From dcd66c3814991e686615eac2e65d01a7fa80cb66 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Fri, 16 Sep 2022 20:30:08 +0300 Subject: [PATCH 028/113] MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables Usually when we get into finalize_locked_tables() with error m_locked_tables_count was not decremented. m_locked_tables_count is decremented when we drop the original table and if we failed that m_locked_tables_count is expected intact. The bug comes from the fact that finalize_atomic_replace() violates the above contract. It does HA_EXTRA_PREPARE_FOR_DROP and decrements m_locked_tables_count. Then it tries rename_table_and_triggers() and fails. With decremented m_locked_tables_count reopen_tables() does nothing and we don't get new value for pos_in_locked_tables->table. The test case demonstrates ER_ERROR_ON_RENAME where non-atomic CREATE OR REPLACE would not fail. The original RENAME TABLE fails under such broken environment, so nothing is wrong with atomic CREATE OR REPLACE failing there too. --- mysql-test/main/create_or_replace.result | 21 +++++++++++++++++++++ mysql-test/main/create_or_replace.test | 20 ++++++++++++++++++++ sql/sql_table.cc | 15 ++++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index d3b3a8d4f36fb..31a3d5494724f 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -891,3 +891,24 @@ select * from information_schema.innodb_sys_foreign; ID FOR_NAME REF_NAME N_COLS TYPE select * from information_schema.innodb_sys_foreign_cols; ID FOR_COL_NAME REF_COL_NAME POS +# +# MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables +# +call mtr.add_suppression("mysql.innodb_index_stats"); +set sql_mode= ''; +create table t (x int) engine innodb; +insert into t values (77); +alter table mysql.innodb_index_stats modify stat_description char(10); +Warnings: +Warning 1265 Data truncated for column 'stat_description' at row 2 +Warning 1265 Data truncated for column 'stat_description' at row 3 +lock table t write; +create or replace table t (y int); +ERROR HY000: Error on rename of './test/t' to './test/#sql-backup-t' (errno: 168 "Unknown (generic) error from engine") +unlock tables; +alter table mysql.innodb_index_stats modify stat_description varchar(1024) not null; +select * from t; +x +77 +drop table t; +set sql_mode= default; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index c5dc01de84fd8..205355911e8e4 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -677,3 +677,23 @@ select * from information_schema.innodb_sys_foreign_cols; drop tables u, t; select * from information_schema.innodb_sys_foreign; select * from information_schema.innodb_sys_foreign_cols; + +--echo # +--echo # MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables +--echo # +call mtr.add_suppression("mysql.innodb_index_stats"); +set sql_mode= ''; +create table t (x int) engine innodb; +insert into t values (77); +alter table mysql.innodb_index_stats modify stat_description char(10); +lock table t write; +--replace_regex /#sql-backup-.+-.+-/#sql-backup-/ +--replace_result $MYSQLD_DATADIR ./ +--error ER_ERROR_ON_RENAME +create or replace table t (y int); +# cleanup +unlock tables; +alter table mysql.innodb_index_stats modify stat_description varchar(1024) not null; +select * from t; +drop table t; +set sql_mode= default; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 13168e9cec8d9..de71432a355dd 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4398,6 +4398,7 @@ bool HA_CREATE_INFO::finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table) LEX_CSTRING cpath; char path[FN_REFLEN + 1]; cpath.str= path; + bool locked_tables_decremented= false; DBUG_ASSERT(is_atomic_replace()); @@ -4435,11 +4436,15 @@ bool HA_CREATE_INFO::finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table) DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_EXCLUSIVE)); - + /* + HA_EXTRA_PREPARE_FOR_DROP: after CREATE OR REPLACE table + must be not locked, removing it from thd->locked_tables_list. + */ close_all_tables_for_name(thd, table->s, HA_EXTRA_PREPARE_FOR_DROP, NULL); table= NULL; orig_table->table= NULL; + locked_tables_decremented= true; } param.rename_flags= FN_TO_IS_TMP; @@ -4450,7 +4455,11 @@ bool HA_CREATE_INFO::finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table) param.new_alias= backup_name.table_name; if (rename_table_and_triggers(thd, ¶m, NULL, orig_table, &backup_name.db, false, &dummy)) + { + if (locked_tables_decremented) + thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); return true; + } debug_crash_here("ddl_log_create_after_save_backup"); } @@ -4465,7 +4474,11 @@ bool HA_CREATE_INFO::finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table) &cpath, &db, &table_name, false) || rename_table_and_triggers(thd, ¶m, NULL, &tmp_name, &db, false, &dummy)) + { + if (locked_tables_decremented) + thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); return true; + } debug_crash_here("ddl_log_create_after_install_new"); return false; } From cb583b2f1bf1c910e82c7caee4a53e0f3ff954ba Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Fri, 23 Sep 2022 01:09:46 +0300 Subject: [PATCH 029/113] MDEV-29609 create_not_windows test fails with different result make_tmp_name() creates temporary name with prefix containing PID and TID. This prefix influences max length of the rest of the name (the whole name is limited by NAME_LEN). During the test run PID and TID can change. PID increases when the server restarts. TID is incremented with the new connections (generated by next_thread_id(), is not the posix thread ID). During the test run PID can increase max 2 decimal positions: from tens to thousands this requires ~900 restarts. TID depends on connection count, but for test we assume it will not trespass 100000 connections which is 5 decimal positions. So it should be enough to reserve 7 characters for PID and TID increment. The patch reserves more: it reserves 12 characters for 7-decimal PID and 5-decimal TID plus 4 chars of additional reserve (for future prefix changes) and assumes minimal legth of the prefix is 30 bytes: #sql-backup-PID-TID- #sql-create-PID-TID- 4-6-PID-TID- is 10 + 4 + PID + TID, so PID + TID is 16 chars (7 + 5 + 4). --- mysql-test/main/create_not_windows.result | 12 ++++++------ sql/sql_table.cc | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mysql-test/main/create_not_windows.result b/mysql-test/main/create_not_windows.result index 3ab2d56bf1788..43860c2fdca85 100644 --- a/mysql-test/main/create_not_windows.result +++ b/mysql-test/main/create_not_windows.result @@ -57,11 +57,11 @@ tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ set @@debug_dbug="+d,ddl_log_create_after_save_backup", @debug_crash_counter=1; create or replace table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (z int); ERROR HY000: Lost connection to server during query -#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD -#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI -#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm -#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD -#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI -#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm +#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD +#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI +#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm +#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD +#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI +#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm drop table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎; set @@debug_dbug=""; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index de71432a355dd..23dab5056c381 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1251,13 +1251,19 @@ bool make_tmp_name(THD *thd, const char *prefix, const Table_name *orig, char res_name[NAME_LEN + 1]; char file_name[NAME_LEN + 1]; LEX_CSTRING table_name; + /* + Filename trimming should not depend on prefix length with variable PID and + thread ID. This makes tests happier. + */ + constexpr int MIN_PREFIX= 30; size_t len= my_snprintf(res_name, sizeof(res_name) - 1, tmp_file_prefix "-%s-%lx-%llx-", prefix, current_pid, thd->thread_id); + const size_t pfx_len= len < MIN_PREFIX ? MIN_PREFIX : len; uint len2= tablename_to_filename(orig->table_name.str, file_name, - sizeof(res_name) - len - 1); + sizeof(res_name) - pfx_len - 1); DBUG_ASSERT(len + len2 < sizeof(res_name) - 1); memcpy(res_name + len, file_name, len2 + 1); From c579d66ba689c8a20a951de5e6be2e1bc255ba7f Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Sun, 25 Sep 2022 00:08:35 +0300 Subject: [PATCH 030/113] MDEV-29628 Memory leak after CREATE OR REPLACE with foreign key MDEV-28933 added a condition to avoid keeping cached foreign keys when renaming into temporary table. Such foreign keys must be freed. --- storage/innobase/dict/dict0dict.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 90c2d786eb92e..59daa6396a304 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1804,6 +1804,8 @@ dict_table_rename_in_cache( foreign->referenced_table ->referenced_set.insert(foreign); } + } else { + dict_foreign_free(foreign); } } From aa08a7442a5141750de96353132c7799e10c9302 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Tue, 27 Sep 2022 13:44:30 +0300 Subject: [PATCH 031/113] MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock ha_release_auto_increment() must be done before F_UNLCK. Non-atomic case is handled by select_insert::binlog_query(). --- mysql-test/main/create_or_replace.result | 5 +++++ mysql-test/main/create_or_replace.test | 6 ++++++ sql/sql_insert.cc | 2 ++ 3 files changed, 13 insertions(+) diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index 31a3d5494724f..7dd930ff0487b 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -912,3 +912,8 @@ x 77 drop table t; set sql_mode= default; +# +# MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock +# +create or replace table t1 (i serial) as select * from (values(1), (2)) dt; +drop table t1; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 205355911e8e4..83fc1688e232d 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -697,3 +697,9 @@ alter table mysql.innodb_index_stats modify stat_description varchar(1024) not n select * from t; drop table t; set sql_mode= default; + +--echo # +--echo # MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock +--echo # +create or replace table t1 (i serial) as select * from (values(1), (2)) dt; +drop table t1; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 163dd45f50c1e..e2ec0507cddb9 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4289,6 +4289,8 @@ bool select_insert::prepare_eof() { DBUG_ASSERT(table->s->tmp_table); + table->file->ha_release_auto_increment(); + /* Note: InnoDB does autocommit on external unlock. We cannot do commit twice and we must commit after binlog From ba875e939619baefb08936863a889830f595e426 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Fri, 30 Sep 2022 23:58:08 +0300 Subject: [PATCH 032/113] MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection When ha_end_bulk_insert() fails F_UNLCK was done twice: in select_insert::prepare_eof() and in select_create::abort_result_set(). Now we avoid making F_UNLCK in prepare_eof() if error is non-zero. --- ...or_replace2.result => create_replace_debug.result} | 10 ++++++++++ ...ate_or_replace2.test => create_replace_debug.test} | 11 +++++++++++ sql/handler.cc | 5 +++++ sql/sql_insert.cc | 5 ++++- storage/innobase/handler/ha_innodb.cc | 1 + 5 files changed, 31 insertions(+), 1 deletion(-) rename mysql-test/main/{create_or_replace2.result => create_replace_debug.result} (90%) rename mysql-test/main/{create_or_replace2.test => create_replace_debug.test} (88%) diff --git a/mysql-test/main/create_or_replace2.result b/mysql-test/main/create_replace_debug.result similarity index 90% rename from mysql-test/main/create_or_replace2.result rename to mysql-test/main/create_replace_debug.result index 248d5dbc3f59d..3a3ef21bdecea 100644 --- a/mysql-test/main/create_or_replace2.result +++ b/mysql-test/main/create_replace_debug.result @@ -91,3 +91,13 @@ ERROR HY000: Table 't2' was not locked with LOCK TABLES unlock tables; drop tables t1; set @@debug_dbug= @saved_debug_dbug; +# +# MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection +# +create table t1 (x int); +set @old_dbug= @@debug_dbug; +set @@debug_dbug= '+d,ha_end_bulk_insert_fail'; +create or replace table t2 (y int) engine innodb select * from t1; +ERROR HY000: Out of memory. +set @@debug_dbug= @old_dbug; +drop table t1; diff --git a/mysql-test/main/create_or_replace2.test b/mysql-test/main/create_replace_debug.test similarity index 88% rename from mysql-test/main/create_or_replace2.test rename to mysql-test/main/create_replace_debug.test index bd82d13f1d1ae..86e68c4774318 100644 --- a/mysql-test/main/create_or_replace2.test +++ b/mysql-test/main/create_replace_debug.test @@ -86,3 +86,14 @@ unlock tables; drop tables t1; set @@debug_dbug= @saved_debug_dbug; + +--echo # +--echo # MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection +--echo # +create table t1 (x int); +set @old_dbug= @@debug_dbug; +set @@debug_dbug= '+d,ha_end_bulk_insert_fail'; +--error ER_OUT_OF_RESOURCES +create or replace table t2 (y int) engine innodb select * from t1; +set @@debug_dbug= @old_dbug; +drop table t1; diff --git a/sql/handler.cc b/sql/handler.cc index 4d7c2eb228ff0..477f1b7f8c29a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5030,6 +5030,11 @@ int handler::ha_end_bulk_insert() DBUG_ENTER("handler::ha_end_bulk_insert"); DBUG_EXECUTE_IF("crash_end_bulk_insert", { extra(HA_EXTRA_FLUSH) ; DBUG_SUICIDE();}); + if (DBUG_IF("ha_end_bulk_insert_fail")) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } estimation_rows_to_insert= 0; DBUG_RETURN(end_bulk_insert()); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e2ec0507cddb9..c850bdbe34f02 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4285,7 +4285,7 @@ bool select_insert::prepare_eof() table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); - if (atomic_replace) + if (atomic_replace && !error) { DBUG_ASSERT(table->s->tmp_table); @@ -5490,7 +5490,10 @@ void select_create::abort_result_set() if (atomic_replace) { + ulonglong save_options_bits= thd->variables.option_bits; + thd->variables.option_bits|= OPTION_NOT_AUTOCOMMIT; (void) table->file->ha_external_lock(thd, F_UNLCK); + thd->variables.option_bits= save_options_bits; (void) thd->drop_temporary_table(table, NULL, true); } else diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index b0a70a5cb6c69..9cc9ed0438584 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -16172,6 +16172,7 @@ ha_innobase::external_lock( /* MySQL is releasing a table lock */ + ut_ad(trx->n_mysql_tables_in_use); trx->n_mysql_tables_in_use--; m_mysql_has_locked = false; From 315f2e8b81100de8f0a91363e785c9f9cff5d4f2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 26 Sep 2022 17:52:30 +0200 Subject: [PATCH 033/113] cleanup: remove *slow*_basic tests --- .../log_slow_disabled_statements_basic.result | 72 -------- .../sys_vars/r/log_slow_filter_basic.result | 100 ---------- .../sys_vars/r/log_slow_queries_basic.result | 132 -------------- .../r/log_slow_rate_limit_basic.result | 47 ----- .../r/log_slow_verbosity_basic.result | 86 --------- .../sys_vars/r/slow_launch_time_basic.result | 129 ------------- .../sys_vars/r/slow_query_log_basic.result | 96 ---------- .../r/slow_query_log_file_basic.result | 28 --- .../t/log_slow_disabled_statements_basic.test | 57 ------ .../sys_vars/t/log_slow_filter_basic.test | 71 -------- .../sys_vars/t/log_slow_rate_limit_basic.test | 42 ----- .../sys_vars/t/log_slow_verbosity_basic.test | 67 ------- .../sys_vars/t/slow_launch_time_basic.test | 172 ------------------ .../sys_vars/t/slow_query_log_basic.test | 167 ----------------- .../t/slow_query_log_file_basic-master.opt | 1 - .../sys_vars/t/slow_query_log_file_basic.test | 86 --------- 16 files changed, 1353 deletions(-) delete mode 100644 mysql-test/suite/sys_vars/r/log_slow_disabled_statements_basic.result delete mode 100644 mysql-test/suite/sys_vars/r/log_slow_filter_basic.result delete mode 100644 mysql-test/suite/sys_vars/r/log_slow_queries_basic.result delete mode 100644 mysql-test/suite/sys_vars/r/log_slow_rate_limit_basic.result delete mode 100644 mysql-test/suite/sys_vars/r/log_slow_verbosity_basic.result delete mode 100644 mysql-test/suite/sys_vars/r/slow_launch_time_basic.result delete mode 100644 mysql-test/suite/sys_vars/r/slow_query_log_basic.result delete mode 100644 mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result delete mode 100644 mysql-test/suite/sys_vars/t/log_slow_disabled_statements_basic.test delete mode 100644 mysql-test/suite/sys_vars/t/log_slow_filter_basic.test delete mode 100644 mysql-test/suite/sys_vars/t/log_slow_rate_limit_basic.test delete mode 100644 mysql-test/suite/sys_vars/t/log_slow_verbosity_basic.test delete mode 100644 mysql-test/suite/sys_vars/t/slow_launch_time_basic.test delete mode 100644 mysql-test/suite/sys_vars/t/slow_query_log_basic.test delete mode 100644 mysql-test/suite/sys_vars/t/slow_query_log_file_basic-master.opt delete mode 100644 mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test diff --git a/mysql-test/suite/sys_vars/r/log_slow_disabled_statements_basic.result b/mysql-test/suite/sys_vars/r/log_slow_disabled_statements_basic.result deleted file mode 100644 index 7ef4931a288ad..0000000000000 --- a/mysql-test/suite/sys_vars/r/log_slow_disabled_statements_basic.result +++ /dev/null @@ -1,72 +0,0 @@ -SET @start_global_value = @@global.log_slow_disabled_statements; -select @@global.log_slow_disabled_statements; -@@global.log_slow_disabled_statements -sp -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -sp -show global variables like 'log_slow_disabled_statements'; -Variable_name Value -log_slow_disabled_statements sp -show session variables like 'log_slow_disabled_statements'; -Variable_name Value -log_slow_disabled_statements sp -select * from information_schema.global_variables where variable_name='log_slow_disabled_statements'; -VARIABLE_NAME VARIABLE_VALUE -LOG_SLOW_DISABLED_STATEMENTS sp -select * from information_schema.session_variables where variable_name='log_slow_disabled_statements'; -VARIABLE_NAME VARIABLE_VALUE -LOG_SLOW_DISABLED_STATEMENTS sp -set global log_slow_disabled_statements=1; -select @@global.log_slow_disabled_statements; -@@global.log_slow_disabled_statements -admin -set session log_slow_disabled_statements=1; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -admin -set session log_slow_disabled_statements=1; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -admin -set session log_slow_disabled_statements=2; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -call -set session log_slow_disabled_statements=5; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -admin,slave -set session log_slow_disabled_statements='admin'; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -admin -set session log_slow_disabled_statements='slave'; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -slave -set session log_slow_disabled_statements='call'; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -call -set session log_slow_disabled_statements='sp'; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -sp -set session log_slow_disabled_statements='admin,sp,call,slave'; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements -admin,call,slave,sp -set session log_slow_disabled_statements=''; -select @@session.log_slow_disabled_statements; -@@session.log_slow_disabled_statements - -set session log_slow_disabled_statements=1.1; -ERROR 42000: Incorrect argument type to variable 'log_slow_disabled_statements' -set session log_slow_disabled_statements=1e1; -ERROR 42000: Incorrect argument type to variable 'log_slow_disabled_statements' -set session log_slow_disabled_statements="foo"; -ERROR 42000: Variable 'log_slow_disabled_statements' can't be set to the value of 'foo' -set session log_slow_disabled_statements=1024; -ERROR 42000: Variable 'log_slow_disabled_statements' can't be set to the value of '1024' -SET @@global.log_slow_disabled_statements = @start_global_value; diff --git a/mysql-test/suite/sys_vars/r/log_slow_filter_basic.result b/mysql-test/suite/sys_vars/r/log_slow_filter_basic.result deleted file mode 100644 index 93558fb6dd909..0000000000000 --- a/mysql-test/suite/sys_vars/r/log_slow_filter_basic.result +++ /dev/null @@ -1,100 +0,0 @@ -SET @start_global_value = @@global.log_slow_filter; -select @@global.log_slow_filter; -@@global.log_slow_filter -admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk -select @@session.log_slow_filter; -@@session.log_slow_filter -admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk -show global variables like 'log_slow_filter'; -Variable_name Value -log_slow_filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk -show session variables like 'log_slow_filter'; -Variable_name Value -log_slow_filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk -select * from information_schema.global_variables where variable_name='log_slow_filter'; -VARIABLE_NAME VARIABLE_VALUE -LOG_SLOW_FILTER admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk -select * from information_schema.session_variables where variable_name='log_slow_filter'; -VARIABLE_NAME VARIABLE_VALUE -LOG_SLOW_FILTER admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk -set global log_slow_filter=1; -select @@global.log_slow_filter; -@@global.log_slow_filter -admin -set session log_slow_filter=1; -select @@session.log_slow_filter; -@@session.log_slow_filter -admin -set session log_slow_filter=1; -select @@session.log_slow_filter; -@@session.log_slow_filter -admin -set session log_slow_filter=2; -select @@session.log_slow_filter; -@@session.log_slow_filter -filesort -set session log_slow_filter=5; -select @@session.log_slow_filter; -@@session.log_slow_filter -admin,filesort_on_disk -set session log_slow_filter='admin'; -select @@session.log_slow_filter; -@@session.log_slow_filter -admin -set session log_slow_filter='filesort'; -select @@session.log_slow_filter; -@@session.log_slow_filter -filesort -set session log_slow_filter='filesort_on_disk'; -select @@session.log_slow_filter; -@@session.log_slow_filter -filesort_on_disk -set session log_slow_filter='full_join'; -select @@session.log_slow_filter; -@@session.log_slow_filter -full_join -set session log_slow_filter='full_scan'; -select @@session.log_slow_filter; -@@session.log_slow_filter -full_scan -set session log_slow_filter='not_using_index'; -select @@session.log_slow_filter; -@@session.log_slow_filter -not_using_index -set session log_slow_filter='query_cache'; -select @@session.log_slow_filter; -@@session.log_slow_filter -query_cache -set session log_slow_filter='query_cache_miss'; -select @@session.log_slow_filter; -@@session.log_slow_filter -query_cache_miss -set session log_slow_filter='tmp_table'; -select @@session.log_slow_filter; -@@session.log_slow_filter -tmp_table -set session log_slow_filter='tmp_table_on_disk'; -select @@session.log_slow_filter; -@@session.log_slow_filter -tmp_table_on_disk -set session log_slow_filter='filesort,query_cache'; -select @@session.log_slow_filter; -@@session.log_slow_filter -filesort,query_cache -set session log_slow_filter='admin,not_using_index,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk'; -select @@session.log_slow_filter; -@@session.log_slow_filter -admin,filesort,filesort_on_disk,full_join,full_scan,not_using_index,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk -set session log_slow_filter=''; -select @@session.log_slow_filter; -@@session.log_slow_filter - -set session log_slow_filter=1.1; -ERROR 42000: Incorrect argument type to variable 'log_slow_filter' -set session log_slow_filter=1e1; -ERROR 42000: Incorrect argument type to variable 'log_slow_filter' -set session log_slow_filter="foo"; -ERROR 42000: Variable 'log_slow_filter' can't be set to the value of 'foo' -set session log_slow_filter=16384; -ERROR 42000: Variable 'log_slow_filter' can't be set to the value of '16384' -SET @@global.log_slow_filter = @start_global_value; diff --git a/mysql-test/suite/sys_vars/r/log_slow_queries_basic.result b/mysql-test/suite/sys_vars/r/log_slow_queries_basic.result deleted file mode 100644 index 2c47106ecb351..0000000000000 --- a/mysql-test/suite/sys_vars/r/log_slow_queries_basic.result +++ /dev/null @@ -1,132 +0,0 @@ -SET @start_value = @@global.log_slow_queries; -SELECT @start_value; -@start_value -1 -'#---------------------FN_DYNVARS_004_01-------------------------#' -SET @@global.log_slow_queries = DEFAULT; -Warnings: -Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead -SELECT @@global.log_slow_queries = 0; -@@global.log_slow_queries = 0 -1 -'#--------------------FN_DYNVARS_004_02------------------------#' -SET @@global.log_slow_queries = ON; -Warnings: -Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead -SELECT @@global.log_slow_queries; -@@global.log_slow_queries -1 -SET @@global.log_slow_queries = OFF; -Warnings: -Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead -SELECT @@global.log_slow_queries; -@@global.log_slow_queries -0 -'#--------------------FN_DYNVARS_004_03-------------------------#' -SET @@global.log_slow_queries = 2; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of '2' -SET @@global.log_slow_queries = -1; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of '-1' -SET @@global.log_slow_queries = TRUEF; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of 'TRUEF' -SET @@global.log_slow_queries = TRUE_F; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of 'TRUE_F' -SET @@global.log_slow_queries = FALSE0; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of 'FALSE0' -SET @@global.log_slow_queries = OON; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of 'OON' -SET @@global.log_slow_queries = ONN; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of 'ONN' -SET @@global.log_slow_queries = OOFF; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of 'OOFF' -SET @@global.log_slow_queries = 0FF; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of '0FF' -SET @@global.log_slow_queries = ' '; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of ' ' -SET @@global.log_slow_queries = " "; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of ' ' -SET @@global.log_slow_queries = ''; -ERROR 42000: Variable 'log_slow_queries' can't be set to the value of '' -'#-------------------FN_DYNVARS_004_04----------------------------#' -SET @@session.log_slow_queries = OFF; -ERROR HY000: Variable 'log_slow_queries' is a GLOBAL variable and should be set with SET GLOBAL -SELECT @@session.log_slow_queries; -ERROR HY000: Variable 'log_slow_queries' is a GLOBAL variable -'#----------------------FN_DYNVARS_004_05------------------------#' -SELECT IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='log_slow_queries'; -IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -1 -'#---------------------FN_DYNVARS_004_06----------------------#' -SET @@global.log_slow_queries = 0; -Warnings: -Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead -SELECT @@global.log_slow_queries; -@@global.log_slow_queries -0 -SELECT IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='log_slow_queries'; -IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -1 -SET @@global.log_slow_queries = 1; -Warnings: -Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead -SELECT @@global.log_slow_queries; -@@global.log_slow_queries -1 -SELECT IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='log_slow_queries'; -IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -1 -'#---------------------FN_DYNVARS_004_07----------------------#' -SET @@global.log_slow_queries = TRUE; -Warnings: -Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead -SELECT @@global.log_slow_queries; -@@global.log_slow_queries -1 -SELECT IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='log_slow_queries'; -IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -1 -SET @@global.log_slow_queries = FALSE; -Warnings: -Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead -SELECT @@global.log_slow_queries; -@@global.log_slow_queries -0 -SELECT IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='log_slow_queries'; -IF(@@global.log_slow_queries, "ON", "OFF") = VARIABLE_VALUE -1 -'#---------------------FN_DYNVARS_004_08----------------------#' -SET @@global.log_slow_queries = ON; -Warnings: -Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead -SELECT @@log_slow_queries = @@global.log_slow_queries; -@@log_slow_queries = @@global.log_slow_queries -1 -'#---------------------FN_DYNVARS_004_09----------------------#' -SET log_slow_queries = ON; -ERROR HY000: Variable 'log_slow_queries' is a GLOBAL variable and should be set with SET GLOBAL -SET local.log_slow_queries = OFF; -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 'log_slow_queries = OFF' at line 1 -SELECT local.log_slow_queries; -ERROR 42S02: Unknown table 'local' in field list -SET global.log_slow_queries = ON; -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 'log_slow_queries = ON' at line 1 -SELECT global.log_slow_queries; -ERROR 42S02: Unknown table 'global' in field list -SELECT log_slow_queries = @@session.log_slow_queries; -ERROR 42S22: Unknown column 'log_slow_queries' in 'field list' -SET @@global.log_slow_queries = @start_value; -Warnings: -Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead -SELECT @@global.log_slow_queries; -@@global.log_slow_queries -1 diff --git a/mysql-test/suite/sys_vars/r/log_slow_rate_limit_basic.result b/mysql-test/suite/sys_vars/r/log_slow_rate_limit_basic.result deleted file mode 100644 index 707c4f2a05809..0000000000000 --- a/mysql-test/suite/sys_vars/r/log_slow_rate_limit_basic.result +++ /dev/null @@ -1,47 +0,0 @@ -SET @start_global_value = @@global.log_slow_rate_limit; -select @@global.log_slow_rate_limit; -@@global.log_slow_rate_limit -1 -select @@session.log_slow_rate_limit; -@@session.log_slow_rate_limit -1 -show global variables like 'log_slow_rate_limit'; -Variable_name Value -log_slow_rate_limit 1 -show session variables like 'log_slow_rate_limit'; -Variable_name Value -log_slow_rate_limit 1 -select * from information_schema.global_variables where variable_name='log_slow_rate_limit'; -VARIABLE_NAME VARIABLE_VALUE -LOG_SLOW_RATE_LIMIT 1 -select * from information_schema.session_variables where variable_name='log_slow_rate_limit'; -VARIABLE_NAME VARIABLE_VALUE -LOG_SLOW_RATE_LIMIT 1 -set global log_slow_rate_limit=10; -select @@global.log_slow_rate_limit; -@@global.log_slow_rate_limit -10 -set session log_slow_rate_limit=10; -select @@session.log_slow_rate_limit; -@@session.log_slow_rate_limit -10 -set global log_slow_rate_limit=1.1; -ERROR 42000: Incorrect argument type to variable 'log_slow_rate_limit' -set session log_slow_rate_limit=1e1; -ERROR 42000: Incorrect argument type to variable 'log_slow_rate_limit' -set global log_slow_rate_limit="foo"; -ERROR 42000: Incorrect argument type to variable 'log_slow_rate_limit' -set global log_slow_rate_limit=0; -Warnings: -Warning 1292 Truncated incorrect log_slow_rate_limit value: '0' -select @@global.log_slow_rate_limit; -@@global.log_slow_rate_limit -1 -set session log_slow_rate_limit=cast(-1 as unsigned int); -Warnings: -Note 1105 Cast to unsigned converted negative integer to it's positive complement -Warning 1292 Truncated incorrect log_slow_rate_limit value: '18446744073709551615' -select @@session.log_slow_rate_limit; -@@session.log_slow_rate_limit -4294967295 -SET @@global.log_slow_rate_limit = @start_global_value; diff --git a/mysql-test/suite/sys_vars/r/log_slow_verbosity_basic.result b/mysql-test/suite/sys_vars/r/log_slow_verbosity_basic.result deleted file mode 100644 index 8b5b06ee4b7b5..0000000000000 --- a/mysql-test/suite/sys_vars/r/log_slow_verbosity_basic.result +++ /dev/null @@ -1,86 +0,0 @@ -SET @start_global_value = @@global.log_slow_verbosity; -select @@global.log_slow_verbosity = @@session.log_slow_verbosity; -@@global.log_slow_verbosity = @@session.log_slow_verbosity -1 -SET @@global.log_slow_verbosity="",@@session.log_slow_verbosity=""; -show global variables like 'log_slow_verbosity'; -Variable_name Value -log_slow_verbosity -show session variables like 'log_slow_verbosity'; -Variable_name Value -log_slow_verbosity -select * from information_schema.global_variables where variable_name='log_slow_verbosity'; -VARIABLE_NAME VARIABLE_VALUE -LOG_SLOW_VERBOSITY -select * from information_schema.session_variables where variable_name='log_slow_verbosity'; -VARIABLE_NAME VARIABLE_VALUE -LOG_SLOW_VERBOSITY -set global log_slow_verbosity=1; -select @@global.log_slow_verbosity; -@@global.log_slow_verbosity -innodb -set session log_slow_verbosity=1; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -innodb -set session log_slow_verbosity=1; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -innodb -set session log_slow_verbosity=2; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -query_plan -set session log_slow_verbosity=3; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -innodb,query_plan -set session log_slow_verbosity=4; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -explain -set session log_slow_verbosity=5; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -innodb,explain -set session log_slow_verbosity=6; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -query_plan,explain -set session log_slow_verbosity=7; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -innodb,query_plan,explain -set session log_slow_verbosity='innodb'; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -innodb -set session log_slow_verbosity='query_plan'; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -query_plan -set session log_slow_verbosity='innodb,query_plan'; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -innodb,query_plan -set session log_slow_verbosity='explain'; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -explain -set session log_slow_verbosity='innodb,query_plan,explain'; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity -innodb,query_plan,explain -set session log_slow_verbosity=''; -select @@session.log_slow_verbosity; -@@session.log_slow_verbosity - -set session log_slow_verbosity=1.1; -ERROR 42000: Incorrect argument type to variable 'log_slow_verbosity' -set session log_slow_verbosity=1e1; -ERROR 42000: Incorrect argument type to variable 'log_slow_verbosity' -set session log_slow_verbosity="foo"; -ERROR 42000: Variable 'log_slow_verbosity' can't be set to the value of 'foo' -set session log_slow_verbosity=8; -ERROR 42000: Variable 'log_slow_verbosity' can't be set to the value of '8' -SET @@global.log_slow_verbosity = @start_global_value; diff --git a/mysql-test/suite/sys_vars/r/slow_launch_time_basic.result b/mysql-test/suite/sys_vars/r/slow_launch_time_basic.result deleted file mode 100644 index 3acd29b0c6210..0000000000000 --- a/mysql-test/suite/sys_vars/r/slow_launch_time_basic.result +++ /dev/null @@ -1,129 +0,0 @@ -SET @start_value = @@global.slow_launch_time; -SELECT @start_value; -@start_value -2 -'#--------------------FN_DYNVARS_150_01------------------------#' -SET @@global.slow_launch_time = 99; -SET @@global.slow_launch_time = DEFAULT; -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -2 -'#---------------------FN_DYNVARS_150_02-------------------------#' -SET @@global.slow_launch_time = @start_value; -SELECT @@global.slow_launch_time = 2; -@@global.slow_launch_time = 2 -1 -'#--------------------FN_DYNVARS_150_03------------------------#' -SET @@global.slow_launch_time = 0; -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -0 -SET @@global.slow_launch_time = 1; -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -1 -SET @@global.slow_launch_time = 31536000; -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -31536000 -SET @@global.slow_launch_time = 31535999; -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -31535999 -SET @@global.slow_launch_time = 65536; -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -65536 -'#--------------------FN_DYNVARS_150_04-------------------------#' -SET @@global.slow_launch_time = -1; -Warnings: -Warning 1292 Truncated incorrect slow_launch_time value: '-1' -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -0 -SET @@global.slow_launch_time = 31536001; -Warnings: -Warning 1292 Truncated incorrect slow_launch_time value: '31536001' -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -31536000 -SET @@global.slow_launch_time = 10240022115; -Warnings: -Warning 1292 Truncated incorrect slow_launch_time value: '10240022115' -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -31536000 -SET @@global.slow_launch_time = 10000.01; -ERROR 42000: Incorrect argument type to variable 'slow_launch_time' -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -31536000 -SET @@global.slow_launch_time = -1024; -Warnings: -Warning 1292 Truncated incorrect slow_launch_time value: '-1024' -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -0 -SET @@global.slow_launch_time = 42949672950; -Warnings: -Warning 1292 Truncated incorrect slow_launch_time value: '42949672950' -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -31536000 -SET @@global.slow_launch_time = ON; -ERROR 42000: Incorrect argument type to variable 'slow_launch_time' -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -31536000 -SET @@global.slow_launch_time = 'test'; -ERROR 42000: Incorrect argument type to variable 'slow_launch_time' -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -31536000 -'#-------------------FN_DYNVARS_150_05----------------------------#' -SET @@session.slow_launch_time = 0; -ERROR HY000: Variable 'slow_launch_time' is a GLOBAL variable and should be set with SET GLOBAL -SELECT @@slow_launch_time; -@@slow_launch_time -31536000 -'#----------------------FN_DYNVARS_150_06------------------------#' -SELECT @@global.slow_launch_time = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='slow_launch_time'; -@@global.slow_launch_time = VARIABLE_VALUE -1 -SELECT @@slow_launch_time = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES -WHERE VARIABLE_NAME='slow_launch_time'; -@@slow_launch_time = VARIABLE_VALUE -1 -'#---------------------FN_DYNVARS_150_07----------------------#' -SET @@global.slow_launch_time = TRUE; -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -1 -SET @@global.slow_launch_time = FALSE; -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -0 -'#---------------------FN_DYNVARS_150_08----------------------#' -SET @@global.slow_launch_time = 1; -SELECT @@slow_launch_time = @@global.slow_launch_time; -@@slow_launch_time = @@global.slow_launch_time -1 -'#---------------------FN_DYNVARS_150_09----------------------#' -SET slow_launch_time = 1; -ERROR HY000: Variable 'slow_launch_time' is a GLOBAL variable and should be set with SET GLOBAL -SELECT @@slow_launch_time; -@@slow_launch_time -1 -SELECT local.slow_launch_time; -ERROR 42S02: Unknown table 'local' in field list -SELECT global.slow_launch_time; -ERROR 42S02: Unknown table 'global' in field list -SELECT slow_launch_time = @@session.slow_launch_time; -ERROR 42S22: Unknown column 'slow_launch_time' in 'field list' -SET @@global.slow_launch_time = @start_value; -SELECT @@global.slow_launch_time; -@@global.slow_launch_time -2 diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_basic.result b/mysql-test/suite/sys_vars/r/slow_query_log_basic.result deleted file mode 100644 index 17dfdeea3f3f9..0000000000000 --- a/mysql-test/suite/sys_vars/r/slow_query_log_basic.result +++ /dev/null @@ -1,96 +0,0 @@ -SET @start_value = @@global.slow_query_log; -SELECT @start_value; -@start_value -1 -'#---------------------FN_DYNVARS_004_01-------------------------#' -SET @@global.slow_query_log = DEFAULT; -SELECT @@global.slow_query_log = 0; -@@global.slow_query_log = 0 -1 -'#--------------------FN_DYNVARS_004_02------------------------#' -SET @@global.slow_query_log = ON; -SELECT @@global.slow_query_log; -@@global.slow_query_log -1 -SET @@global.slow_query_log = OFF; -SELECT @@global.slow_query_log; -@@global.slow_query_log -0 -'#--------------------FN_DYNVARS_004_03-------------------------#' -SET @@global.slow_query_log = 2; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of '2' -SET @@global.slow_query_log = -1; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of '-1' -SET @@global.slow_query_log = TRUEF; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of 'TRUEF' -SET @@global.slow_query_log = TRUE_F; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of 'TRUE_F' -SET @@global.slow_query_log = FALSE0; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of 'FALSE0' -SET @@global.slow_query_log = OON; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of 'OON' -SET @@global.slow_query_log = ONN; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of 'ONN' -SET @@global.slow_query_log = OOFF; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of 'OOFF' -SET @@global.slow_query_log = 0FF; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of '0FF' -SET @@global.slow_query_log = ' '; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of ' ' -SET @@global.slow_query_log = " "; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of ' ' -SET @@global.slow_query_log = ''; -ERROR 42000: Variable 'slow_query_log' can't be set to the value of '' -'#-------------------FN_DYNVARS_004_04----------------------------#' -SET @@global.slow_query_log = ON; -SET @@session.slow_query_log = ON; -SELECT @@session.slow_query_log; -@@session.slow_query_log -1 -SET @@session.slow_query_log = OFF; -SELECT @@session.slow_query_log; -@@session.slow_query_log -0 -SET @@global.slow_query_log = OFF; -SET @@session.slow_query_log = ON; -'#----------------------FN_DYNVARS_004_05------------------------#' -SELECT IF(@@global.slow_query_log, "ON", "OFF") = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='slow_query_log'; -IF(@@global.slow_query_log, "ON", "OFF") = VARIABLE_VALUE -1 -'#---------------------FN_DYNVARS_004_06----------------------#' -SET @@global.slow_query_log = 0; -SELECT @@global.slow_query_log; -@@global.slow_query_log -0 -SET @@global.slow_query_log = 1; -SELECT @@global.slow_query_log; -@@global.slow_query_log -1 -'#---------------------FN_DYNVARS_004_07----------------------#' -SET @@global.slow_query_log = TRUE; -SELECT @@global.slow_query_log; -@@global.slow_query_log -1 -SET @@global.slow_query_log = FALSE; -SELECT @@global.slow_query_log; -@@global.slow_query_log -0 -'#---------------------FN_DYNVARS_004_08----------------------#' -SET @@global.slow_query_log = ON; -SET @@local.slow_query_log = OFF; -SELECT @@slow_query_log = @@global.slow_query_log; -@@slow_query_log = @@global.slow_query_log -0 -'#---------------------FN_DYNVARS_004_09----------------------#' -SELECT local.slow_query_log; -ERROR 42S02: Unknown table 'local' in field list -SELECT global.slow_query_log; -ERROR 42S02: Unknown table 'global' in field list -SELECT slow_query_log = @@session.slow_query_log; -ERROR 42S22: Unknown column 'slow_query_log' in 'field list' -SET @@global.slow_query_log = @start_value; -SELECT @@global.slow_query_log; -@@global.slow_query_log -1 diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result b/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result deleted file mode 100644 index 47bc780c96ac3..0000000000000 --- a/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result +++ /dev/null @@ -1,28 +0,0 @@ -SET @start_value = @@global.slow_query_log_file; -'#---------------------FN_DYNVARS_004_01-------------------------#' -SET @@global.slow_query_log_file = DEFAULT; -SELECT length(@@global.slow_query_log_file) > 0; -length(@@global.slow_query_log_file) > 0 -1 -'#--------------------FN_DYNVARS_004_02------------------------#' -SET @@global.slow_query_log_file = mytest.log; -ERROR 42000: Incorrect argument type to variable 'slow_query_log_file' -SET @@global.slow_query_log_file = 12; -ERROR 42000: Incorrect argument type to variable 'slow_query_log_file' -SET @@global.slow_query_log_file = 'my.cnf'; -ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'my.cnf' -SET @@global.slow_query_log_file = '/tmp/my.cnf'; -ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/tmp/my.cnf' -SET @@global.general_log_file = '.my.cnf'; -ERROR 42000: Variable 'general_log_file' can't be set to the value of '.my.cnf' -SET @@global.general_log_file = 'my.cnf\0foo'; -ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.cnf\0000foo' -SET @@global.general_log_file = 'my.ini'; -ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.ini' -'#----------------------FN_DYNVARS_004_03------------------------#' -SELECT @@global.slow_query_log_file = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='slow_query_log_file'; -@@global.slow_query_log_file = VARIABLE_VALUE -1 -SET @@global.slow_query_log_file= @start_value; diff --git a/mysql-test/suite/sys_vars/t/log_slow_disabled_statements_basic.test b/mysql-test/suite/sys_vars/t/log_slow_disabled_statements_basic.test deleted file mode 100644 index 77391df6b3c63..0000000000000 --- a/mysql-test/suite/sys_vars/t/log_slow_disabled_statements_basic.test +++ /dev/null @@ -1,57 +0,0 @@ -# set session - -SET @start_global_value = @@global.log_slow_disabled_statements; - -# -# exists as global only -# -select @@global.log_slow_disabled_statements; -select @@session.log_slow_disabled_statements; -show global variables like 'log_slow_disabled_statements'; -show session variables like 'log_slow_disabled_statements'; -select * from information_schema.global_variables where variable_name='log_slow_disabled_statements'; -select * from information_schema.session_variables where variable_name='log_slow_disabled_statements'; - -# -# show that it's writable -# -set global log_slow_disabled_statements=1; -select @@global.log_slow_disabled_statements; -set session log_slow_disabled_statements=1; -select @@session.log_slow_disabled_statements; - -# -# all valid values -# -set session log_slow_disabled_statements=1; -select @@session.log_slow_disabled_statements; -set session log_slow_disabled_statements=2; -select @@session.log_slow_disabled_statements; -set session log_slow_disabled_statements=5; -select @@session.log_slow_disabled_statements; -set session log_slow_disabled_statements='admin'; -select @@session.log_slow_disabled_statements; -set session log_slow_disabled_statements='slave'; -select @@session.log_slow_disabled_statements; -set session log_slow_disabled_statements='call'; -select @@session.log_slow_disabled_statements; -set session log_slow_disabled_statements='sp'; -select @@session.log_slow_disabled_statements; -set session log_slow_disabled_statements='admin,sp,call,slave'; -select @@session.log_slow_disabled_statements; -set session log_slow_disabled_statements=''; -select @@session.log_slow_disabled_statements; - -# -# incorrect types/values -# ---error ER_WRONG_TYPE_FOR_VAR -set session log_slow_disabled_statements=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set session log_slow_disabled_statements=1e1; ---error ER_WRONG_VALUE_FOR_VAR -set session log_slow_disabled_statements="foo"; ---error ER_WRONG_VALUE_FOR_VAR -set session log_slow_disabled_statements=1024; - -SET @@global.log_slow_disabled_statements = @start_global_value; diff --git a/mysql-test/suite/sys_vars/t/log_slow_filter_basic.test b/mysql-test/suite/sys_vars/t/log_slow_filter_basic.test deleted file mode 100644 index 5309456b3ef21..0000000000000 --- a/mysql-test/suite/sys_vars/t/log_slow_filter_basic.test +++ /dev/null @@ -1,71 +0,0 @@ -# set session - -SET @start_global_value = @@global.log_slow_filter; - -# -# exists as global only -# -select @@global.log_slow_filter; -select @@session.log_slow_filter; -show global variables like 'log_slow_filter'; -show session variables like 'log_slow_filter'; -select * from information_schema.global_variables where variable_name='log_slow_filter'; -select * from information_schema.session_variables where variable_name='log_slow_filter'; - -# -# show that it's writable -# -set global log_slow_filter=1; -select @@global.log_slow_filter; -set session log_slow_filter=1; -select @@session.log_slow_filter; - -# -# all valid values -# -set session log_slow_filter=1; -select @@session.log_slow_filter; -set session log_slow_filter=2; -select @@session.log_slow_filter; -set session log_slow_filter=5; -select @@session.log_slow_filter; -set session log_slow_filter='admin'; -select @@session.log_slow_filter; -set session log_slow_filter='filesort'; -select @@session.log_slow_filter; -set session log_slow_filter='filesort_on_disk'; -select @@session.log_slow_filter; -set session log_slow_filter='full_join'; -select @@session.log_slow_filter; -set session log_slow_filter='full_scan'; -select @@session.log_slow_filter; -set session log_slow_filter='not_using_index'; -select @@session.log_slow_filter; -set session log_slow_filter='query_cache'; -select @@session.log_slow_filter; -set session log_slow_filter='query_cache_miss'; -select @@session.log_slow_filter; -set session log_slow_filter='tmp_table'; -select @@session.log_slow_filter; -set session log_slow_filter='tmp_table_on_disk'; -select @@session.log_slow_filter; -set session log_slow_filter='filesort,query_cache'; -select @@session.log_slow_filter; -set session log_slow_filter='admin,not_using_index,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk'; -select @@session.log_slow_filter; -set session log_slow_filter=''; -select @@session.log_slow_filter; - -# -# incorrect types/values -# ---error ER_WRONG_TYPE_FOR_VAR -set session log_slow_filter=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set session log_slow_filter=1e1; ---error ER_WRONG_VALUE_FOR_VAR -set session log_slow_filter="foo"; ---error ER_WRONG_VALUE_FOR_VAR -set session log_slow_filter=16384; - -SET @@global.log_slow_filter = @start_global_value; diff --git a/mysql-test/suite/sys_vars/t/log_slow_rate_limit_basic.test b/mysql-test/suite/sys_vars/t/log_slow_rate_limit_basic.test deleted file mode 100644 index bb90b29e5f425..0000000000000 --- a/mysql-test/suite/sys_vars/t/log_slow_rate_limit_basic.test +++ /dev/null @@ -1,42 +0,0 @@ -# ulong session - -SET @start_global_value = @@global.log_slow_rate_limit; - -# -# exists as global only -# -select @@global.log_slow_rate_limit; -select @@session.log_slow_rate_limit; -show global variables like 'log_slow_rate_limit'; -show session variables like 'log_slow_rate_limit'; -select * from information_schema.global_variables where variable_name='log_slow_rate_limit'; -select * from information_schema.session_variables where variable_name='log_slow_rate_limit'; - -# -# show that it's writable -# -set global log_slow_rate_limit=10; -select @@global.log_slow_rate_limit; -set session log_slow_rate_limit=10; -select @@session.log_slow_rate_limit; - -# -# incorrect types -# ---error ER_WRONG_TYPE_FOR_VAR -set global log_slow_rate_limit=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set session log_slow_rate_limit=1e1; ---error ER_WRONG_TYPE_FOR_VAR -set global log_slow_rate_limit="foo"; - -# -# min/max values, block size -# -set global log_slow_rate_limit=0; -select @@global.log_slow_rate_limit; -set session log_slow_rate_limit=cast(-1 as unsigned int); -select @@session.log_slow_rate_limit; - -SET @@global.log_slow_rate_limit = @start_global_value; - diff --git a/mysql-test/suite/sys_vars/t/log_slow_verbosity_basic.test b/mysql-test/suite/sys_vars/t/log_slow_verbosity_basic.test deleted file mode 100644 index 9f1cf6351a0d0..0000000000000 --- a/mysql-test/suite/sys_vars/t/log_slow_verbosity_basic.test +++ /dev/null @@ -1,67 +0,0 @@ -# set session - -SET @start_global_value = @@global.log_slow_verbosity; -select @@global.log_slow_verbosity = @@session.log_slow_verbosity; -SET @@global.log_slow_verbosity="",@@session.log_slow_verbosity=""; - -# -# exists as global only -# -show global variables like 'log_slow_verbosity'; -show session variables like 'log_slow_verbosity'; -select * from information_schema.global_variables where variable_name='log_slow_verbosity'; -select * from information_schema.session_variables where variable_name='log_slow_verbosity'; - -# -# show that it's writable -# -set global log_slow_verbosity=1; -select @@global.log_slow_verbosity; -set session log_slow_verbosity=1; -select @@session.log_slow_verbosity; - -# -# all valid values -# -set session log_slow_verbosity=1; -select @@session.log_slow_verbosity; -set session log_slow_verbosity=2; -select @@session.log_slow_verbosity; -set session log_slow_verbosity=3; -select @@session.log_slow_verbosity; -set session log_slow_verbosity=4; -select @@session.log_slow_verbosity; -set session log_slow_verbosity=5; -select @@session.log_slow_verbosity; -set session log_slow_verbosity=6; -select @@session.log_slow_verbosity; -set session log_slow_verbosity=7; -select @@session.log_slow_verbosity; - - -set session log_slow_verbosity='innodb'; -select @@session.log_slow_verbosity; -set session log_slow_verbosity='query_plan'; -select @@session.log_slow_verbosity; -set session log_slow_verbosity='innodb,query_plan'; -select @@session.log_slow_verbosity; -set session log_slow_verbosity='explain'; -select @@session.log_slow_verbosity; -set session log_slow_verbosity='innodb,query_plan,explain'; -select @@session.log_slow_verbosity; -set session log_slow_verbosity=''; -select @@session.log_slow_verbosity; - -# -# incorrect types/values -# ---error ER_WRONG_TYPE_FOR_VAR -set session log_slow_verbosity=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set session log_slow_verbosity=1e1; ---error ER_WRONG_VALUE_FOR_VAR -set session log_slow_verbosity="foo"; ---error ER_WRONG_VALUE_FOR_VAR -set session log_slow_verbosity=8; - -SET @@global.log_slow_verbosity = @start_global_value; diff --git a/mysql-test/suite/sys_vars/t/slow_launch_time_basic.test b/mysql-test/suite/sys_vars/t/slow_launch_time_basic.test deleted file mode 100644 index 71b251855498f..0000000000000 --- a/mysql-test/suite/sys_vars/t/slow_launch_time_basic.test +++ /dev/null @@ -1,172 +0,0 @@ -############## mysql-test\t\slow_launch_time_basic.test ############### -# # -# Variable Name: slow_launch_time # -# Scope: GLOBAL # -# Access Type: Dynamic # -# Data Type: numeric # -# Default Value: 2 # -# Range: - # -# # -# # -# Creation Date: 2008-02-07 # -# Author: Salman # -# # -# Description: Test Cases of Dynamic System Variable slow_launch_time # -# that checks the behavior of this variable in the following ways# -# * Default Value # -# * Valid & Invalid values # -# * Scope & Access method # -# * Data Integrity # -# # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html # -# # -############################################################################### - ---source include/load_sysvars.inc -######################################################################## -# START OF slow_launch_time TESTS # -######################################################################## - - -######################################################################## -# Saving initial value of slow_launch_time in a temporary variable # -######################################################################## - -SET @start_value = @@global.slow_launch_time; -SELECT @start_value; - - ---echo '#--------------------FN_DYNVARS_150_01------------------------#' -######################################################################## -# Display the DEFAULT value of slow_launch_time # -######################################################################## - -SET @@global.slow_launch_time = 99; -SET @@global.slow_launch_time = DEFAULT; -SELECT @@global.slow_launch_time; - - ---echo '#---------------------FN_DYNVARS_150_02-------------------------#' -############################################### -# Verify default value of variable # -############################################### - -SET @@global.slow_launch_time = @start_value; -SELECT @@global.slow_launch_time = 2; - - ---echo '#--------------------FN_DYNVARS_150_03------------------------#' -######################################################################## -# Change the value of slow_launch_time to a valid value # -######################################################################## - -SET @@global.slow_launch_time = 0; -SELECT @@global.slow_launch_time; -SET @@global.slow_launch_time = 1; -SELECT @@global.slow_launch_time; -SET @@global.slow_launch_time = 31536000; -SELECT @@global.slow_launch_time; -SET @@global.slow_launch_time = 31535999; -SELECT @@global.slow_launch_time; -SET @@global.slow_launch_time = 65536; -SELECT @@global.slow_launch_time; - ---echo '#--------------------FN_DYNVARS_150_04-------------------------#' -########################################################################### -# Change the value of slow_launch_time to invalid value # -########################################################################### - -SET @@global.slow_launch_time = -1; -SELECT @@global.slow_launch_time; -SET @@global.slow_launch_time = 31536001; -SELECT @@global.slow_launch_time; -SET @@global.slow_launch_time = 10240022115; -SELECT @@global.slow_launch_time; ---Error ER_WRONG_TYPE_FOR_VAR -SET @@global.slow_launch_time = 10000.01; -SELECT @@global.slow_launch_time; -SET @@global.slow_launch_time = -1024; -SELECT @@global.slow_launch_time; -SET @@global.slow_launch_time = 42949672950; -SELECT @@global.slow_launch_time; - ---Error ER_WRONG_TYPE_FOR_VAR -SET @@global.slow_launch_time = ON; -SELECT @@global.slow_launch_time; ---Error ER_WRONG_TYPE_FOR_VAR -SET @@global.slow_launch_time = 'test'; -SELECT @@global.slow_launch_time; - - ---echo '#-------------------FN_DYNVARS_150_05----------------------------#' -########################################################################### -# Test if accessing session slow_launch_time gives error # -########################################################################### - ---Error ER_GLOBAL_VARIABLE -SET @@session.slow_launch_time = 0; -SELECT @@slow_launch_time; - - ---echo '#----------------------FN_DYNVARS_150_06------------------------#' -############################################################################## -# Check if the value in GLOBAL & SESSION Tables matches values in variable # -############################################################################## - -SELECT @@global.slow_launch_time = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='slow_launch_time'; - -SELECT @@slow_launch_time = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES -WHERE VARIABLE_NAME='slow_launch_time'; - - ---echo '#---------------------FN_DYNVARS_150_07----------------------#' -################################################################### -# Check if TRUE and FALSE values can be used on variable # -################################################################### - -SET @@global.slow_launch_time = TRUE; -SELECT @@global.slow_launch_time; -SET @@global.slow_launch_time = FALSE; -SELECT @@global.slow_launch_time; - - ---echo '#---------------------FN_DYNVARS_150_08----------------------#' -######################################################################################################## -# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable # -######################################################################################################## - -SET @@global.slow_launch_time = 1; -SELECT @@slow_launch_time = @@global.slow_launch_time; - - ---echo '#---------------------FN_DYNVARS_150_09----------------------#' -########################################################################## -# Check if slow_launch_time can be accessed with and without @@ sign # -########################################################################## - ---Error ER_GLOBAL_VARIABLE -SET slow_launch_time = 1; -SELECT @@slow_launch_time; ---Error ER_UNKNOWN_TABLE -SELECT local.slow_launch_time; ---Error ER_UNKNOWN_TABLE -SELECT global.slow_launch_time; ---Error ER_BAD_FIELD_ERROR -SELECT slow_launch_time = @@session.slow_launch_time; - - -############################## -# Restore initial value # -############################## - -SET @@global.slow_launch_time = @start_value; -SELECT @@global.slow_launch_time; - - -######################################################################## -# END OF slow_launch_time TESTS # -######################################################################## diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_basic.test b/mysql-test/suite/sys_vars/t/slow_query_log_basic.test deleted file mode 100644 index 3d58902ab8d03..0000000000000 --- a/mysql-test/suite/sys_vars/t/slow_query_log_basic.test +++ /dev/null @@ -1,167 +0,0 @@ -##################### mysql-test\t\slow_query_log_basic.test ################### -# # -# Variable Name: slow_query_log # -# Scope: GLOBAL # -# Access Type: Dynamic # -# Data Type: BOOLEAN # -# Default Value: OFF # -# Valid Values: ON, OFF # -# # -# # -# Creation Date: 2008-03-16 # -# Author: Salman Rawala # -# # -# Description: Test Cases of Dynamic System Variable "slow_query_log" # -# that checks behavior of this variable in the following ways # -# * Default Value # -# * Valid & Invalid values # -# * Scope & Access method # -# * Data Integrity # -# # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-options.html#option_mysqld_event-scheduler # -# # -################################################################################ - ---source include/load_sysvars.inc - -########################################################### -# START OF slow_query_log TESTS # -########################################################### - - -###################################################################### -# Saving initial value of slow_query_log in a temporary variable # -###################################################################### - -SET @start_value = @@global.slow_query_log; -SELECT @start_value; - - ---echo '#---------------------FN_DYNVARS_004_01-------------------------#' -############################################### -# Verify default value of variable # -############################################### - -SET @@global.slow_query_log = DEFAULT; -SELECT @@global.slow_query_log = 0; - - ---echo '#--------------------FN_DYNVARS_004_02------------------------#' -###################################################################### -# Change the value of slow_query_log to a valid value # -###################################################################### - -SET @@global.slow_query_log = ON; -SELECT @@global.slow_query_log; -SET @@global.slow_query_log = OFF; -SELECT @@global.slow_query_log; - ---echo '#--------------------FN_DYNVARS_004_03-------------------------#' -###################################################################### -# Change the value of slow_query_log to invalid value # -###################################################################### - ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = 2; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = -1; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = TRUEF; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = TRUE_F; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = FALSE0; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = OON; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = ONN; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = OOFF; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = 0FF; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = ' '; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = " "; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log = ''; - - ---echo '#-------------------FN_DYNVARS_004_04----------------------------#' -################################################################## -# Test that accessing session slow_query_log dows not give # -################################################################## - -SET @@global.slow_query_log = ON; -SET @@session.slow_query_log = ON; -SELECT @@session.slow_query_log; -SET @@session.slow_query_log = OFF; -SELECT @@session.slow_query_log; -SET @@global.slow_query_log = OFF; -SET @@session.slow_query_log = ON; - ---echo '#----------------------FN_DYNVARS_004_05------------------------#' -############################################################################## -# Check if the value in GLOBAL Tables matches values in variable # -############################################################################## - -SELECT IF(@@global.slow_query_log, "ON", "OFF") = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='slow_query_log'; - - ---echo '#---------------------FN_DYNVARS_004_06----------------------#' -################################################################ -# Check if 0 and 1 values can be used on variable # -################################################################ - -SET @@global.slow_query_log = 0; -SELECT @@global.slow_query_log; -SET @@global.slow_query_log = 1; -SELECT @@global.slow_query_log; - ---echo '#---------------------FN_DYNVARS_004_07----------------------#' -################################################################### -# Check if TRUE and FALSE values can be used on variable # -################################################################### - -SET @@global.slow_query_log = TRUE; -SELECT @@global.slow_query_log; -SET @@global.slow_query_log = FALSE; -SELECT @@global.slow_query_log; - ---echo '#---------------------FN_DYNVARS_004_08----------------------#' -############################################################################## -# Check if accessing variable with SESSION,LOCAL and without SCOPE points # -# to same session variable (doesn't) # -############################################################################## - -SET @@global.slow_query_log = ON; -SET @@local.slow_query_log = OFF; -SELECT @@slow_query_log = @@global.slow_query_log; - ---echo '#---------------------FN_DYNVARS_004_09----------------------#' -###################################################################### -# Check if slow_query_log can be accessed with and without @@ sign # -###################################################################### ---Error ER_UNKNOWN_TABLE -SELECT local.slow_query_log; ---Error ER_UNKNOWN_TABLE -SELECT global.slow_query_log; ---Error ER_BAD_FIELD_ERROR -SELECT slow_query_log = @@session.slow_query_log; - - - -############################## -# Restore initial value # -############################## - -SET @@global.slow_query_log = @start_value; -SELECT @@global.slow_query_log; - - -#################################################### -# END OF slow_query_log TESTS # -#################################################### diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_file_basic-master.opt b/mysql-test/suite/sys_vars/t/slow_query_log_file_basic-master.opt deleted file mode 100644 index 2b6ac309d6c60..0000000000000 --- a/mysql-test/suite/sys_vars/t/slow_query_log_file_basic-master.opt +++ /dev/null @@ -1 +0,0 @@ ---slow-query-log --slow-query-log-file=slowtest.log diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test b/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test deleted file mode 100644 index 87a3e671b951c..0000000000000 --- a/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test +++ /dev/null @@ -1,86 +0,0 @@ -################### mysql-test\t\slow_query_log_file_basic.test ################ -# # -# Variable Name: slow_query_log_file # -# Scope: GLOBAL # -# Access Type: Dynamic # -# Data Type: Filename # -# Default Value: host_name-slow.log # -# Valid Values: # -# # -# # -# Creation Date: 2008-03-16 # -# Author: Salman Rawala # -# Modified: HHunger 2008-09-11 set system var back to start value # -# # -# Description: Test Cases of Dynamic System Variable "slow_query_log_file" # -# that checks behavior of this variable in the following ways # -# * Default Value # -# * Valid & Invalid values # -# * Scope & Access method # -# * Data Integrity # -# # -# Reference: # -# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html -# # -################################################################################ - ---source include/load_sysvars.inc - -########################################################### -# START OF slow_query_log_file TESTS # -########################################################### - - -########################################################################### -# Saving initial value of slow_query_log_file in a temporary variable # -########################################################################### - -SET @start_value = @@global.slow_query_log_file; - ---echo '#---------------------FN_DYNVARS_004_01-------------------------#' -############################################### -# Verify default value of variable # -############################################### - -SET @@global.slow_query_log_file = DEFAULT; -SELECT length(@@global.slow_query_log_file) > 0; - - ---echo '#--------------------FN_DYNVARS_004_02------------------------#' -####################################################################### -# Change the value of slow_query_log_file to a invalid value # -####################################################################### - ---error ER_WRONG_TYPE_FOR_VAR -SET @@global.slow_query_log_file = mytest.log; ---error ER_WRONG_TYPE_FOR_VAR -SET @@global.slow_query_log_file = 12; - -# -# MDEV-10465 -# ---error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log_file = 'my.cnf'; ---error ER_WRONG_VALUE_FOR_VAR -SET @@global.slow_query_log_file = '/tmp/my.cnf'; ---error ER_WRONG_VALUE_FOR_VAR -SET @@global.general_log_file = '.my.cnf'; ---error ER_WRONG_VALUE_FOR_VAR -SET @@global.general_log_file = 'my.cnf\0foo'; ---error ER_WRONG_VALUE_FOR_VAR -SET @@global.general_log_file = 'my.ini'; - ---echo '#----------------------FN_DYNVARS_004_03------------------------#' -############################################################################## -# Check if the value in GLOBAL Tables matches values in variable # -############################################################################## - -SELECT @@global.slow_query_log_file = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='slow_query_log_file'; - -SET @@global.slow_query_log_file= @start_value; -##################################################### -# END OF slow_query_log_file TESTS # -##################################################### - From af4918b41f679501809dd407dcfd2c4c980443be Mon Sep 17 00:00:00 2001 From: Michael Qin Date: Wed, 25 May 2022 00:24:53 +0000 Subject: [PATCH 034/113] MDEV-7567 Add aliases with prefix log_slow for system variables relating to slow query log. Thus, all these variables will be grouped together and more logically named. Descriptions for the old variables were updated to indicate they are now aliases for the newly introduced variables with prefix log_slow. log_slow_queries_not_using_indexes_filter will not be addressed in this merge request. log_throttle_queries_not_using_indexes seems to no longer be in use. MTR tests are also updated to include the new variable names. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- mysql-test/main/log_slow.result | 5 ++ mysql-test/main/log_slow.test | 1 + mysql-test/main/mysqld--help,win.rdiff | 30 ++++----- mysql-test/main/mysqld--help.result | 57 ++++++++++++----- mysql-test/main/mysqld--help.test | 1 + .../sys_vars/r/sysvars_server_embedded.result | 62 +++++++++++++++++-- .../r/sysvars_server_notembedded.result | 62 +++++++++++++++++-- sql/sys_vars.cc | 51 ++++++++++++++- 8 files changed, 225 insertions(+), 44 deletions(-) diff --git a/mysql-test/main/log_slow.result b/mysql-test/main/log_slow.result index 31d52ff032379..9c0bd916f2376 100644 --- a/mysql-test/main/log_slow.result +++ b/mysql-test/main/log_slow.result @@ -13,6 +13,11 @@ Variable_name Value log_slow_admin_statements ON log_slow_disabled_statements sp log_slow_filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk +log_slow_min_examined_row_limit 0 +log_slow_queries_not_using_indexes OFF +log_slow_query_enable ON +log_slow_query_file_name $PATH/mysqld-slow.log +log_slow_query_time 10.000000 log_slow_rate_limit 1 log_slow_slave_statements ON log_slow_verbosity diff --git a/mysql-test/main/log_slow.test b/mysql-test/main/log_slow.test index 64fd820298564..b225c9c613705 100644 --- a/mysql-test/main/log_slow.test +++ b/mysql-test/main/log_slow.test @@ -7,6 +7,7 @@ set @@log_slow_verbosity=""; select @@log_slow_filter; select @@log_slow_rate_limit; select @@log_slow_verbosity; +--replace_regex /\S+mysqld-slow.log/$PATH\/mysqld-slow.log/ show variables like "log_slow%"; set @org_slow_query_log= @@global.slow_query_log; diff --git a/mysql-test/main/mysqld--help,win.rdiff b/mysql-test/main/mysqld--help,win.rdiff index 337755252ba5d..891870c23f165 100644 --- a/mysql-test/main/mysqld--help,win.rdiff +++ b/mysql-test/main/mysqld--help,win.rdiff @@ -1,6 +1,6 @@ --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result -@@ -647,6 +646,7 @@ +@@ -686,6 +686,7 @@ Use MySQL-5.6 (instead of MariaDB-5.3) format for TIME, DATETIME, TIMESTAMP columns. (Defaults to on; use --skip-mysql56-temporal-format to disable.) @@ -8,18 +8,18 @@ --net-buffer-length=# Buffer length for TCP/IP and socket communication --net-read-timeout=# -@@ -1236,6 +1236,10 @@ - Log slow queries to given log file. Defaults logging to - 'hostname'-slow.log. Must be enabled to activate other - slow log options +@@ -1275,6 +1276,10 @@ + will be written to the binlog. ENFORCE means that + triggers will always be run on the slave, even if there + are triggers on the master. ENFORCE implies LOGGING. + --slow-start-timeout=# + Maximum number of milliseconds that the service control + manager should wait before trying to kill the windows + service during startup(Default: 15000). - --socket=name Socket file to use for connection - --sort-buffer-size=# - Each thread that needs to do a sort allocates a buffer of -@@ -1260,6 +1264,7 @@ + --slave-skip-errors=name + Tells the slave thread to continue replication when a + query event returns an error from the provided list +@@ -1343,6 +1348,7 @@ deleting or updating every row in a table. --stack-trace Print a symbolic stack trace on failure (Defaults to on; use --skip-stack-trace to disable.) @@ -27,7 +27,7 @@ --standard-compliant-cte Allow only CTEs compliant to SQL standard (Defaults to on; use --skip-standard-compliant-cte to disable.) -@@ -1330,6 +1335,11 @@ +@@ -1418,6 +1424,11 @@ --thread-pool-max-threads=# Maximum allowed number of worker threads in the thread pool @@ -39,7 +39,7 @@ --thread-pool-oversubscribe=# How many additional active worker threads in a group are allowed. -@@ -1370,8 +1380,8 @@ +@@ -1456,8 +1467,8 @@ automatically convert it to an on-disk MyISAM or Aria table. -t, --tmpdir=name Path for temporary files. Several paths may be specified, @@ -50,7 +50,7 @@ --transaction-alloc-block-size=# Allocation block size for transactions to be stored in binary log -@@ -1587,6 +1596,7 @@ +@@ -1678,6 +1689,7 @@ myisam-stats-method NULLS_UNEQUAL myisam-use-mmap FALSE mysql56-temporal-format TRUE @@ -58,7 +58,7 @@ net-buffer-length 16384 net-read-timeout 30 net-retry-count 10 -@@ -1726,6 +1736,7 @@ +@@ -1832,6 +1844,7 @@ slave-type-conversions slow-launch-time 2 slow-query-log FALSE @@ -66,8 +66,8 @@ sort-buffer-size 2097152 sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION sql-safe-updates FALSE -@@ -1753,6 +1764,8 @@ - thread-cache-size 151 +@@ -1858,6 +1871,8 @@ + thread-pool-exact-stats FALSE thread-pool-idle-timeout 60 thread-pool-max-threads 65536 +thread-pool-min-threads 1 diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 4053f75e35f31..7cf18ea9f63e1 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -497,8 +497,9 @@ The following specify which files/extra groups are read (specified before remain --log-output=name How logs should be written. Any combination of: NONE, FILE, TABLE --log-queries-not-using-indexes - Log queries that are executed without benefit of any - index to the slow log if it is open. Same as + Alias for log_slow_queries_not_using_indexes. Log queries + that are executed without benefit of any index to the + slow log if it is open. Same as log_slow_filter='not_using_index' --log-short-format Don't log extra information to update and slow-query logs. @@ -523,6 +524,27 @@ The following specify which files/extra groups are read (specified before remain filesort_priority_queue, full_join, full_scan, not_using_index, query_cache, query_cache_miss, tmp_table, tmp_table_on_disk + --log-slow-min-examined-row-limit=# + Don't write queries to slow log that examine fewer rows + than that + --log-slow-queries-not-using-indexes + Log queries that are executed without benefit of any + index to the slow log if it is open. Same as + log_slow_filter='not_using_index' + --log-slow-query-enable + Log slow queries to a table or log file. Defaults logging + to a file 'hostname'-slow.log or a table mysql.slow_log + if --log-output=TABLE is used. Must be enabled to + activate other slow log options. + --log-slow-query-file-name=name + Log slow queries to given log file. Defaults logging to + 'hostname'-slow.log. Must be enabled to activate other + slow log options + --log-slow-query-time=# + Log all queries that have taken more than + log_slow_query_time seconds to execute to the slow query + log file. The argument will be treated as a decimal value + with microsecond precision --log-slow-rate-limit=# Write to slow log every #th slow query. Set to 1 to log everything. Increase it to reduce the size of the slow or @@ -543,10 +565,10 @@ The following specify which files/extra groups are read (specified before remain Log some not critical warnings to the general log file.Value can be between 0 and 11. Higher values mean more verbosity - --long-query-time=# Log all queries that have taken more than long_query_time - seconds to execute to the slow query log file. The - argument will be treated as a decimal value with - microsecond precision + --long-query-time=# Alias for log_slow_query_time. Log all queries that have + taken more than long_query_time seconds to execute to the + slow query log file. The argument will be treated as a + decimal value with microsecond precision --low-priority-updates INSERT/DELETE/UPDATE has lower priority than selects --lower-case-table-names[=#] @@ -635,8 +657,8 @@ The following specify which files/extra groups are read (specified before remain --metadata-locks-hash-instances=# Unused --min-examined-row-limit=# - Don't write queries to slow log that examine fewer rows - than that + Alias for log_slow_min_examined_row_limit. Don't write + queries to slow log that examine fewer rows than that --mrr-buffer-size=# Size of buffer to use when using MRR with range access --myisam-block-size=# Block size to be used for MyISAM index pages @@ -1304,14 +1326,15 @@ The following specify which files/extra groups are read (specified before remain If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented - --slow-query-log Log slow queries to a table or log file. Defaults logging - to a file 'hostname'-slow.log or a table mysql.slow_log - if --log-output=TABLE is used. Must be enabled to - activate other slow log options. + --slow-query-log Alias for log_slow_query_enable. Log slow queries to a + table or log file. Defaults logging to a file + 'hostname'-slow.log or a table mysql.slow_log if + --log-output=TABLE is used. Must be enabled to activate + other slow log options. --slow-query-log-file=name - Log slow queries to given log file. Defaults logging to - 'hostname'-slow.log. Must be enabled to activate other - slow log options + Alias for log_slow_query_file_name. Log slow queries to + given log file. Defaults logging to 'hostname'-slow.log. + Must be enabled to activate other slow log options --socket=name Socket file to use for connection --sort-buffer-size=# Each thread that needs to do a sort allocates a buffer of @@ -1617,6 +1640,10 @@ log-slave-updates FALSE log-slow-admin-statements TRUE log-slow-disabled-statements sp log-slow-filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk +log-slow-min-examined-row-limit 0 +log-slow-queries-not-using-indexes FALSE +log-slow-query-enable FALSE +log-slow-query-time 10 log-slow-rate-limit 1 log-slow-slave-statements TRUE log-slow-verbosity diff --git a/mysql-test/main/mysqld--help.test b/mysql-test/main/mysqld--help.test index 9bf53c7200bb0..eeeaf2e2393c6 100644 --- a/mysql-test/main/mysqld--help.test +++ b/mysql-test/main/mysqld--help.test @@ -23,6 +23,7 @@ perl; # their paths may vary: @skipvars=qw/basedir open-files-limit general-log-file log plugin-dir plugin-maturity log-slow-queries pid-file slow-query-log-file log-basename + log-slow-query-file-name datadir slave-load-tmpdir tmpdir socket thread-pool-size large-files-support lower-case-file-system system-time-zone collation-server character-set-server log-tc-size table-cache 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 157c50a78c700..e6a83e7130600 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -1655,7 +1655,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_QUERIES_NOT_USING_INDEXES VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' +VARIABLE_COMMENT Alias for log_slow_queries_not_using_indexes. Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL @@ -1692,6 +1692,56 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,not_using_index,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME LOG_SLOW_MIN_EXAMINED_ROW_LIMIT +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_COMMENT Don't write queries to slow log that examine fewer rows than that +NUMERIC_MIN_VALUE 0 +NUMERIC_MAX_VALUE 4294967295 +NUMERIC_BLOCK_SIZE 1 +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME LOG_SLOW_QUERIES_NOT_USING_INDEXES +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' +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 LOG_SLOW_QUERY_ENABLE +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. +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 LOG_SLOW_QUERY_FILE_NAME +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE VARCHAR +VARIABLE_COMMENT Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME LOG_SLOW_QUERY_TIME +VARIABLE_SCOPE SESSION +VARIABLE_TYPE DOUBLE +VARIABLE_COMMENT Log all queries that have taken more than log_slow_query_time seconds to execute to the slow query log file. The argument will be treated as a decimal value with microsecond precision +NUMERIC_MIN_VALUE 0 +NUMERIC_MAX_VALUE 31536000 +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_SLOW_RATE_LIMIT VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED @@ -1735,7 +1785,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME LONG_QUERY_TIME VARIABLE_SCOPE SESSION VARIABLE_TYPE DOUBLE -VARIABLE_COMMENT Log all queries that have taken more than long_query_time seconds to execute to the slow query log file. The argument will be treated as a decimal value with microsecond precision +VARIABLE_COMMENT Alias for log_slow_query_time. Log all queries that have taken more than long_query_time seconds to execute to the slow query log file. The argument will be treated as a decimal value with microsecond precision NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 NUMERIC_BLOCK_SIZE NULL @@ -1875,7 +1925,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_INSERT_DELAYED_THREADS VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used +VARIABLE_COMMENT Alias for max_delayed_threads. Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 NUMERIC_BLOCK_SIZE 1 @@ -2045,7 +2095,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MIN_EXAMINED_ROW_LIMIT VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT Don't write queries to slow log that examine fewer rows than that +VARIABLE_COMMENT Alias for log_slow_min_examined_row_limit. Don't write queries to slow log that examine fewer rows than that NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 NUMERIC_BLOCK_SIZE 1 @@ -3185,7 +3235,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLOW_QUERY_LOG VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. +VARIABLE_COMMENT Alias for log_slow_query_enable. Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL @@ -3195,7 +3245,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME SLOW_QUERY_LOG_FILE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR -VARIABLE_COMMENT Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options +VARIABLE_COMMENT Alias for log_slow_query_file_name. Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE 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 fc006a0013e32..7ed3f62707fc3 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -1795,7 +1795,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_QUERIES_NOT_USING_INDEXES VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' +VARIABLE_COMMENT Alias for log_slow_queries_not_using_indexes. Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL @@ -1842,6 +1842,56 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,not_using_index,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME LOG_SLOW_MIN_EXAMINED_ROW_LIMIT +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_COMMENT Don't write queries to slow log that examine fewer rows than that +NUMERIC_MIN_VALUE 0 +NUMERIC_MAX_VALUE 4294967295 +NUMERIC_BLOCK_SIZE 1 +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME LOG_SLOW_QUERIES_NOT_USING_INDEXES +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' +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 LOG_SLOW_QUERY_ENABLE +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. +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 LOG_SLOW_QUERY_FILE_NAME +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE VARCHAR +VARIABLE_COMMENT Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME LOG_SLOW_QUERY_TIME +VARIABLE_SCOPE SESSION +VARIABLE_TYPE DOUBLE +VARIABLE_COMMENT Log all queries that have taken more than log_slow_query_time seconds to execute to the slow query log file. The argument will be treated as a decimal value with microsecond precision +NUMERIC_MIN_VALUE 0 +NUMERIC_MAX_VALUE 31536000 +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_SLOW_RATE_LIMIT VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED @@ -1885,7 +1935,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME LONG_QUERY_TIME VARIABLE_SCOPE SESSION VARIABLE_TYPE DOUBLE -VARIABLE_COMMENT Log all queries that have taken more than long_query_time seconds to execute to the slow query log file. The argument will be treated as a decimal value with microsecond precision +VARIABLE_COMMENT Alias for log_slow_query_time. Log all queries that have taken more than long_query_time seconds to execute to the slow query log file. The argument will be treated as a decimal value with microsecond precision NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 NUMERIC_BLOCK_SIZE NULL @@ -2035,7 +2085,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_INSERT_DELAYED_THREADS VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used +VARIABLE_COMMENT Alias for max_delayed_threads. Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 NUMERIC_BLOCK_SIZE 1 @@ -2215,7 +2265,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MIN_EXAMINED_ROW_LIMIT VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT Don't write queries to slow log that examine fewer rows than that +VARIABLE_COMMENT Alias for log_slow_min_examined_row_limit. Don't write queries to slow log that examine fewer rows than that NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 NUMERIC_BLOCK_SIZE 1 @@ -3865,7 +3915,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLOW_QUERY_LOG VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. +VARIABLE_COMMENT Alias for log_slow_query_enable. Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL @@ -3875,7 +3925,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME SLOW_QUERY_LOG_FILE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR -VARIABLE_COMMENT Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options +VARIABLE_COMMENT Alias for log_slow_query_file_name. Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 63f4268c89d0d..c9d4874d9b754 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1501,6 +1501,14 @@ static Sys_var_charptr_fscs Sys_log_error( static Sys_var_bit Sys_log_queries_not_using_indexes( "log_queries_not_using_indexes", + "Alias for log_slow_queries_not_using_indexes. " + "Log queries that are executed without benefit of any index to the " + "slow log if it is open. Same as log_slow_filter='not_using_index'", + SESSION_VAR(log_slow_filter), CMD_LINE(OPT_ARG), QPLAN_NOT_USING_INDEX, + DEFAULT(FALSE)); + +static Sys_var_bit Sys_log_slow_queries_not_using_indexes( + "log_slow_queries_not_using_indexes", "Log queries that are executed without benefit of any index to the " "slow log if it is open. Same as log_slow_filter='not_using_index'", SESSION_VAR(log_slow_filter), CMD_LINE(OPT_ARG), QPLAN_NOT_USING_INDEX, @@ -1544,6 +1552,7 @@ static bool update_cached_long_query_time(sys_var *self, THD *thd, static Sys_var_double Sys_long_query_time( "long_query_time", + "Alias for log_slow_query_time. " "Log all queries that have taken more than long_query_time seconds " "to execute to the slow query log file. The argument will be treated " "as a decimal value with microsecond precision", @@ -1552,6 +1561,15 @@ static Sys_var_double Sys_long_query_time( NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(update_cached_long_query_time)); +static Sys_var_double Sys_log_slow_query_time( + "log_slow_query_time", + "Log all queries that have taken more than log_slow_query_time seconds " + "to execute to the slow query log file. The argument will be treated " + "as a decimal value with microsecond precision", + SESSION_VAR(long_query_time_double), + CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(10), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), + ON_UPDATE(update_cached_long_query_time)); static bool update_cached_max_statement_time(sys_var *self, THD *thd, enum_var_type type) @@ -1769,9 +1787,9 @@ static bool check_max_delayed_threads(sys_var *self, THD *thd, set_var *var) global_system_variables.max_insert_delayed_threads; } -// Alias for max_delayed_threads static Sys_var_ulong Sys_max_insert_delayed_threads( "max_insert_delayed_threads", + "Alias for max_delayed_threads. " "Don't start more than this number of threads to handle INSERT " "DELAYED statements. If set to zero INSERT DELAYED will be not used", SESSION_VAR(max_insert_delayed_threads), @@ -2600,6 +2618,14 @@ static Sys_var_ulong Sys_max_write_lock_count( static Sys_var_ulong Sys_min_examined_row_limit( "min_examined_row_limit", + "Alias for log_slow_min_examined_row_limit. " + "Don't write queries to slow log that examine fewer rows " + "than that", + SESSION_VAR(min_examined_row_limit), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1)); + +static Sys_var_ulong Sys_log_slow_min_examined_row_limit( + "log_slow_min_examined_row_limit", "Don't write queries to slow log that examine fewer rows " "than that", SESSION_VAR(min_examined_row_limit), CMD_LINE(REQUIRED_ARG), @@ -5140,8 +5166,19 @@ static bool fix_slow_log_file(sys_var *self, THD *thd, enum_var_type type) return fix_log(&opt_slow_logname, opt_log_basename, "-slow.log", global_system_variables.sql_log_slow, reopen_slow_log); } + static Sys_var_charptr_fscs Sys_slow_log_path( - "slow_query_log_file", "Log slow queries to given log file. " + "slow_query_log_file", + "Alias for log_slow_query_file_name. " + "Log slow queries to given log file. " + "Defaults logging to 'hostname'-slow.log. Must be enabled to activate " + "other slow log options", + PREALLOCATED GLOBAL_VAR(opt_slow_logname), CMD_LINE(REQUIRED_ARG), + DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, + ON_CHECK(check_log_path), ON_UPDATE(fix_slow_log_file)); + +static Sys_var_charptr_fscs Sys_log_slow_query_file_name( + "log_slow_query_file_name", "Log slow queries to given log file. " "Defaults logging to 'hostname'-slow.log. Must be enabled to activate " "other slow log options", PREALLOCATED GLOBAL_VAR(opt_slow_logname), CMD_LINE(REQUIRED_ARG), @@ -5242,6 +5279,16 @@ static Sys_var_mybool Sys_general_log( static Sys_var_mybool Sys_slow_query_log( "slow_query_log", + "Alias for log_slow_query_enable. " + "Log slow queries to a table or log file. Defaults logging to a file " + "'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is " + "used. Must be enabled to activate other slow log options.", + SESSION_VAR(sql_log_slow), CMD_LINE(OPT_ARG), + DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, + ON_CHECK(0), ON_UPDATE(fix_log_state)); + +static Sys_var_mybool Sys_log_slow_query_enable( + "log_slow_query_enable", "Log slow queries to a table or log file. Defaults logging to a file " "'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is " "used. Must be enabled to activate other slow log options.", From ef08810b8b9418f4bababd523ae63d2be22e1e97 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 12 Sep 2022 11:34:29 +0200 Subject: [PATCH 035/113] MDEV-7567 Add aliases with prefix log_slow for system variables relating to slow query log post-merge fixes: * remove log_slow_queries_not_using_indexes, no need to create variables that are deprecated since the moment of creation * rename log_slow_query_enable->log_slow_query no other variable uses *_enable pattern * MDEV-29626 Assertion `self == &Sys_slow_query_log' failed in fix_log_state * tests Closes #2137 --- mysql-test/main/log_slow.result | 3 +- mysql-test/main/mysqld--help,win.rdiff | 26 +- mysql-test/main/mysqld--help.result | 24 +- mysql-test/main/set_statement.result | 24 ++ mysql-test/main/set_statement.test | 8 + .../r/slow_query_log_file_func.result | 6 + .../sys_vars/r/slow_query_log_func.result | 8 +- .../r/sysvars_server_embedded,32bit.rdiff | 307 +++++++++-------- .../sys_vars/r/sysvars_server_embedded.result | 16 +- .../r/sysvars_server_notembedded,32bit.rdiff | 323 +++++++++--------- .../r/sysvars_server_notembedded.result | 16 +- .../sys_vars/t/slow_query_log_file_func.test | 7 + .../suite/sys_vars/t/slow_query_log_func.test | 8 +- sql/sys_vars.cc | 16 +- 14 files changed, 411 insertions(+), 381 deletions(-) diff --git a/mysql-test/main/log_slow.result b/mysql-test/main/log_slow.result index 9c0bd916f2376..465f2f5ebd3be 100644 --- a/mysql-test/main/log_slow.result +++ b/mysql-test/main/log_slow.result @@ -14,8 +14,7 @@ log_slow_admin_statements ON log_slow_disabled_statements sp log_slow_filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk log_slow_min_examined_row_limit 0 -log_slow_queries_not_using_indexes OFF -log_slow_query_enable ON +log_slow_query ON log_slow_query_file_name $PATH/mysqld-slow.log log_slow_query_time 10.000000 log_slow_rate_limit 1 diff --git a/mysql-test/main/mysqld--help,win.rdiff b/mysql-test/main/mysqld--help,win.rdiff index 891870c23f165..65d5741e6b115 100644 --- a/mysql-test/main/mysqld--help,win.rdiff +++ b/mysql-test/main/mysqld--help,win.rdiff @@ -8,18 +8,18 @@ --net-buffer-length=# Buffer length for TCP/IP and socket communication --net-read-timeout=# -@@ -1275,6 +1276,10 @@ - will be written to the binlog. ENFORCE means that - triggers will always be run on the slave, even if there - are triggers on the master. ENFORCE implies LOGGING. +@@ -1328,6 +1329,10 @@ + Alias for log_slow_query_file_name. Log slow queries to + given log file. Defaults logging to 'hostname'-slow.log. + Must be enabled to activate other slow log options + --slow-start-timeout=# + Maximum number of milliseconds that the service control + manager should wait before trying to kill the windows + service during startup(Default: 15000). - --slave-skip-errors=name - Tells the slave thread to continue replication when a - query event returns an error from the provided list -@@ -1343,6 +1348,7 @@ + --socket=name Socket file to use for connection + --sort-buffer-size=# + Each thread that needs to do a sort allocates a buffer of +@@ -1352,6 +1357,7 @@ deleting or updating every row in a table. --stack-trace Print a symbolic stack trace on failure (Defaults to on; use --skip-stack-trace to disable.) @@ -27,7 +27,7 @@ --standard-compliant-cte Allow only CTEs compliant to SQL standard (Defaults to on; use --skip-standard-compliant-cte to disable.) -@@ -1418,6 +1424,11 @@ +@@ -1427,6 +1433,11 @@ --thread-pool-max-threads=# Maximum allowed number of worker threads in the thread pool @@ -39,7 +39,7 @@ --thread-pool-oversubscribe=# How many additional active worker threads in a group are allowed. -@@ -1456,8 +1467,8 @@ +@@ -1465,8 +1476,8 @@ automatically convert it to an on-disk MyISAM or Aria table. -t, --tmpdir=name Path for temporary files. Several paths may be specified, @@ -50,7 +50,7 @@ --transaction-alloc-block-size=# Allocation block size for transactions to be stored in binary log -@@ -1678,6 +1689,7 @@ +@@ -1686,6 +1697,7 @@ myisam-stats-method NULLS_UNEQUAL myisam-use-mmap FALSE mysql56-temporal-format TRUE @@ -58,7 +58,7 @@ net-buffer-length 16384 net-read-timeout 30 net-retry-count 10 -@@ -1832,6 +1844,7 @@ +@@ -1842,6 +1854,7 @@ slave-type-conversions slow-launch-time 2 slow-query-log FALSE @@ -66,7 +66,7 @@ sort-buffer-size 2097152 sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION sql-safe-updates FALSE -@@ -1858,6 +1871,8 @@ +@@ -1868,6 +1881,8 @@ thread-pool-exact-stats FALSE thread-pool-idle-timeout 60 thread-pool-max-threads 65536 diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 7cf18ea9f63e1..46d537cc0d143 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -497,9 +497,8 @@ The following specify which files/extra groups are read (specified before remain --log-output=name How logs should be written. Any combination of: NONE, FILE, TABLE --log-queries-not-using-indexes - Alias for log_slow_queries_not_using_indexes. Log queries - that are executed without benefit of any index to the - slow log if it is open. Same as + Log queries that are executed without benefit of any + index to the slow log if it is open. Same as log_slow_filter='not_using_index' --log-short-format Don't log extra information to update and slow-query logs. @@ -527,12 +526,7 @@ The following specify which files/extra groups are read (specified before remain --log-slow-min-examined-row-limit=# Don't write queries to slow log that examine fewer rows than that - --log-slow-queries-not-using-indexes - Log queries that are executed without benefit of any - index to the slow log if it is open. Same as - log_slow_filter='not_using_index' - --log-slow-query-enable - Log slow queries to a table or log file. Defaults logging + --log-slow-query Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. @@ -1326,11 +1320,10 @@ The following specify which files/extra groups are read (specified before remain If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented - --slow-query-log Alias for log_slow_query_enable. Log slow queries to a - table or log file. Defaults logging to a file - 'hostname'-slow.log or a table mysql.slow_log if - --log-output=TABLE is used. Must be enabled to activate - other slow log options. + --slow-query-log Alias for log_slow_query. Log slow queries to a table or + log file. Defaults logging to a file 'hostname'-slow.log + or a table mysql.slow_log if --log-output=TABLE is used. + Must be enabled to activate other slow log options. --slow-query-log-file=name Alias for log_slow_query_file_name. Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. @@ -1641,8 +1634,7 @@ log-slow-admin-statements TRUE log-slow-disabled-statements sp log-slow-filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk log-slow-min-examined-row-limit 0 -log-slow-queries-not-using-indexes FALSE -log-slow-query-enable FALSE +log-slow-query FALSE log-slow-query-time 10 log-slow-rate-limit 1 log-slow-slave-statements TRUE diff --git a/mysql-test/main/set_statement.result b/mysql-test/main/set_statement.result index 7e8266d2ab3a2..f0a362e9fe21a 100644 --- a/mysql-test/main/set_statement.result +++ b/mysql-test/main/set_statement.result @@ -1147,6 +1147,16 @@ sql_text select sleep(0.1) set statement long_query_time=0.01 for select sleep(0.1) #--- +#should be written +set statement log_slow_query_time=0.01 for select sleep(0.1); +sleep(0.1) +0 +select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_time%'; +sql_text +select sleep(0.1) +set statement long_query_time=0.01 for select sleep(0.1) +set statement log_slow_query_time=0.01 for select sleep(0.1) +#--- set @@long_query_time=0.01; #should NOT be written set statement slow_query_log=0 for select sleep(0.1); @@ -1157,6 +1167,7 @@ select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_ti sql_text select sleep(0.1) set statement long_query_time=0.01 for select sleep(0.1) +set statement log_slow_query_time=0.01 for select sleep(0.1) #--- #should NOT be written set statement long_query_time=0.01,log_slow_filter='full_scan' for select sleep(0.1); @@ -1166,6 +1177,7 @@ select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_ti sql_text select sleep(0.1) set statement long_query_time=0.01 for select sleep(0.1) +set statement log_slow_query_time=0.01 for select sleep(0.1) #--- #should NOT be written set statement long_query_time=0.01,log_slow_rate_limit=9999 for select sleep(0.1); @@ -1175,6 +1187,7 @@ select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_ti sql_text select sleep(0.1) set statement long_query_time=0.01 for select sleep(0.1) +set statement log_slow_query_time=0.01 for select sleep(0.1) #--- #should NOT be written set statement long_query_time=0.01,min_examined_row_limit=50 for select sleep(0.1); @@ -1184,6 +1197,17 @@ select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_ti sql_text select sleep(0.1) set statement long_query_time=0.01 for select sleep(0.1) +set statement log_slow_query_time=0.01 for select sleep(0.1) +#--- +#should NOT be written +set statement long_query_time=0.01,log_slow_min_examined_row_limit=50 for select sleep(0.1); +sleep(0.1) +0 +select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_time%'; +sql_text +select sleep(0.1) +set statement long_query_time=0.01 for select sleep(0.1) +set statement log_slow_query_time=0.01 for select sleep(0.1) #--- set global log_output= @save_log_output; set @@slow_query_log= @save_slow_query_log; diff --git a/mysql-test/main/set_statement.test b/mysql-test/main/set_statement.test index 0bf9f423dab53..b46380772f9e2 100644 --- a/mysql-test/main/set_statement.test +++ b/mysql-test/main/set_statement.test @@ -1018,6 +1018,10 @@ select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_ti set statement long_query_time=0.01 for select sleep(0.1); select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_time%'; --echo #--- +--echo #should be written +set statement log_slow_query_time=0.01 for select sleep(0.1); +select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_time%'; +--echo #--- set @@long_query_time=0.01; --echo #should NOT be written set statement slow_query_log=0 for select sleep(0.1); @@ -1036,6 +1040,10 @@ select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_ti set statement long_query_time=0.01,min_examined_row_limit=50 for select sleep(0.1); select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_time%'; --echo #--- +--echo #should NOT be written +set statement long_query_time=0.01,log_slow_min_examined_row_limit=50 for select sleep(0.1); +select sql_text from mysql.slow_log where sql_text not like 'set @@long_query_time%'; +--echo #--- # # log_slow_verbosity is impossible to check because results are not written # in TABLE mode diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_file_func.result b/mysql-test/suite/sys_vars/r/slow_query_log_file_func.result index 201b33c8edb5f..2910c78f02fde 100644 --- a/mysql-test/suite/sys_vars/r/slow_query_log_file_func.result +++ b/mysql-test/suite/sys_vars/r/slow_query_log_file_func.result @@ -1,3 +1,9 @@ '#--------------------FN_DYNVARS_018_01-------------------------#' ## Checking if my_slow_test.log exists in servers datadir ## ## This case should pass because we have set this filename in opt file ## +set @oldval= @@global.slow_query_log_file; +set global log_slow_query_file_name='$MYSQLTEST_VARDIR/tmp/slow-7567.log'; +select @@global.log_slow_query_file_name; +@@global.log_slow_query_file_name +MYSQLTEST_VARDIR/tmp/slow-7567.log +set @@global.log_slow_query_file_name=@oldval; diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_func.result b/mysql-test/suite/sys_vars/r/slow_query_log_func.result index cccf10a15eb5e..acda9643f32d7 100644 --- a/mysql-test/suite/sys_vars/r/slow_query_log_func.result +++ b/mysql-test/suite/sys_vars/r/slow_query_log_func.result @@ -2,8 +2,8 @@ SET @global_slow_query_log = @@global.slow_query_log; SET @global_log_output = @@global.log_output; SET @@session.long_query_time=1; SET @@global.log_output = 'TABLE'; -'----When global.slow_query_log = OFF----' -SET @@global.slow_query_log = OFF; +'----When global.log_slow_query = OFF----' +SET @@global.log_slow_query = OFF; TRUNCATE mysql.slow_log; SELECT sleep(2); sleep(2) @@ -20,8 +20,8 @@ sleep(2) SELECT count(*) > 0 FROM mysql.slow_log; count(*) > 0 1 -'----When local.slow_query_log = OFF-----' -SET @@local.slow_query_log = OFF; +'----When local.log_slow_query = OFF-----' +SET @@local.log_slow_query = OFF; TRUNCATE mysql.slow_log; SELECT sleep(2); sleep(2) diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_embedded,32bit.rdiff index e018489446b48..a632e049c5e9d 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded,32bit.rdiff @@ -1,4 +1,6 @@ -@@ -44,7 +44,7 @@ +--- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result ++++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +@@ -44,7 +44,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_BLOCK_SIZE VARIABLE_SCOPE GLOBAL @@ -7,7 +9,7 @@ VARIABLE_COMMENT Block size to be used for Aria index pages. NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 32768 -@@ -54,7 +54,7 @@ +@@ -54,7 +54,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_CHECKPOINT_INTERVAL VARIABLE_SCOPE GLOBAL @@ -16,7 +18,7 @@ VARIABLE_COMMENT Interval between tries to do an automatic checkpoints. In seconds; 0 means 'no automatic checkpoints' which makes sense only for testing. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -64,7 +64,7 @@ +@@ -64,7 +64,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_CHECKPOINT_LOG_ACTIVITY VARIABLE_SCOPE GLOBAL @@ -25,7 +27,7 @@ VARIABLE_COMMENT Number of bytes that the transaction log has to grow between checkpoints before a new checkpoint is written to the log. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -84,7 +84,7 @@ +@@ -84,7 +84,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ARIA_FORCE_START_AFTER_RECOVERY_FAILURES VARIABLE_SCOPE GLOBAL @@ -34,7 +36,7 @@ VARIABLE_COMMENT Number of consecutive log recovery failures after which logs will be automatically deleted to cure the problem; 0 (the default) disables the feature. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 255 -@@ -104,7 +104,7 @@ +@@ -104,7 +104,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_GROUP_COMMIT_INTERVAL VARIABLE_SCOPE GLOBAL @@ -43,7 +45,7 @@ VARIABLE_COMMENT Interval between commits in microseconds (1/1000000 sec). 0 stands for no waiting for other threads to come and do a commit in "hard" mode and no sync()/commit at all in "soft" mode. Option has only an effect if aria_group_commit is used NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -114,7 +114,7 @@ +@@ -114,7 +114,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_LOG_FILE_SIZE VARIABLE_SCOPE GLOBAL @@ -52,7 +54,7 @@ VARIABLE_COMMENT Limit for transaction log size NUMERIC_MIN_VALUE 8388608 NUMERIC_MAX_VALUE 4294967295 -@@ -144,10 +144,10 @@ +@@ -144,10 +144,10 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_PAGECACHE_AGE_THRESHOLD VARIABLE_SCOPE GLOBAL @@ -65,7 +67,7 @@ NUMERIC_BLOCK_SIZE 100 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -164,7 +164,7 @@ +@@ -164,7 +164,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_PAGECACHE_DIVISION_LIMIT VARIABLE_SCOPE GLOBAL @@ -74,7 +76,7 @@ VARIABLE_COMMENT The minimum percentage of warm blocks in key cache NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 100 -@@ -174,7 +174,7 @@ +@@ -174,7 +174,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_PAGECACHE_FILE_HASH_SIZE VARIABLE_SCOPE GLOBAL @@ -83,7 +85,7 @@ VARIABLE_COMMENT Number of hash buckets for open and changed files. If you have a lot of Aria files open you should increase this for faster flush of changes. A good value is probably 1/10 of number of possible open Aria files. NUMERIC_MIN_VALUE 128 NUMERIC_MAX_VALUE 16384 -@@ -204,7 +204,7 @@ +@@ -204,7 +204,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ARIA_REPAIR_THREADS VARIABLE_SCOPE SESSION @@ -92,7 +94,7 @@ VARIABLE_COMMENT Number of threads to use when repairing Aria tables. The value of 1 disables parallel repair. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 128 -@@ -217,7 +217,7 @@ +@@ -217,7 +217,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE. NUMERIC_MIN_VALUE 4096 @@ -101,7 +103,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -274,7 +274,7 @@ +@@ -274,7 +274,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME AUTO_INCREMENT_INCREMENT VARIABLE_SCOPE SESSION @@ -110,7 +112,7 @@ VARIABLE_COMMENT Auto-increment columns are incremented by this NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 65535 -@@ -284,7 +284,7 @@ +@@ -284,7 +284,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME AUTO_INCREMENT_OFFSET VARIABLE_SCOPE SESSION @@ -119,7 +121,7 @@ VARIABLE_COMMENT Offset added to Auto-increment columns. Used when auto-increment-increment != 1 NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 65535 -@@ -294,7 +294,7 @@ +@@ -294,7 +294,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME BACK_LOG VARIABLE_SCOPE GLOBAL @@ -128,7 +130,7 @@ VARIABLE_COMMENT The number of outstanding connection requests MariaDB can have. This comes into play when the main MariaDB thread gets very many connection requests in a very short time NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 65535 -@@ -347,7 +347,7 @@ +@@ -347,7 +347,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of the transactional cache for updates to transactional engines for the binary log. If you often use transactions containing many statements, you can increase this to get more performance NUMERIC_MIN_VALUE 4096 @@ -137,7 +139,7 @@ NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -364,20 +364,20 @@ +@@ -364,20 +364,20 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME BINLOG_COMMIT_WAIT_COUNT VARIABLE_SCOPE GLOBAL @@ -162,7 +164,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -394,7 +394,7 @@ +@@ -394,7 +394,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME BINLOG_EXPIRE_LOGS_SECONDS VARIABLE_SCOPE GLOBAL @@ -171,7 +173,7 @@ VARIABLE_COMMENT If non-zero, binary logs will be purged after binlog_expire_logs_seconds seconds; It and expire_logs_days are linked, such that changes in one are converted into the other. Possible purges happen at startup and at binary log rotation. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 8553600 -@@ -407,7 +407,7 @@ +@@ -407,7 +407,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of file cache for the binary log NUMERIC_MIN_VALUE 8192 @@ -180,7 +182,7 @@ NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -457,7 +457,7 @@ +@@ -457,7 +457,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of the statement cache for updates to non-transactional engines for the binary log. If you often use statements updating a great number of rows, you can increase this to get more performance. NUMERIC_MIN_VALUE 4096 @@ -189,7 +191,7 @@ NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -467,7 +467,7 @@ +@@ -467,7 +467,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread! NUMERIC_MIN_VALUE 0 @@ -198,7 +200,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -654,7 +654,7 @@ +@@ -654,7 +654,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME CONNECT_TIMEOUT VARIABLE_SCOPE GLOBAL @@ -207,7 +209,7 @@ VARIABLE_COMMENT The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake' NUMERIC_MIN_VALUE 2 NUMERIC_MAX_VALUE 31536000 -@@ -704,7 +704,7 @@ +@@ -704,7 +704,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DEADLOCK_SEARCH_DEPTH_LONG VARIABLE_SCOPE SESSION @@ -216,7 +218,7 @@ VARIABLE_COMMENT Long search depth for the two-step deadlock detection NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 33 -@@ -714,7 +714,7 @@ +@@ -714,7 +714,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DEADLOCK_SEARCH_DEPTH_SHORT VARIABLE_SCOPE SESSION @@ -225,7 +227,7 @@ VARIABLE_COMMENT Short search depth for the two-step deadlock detection NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 32 -@@ -724,7 +724,7 @@ +@@ -724,7 +724,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DEADLOCK_TIMEOUT_LONG VARIABLE_SCOPE SESSION @@ -234,7 +236,7 @@ VARIABLE_COMMENT Long timeout for the two-step deadlock detection (in microseconds) NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -734,7 +734,7 @@ +@@ -734,7 +734,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DEADLOCK_TIMEOUT_SHORT VARIABLE_SCOPE SESSION @@ -243,7 +245,7 @@ VARIABLE_COMMENT Short timeout for the two-step deadlock detection (in microseconds) NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -784,7 +784,7 @@ +@@ -784,7 +784,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME DEFAULT_WEEK_FORMAT VARIABLE_SCOPE SESSION @@ -252,7 +254,7 @@ VARIABLE_COMMENT The default week format used by WEEK() functions NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 7 -@@ -794,7 +794,7 @@ +@@ -794,7 +794,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DELAYED_INSERT_LIMIT VARIABLE_SCOPE GLOBAL @@ -261,7 +263,7 @@ VARIABLE_COMMENT After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if there are any SELECT statements pending. If so, it allows these to execute before continuing. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -804,7 +804,7 @@ +@@ -804,7 +804,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DELAYED_INSERT_TIMEOUT VARIABLE_SCOPE GLOBAL @@ -270,7 +272,7 @@ VARIABLE_COMMENT How long a INSERT DELAYED thread should wait for INSERT statements before terminating NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -814,7 +814,7 @@ +@@ -814,7 +814,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DELAYED_QUEUE_SIZE VARIABLE_SCOPE GLOBAL @@ -279,7 +281,7 @@ VARIABLE_COMMENT What size queue (in rows) should be allocated for handling INSERT DELAYED. If the queue becomes full, any client that does INSERT DELAYED will wait until there is room in the queue again NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -844,7 +844,7 @@ +@@ -844,7 +844,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME DIV_PRECISION_INCREMENT VARIABLE_SCOPE SESSION @@ -288,7 +290,7 @@ VARIABLE_COMMENT Precision of the result of '/' operator will be increased on that value NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 38 -@@ -954,7 +954,7 @@ +@@ -954,7 +954,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME EXTRA_MAX_CONNECTIONS VARIABLE_SCOPE GLOBAL @@ -297,7 +299,7 @@ VARIABLE_COMMENT The number of connections on extra-port NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 100000 -@@ -984,7 +984,7 @@ +@@ -984,7 +984,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME FLUSH_TIME VARIABLE_SCOPE GLOBAL @@ -306,7 +308,7 @@ VARIABLE_COMMENT A dedicated thread is created to flush all tables at the given interval NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 -@@ -1014,7 +1014,7 @@ +@@ -1014,7 +1014,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME FT_MAX_WORD_LEN VARIABLE_SCOPE GLOBAL @@ -315,7 +317,7 @@ VARIABLE_COMMENT The maximum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 84 -@@ -1024,7 +1024,7 @@ +@@ -1024,7 +1024,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME FT_MIN_WORD_LEN VARIABLE_SCOPE GLOBAL @@ -324,7 +326,7 @@ VARIABLE_COMMENT The minimum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 84 -@@ -1034,7 +1034,7 @@ +@@ -1034,7 +1034,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME FT_QUERY_EXPANSION_LIMIT VARIABLE_SCOPE GLOBAL @@ -333,7 +335,7 @@ VARIABLE_COMMENT Number of best matches to use for query expansion NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1000 -@@ -1204,7 +1204,7 @@ +@@ -1204,7 +1204,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME HISTOGRAM_SIZE VARIABLE_SCOPE SESSION @@ -342,7 +344,7 @@ VARIABLE_COMMENT Number of bytes used for a histogram. If set to 0, no histograms are created by ANALYZE. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 255 -@@ -1234,7 +1234,7 @@ +@@ -1234,7 +1234,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME HOST_CACHE_SIZE VARIABLE_SCOPE GLOBAL @@ -351,7 +353,7 @@ VARIABLE_COMMENT How many host names should be cached to avoid resolving. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 65536 -@@ -1344,7 +1344,7 @@ +@@ -1344,7 +1344,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME INTERACTIVE_TIMEOUT VARIABLE_SCOPE SESSION @@ -360,7 +362,7 @@ VARIABLE_COMMENT The number of seconds the server waits for activity on an interactive connection before closing it NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -1377,7 +1377,7 @@ +@@ -1377,7 +1377,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of the buffer that is used for joins NUMERIC_MIN_VALUE 128 @@ -369,7 +371,7 @@ NUMERIC_BLOCK_SIZE 128 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1394,7 +1394,7 @@ +@@ -1394,7 +1394,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME JOIN_CACHE_LEVEL VARIABLE_SCOPE SESSION @@ -378,7 +380,7 @@ VARIABLE_COMMENT Controls what join operations can be executed with join buffers. Odd numbers are used for plain join buffers while even numbers are used for linked buffers NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 8 -@@ -1417,7 +1417,7 @@ +@@ -1417,7 +1417,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford NUMERIC_MIN_VALUE 0 @@ -387,7 +389,7 @@ NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1574,7 +1574,7 @@ +@@ -1574,7 +1574,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME LOCK_WAIT_TIMEOUT VARIABLE_SCOPE SESSION @@ -396,7 +398,16 @@ VARIABLE_COMMENT Timeout in seconds to wait for a lock before returning an error. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 -@@ -1694,7 +1694,7 @@ +@@ -1694,7 +1694,7 @@ READ_ONLY NO + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME LOG_SLOW_MIN_EXAMINED_ROW_LIMIT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Don't write queries to slow log that examine fewer rows than that + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -1734,7 +1734,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_SLOW_RATE_LIMIT VARIABLE_SCOPE SESSION @@ -405,7 +416,7 @@ VARIABLE_COMMENT Write to slow log every #th slow query. Set to 1 to log everything. Increase it to reduce the size of the slow or the performance impact of slow logging NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -1724,7 +1724,7 @@ +@@ -1764,7 +1764,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_WARNINGS VARIABLE_SCOPE SESSION @@ -414,7 +425,7 @@ VARIABLE_COMMENT Log some not critical warnings to the general log file.Value can be between 0 and 11. Higher values mean more verbosity NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -1774,7 +1774,7 @@ +@@ -1814,7 +1814,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME MAX_ALLOWED_PACKET VARIABLE_SCOPE SESSION @@ -423,7 +434,7 @@ VARIABLE_COMMENT Max packet length to send to or receive from the server NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -1787,14 +1787,14 @@ +@@ -1827,14 +1827,14 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the total size of the transactional cache NUMERIC_MIN_VALUE 4096 @@ -440,7 +451,7 @@ VARIABLE_COMMENT Binary log will be rotated automatically when the size exceeds this value. NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 1073741824 -@@ -1807,14 +1807,14 @@ +@@ -1847,14 +1847,14 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the total size of the statement cache NUMERIC_MIN_VALUE 4096 @@ -457,7 +468,7 @@ VARIABLE_COMMENT The number of simultaneous clients allowed NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 100000 -@@ -1824,7 +1824,7 @@ +@@ -1864,7 +1864,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_CONNECT_ERRORS VARIABLE_SCOPE GLOBAL @@ -466,7 +477,7 @@ VARIABLE_COMMENT If there is more than this number of interrupted connections from a host this host will be blocked from further connections NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -1834,7 +1834,7 @@ +@@ -1874,7 +1874,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_DELAYED_THREADS VARIABLE_SCOPE SESSION @@ -475,7 +486,7 @@ VARIABLE_COMMENT Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 -@@ -1854,7 +1854,7 @@ +@@ -1894,7 +1894,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_ERROR_COUNT VARIABLE_SCOPE SESSION @@ -484,7 +495,7 @@ VARIABLE_COMMENT Max number of errors/warnings to store for a statement NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 65535 -@@ -1867,14 +1867,14 @@ +@@ -1907,14 +1907,14 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Don't allow creation of heap tables bigger than this NUMERIC_MIN_VALUE 16384 @@ -498,10 +509,10 @@ VARIABLE_SCOPE SESSION -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used + VARIABLE_COMMENT Alias for max_delayed_threads. Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 -@@ -1894,7 +1894,7 @@ +@@ -1934,7 +1934,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_LENGTH_FOR_SORT_DATA VARIABLE_SCOPE SESSION @@ -510,7 +521,7 @@ VARIABLE_COMMENT Max number of bytes in sorted records NUMERIC_MIN_VALUE 4 NUMERIC_MAX_VALUE 8388608 -@@ -1924,7 +1924,7 @@ +@@ -1964,7 +1964,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_RECURSIVE_ITERATIONS VARIABLE_SCOPE SESSION @@ -519,7 +530,7 @@ VARIABLE_COMMENT Maximum number of iterations when executing recursive queries NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -1937,14 +1937,14 @@ +@@ -1977,14 +1977,14 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The maximum size of the container of a rowid filter NUMERIC_MIN_VALUE 1024 @@ -536,7 +547,7 @@ VARIABLE_COMMENT Limit assumed max number of seeks when looking up rows based on a key NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -1964,7 +1964,7 @@ +@@ -2004,7 +2004,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_SORT_LENGTH VARIABLE_SCOPE SESSION @@ -545,7 +556,7 @@ VARIABLE_COMMENT The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored) NUMERIC_MIN_VALUE 64 NUMERIC_MAX_VALUE 8388608 -@@ -1974,7 +1974,7 @@ +@@ -2014,7 +2014,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_SP_RECURSION_DEPTH VARIABLE_SCOPE SESSION @@ -554,7 +565,7 @@ VARIABLE_COMMENT Maximum stored procedure recursion depth NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 255 -@@ -1994,7 +1994,7 @@ +@@ -2034,7 +2034,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_TMP_TABLES VARIABLE_SCOPE SESSION @@ -563,7 +574,7 @@ VARIABLE_COMMENT Unused, will be removed. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -2014,7 +2014,7 @@ +@@ -2054,7 +2054,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_WRITE_LOCK_COUNT VARIABLE_SCOPE GLOBAL @@ -572,7 +583,7 @@ VARIABLE_COMMENT After this many write locks, allow some read locks to run in between NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -2024,7 +2024,7 @@ +@@ -2064,7 +2064,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME METADATA_LOCKS_CACHE_SIZE VARIABLE_SCOPE GLOBAL @@ -581,7 +592,7 @@ VARIABLE_COMMENT Unused NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1048576 -@@ -2034,7 +2034,7 @@ +@@ -2074,7 +2074,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME METADATA_LOCKS_HASH_INSTANCES VARIABLE_SCOPE GLOBAL @@ -590,16 +601,16 @@ VARIABLE_COMMENT Unused NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1024 -@@ -2044,7 +2044,7 @@ +@@ -2084,7 +2084,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MIN_EXAMINED_ROW_LIMIT VARIABLE_SCOPE SESSION -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Don't write queries to slow log that examine fewer rows than that + VARIABLE_COMMENT Alias for log_slow_min_examined_row_limit. Don't write queries to slow log that examine fewer rows than that NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2054,7 +2054,7 @@ +@@ -2094,7 +2094,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MRR_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -608,7 +619,7 @@ VARIABLE_COMMENT Size of buffer to use when using MRR with range access NUMERIC_MIN_VALUE 8192 NUMERIC_MAX_VALUE 2147483647 -@@ -2064,7 +2064,7 @@ +@@ -2104,7 +2104,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MYISAM_BLOCK_SIZE VARIABLE_SCOPE GLOBAL @@ -617,7 +628,7 @@ VARIABLE_COMMENT Block size to be used for MyISAM index pages NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 16384 -@@ -2074,7 +2074,7 @@ +@@ -2114,7 +2114,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MYISAM_DATA_POINTER_SIZE VARIABLE_SCOPE GLOBAL @@ -626,7 +637,7 @@ VARIABLE_COMMENT Default pointer size to be used for MyISAM tables NUMERIC_MIN_VALUE 2 NUMERIC_MAX_VALUE 7 -@@ -2097,7 +2097,7 @@ +@@ -2137,7 +2137,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Restricts the total memory used for memory mapping of MySQL tables NUMERIC_MIN_VALUE 7 @@ -635,7 +646,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY YES -@@ -2114,10 +2114,10 @@ +@@ -2154,10 +2154,10 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME MYISAM_REPAIR_THREADS VARIABLE_SCOPE SESSION @@ -648,7 +659,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -2127,7 +2127,7 @@ +@@ -2167,7 +2167,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE NUMERIC_MIN_VALUE 4096 @@ -657,7 +668,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -2164,7 +2164,7 @@ +@@ -2204,7 +2204,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME NET_BUFFER_LENGTH VARIABLE_SCOPE SESSION @@ -666,7 +677,7 @@ VARIABLE_COMMENT Buffer length for TCP/IP and socket communication NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1048576 -@@ -2174,7 +2174,7 @@ +@@ -2214,7 +2214,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME NET_READ_TIMEOUT VARIABLE_SCOPE SESSION @@ -675,7 +686,7 @@ VARIABLE_COMMENT Number of seconds to wait for more data from a connection before aborting the read NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -2184,7 +2184,7 @@ +@@ -2224,7 +2224,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME NET_RETRY_COUNT VARIABLE_SCOPE SESSION @@ -684,7 +695,7 @@ VARIABLE_COMMENT If a read on a communication port is interrupted, retry this many times before giving up NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -2194,7 +2194,7 @@ +@@ -2234,7 +2234,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME NET_WRITE_TIMEOUT VARIABLE_SCOPE SESSION @@ -693,7 +704,7 @@ VARIABLE_COMMENT Number of seconds to wait for a block to be written to a connection before aborting the write NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -2244,7 +2244,7 @@ +@@ -2284,7 +2284,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME OPEN_FILES_LIMIT VARIABLE_SCOPE GLOBAL @@ -702,7 +713,7 @@ VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2254,7 +2254,7 @@ +@@ -2294,7 +2294,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_EXTRA_PRUNING_DEPTH VARIABLE_SCOPE SESSION @@ -711,7 +722,7 @@ VARIABLE_COMMENT If the optimizer needs to enumerate join prefix of this size or larger, then it will try agressively prune away the search space. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 62 -@@ -2264,17 +2264,17 @@ +@@ -2304,17 +2304,17 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_MAX_SEL_ARG_WEIGHT VARIABLE_SCOPE SESSION @@ -732,7 +743,7 @@ VARIABLE_COMMENT Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search: 1 - prune plans based on cost and number of retrieved rows eq_ref: 2 - prune also if we find an eq_ref chain NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2 -@@ -2284,7 +2284,7 @@ +@@ -2324,7 +2324,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_SEARCH_DEPTH VARIABLE_SCOPE SESSION @@ -741,7 +752,7 @@ VARIABLE_COMMENT Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Values smaller than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 62 -@@ -2294,7 +2294,7 @@ +@@ -2334,7 +2334,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_SELECTIVITY_SAMPLING_LIMIT VARIABLE_SCOPE SESSION @@ -750,7 +761,7 @@ VARIABLE_COMMENT Controls number of record samples to check condition selectivity NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 4294967295 -@@ -2324,17 +2324,17 @@ +@@ -2364,17 +2364,17 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_TRACE_MAX_MEM_SIZE VARIABLE_SCOPE SESSION @@ -771,7 +782,7 @@ VARIABLE_COMMENT Controls selectivity of which conditions the optimizer takes into account to calculate cardinality of a partial join when it searches for the best execution plan Meaning: 1 - use selectivity of index backed range conditions to calculate the cardinality of a partial join if the last joined table is accessed by full table scan or an index scan, 2 - use selectivity of index backed range conditions to calculate the cardinality of a partial join in any case, 3 - additionally always use selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join, 4 - use histograms to calculate selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join.5 - additionally use selectivity of certain non-range predicates calculated on record samples NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 5 -@@ -2354,7 +2354,7 @@ +@@ -2394,7 +2394,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME PERFORMANCE_SCHEMA_ACCOUNTS_SIZE VARIABLE_SCOPE GLOBAL @@ -780,7 +791,7 @@ VARIABLE_COMMENT Maximum number of instrumented user@host accounts. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2364,7 +2364,7 @@ +@@ -2404,7 +2404,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_DIGESTS_SIZE VARIABLE_SCOPE GLOBAL @@ -789,7 +800,7 @@ VARIABLE_COMMENT Size of the statement digest. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2374,7 +2374,7 @@ +@@ -2414,7 +2414,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -798,7 +809,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_STAGES_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2384,7 +2384,7 @@ +@@ -2424,7 +2424,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -807,7 +818,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STAGES_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2394,7 +2394,7 @@ +@@ -2434,7 +2434,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -816,7 +827,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_STATEMENTS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2404,7 +2404,7 @@ +@@ -2444,7 +2444,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -825,7 +836,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2414,7 +2414,7 @@ +@@ -2454,7 +2454,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -834,7 +845,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_TRANSACTIONS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2424,7 +2424,7 @@ +@@ -2464,7 +2464,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -843,7 +854,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_TRANSACTIONS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2434,7 +2434,7 @@ +@@ -2474,7 +2474,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -852,7 +863,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_WAITS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2444,7 +2444,7 @@ +@@ -2484,7 +2484,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -861,7 +872,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_WAITS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2454,7 +2454,7 @@ +@@ -2494,7 +2494,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_HOSTS_SIZE VARIABLE_SCOPE GLOBAL @@ -870,7 +881,7 @@ VARIABLE_COMMENT Maximum number of instrumented hosts. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2464,7 +2464,7 @@ +@@ -2504,7 +2504,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_CLASSES VARIABLE_SCOPE GLOBAL @@ -879,7 +890,7 @@ VARIABLE_COMMENT Maximum number of condition instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2474,7 +2474,7 @@ +@@ -2514,7 +2514,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_INSTANCES VARIABLE_SCOPE GLOBAL @@ -888,7 +899,7 @@ VARIABLE_COMMENT Maximum number of instrumented condition objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2484,7 +2484,7 @@ +@@ -2524,7 +2524,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_DIGEST_LENGTH VARIABLE_SCOPE GLOBAL @@ -897,7 +908,7 @@ VARIABLE_COMMENT Maximum length considered for digest text, when stored in performance_schema tables. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2494,7 +2494,7 @@ +@@ -2534,7 +2534,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_CLASSES VARIABLE_SCOPE GLOBAL @@ -906,7 +917,7 @@ VARIABLE_COMMENT Maximum number of file instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2504,7 +2504,7 @@ +@@ -2544,7 +2544,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_HANDLES VARIABLE_SCOPE GLOBAL @@ -915,7 +926,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented files. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2514,7 +2514,7 @@ +@@ -2554,7 +2554,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES VARIABLE_SCOPE GLOBAL @@ -924,7 +935,7 @@ VARIABLE_COMMENT Maximum number of instrumented files. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2524,7 +2524,7 @@ +@@ -2564,7 +2564,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_INDEX_STAT VARIABLE_SCOPE GLOBAL @@ -933,7 +944,7 @@ VARIABLE_COMMENT Maximum number of index statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2534,7 +2534,7 @@ +@@ -2574,7 +2574,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MEMORY_CLASSES VARIABLE_SCOPE GLOBAL @@ -942,7 +953,7 @@ VARIABLE_COMMENT Maximum number of memory pool instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1024 -@@ -2544,7 +2544,7 @@ +@@ -2584,7 +2584,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_METADATA_LOCKS VARIABLE_SCOPE GLOBAL @@ -951,7 +962,7 @@ VARIABLE_COMMENT Maximum number of metadata locks. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -2554,7 +2554,7 @@ +@@ -2594,7 +2594,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES VARIABLE_SCOPE GLOBAL @@ -960,7 +971,7 @@ VARIABLE_COMMENT Maximum number of mutex instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2564,7 +2564,7 @@ +@@ -2604,7 +2604,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES VARIABLE_SCOPE GLOBAL @@ -969,7 +980,7 @@ VARIABLE_COMMENT Maximum number of instrumented MUTEX objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -2574,7 +2574,7 @@ +@@ -2614,7 +2614,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PREPARED_STATEMENTS_INSTANCES VARIABLE_SCOPE GLOBAL @@ -978,7 +989,7 @@ VARIABLE_COMMENT Maximum number of instrumented prepared statements. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2584,7 +2584,7 @@ +@@ -2624,7 +2624,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PROGRAM_INSTANCES VARIABLE_SCOPE GLOBAL @@ -987,7 +998,7 @@ VARIABLE_COMMENT Maximum number of instrumented programs. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2594,7 +2594,7 @@ +@@ -2634,7 +2634,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES VARIABLE_SCOPE GLOBAL @@ -996,7 +1007,7 @@ VARIABLE_COMMENT Maximum number of rwlock instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2604,7 +2604,7 @@ +@@ -2644,7 +2644,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1005,7 +1016,7 @@ VARIABLE_COMMENT Maximum number of instrumented RWLOCK objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -2614,7 +2614,7 @@ +@@ -2654,7 +2654,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_CLASSES VARIABLE_SCOPE GLOBAL @@ -1014,7 +1025,7 @@ VARIABLE_COMMENT Maximum number of socket instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2624,7 +2624,7 @@ +@@ -2664,7 +2664,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1023,7 +1034,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented sockets. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2634,7 +2634,7 @@ +@@ -2674,7 +2674,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SQL_TEXT_LENGTH VARIABLE_SCOPE GLOBAL @@ -1032,7 +1043,7 @@ VARIABLE_COMMENT Maximum length of displayed sql text. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2644,7 +2644,7 @@ +@@ -2684,7 +2684,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STAGE_CLASSES VARIABLE_SCOPE GLOBAL @@ -1041,7 +1052,7 @@ VARIABLE_COMMENT Maximum number of stage instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2654,7 +2654,7 @@ +@@ -2694,7 +2694,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_CLASSES VARIABLE_SCOPE GLOBAL @@ -1050,7 +1061,7 @@ VARIABLE_COMMENT Maximum number of statement instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2664,7 +2664,7 @@ +@@ -2704,7 +2704,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_STACK VARIABLE_SCOPE GLOBAL @@ -1059,7 +1070,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_CURRENT. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 256 -@@ -2674,7 +2674,7 @@ +@@ -2714,7 +2714,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES VARIABLE_SCOPE GLOBAL @@ -1068,7 +1079,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented tables. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2684,7 +2684,7 @@ +@@ -2724,7 +2724,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1077,7 +1088,7 @@ VARIABLE_COMMENT Maximum number of instrumented tables. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2694,7 +2694,7 @@ +@@ -2734,7 +2734,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_LOCK_STAT VARIABLE_SCOPE GLOBAL @@ -1086,7 +1097,7 @@ VARIABLE_COMMENT Maximum number of lock statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2704,7 +2704,7 @@ +@@ -2744,7 +2744,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES VARIABLE_SCOPE GLOBAL @@ -1095,7 +1106,7 @@ VARIABLE_COMMENT Maximum number of thread instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2714,7 +2714,7 @@ +@@ -2754,7 +2754,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1104,7 +1115,7 @@ VARIABLE_COMMENT Maximum number of instrumented threads. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2724,7 +2724,7 @@ +@@ -2764,7 +2764,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SESSION_CONNECT_ATTRS_SIZE VARIABLE_SCOPE GLOBAL @@ -1113,7 +1124,7 @@ VARIABLE_COMMENT Size of session attribute string buffer per thread. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2734,7 +2734,7 @@ +@@ -2774,7 +2774,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_ACTORS_SIZE VARIABLE_SCOPE GLOBAL @@ -1122,7 +1133,7 @@ VARIABLE_COMMENT Maximum number of rows in SETUP_ACTORS. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2744,7 +2744,7 @@ +@@ -2784,7 +2784,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_OBJECTS_SIZE VARIABLE_SCOPE GLOBAL @@ -1131,7 +1142,7 @@ VARIABLE_COMMENT Maximum number of rows in SETUP_OBJECTS. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2754,7 +2754,7 @@ +@@ -2794,7 +2794,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_USERS_SIZE VARIABLE_SCOPE GLOBAL @@ -1140,7 +1151,7 @@ VARIABLE_COMMENT Maximum number of instrumented users. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2804,7 +2804,7 @@ +@@ -2844,7 +2844,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PRELOAD_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1149,7 +1160,7 @@ VARIABLE_COMMENT The size of the buffer that is allocated when preloading indexes NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -2824,7 +2824,7 @@ +@@ -2864,7 +2864,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME PROFILING_HISTORY_SIZE VARIABLE_SCOPE SESSION @@ -1158,7 +1169,7 @@ VARIABLE_COMMENT Number of statements about which profiling information is maintained. If set to 0, no profiles are stored. See SHOW PROFILES. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 100 -@@ -2834,7 +2834,7 @@ +@@ -2874,7 +2874,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PROGRESS_REPORT_TIME VARIABLE_SCOPE SESSION @@ -1167,7 +1178,7 @@ VARIABLE_COMMENT Seconds between sending progress reports to the client for time-consuming statements. Set to 0 to disable progress reporting. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2894,7 +2894,7 @@ +@@ -2934,7 +2934,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME QUERY_ALLOC_BLOCK_SIZE VARIABLE_SCOPE SESSION @@ -1176,7 +1187,7 @@ VARIABLE_COMMENT Allocation block size for query parsing and execution NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 4294967295 -@@ -2904,7 +2904,7 @@ +@@ -2944,7 +2944,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME QUERY_CACHE_LIMIT VARIABLE_SCOPE GLOBAL @@ -1185,7 +1196,7 @@ VARIABLE_COMMENT Don't cache results that are bigger than this NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2914,7 +2914,7 @@ +@@ -2954,7 +2954,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME QUERY_CACHE_MIN_RES_UNIT VARIABLE_SCOPE GLOBAL @@ -1194,7 +1205,7 @@ VARIABLE_COMMENT The minimum size for blocks allocated by the query cache NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2927,7 +2927,7 @@ +@@ -2967,7 +2967,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The memory allocated to store results from old queries NUMERIC_MIN_VALUE 0 @@ -1203,7 +1214,7 @@ NUMERIC_BLOCK_SIZE 1024 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -2964,7 +2964,7 @@ +@@ -3004,7 +3004,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME QUERY_PREALLOC_SIZE VARIABLE_SCOPE SESSION @@ -1212,7 +1223,7 @@ VARIABLE_COMMENT Persistent buffer for query parsing and execution NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 4294967295 -@@ -2977,7 +2977,7 @@ +@@ -3017,7 +3017,7 @@ VARIABLE_SCOPE SESSION ONLY VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes NUMERIC_MIN_VALUE 0 @@ -1221,7 +1232,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -2987,14 +2987,14 @@ +@@ -3027,14 +3027,14 @@ VARIABLE_SCOPE SESSION ONLY VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes NUMERIC_MIN_VALUE 0 @@ -1238,7 +1249,7 @@ VARIABLE_COMMENT Allocation block size for storing ranges during optimization NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 4294967295 -@@ -3004,7 +3004,7 @@ +@@ -3044,7 +3044,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME READ_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1247,7 +1258,7 @@ VARIABLE_COMMENT Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value NUMERIC_MIN_VALUE 8192 NUMERIC_MAX_VALUE 2147483647 -@@ -3024,7 +3024,7 @@ +@@ -3064,7 +3064,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME READ_RND_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1256,7 +1267,7 @@ VARIABLE_COMMENT When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 2147483647 -@@ -3044,10 +3044,10 @@ +@@ -3084,10 +3084,10 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ROWID_MERGE_BUFF_SIZE VARIABLE_SCOPE SESSION @@ -1269,7 +1280,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3084,7 +3084,7 @@ +@@ -3124,7 +3124,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SERVER_ID VARIABLE_SCOPE SESSION @@ -1278,7 +1289,7 @@ VARIABLE_COMMENT Uniquely identifies the server instance in the community of replication partners NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -3164,7 +3164,7 @@ +@@ -3204,7 +3204,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME SLAVE_MAX_ALLOWED_PACKET VARIABLE_SCOPE GLOBAL @@ -1287,7 +1298,7 @@ VARIABLE_COMMENT The maximum packet length to sent successfully from the master to slave. NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -3174,7 +3174,7 @@ +@@ -3214,7 +3214,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLOW_LAUNCH_TIME VARIABLE_SCOPE GLOBAL @@ -1296,7 +1307,7 @@ VARIABLE_COMMENT If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 -@@ -3217,7 +3217,7 @@ +@@ -3257,7 +3257,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Each thread that needs to do a sort allocates a buffer of this size NUMERIC_MIN_VALUE 1024 @@ -1305,7 +1316,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3434,7 +3434,7 @@ +@@ -3474,7 +3474,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME STORED_PROGRAM_CACHE VARIABLE_SCOPE GLOBAL @@ -1314,8 +1325,8 @@ VARIABLE_COMMENT The soft upper limit for number of cached stored routines for one connection. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 524288 -@@ -3514,7 +3514,7 @@ - COMMAND_LINE_ARGUMENT NULL +@@ -3564,7 +3564,7 @@ READ_ONLY NO + COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME TABLE_DEFINITION_CACHE VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED @@ -1323,7 +1334,7 @@ VARIABLE_COMMENT The number of cached table definitions NUMERIC_MIN_VALUE 400 NUMERIC_MAX_VALUE 2097152 -@@ -3524,7 +3524,7 @@ +@@ -3574,7 +3574,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME TABLE_OPEN_CACHE VARIABLE_SCOPE GLOBAL @@ -1332,7 +1343,7 @@ VARIABLE_COMMENT The number of cached open tables NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 1048576 -@@ -3584,7 +3584,7 @@ +@@ -3634,7 +3634,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME THREAD_CACHE_SIZE VARIABLE_SCOPE GLOBAL @@ -1341,7 +1352,7 @@ VARIABLE_COMMENT How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 -@@ -3667,7 +3667,7 @@ +@@ -3717,7 +3717,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Max size for data for an internal temporary on-disk MyISAM or Aria table. NUMERIC_MIN_VALUE 1024 @@ -1350,7 +1361,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3677,7 +3677,7 @@ +@@ -3727,7 +3727,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table. Same as tmp_table_size. NUMERIC_MIN_VALUE 0 @@ -1359,7 +1370,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3687,14 +3687,14 @@ +@@ -3737,14 +3737,14 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Alias for tmp_memory_table_size. If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table. NUMERIC_MIN_VALUE 0 @@ -1376,7 +1387,7 @@ VARIABLE_COMMENT Allocation block size for transactions to be stored in binary log NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 134217728 -@@ -3704,7 +3704,7 @@ +@@ -3754,7 +3754,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME TRANSACTION_PREALLOC_SIZE VARIABLE_SCOPE SESSION @@ -1385,7 +1396,7 @@ VARIABLE_COMMENT Persistent buffer for transactions to be stored in binary log NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 134217728 -@@ -3844,7 +3844,7 @@ +@@ -3894,7 +3894,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME WAIT_TIMEOUT VARIABLE_SCOPE SESSION @@ -1394,7 +1405,7 @@ VARIABLE_COMMENT The number of seconds the server waits for activity on a connection before closing it NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -3871,7 +3871,7 @@ +@@ -3921,7 +3921,7 @@ order by variable_name; VARIABLE_NAME LOG_TC_SIZE GLOBAL_VALUE_ORIGIN AUTO 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 e6a83e7130600..467b832eca593 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -1655,7 +1655,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_QUERIES_NOT_USING_INDEXES VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Alias for log_slow_queries_not_using_indexes. Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' +VARIABLE_COMMENT Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL @@ -1702,17 +1702,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED -VARIABLE_NAME LOG_SLOW_QUERIES_NOT_USING_INDEXES -VARIABLE_SCOPE SESSION -VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' -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 LOG_SLOW_QUERY_ENABLE +VARIABLE_NAME LOG_SLOW_QUERY VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN VARIABLE_COMMENT Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. @@ -3235,7 +3225,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLOW_QUERY_LOG VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Alias for log_slow_query_enable. Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. +VARIABLE_COMMENT Alias for log_slow_query. Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff index 8ba94d3ba7792..38dc9d215b891 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff @@ -1,4 +1,6 @@ -@@ -44,7 +44,7 @@ +--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result ++++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +@@ -44,7 +44,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_BLOCK_SIZE VARIABLE_SCOPE GLOBAL @@ -7,7 +9,7 @@ VARIABLE_COMMENT Block size to be used for Aria index pages. NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 32768 -@@ -54,7 +54,7 @@ +@@ -54,7 +54,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_CHECKPOINT_INTERVAL VARIABLE_SCOPE GLOBAL @@ -16,7 +18,7 @@ VARIABLE_COMMENT Interval between tries to do an automatic checkpoints. In seconds; 0 means 'no automatic checkpoints' which makes sense only for testing. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -64,7 +64,7 @@ +@@ -64,7 +64,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_CHECKPOINT_LOG_ACTIVITY VARIABLE_SCOPE GLOBAL @@ -25,7 +27,7 @@ VARIABLE_COMMENT Number of bytes that the transaction log has to grow between checkpoints before a new checkpoint is written to the log. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -84,7 +84,7 @@ +@@ -84,7 +84,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ARIA_FORCE_START_AFTER_RECOVERY_FAILURES VARIABLE_SCOPE GLOBAL @@ -34,7 +36,7 @@ VARIABLE_COMMENT Number of consecutive log recovery failures after which logs will be automatically deleted to cure the problem; 0 (the default) disables the feature. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 255 -@@ -104,7 +104,7 @@ +@@ -104,7 +104,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_GROUP_COMMIT_INTERVAL VARIABLE_SCOPE GLOBAL @@ -43,7 +45,7 @@ VARIABLE_COMMENT Interval between commits in microseconds (1/1000000 sec). 0 stands for no waiting for other threads to come and do a commit in "hard" mode and no sync()/commit at all in "soft" mode. Option has only an effect if aria_group_commit is used NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -114,7 +114,7 @@ +@@ -114,7 +114,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_LOG_FILE_SIZE VARIABLE_SCOPE GLOBAL @@ -52,7 +54,7 @@ VARIABLE_COMMENT Limit for transaction log size NUMERIC_MIN_VALUE 8388608 NUMERIC_MAX_VALUE 4294967295 -@@ -144,10 +144,10 @@ +@@ -144,10 +144,10 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_PAGECACHE_AGE_THRESHOLD VARIABLE_SCOPE GLOBAL @@ -65,7 +67,7 @@ NUMERIC_BLOCK_SIZE 100 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -164,7 +164,7 @@ +@@ -164,7 +164,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_PAGECACHE_DIVISION_LIMIT VARIABLE_SCOPE GLOBAL @@ -74,7 +76,7 @@ VARIABLE_COMMENT The minimum percentage of warm blocks in key cache NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 100 -@@ -174,7 +174,7 @@ +@@ -174,7 +174,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_PAGECACHE_FILE_HASH_SIZE VARIABLE_SCOPE GLOBAL @@ -83,7 +85,7 @@ VARIABLE_COMMENT Number of hash buckets for open and changed files. If you have a lot of Aria files open you should increase this for faster flush of changes. A good value is probably 1/10 of number of possible open Aria files. NUMERIC_MIN_VALUE 128 NUMERIC_MAX_VALUE 16384 -@@ -204,7 +204,7 @@ +@@ -204,7 +204,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ARIA_REPAIR_THREADS VARIABLE_SCOPE SESSION @@ -92,7 +94,7 @@ VARIABLE_COMMENT Number of threads to use when repairing Aria tables. The value of 1 disables parallel repair. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 128 -@@ -217,7 +217,7 @@ +@@ -217,7 +217,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE. NUMERIC_MIN_VALUE 4096 @@ -101,7 +103,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -274,7 +274,7 @@ +@@ -274,7 +274,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME AUTO_INCREMENT_INCREMENT VARIABLE_SCOPE SESSION @@ -110,7 +112,7 @@ VARIABLE_COMMENT Auto-increment columns are incremented by this NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 65535 -@@ -284,7 +284,7 @@ +@@ -284,7 +284,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME AUTO_INCREMENT_OFFSET VARIABLE_SCOPE SESSION @@ -119,7 +121,7 @@ VARIABLE_COMMENT Offset added to Auto-increment columns. Used when auto-increment-increment != 1 NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 65535 -@@ -294,7 +294,7 @@ +@@ -294,7 +294,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME BACK_LOG VARIABLE_SCOPE GLOBAL @@ -128,7 +130,7 @@ VARIABLE_COMMENT The number of outstanding connection requests MariaDB can have. This comes into play when the main MariaDB thread gets very many connection requests in a very short time NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 65535 -@@ -357,7 +357,7 @@ +@@ -357,7 +357,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of the transactional cache for updates to transactional engines for the binary log. If you often use transactions containing many statements, you can increase this to get more performance NUMERIC_MIN_VALUE 4096 @@ -137,7 +139,7 @@ NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -374,20 +374,20 @@ +@@ -374,20 +374,20 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME BINLOG_COMMIT_WAIT_COUNT VARIABLE_SCOPE GLOBAL @@ -162,7 +164,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -404,7 +404,7 @@ +@@ -404,7 +404,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME BINLOG_EXPIRE_LOGS_SECONDS VARIABLE_SCOPE GLOBAL @@ -171,7 +173,7 @@ VARIABLE_COMMENT If non-zero, binary logs will be purged after binlog_expire_logs_seconds seconds; It and expire_logs_days are linked, such that changes in one are converted into the other. Possible purges happen at startup and at binary log rotation. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 8553600 -@@ -417,7 +417,7 @@ +@@ -417,7 +417,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of file cache for the binary log NUMERIC_MIN_VALUE 8192 @@ -180,7 +182,7 @@ NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -467,7 +467,7 @@ +@@ -467,7 +467,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of the statement cache for updates to non-transactional engines for the binary log. If you often use statements updating a great number of rows, you can increase this to get more performance. NUMERIC_MIN_VALUE 4096 @@ -189,7 +191,7 @@ NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -477,7 +477,7 @@ +@@ -477,7 +477,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread! NUMERIC_MIN_VALUE 0 @@ -198,7 +200,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -664,7 +664,7 @@ +@@ -664,7 +664,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME CONNECT_TIMEOUT VARIABLE_SCOPE GLOBAL @@ -207,7 +209,7 @@ VARIABLE_COMMENT The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake' NUMERIC_MIN_VALUE 2 NUMERIC_MAX_VALUE 31536000 -@@ -714,7 +714,7 @@ +@@ -714,7 +714,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DEADLOCK_SEARCH_DEPTH_LONG VARIABLE_SCOPE SESSION @@ -216,7 +218,7 @@ VARIABLE_COMMENT Long search depth for the two-step deadlock detection NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 33 -@@ -724,7 +724,7 @@ +@@ -724,7 +724,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DEADLOCK_SEARCH_DEPTH_SHORT VARIABLE_SCOPE SESSION @@ -225,7 +227,7 @@ VARIABLE_COMMENT Short search depth for the two-step deadlock detection NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 32 -@@ -734,7 +734,7 @@ +@@ -734,7 +734,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DEADLOCK_TIMEOUT_LONG VARIABLE_SCOPE SESSION @@ -234,7 +236,7 @@ VARIABLE_COMMENT Long timeout for the two-step deadlock detection (in microseconds) NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -744,7 +744,7 @@ +@@ -744,7 +744,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DEADLOCK_TIMEOUT_SHORT VARIABLE_SCOPE SESSION @@ -243,7 +245,7 @@ VARIABLE_COMMENT Short timeout for the two-step deadlock detection (in microseconds) NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -804,7 +804,7 @@ +@@ -804,7 +804,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME DEFAULT_WEEK_FORMAT VARIABLE_SCOPE SESSION @@ -252,7 +254,7 @@ VARIABLE_COMMENT The default week format used by WEEK() functions NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 7 -@@ -814,7 +814,7 @@ +@@ -814,7 +814,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DELAYED_INSERT_LIMIT VARIABLE_SCOPE GLOBAL @@ -261,7 +263,7 @@ VARIABLE_COMMENT After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if there are any SELECT statements pending. If so, it allows these to execute before continuing. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -824,7 +824,7 @@ +@@ -824,7 +824,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DELAYED_INSERT_TIMEOUT VARIABLE_SCOPE GLOBAL @@ -270,7 +272,7 @@ VARIABLE_COMMENT How long a INSERT DELAYED thread should wait for INSERT statements before terminating NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -834,7 +834,7 @@ +@@ -834,7 +834,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME DELAYED_QUEUE_SIZE VARIABLE_SCOPE GLOBAL @@ -279,7 +281,7 @@ VARIABLE_COMMENT What size queue (in rows) should be allocated for handling INSERT DELAYED. If the queue becomes full, any client that does INSERT DELAYED will wait until there is room in the queue again NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -864,7 +864,7 @@ +@@ -864,7 +864,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME DIV_PRECISION_INCREMENT VARIABLE_SCOPE SESSION @@ -288,7 +290,7 @@ VARIABLE_COMMENT Precision of the result of '/' operator will be increased on that value NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 38 -@@ -984,7 +984,7 @@ +@@ -984,7 +984,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME EXTRA_MAX_CONNECTIONS VARIABLE_SCOPE GLOBAL @@ -297,7 +299,7 @@ VARIABLE_COMMENT The number of connections on extra-port NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 100000 -@@ -1014,7 +1014,7 @@ +@@ -1014,7 +1014,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME FLUSH_TIME VARIABLE_SCOPE GLOBAL @@ -306,7 +308,7 @@ VARIABLE_COMMENT A dedicated thread is created to flush all tables at the given interval NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 -@@ -1044,7 +1044,7 @@ +@@ -1044,7 +1044,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME FT_MAX_WORD_LEN VARIABLE_SCOPE GLOBAL @@ -315,7 +317,7 @@ VARIABLE_COMMENT The maximum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 84 -@@ -1054,7 +1054,7 @@ +@@ -1054,7 +1054,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME FT_MIN_WORD_LEN VARIABLE_SCOPE GLOBAL @@ -324,7 +326,7 @@ VARIABLE_COMMENT The minimum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 84 -@@ -1064,7 +1064,7 @@ +@@ -1064,7 +1064,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME FT_QUERY_EXPANSION_LIMIT VARIABLE_SCOPE GLOBAL @@ -333,7 +335,7 @@ VARIABLE_COMMENT Number of best matches to use for query expansion NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1000 -@@ -1314,7 +1314,7 @@ +@@ -1314,7 +1314,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME HISTOGRAM_SIZE VARIABLE_SCOPE SESSION @@ -342,7 +344,7 @@ VARIABLE_COMMENT Number of bytes used for a histogram. If set to 0, no histograms are created by ANALYZE. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 255 -@@ -1344,7 +1344,7 @@ +@@ -1344,7 +1344,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME HOST_CACHE_SIZE VARIABLE_SCOPE GLOBAL @@ -351,7 +353,7 @@ VARIABLE_COMMENT How many host names should be cached to avoid resolving. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 65536 -@@ -1454,7 +1454,7 @@ +@@ -1454,7 +1454,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME INTERACTIVE_TIMEOUT VARIABLE_SCOPE SESSION @@ -360,7 +362,7 @@ VARIABLE_COMMENT The number of seconds the server waits for activity on an interactive connection before closing it NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -1487,7 +1487,7 @@ +@@ -1487,7 +1487,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of the buffer that is used for joins NUMERIC_MIN_VALUE 128 @@ -369,7 +371,7 @@ NUMERIC_BLOCK_SIZE 128 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1504,7 +1504,7 @@ +@@ -1504,7 +1504,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME JOIN_CACHE_LEVEL VARIABLE_SCOPE SESSION @@ -378,7 +380,7 @@ VARIABLE_COMMENT Controls what join operations can be executed with join buffers. Odd numbers are used for plain join buffers while even numbers are used for linked buffers NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 8 -@@ -1527,7 +1527,7 @@ +@@ -1527,7 +1527,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford NUMERIC_MIN_VALUE 0 @@ -387,7 +389,7 @@ NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1694,7 +1694,7 @@ +@@ -1694,7 +1694,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME LOCK_WAIT_TIMEOUT VARIABLE_SCOPE SESSION @@ -396,7 +398,16 @@ VARIABLE_COMMENT Timeout in seconds to wait for a lock before returning an error. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 -@@ -1844,7 +1844,7 @@ +@@ -1844,7 +1844,7 @@ READ_ONLY NO + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME LOG_SLOW_MIN_EXAMINED_ROW_LIMIT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Don't write queries to slow log that examine fewer rows than that + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -1884,7 +1884,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_SLOW_RATE_LIMIT VARIABLE_SCOPE SESSION @@ -405,7 +416,7 @@ VARIABLE_COMMENT Write to slow log every #th slow query. Set to 1 to log everything. Increase it to reduce the size of the slow or the performance impact of slow logging NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -1874,7 +1874,7 @@ +@@ -1914,7 +1914,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_WARNINGS VARIABLE_SCOPE SESSION @@ -414,7 +425,7 @@ VARIABLE_COMMENT Log some not critical warnings to the general log file.Value can be between 0 and 11. Higher values mean more verbosity NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -1934,7 +1934,7 @@ +@@ -1974,7 +1974,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME MAX_ALLOWED_PACKET VARIABLE_SCOPE SESSION @@ -423,7 +434,7 @@ VARIABLE_COMMENT Max packet length to send to or receive from the server NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -1947,14 +1947,14 @@ +@@ -1987,14 +1987,14 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the total size of the transactional cache NUMERIC_MIN_VALUE 4096 @@ -440,7 +451,7 @@ VARIABLE_COMMENT Binary log will be rotated automatically when the size exceeds this value. NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 1073741824 -@@ -1967,14 +1967,14 @@ +@@ -2007,14 +2007,14 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the total size of the statement cache NUMERIC_MIN_VALUE 4096 @@ -457,7 +468,7 @@ VARIABLE_COMMENT The number of simultaneous clients allowed NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 100000 -@@ -1984,7 +1984,7 @@ +@@ -2024,7 +2024,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_CONNECT_ERRORS VARIABLE_SCOPE GLOBAL @@ -466,7 +477,7 @@ VARIABLE_COMMENT If there is more than this number of interrupted connections from a host this host will be blocked from further connections NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -1994,7 +1994,7 @@ +@@ -2034,7 +2034,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_DELAYED_THREADS VARIABLE_SCOPE SESSION @@ -475,7 +486,7 @@ VARIABLE_COMMENT Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 -@@ -2014,7 +2014,7 @@ +@@ -2054,7 +2054,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_ERROR_COUNT VARIABLE_SCOPE SESSION @@ -484,7 +495,7 @@ VARIABLE_COMMENT Max number of errors/warnings to store for a statement NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 65535 -@@ -2027,14 +2027,14 @@ +@@ -2067,14 +2067,14 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Don't allow creation of heap tables bigger than this NUMERIC_MIN_VALUE 16384 @@ -498,10 +509,10 @@ VARIABLE_SCOPE SESSION -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used + VARIABLE_COMMENT Alias for max_delayed_threads. Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 -@@ -2054,7 +2054,7 @@ +@@ -2094,7 +2094,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_LENGTH_FOR_SORT_DATA VARIABLE_SCOPE SESSION @@ -510,7 +521,7 @@ VARIABLE_COMMENT Max number of bytes in sorted records NUMERIC_MIN_VALUE 4 NUMERIC_MAX_VALUE 8388608 -@@ -2084,7 +2084,7 @@ +@@ -2124,7 +2124,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_RECURSIVE_ITERATIONS VARIABLE_SCOPE SESSION @@ -519,7 +530,7 @@ VARIABLE_COMMENT Maximum number of iterations when executing recursive queries NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2107,14 +2107,14 @@ +@@ -2147,14 +2147,14 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The maximum size of the container of a rowid filter NUMERIC_MIN_VALUE 1024 @@ -536,7 +547,7 @@ VARIABLE_COMMENT Limit assumed max number of seeks when looking up rows based on a key NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -2134,7 +2134,7 @@ +@@ -2174,7 +2174,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_SORT_LENGTH VARIABLE_SCOPE SESSION @@ -545,7 +556,7 @@ VARIABLE_COMMENT The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored) NUMERIC_MIN_VALUE 64 NUMERIC_MAX_VALUE 8388608 -@@ -2144,7 +2144,7 @@ +@@ -2184,7 +2184,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_SP_RECURSION_DEPTH VARIABLE_SCOPE SESSION @@ -554,7 +565,7 @@ VARIABLE_COMMENT Maximum stored procedure recursion depth NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 255 -@@ -2164,7 +2164,7 @@ +@@ -2204,7 +2204,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_TMP_TABLES VARIABLE_SCOPE SESSION @@ -563,7 +574,7 @@ VARIABLE_COMMENT Unused, will be removed. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -2184,7 +2184,7 @@ +@@ -2224,7 +2224,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MAX_WRITE_LOCK_COUNT VARIABLE_SCOPE GLOBAL @@ -572,7 +583,7 @@ VARIABLE_COMMENT After this many write locks, allow some read locks to run in between NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -2194,7 +2194,7 @@ +@@ -2234,7 +2234,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME METADATA_LOCKS_CACHE_SIZE VARIABLE_SCOPE GLOBAL @@ -581,7 +592,7 @@ VARIABLE_COMMENT Unused NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1048576 -@@ -2204,7 +2204,7 @@ +@@ -2244,7 +2244,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME METADATA_LOCKS_HASH_INSTANCES VARIABLE_SCOPE GLOBAL @@ -590,16 +601,16 @@ VARIABLE_COMMENT Unused NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1024 -@@ -2214,7 +2214,7 @@ +@@ -2254,7 +2254,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MIN_EXAMINED_ROW_LIMIT VARIABLE_SCOPE SESSION -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Don't write queries to slow log that examine fewer rows than that + VARIABLE_COMMENT Alias for log_slow_min_examined_row_limit. Don't write queries to slow log that examine fewer rows than that NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2224,7 +2224,7 @@ +@@ -2264,7 +2264,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MRR_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -608,7 +619,7 @@ VARIABLE_COMMENT Size of buffer to use when using MRR with range access NUMERIC_MIN_VALUE 8192 NUMERIC_MAX_VALUE 2147483647 -@@ -2234,7 +2234,7 @@ +@@ -2274,7 +2274,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MYISAM_BLOCK_SIZE VARIABLE_SCOPE GLOBAL @@ -617,7 +628,7 @@ VARIABLE_COMMENT Block size to be used for MyISAM index pages NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 16384 -@@ -2244,7 +2244,7 @@ +@@ -2284,7 +2284,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME MYISAM_DATA_POINTER_SIZE VARIABLE_SCOPE GLOBAL @@ -626,7 +637,7 @@ VARIABLE_COMMENT Default pointer size to be used for MyISAM tables NUMERIC_MIN_VALUE 2 NUMERIC_MAX_VALUE 7 -@@ -2267,7 +2267,7 @@ +@@ -2307,7 +2307,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Restricts the total memory used for memory mapping of MySQL tables NUMERIC_MIN_VALUE 7 @@ -635,7 +646,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY YES -@@ -2284,10 +2284,10 @@ +@@ -2324,10 +2324,10 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME MYISAM_REPAIR_THREADS VARIABLE_SCOPE SESSION @@ -648,7 +659,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -2297,7 +2297,7 @@ +@@ -2337,7 +2337,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE NUMERIC_MIN_VALUE 4096 @@ -657,7 +668,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -2334,7 +2334,7 @@ +@@ -2374,7 +2374,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME NET_BUFFER_LENGTH VARIABLE_SCOPE SESSION @@ -666,7 +677,7 @@ VARIABLE_COMMENT Buffer length for TCP/IP and socket communication NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1048576 -@@ -2344,7 +2344,7 @@ +@@ -2384,7 +2384,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME NET_READ_TIMEOUT VARIABLE_SCOPE SESSION @@ -675,7 +686,7 @@ VARIABLE_COMMENT Number of seconds to wait for more data from a connection before aborting the read NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -2354,7 +2354,7 @@ +@@ -2394,7 +2394,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME NET_RETRY_COUNT VARIABLE_SCOPE SESSION @@ -684,7 +695,7 @@ VARIABLE_COMMENT If a read on a communication port is interrupted, retry this many times before giving up NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -2364,7 +2364,7 @@ +@@ -2404,7 +2404,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME NET_WRITE_TIMEOUT VARIABLE_SCOPE SESSION @@ -693,7 +704,7 @@ VARIABLE_COMMENT Number of seconds to wait for a block to be written to a connection before aborting the write NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -2414,7 +2414,7 @@ +@@ -2454,7 +2454,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME OPEN_FILES_LIMIT VARIABLE_SCOPE GLOBAL @@ -702,7 +713,7 @@ VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2424,7 +2424,7 @@ +@@ -2464,7 +2464,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_EXTRA_PRUNING_DEPTH VARIABLE_SCOPE SESSION @@ -711,7 +722,7 @@ VARIABLE_COMMENT If the optimizer needs to enumerate join prefix of this size or larger, then it will try agressively prune away the search space. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 62 -@@ -2434,17 +2434,17 @@ +@@ -2474,17 +2474,17 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_MAX_SEL_ARG_WEIGHT VARIABLE_SCOPE SESSION @@ -732,7 +743,7 @@ VARIABLE_COMMENT Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search: 1 - prune plans based on cost and number of retrieved rows eq_ref: 2 - prune also if we find an eq_ref chain NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2 -@@ -2454,7 +2454,7 @@ +@@ -2494,7 +2494,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_SEARCH_DEPTH VARIABLE_SCOPE SESSION @@ -741,7 +752,7 @@ VARIABLE_COMMENT Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Values smaller than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 62 -@@ -2464,7 +2464,7 @@ +@@ -2504,7 +2504,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_SELECTIVITY_SAMPLING_LIMIT VARIABLE_SCOPE SESSION @@ -750,7 +761,7 @@ VARIABLE_COMMENT Controls number of record samples to check condition selectivity NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 4294967295 -@@ -2494,17 +2494,17 @@ +@@ -2534,17 +2534,17 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_TRACE_MAX_MEM_SIZE VARIABLE_SCOPE SESSION @@ -771,7 +782,7 @@ VARIABLE_COMMENT Controls selectivity of which conditions the optimizer takes into account to calculate cardinality of a partial join when it searches for the best execution plan Meaning: 1 - use selectivity of index backed range conditions to calculate the cardinality of a partial join if the last joined table is accessed by full table scan or an index scan, 2 - use selectivity of index backed range conditions to calculate the cardinality of a partial join in any case, 3 - additionally always use selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join, 4 - use histograms to calculate selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join.5 - additionally use selectivity of certain non-range predicates calculated on record samples NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 5 -@@ -2524,7 +2524,7 @@ +@@ -2564,7 +2564,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME PERFORMANCE_SCHEMA_ACCOUNTS_SIZE VARIABLE_SCOPE GLOBAL @@ -780,7 +791,7 @@ VARIABLE_COMMENT Maximum number of instrumented user@host accounts. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2534,7 +2534,7 @@ +@@ -2574,7 +2574,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_DIGESTS_SIZE VARIABLE_SCOPE GLOBAL @@ -789,7 +800,7 @@ VARIABLE_COMMENT Size of the statement digest. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2544,7 +2544,7 @@ +@@ -2584,7 +2584,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -798,7 +809,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_STAGES_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2554,7 +2554,7 @@ +@@ -2594,7 +2594,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -807,7 +818,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STAGES_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2564,7 +2564,7 @@ +@@ -2604,7 +2604,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -816,7 +827,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_STATEMENTS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2574,7 +2574,7 @@ +@@ -2614,7 +2614,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -825,7 +836,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2584,7 +2584,7 @@ +@@ -2624,7 +2624,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -834,7 +845,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_TRANSACTIONS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2594,7 +2594,7 @@ +@@ -2634,7 +2634,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -843,7 +854,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_TRANSACTIONS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2604,7 +2604,7 @@ +@@ -2644,7 +2644,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -852,7 +863,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_WAITS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2614,7 +2614,7 @@ +@@ -2654,7 +2654,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -861,7 +872,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_WAITS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2624,7 +2624,7 @@ +@@ -2664,7 +2664,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_HOSTS_SIZE VARIABLE_SCOPE GLOBAL @@ -870,7 +881,7 @@ VARIABLE_COMMENT Maximum number of instrumented hosts. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2634,7 +2634,7 @@ +@@ -2674,7 +2674,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_CLASSES VARIABLE_SCOPE GLOBAL @@ -879,7 +890,7 @@ VARIABLE_COMMENT Maximum number of condition instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2644,7 +2644,7 @@ +@@ -2684,7 +2684,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_INSTANCES VARIABLE_SCOPE GLOBAL @@ -888,7 +899,7 @@ VARIABLE_COMMENT Maximum number of instrumented condition objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2654,7 +2654,7 @@ +@@ -2694,7 +2694,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_DIGEST_LENGTH VARIABLE_SCOPE GLOBAL @@ -897,7 +908,7 @@ VARIABLE_COMMENT Maximum length considered for digest text, when stored in performance_schema tables. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2664,7 +2664,7 @@ +@@ -2704,7 +2704,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_CLASSES VARIABLE_SCOPE GLOBAL @@ -906,7 +917,7 @@ VARIABLE_COMMENT Maximum number of file instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2674,7 +2674,7 @@ +@@ -2714,7 +2714,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_HANDLES VARIABLE_SCOPE GLOBAL @@ -915,7 +926,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented files. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2684,7 +2684,7 @@ +@@ -2724,7 +2724,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES VARIABLE_SCOPE GLOBAL @@ -924,7 +935,7 @@ VARIABLE_COMMENT Maximum number of instrumented files. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2694,7 +2694,7 @@ +@@ -2734,7 +2734,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_INDEX_STAT VARIABLE_SCOPE GLOBAL @@ -933,7 +944,7 @@ VARIABLE_COMMENT Maximum number of index statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2704,7 +2704,7 @@ +@@ -2744,7 +2744,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MEMORY_CLASSES VARIABLE_SCOPE GLOBAL @@ -942,7 +953,7 @@ VARIABLE_COMMENT Maximum number of memory pool instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1024 -@@ -2714,7 +2714,7 @@ +@@ -2754,7 +2754,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_METADATA_LOCKS VARIABLE_SCOPE GLOBAL @@ -951,7 +962,7 @@ VARIABLE_COMMENT Maximum number of metadata locks. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -2724,7 +2724,7 @@ +@@ -2764,7 +2764,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES VARIABLE_SCOPE GLOBAL @@ -960,7 +971,7 @@ VARIABLE_COMMENT Maximum number of mutex instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2734,7 +2734,7 @@ +@@ -2774,7 +2774,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES VARIABLE_SCOPE GLOBAL @@ -969,7 +980,7 @@ VARIABLE_COMMENT Maximum number of instrumented MUTEX objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -2744,7 +2744,7 @@ +@@ -2784,7 +2784,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PREPARED_STATEMENTS_INSTANCES VARIABLE_SCOPE GLOBAL @@ -978,7 +989,7 @@ VARIABLE_COMMENT Maximum number of instrumented prepared statements. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2754,7 +2754,7 @@ +@@ -2794,7 +2794,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PROGRAM_INSTANCES VARIABLE_SCOPE GLOBAL @@ -987,7 +998,7 @@ VARIABLE_COMMENT Maximum number of instrumented programs. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2764,7 +2764,7 @@ +@@ -2804,7 +2804,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES VARIABLE_SCOPE GLOBAL @@ -996,7 +1007,7 @@ VARIABLE_COMMENT Maximum number of rwlock instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2774,7 +2774,7 @@ +@@ -2814,7 +2814,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1005,7 +1016,7 @@ VARIABLE_COMMENT Maximum number of instrumented RWLOCK objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -2784,7 +2784,7 @@ +@@ -2824,7 +2824,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_CLASSES VARIABLE_SCOPE GLOBAL @@ -1014,7 +1025,7 @@ VARIABLE_COMMENT Maximum number of socket instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2794,7 +2794,7 @@ +@@ -2834,7 +2834,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1023,7 +1034,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented sockets. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2804,7 +2804,7 @@ +@@ -2844,7 +2844,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SQL_TEXT_LENGTH VARIABLE_SCOPE GLOBAL @@ -1032,7 +1043,7 @@ VARIABLE_COMMENT Maximum length of displayed sql text. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2814,7 +2814,7 @@ +@@ -2854,7 +2854,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STAGE_CLASSES VARIABLE_SCOPE GLOBAL @@ -1041,7 +1052,7 @@ VARIABLE_COMMENT Maximum number of stage instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2824,7 +2824,7 @@ +@@ -2864,7 +2864,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_CLASSES VARIABLE_SCOPE GLOBAL @@ -1050,7 +1061,7 @@ VARIABLE_COMMENT Maximum number of statement instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2834,7 +2834,7 @@ +@@ -2874,7 +2874,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_STACK VARIABLE_SCOPE GLOBAL @@ -1059,7 +1070,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_CURRENT. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 256 -@@ -2844,7 +2844,7 @@ +@@ -2884,7 +2884,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES VARIABLE_SCOPE GLOBAL @@ -1068,7 +1079,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented tables. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2854,7 +2854,7 @@ +@@ -2894,7 +2894,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1077,7 +1088,7 @@ VARIABLE_COMMENT Maximum number of instrumented tables. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2864,7 +2864,7 @@ +@@ -2904,7 +2904,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_LOCK_STAT VARIABLE_SCOPE GLOBAL @@ -1086,7 +1097,7 @@ VARIABLE_COMMENT Maximum number of lock statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2874,7 +2874,7 @@ +@@ -2914,7 +2914,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES VARIABLE_SCOPE GLOBAL @@ -1095,7 +1106,7 @@ VARIABLE_COMMENT Maximum number of thread instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2884,7 +2884,7 @@ +@@ -2924,7 +2924,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1104,7 +1115,7 @@ VARIABLE_COMMENT Maximum number of instrumented threads. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2894,7 +2894,7 @@ +@@ -2934,7 +2934,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SESSION_CONNECT_ATTRS_SIZE VARIABLE_SCOPE GLOBAL @@ -1113,7 +1124,7 @@ VARIABLE_COMMENT Size of session attribute string buffer per thread. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2904,7 +2904,7 @@ +@@ -2944,7 +2944,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_ACTORS_SIZE VARIABLE_SCOPE GLOBAL @@ -1122,7 +1133,7 @@ VARIABLE_COMMENT Maximum number of rows in SETUP_ACTORS. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2914,7 +2914,7 @@ +@@ -2954,7 +2954,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_OBJECTS_SIZE VARIABLE_SCOPE GLOBAL @@ -1131,7 +1142,7 @@ VARIABLE_COMMENT Maximum number of rows in SETUP_OBJECTS. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2924,7 +2924,7 @@ +@@ -2964,7 +2964,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_USERS_SIZE VARIABLE_SCOPE GLOBAL @@ -1140,7 +1151,7 @@ VARIABLE_COMMENT Maximum number of instrumented users. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2974,7 +2974,7 @@ +@@ -3014,7 +3014,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PRELOAD_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1149,7 +1160,7 @@ VARIABLE_COMMENT The size of the buffer that is allocated when preloading indexes NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -2994,7 +2994,7 @@ +@@ -3034,7 +3034,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME PROFILING_HISTORY_SIZE VARIABLE_SCOPE SESSION @@ -1158,7 +1169,7 @@ VARIABLE_COMMENT Number of statements about which profiling information is maintained. If set to 0, no profiles are stored. See SHOW PROFILES. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 100 -@@ -3004,7 +3004,7 @@ +@@ -3044,7 +3044,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PROGRESS_REPORT_TIME VARIABLE_SCOPE SESSION @@ -1167,7 +1178,7 @@ VARIABLE_COMMENT Seconds between sending progress reports to the client for time-consuming statements. Set to 0 to disable progress reporting. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3064,7 +3064,7 @@ +@@ -3104,7 +3104,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME QUERY_ALLOC_BLOCK_SIZE VARIABLE_SCOPE SESSION @@ -1176,7 +1187,7 @@ VARIABLE_COMMENT Allocation block size for query parsing and execution NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 4294967295 -@@ -3074,7 +3074,7 @@ +@@ -3114,7 +3114,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME QUERY_CACHE_LIMIT VARIABLE_SCOPE GLOBAL @@ -1185,7 +1196,7 @@ VARIABLE_COMMENT Don't cache results that are bigger than this NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3084,7 +3084,7 @@ +@@ -3124,7 +3124,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME QUERY_CACHE_MIN_RES_UNIT VARIABLE_SCOPE GLOBAL @@ -1194,7 +1205,7 @@ VARIABLE_COMMENT The minimum size for blocks allocated by the query cache NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3097,7 +3097,7 @@ +@@ -3137,7 +3137,7 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The memory allocated to store results from old queries NUMERIC_MIN_VALUE 0 @@ -1203,7 +1214,7 @@ NUMERIC_BLOCK_SIZE 1024 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3134,7 +3134,7 @@ +@@ -3174,7 +3174,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME QUERY_PREALLOC_SIZE VARIABLE_SCOPE SESSION @@ -1212,7 +1223,7 @@ VARIABLE_COMMENT Persistent buffer for query parsing and execution NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 4294967295 -@@ -3147,7 +3147,7 @@ +@@ -3187,7 +3187,7 @@ VARIABLE_SCOPE SESSION ONLY VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes NUMERIC_MIN_VALUE 0 @@ -1221,7 +1232,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3157,14 +3157,14 @@ +@@ -3197,14 +3197,14 @@ VARIABLE_SCOPE SESSION ONLY VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes NUMERIC_MIN_VALUE 0 @@ -1238,7 +1249,7 @@ VARIABLE_COMMENT Allocation block size for storing ranges during optimization NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 4294967295 -@@ -3177,14 +3177,14 @@ +@@ -3217,14 +3217,14 @@ VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Maximum speed(KB/s) to read binlog from master (0 = no limit) NUMERIC_MIN_VALUE 0 @@ -1255,7 +1266,7 @@ VARIABLE_COMMENT Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value NUMERIC_MIN_VALUE 8192 NUMERIC_MAX_VALUE 2147483647 -@@ -3204,7 +3204,7 @@ +@@ -3244,7 +3244,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME READ_RND_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1264,7 +1275,7 @@ VARIABLE_COMMENT When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 2147483647 -@@ -3414,10 +3414,10 @@ +@@ -3464,10 +3464,10 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ROWID_MERGE_BUFF_SIZE VARIABLE_SCOPE SESSION @@ -1277,7 +1288,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3434,20 +3434,20 @@ +@@ -3484,20 +3484,20 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME RPL_SEMI_SYNC_MASTER_TIMEOUT VARIABLE_SCOPE GLOBAL @@ -1302,7 +1313,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3504,10 +3504,10 @@ +@@ -3554,10 +3554,10 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME RPL_SEMI_SYNC_SLAVE_TRACE_LEVEL VARIABLE_SCOPE GLOBAL @@ -1315,7 +1326,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3544,7 +3544,7 @@ +@@ -3594,7 +3594,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SERVER_ID VARIABLE_SCOPE SESSION @@ -1324,7 +1335,7 @@ VARIABLE_COMMENT Uniquely identifies the server instance in the community of replication partners NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -3684,7 +3684,7 @@ +@@ -3734,7 +3734,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_DOMAIN_PARALLEL_THREADS VARIABLE_SCOPE GLOBAL @@ -1333,7 +1344,7 @@ VARIABLE_COMMENT Maximum number of parallel threads to use on slave for events in a single replication domain. When using multiple domains, this can be used to limit a single domain from grabbing all threads and thus stalling other domains. The default of 0 means to allow a domain to grab as many threads as it wants, up to the value of slave_parallel_threads. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16383 -@@ -3714,7 +3714,7 @@ +@@ -3764,7 +3764,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_MAX_ALLOWED_PACKET VARIABLE_SCOPE GLOBAL @@ -1342,7 +1353,7 @@ VARIABLE_COMMENT The maximum packet length to sent successfully from the master to slave. NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -3734,7 +3734,7 @@ +@@ -3794,7 +3794,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_PARALLEL_MAX_QUEUED VARIABLE_SCOPE GLOBAL @@ -1351,7 +1362,7 @@ VARIABLE_COMMENT Limit on how much memory SQL threads should use per parallel replication thread when reading ahead in the relay log looking for opportunities for parallel replication. Only used when --slave-parallel-threads > 0. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2147483647 -@@ -3754,7 +3754,7 @@ +@@ -3814,7 +3814,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME SLAVE_PARALLEL_THREADS VARIABLE_SCOPE GLOBAL @@ -1360,7 +1371,7 @@ VARIABLE_COMMENT If non-zero, number of threads to spawn to apply in parallel events on the slave that were group-committed on the master or were logged with GTID in different replication domains. Note that these threads are in addition to the IO and SQL threads, which are always created by a replication slave NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16383 -@@ -3764,7 +3764,7 @@ +@@ -3824,7 +3824,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_PARALLEL_WORKERS VARIABLE_SCOPE GLOBAL @@ -1369,7 +1380,7 @@ VARIABLE_COMMENT Alias for slave_parallel_threads NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16383 -@@ -3804,7 +3804,7 @@ +@@ -3864,7 +3864,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME SLAVE_TRANSACTION_RETRIES VARIABLE_SCOPE GLOBAL @@ -1378,7 +1389,7 @@ VARIABLE_COMMENT Number of times the slave SQL thread will retry a transaction in case it failed with a deadlock, elapsed lock wait timeout or listed in slave_transaction_retry_errors, before giving up and stopping NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3824,7 +3824,7 @@ +@@ -3884,7 +3884,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_TRANSACTION_RETRY_INTERVAL VARIABLE_SCOPE GLOBAL @@ -1387,7 +1398,7 @@ VARIABLE_COMMENT Interval of the slave SQL thread will retry a transaction in case it failed with a deadlock or elapsed lock wait timeout or listed in slave_transaction_retry_errors NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 3600 -@@ -3844,7 +3844,7 @@ +@@ -3904,7 +3904,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLOW_LAUNCH_TIME VARIABLE_SCOPE GLOBAL @@ -1396,7 +1407,7 @@ VARIABLE_COMMENT If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 -@@ -3887,7 +3887,7 @@ +@@ -3947,7 +3947,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Each thread that needs to do a sort allocates a buffer of this size NUMERIC_MIN_VALUE 1024 @@ -1405,7 +1416,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -4114,7 +4114,7 @@ +@@ -4174,7 +4174,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME STORED_PROGRAM_CACHE VARIABLE_SCOPE GLOBAL @@ -1414,8 +1425,8 @@ VARIABLE_COMMENT The soft upper limit for number of cached stored routines for one connection. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 524288 -@@ -4214,7 +4214,7 @@ - COMMAND_LINE_ARGUMENT NULL +@@ -4284,7 +4284,7 @@ READ_ONLY NO + COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME TABLE_DEFINITION_CACHE VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED @@ -1423,7 +1434,7 @@ VARIABLE_COMMENT The number of cached table definitions NUMERIC_MIN_VALUE 400 NUMERIC_MAX_VALUE 2097152 -@@ -4224,7 +4224,7 @@ +@@ -4294,7 +4294,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME TABLE_OPEN_CACHE VARIABLE_SCOPE GLOBAL @@ -1432,7 +1443,7 @@ VARIABLE_COMMENT The number of cached open tables NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 1048576 -@@ -4284,7 +4284,7 @@ +@@ -4354,7 +4354,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME THREAD_CACHE_SIZE VARIABLE_SCOPE GLOBAL @@ -1441,7 +1452,7 @@ VARIABLE_COMMENT How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 -@@ -4457,7 +4457,7 @@ +@@ -4527,7 +4527,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Max size for data for an internal temporary on-disk MyISAM or Aria table. NUMERIC_MIN_VALUE 1024 @@ -1450,7 +1461,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -4467,7 +4467,7 @@ +@@ -4537,7 +4537,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table. Same as tmp_table_size. NUMERIC_MIN_VALUE 0 @@ -1459,7 +1470,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -4477,14 +4477,14 @@ +@@ -4547,14 +4547,14 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Alias for tmp_memory_table_size. If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table. NUMERIC_MIN_VALUE 0 @@ -1476,7 +1487,7 @@ VARIABLE_COMMENT Allocation block size for transactions to be stored in binary log NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 134217728 -@@ -4494,7 +4494,7 @@ +@@ -4564,7 +4564,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME TRANSACTION_PREALLOC_SIZE VARIABLE_SCOPE SESSION @@ -1485,7 +1496,7 @@ VARIABLE_COMMENT Persistent buffer for transactions to be stored in binary log NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 134217728 -@@ -4634,7 +4634,7 @@ +@@ -4704,7 +4704,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME WAIT_TIMEOUT VARIABLE_SCOPE SESSION @@ -1494,7 +1505,7 @@ VARIABLE_COMMENT The number of seconds the server waits for activity on a connection before closing it NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -4661,7 +4661,7 @@ +@@ -4731,7 +4731,7 @@ order by variable_name; VARIABLE_NAME LOG_TC_SIZE GLOBAL_VALUE_ORIGIN AUTO VARIABLE_SCOPE GLOBAL 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 7ed3f62707fc3..6688774eb0bf6 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -1795,7 +1795,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME LOG_QUERIES_NOT_USING_INDEXES VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Alias for log_slow_queries_not_using_indexes. Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' +VARIABLE_COMMENT Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL @@ -1852,17 +1852,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED -VARIABLE_NAME LOG_SLOW_QUERIES_NOT_USING_INDEXES -VARIABLE_SCOPE SESSION -VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Log queries that are executed without benefit of any index to the slow log if it is open. Same as log_slow_filter='not_using_index' -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 LOG_SLOW_QUERY_ENABLE +VARIABLE_NAME LOG_SLOW_QUERY VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN VARIABLE_COMMENT Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. @@ -3915,7 +3905,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLOW_QUERY_LOG VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Alias for log_slow_query_enable. Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. +VARIABLE_COMMENT Alias for log_slow_query. Log slow queries to a table or log file. Defaults logging to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_file_func.test b/mysql-test/suite/sys_vars/t/slow_query_log_file_func.test index 32420fc294a07..c14fa148b2f06 100644 --- a/mysql-test/suite/sys_vars/t/slow_query_log_file_func.test +++ b/mysql-test/suite/sys_vars/t/slow_query_log_file_func.test @@ -31,3 +31,10 @@ let $MYSQLD_DATADIR= `select @@datadir`; --file_exists $MYSQLD_DATADIR/my_slow_test.log --echo ## This case should pass because we have set this filename in opt file ## + +set @oldval= @@global.slow_query_log_file; +evalp set global log_slow_query_file_name='$MYSQLTEST_VARDIR/tmp/slow-7567.log'; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +select @@global.log_slow_query_file_name; +--file_exists $MYSQLTEST_VARDIR/tmp/slow-7567.log +set @@global.log_slow_query_file_name=@oldval; diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_func.test b/mysql-test/suite/sys_vars/t/slow_query_log_func.test index 0c77dbff22676..8dcc0279e7295 100644 --- a/mysql-test/suite/sys_vars/t/slow_query_log_func.test +++ b/mysql-test/suite/sys_vars/t/slow_query_log_func.test @@ -10,10 +10,10 @@ SET @@session.long_query_time=1; SET @@global.log_output = 'TABLE'; #========================================= ---echo '----When global.slow_query_log = OFF----' +--echo '----When global.log_slow_query = OFF----' #========================================= -SET @@global.slow_query_log = OFF; +SET @@global.log_slow_query = OFF; TRUNCATE mysql.slow_log; # The sleep is the slow query SELECT sleep(2); @@ -32,10 +32,10 @@ SELECT sleep(2); SELECT count(*) > 0 FROM mysql.slow_log; #========================================= ---echo '----When local.slow_query_log = OFF-----' +--echo '----When local.log_slow_query = OFF-----' #========================================= -SET @@local.slow_query_log = OFF; +SET @@local.log_slow_query = OFF; TRUNCATE mysql.slow_log; # The sleep is the slow query SELECT sleep(2); diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index c9d4874d9b754..e86b95c870b54 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1501,14 +1501,6 @@ static Sys_var_charptr_fscs Sys_log_error( static Sys_var_bit Sys_log_queries_not_using_indexes( "log_queries_not_using_indexes", - "Alias for log_slow_queries_not_using_indexes. " - "Log queries that are executed without benefit of any index to the " - "slow log if it is open. Same as log_slow_filter='not_using_index'", - SESSION_VAR(log_slow_filter), CMD_LINE(OPT_ARG), QPLAN_NOT_USING_INDEX, - DEFAULT(FALSE)); - -static Sys_var_bit Sys_log_slow_queries_not_using_indexes( - "log_slow_queries_not_using_indexes", "Log queries that are executed without benefit of any index to the " "slow log if it is open. Same as log_slow_filter='not_using_index'", SESSION_VAR(log_slow_filter), CMD_LINE(OPT_ARG), QPLAN_NOT_USING_INDEX, @@ -5279,7 +5271,7 @@ static Sys_var_mybool Sys_general_log( static Sys_var_mybool Sys_slow_query_log( "slow_query_log", - "Alias for log_slow_query_enable. " + "Alias for log_slow_query. " "Log slow queries to a table or log file. Defaults logging to a file " "'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is " "used. Must be enabled to activate other slow log options.", @@ -5287,8 +5279,8 @@ static Sys_var_mybool Sys_slow_query_log( DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_log_state)); -static Sys_var_mybool Sys_log_slow_query_enable( - "log_slow_query_enable", +static Sys_var_mybool Sys_log_slow_query( + "log_slow_query", "Log slow queries to a table or log file. Defaults logging to a file " "'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is " "used. Must be enabled to activate other slow log options.", @@ -5313,7 +5305,7 @@ static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type) } else { - DBUG_ASSERT(self == &Sys_slow_query_log); + DBUG_ASSERT(self == &Sys_slow_query_log || self == &Sys_log_slow_query); newvalptr= &global_system_variables.sql_log_slow; oldval= logger.get_slow_log_file_handler()->is_open(); log_type= QUERY_LOG_SLOW; From 05c11953ab2d4a594ecd666376ab49b75f64a875 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 26 Sep 2022 18:40:17 +0200 Subject: [PATCH 036/113] MDEV-29595 Adjust variable name for slow log file and help referring to the value --- mysql-test/main/log_slow.result | 2 +- mysql-test/main/mysqld--help,win.rdiff | 22 +++++++++---------- mysql-test/main/mysqld--help.result | 11 +++++----- mysql-test/main/mysqld--help.test | 2 +- .../r/slow_query_log_file_func.result | 8 +++---- .../sys_vars/r/sysvars_server_embedded.result | 4 ++-- .../r/sysvars_server_notembedded.result | 4 ++-- .../sys_vars/t/slow_query_log_file_func.test | 6 ++--- sql/mysqld.cc | 2 +- sql/sys_vars.cc | 4 ++-- 10 files changed, 32 insertions(+), 33 deletions(-) diff --git a/mysql-test/main/log_slow.result b/mysql-test/main/log_slow.result index 465f2f5ebd3be..fbbac0a56f462 100644 --- a/mysql-test/main/log_slow.result +++ b/mysql-test/main/log_slow.result @@ -15,7 +15,7 @@ log_slow_disabled_statements sp log_slow_filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk log_slow_min_examined_row_limit 0 log_slow_query ON -log_slow_query_file_name $PATH/mysqld-slow.log +log_slow_query_file $PATH/mysqld-slow.log log_slow_query_time 10.000000 log_slow_rate_limit 1 log_slow_slave_statements ON diff --git a/mysql-test/main/mysqld--help,win.rdiff b/mysql-test/main/mysqld--help,win.rdiff index 65d5741e6b115..a43d7f0d86c50 100644 --- a/mysql-test/main/mysqld--help,win.rdiff +++ b/mysql-test/main/mysqld--help,win.rdiff @@ -1,6 +1,6 @@ --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result -@@ -686,6 +686,7 @@ +@@ -685,6 +685,7 @@ Use MySQL-5.6 (instead of MariaDB-5.3) format for TIME, DATETIME, TIMESTAMP columns. (Defaults to on; use --skip-mysql56-temporal-format to disable.) @@ -8,10 +8,10 @@ --net-buffer-length=# Buffer length for TCP/IP and socket communication --net-read-timeout=# -@@ -1328,6 +1329,10 @@ - Alias for log_slow_query_file_name. Log slow queries to - given log file. Defaults logging to 'hostname'-slow.log. - Must be enabled to activate other slow log options +@@ -1327,6 +1328,10 @@ + Alias for log_slow_query_file. Log slow queries to given + log file. Defaults logging to 'hostname'-slow.log. Must + be enabled to activate other slow log options + --slow-start-timeout=# + Maximum number of milliseconds that the service control + manager should wait before trying to kill the windows @@ -19,7 +19,7 @@ --socket=name Socket file to use for connection --sort-buffer-size=# Each thread that needs to do a sort allocates a buffer of -@@ -1352,6 +1357,7 @@ +@@ -1351,6 +1356,7 @@ deleting or updating every row in a table. --stack-trace Print a symbolic stack trace on failure (Defaults to on; use --skip-stack-trace to disable.) @@ -27,7 +27,7 @@ --standard-compliant-cte Allow only CTEs compliant to SQL standard (Defaults to on; use --skip-standard-compliant-cte to disable.) -@@ -1427,6 +1433,11 @@ +@@ -1426,6 +1432,11 @@ --thread-pool-max-threads=# Maximum allowed number of worker threads in the thread pool @@ -39,7 +39,7 @@ --thread-pool-oversubscribe=# How many additional active worker threads in a group are allowed. -@@ -1465,8 +1476,8 @@ +@@ -1464,8 +1475,8 @@ automatically convert it to an on-disk MyISAM or Aria table. -t, --tmpdir=name Path for temporary files. Several paths may be specified, @@ -50,7 +50,7 @@ --transaction-alloc-block-size=# Allocation block size for transactions to be stored in binary log -@@ -1686,6 +1697,7 @@ +@@ -1685,6 +1696,7 @@ myisam-stats-method NULLS_UNEQUAL myisam-use-mmap FALSE mysql56-temporal-format TRUE @@ -58,7 +58,7 @@ net-buffer-length 16384 net-read-timeout 30 net-retry-count 10 -@@ -1842,6 +1854,7 @@ +@@ -1841,6 +1853,7 @@ slave-type-conversions slow-launch-time 2 slow-query-log FALSE @@ -66,7 +66,7 @@ sort-buffer-size 2097152 sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION sql-safe-updates FALSE -@@ -1868,6 +1881,8 @@ +@@ -1867,6 +1880,8 @@ thread-pool-exact-stats FALSE thread-pool-idle-timeout 60 thread-pool-max-threads 65536 diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 46d537cc0d143..6121ac791f358 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -460,8 +460,7 @@ The following specify which files/extra groups are read (specified before remain the only option you need for specifying log files. Sets names for --log-bin, --log-bin-index, --relay-log, --relay-log-index, --general-log-file, - --log-slow-query-log-file, --log-error-file, and - --pid-file + --log-slow-query-file, --log-error-file, and --pid-file --log-bin[=name] Log update queries in binary format. Optional argument should be name for binary log. If not given 'datadir'/'log-basename'-bin or 'datadir'/mysql-bin will @@ -530,7 +529,7 @@ The following specify which files/extra groups are read (specified before remain to a file 'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. - --log-slow-query-file-name=name + --log-slow-query-file=name Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options @@ -1325,9 +1324,9 @@ The following specify which files/extra groups are read (specified before remain or a table mysql.slow_log if --log-output=TABLE is used. Must be enabled to activate other slow log options. --slow-query-log-file=name - Alias for log_slow_query_file_name. Log slow queries to - given log file. Defaults logging to 'hostname'-slow.log. - Must be enabled to activate other slow log options + Alias for log_slow_query_file. Log slow queries to given + log file. Defaults logging to 'hostname'-slow.log. Must + be enabled to activate other slow log options --socket=name Socket file to use for connection --sort-buffer-size=# Each thread that needs to do a sort allocates a buffer of diff --git a/mysql-test/main/mysqld--help.test b/mysql-test/main/mysqld--help.test index eeeaf2e2393c6..35b3363e8d89a 100644 --- a/mysql-test/main/mysqld--help.test +++ b/mysql-test/main/mysqld--help.test @@ -23,7 +23,7 @@ perl; # their paths may vary: @skipvars=qw/basedir open-files-limit general-log-file log plugin-dir plugin-maturity log-slow-queries pid-file slow-query-log-file log-basename - log-slow-query-file-name + log-slow-query-file datadir slave-load-tmpdir tmpdir socket thread-pool-size large-files-support lower-case-file-system system-time-zone collation-server character-set-server log-tc-size table-cache diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_file_func.result b/mysql-test/suite/sys_vars/r/slow_query_log_file_func.result index 2910c78f02fde..88a5713c65946 100644 --- a/mysql-test/suite/sys_vars/r/slow_query_log_file_func.result +++ b/mysql-test/suite/sys_vars/r/slow_query_log_file_func.result @@ -2,8 +2,8 @@ ## Checking if my_slow_test.log exists in servers datadir ## ## This case should pass because we have set this filename in opt file ## set @oldval= @@global.slow_query_log_file; -set global log_slow_query_file_name='$MYSQLTEST_VARDIR/tmp/slow-7567.log'; -select @@global.log_slow_query_file_name; -@@global.log_slow_query_file_name +set global log_slow_query_file='$MYSQLTEST_VARDIR/tmp/slow-7567.log'; +select @@global.log_slow_query_file; +@@global.log_slow_query_file MYSQLTEST_VARDIR/tmp/slow-7567.log -set @@global.log_slow_query_file_name=@oldval; +set @@global.log_slow_query_file=@oldval; 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 467b832eca593..8a9f1d942f01a 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -1712,7 +1712,7 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL -VARIABLE_NAME LOG_SLOW_QUERY_FILE_NAME +VARIABLE_NAME LOG_SLOW_QUERY_FILE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR VARIABLE_COMMENT Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options @@ -3235,7 +3235,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME SLOW_QUERY_LOG_FILE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR -VARIABLE_COMMENT Alias for log_slow_query_file_name. Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options +VARIABLE_COMMENT Alias for log_slow_query_file. Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE 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 6688774eb0bf6..eab383a30acbf 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -1862,7 +1862,7 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL -VARIABLE_NAME LOG_SLOW_QUERY_FILE_NAME +VARIABLE_NAME LOG_SLOW_QUERY_FILE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR VARIABLE_COMMENT Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options @@ -3915,7 +3915,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME SLOW_QUERY_LOG_FILE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR -VARIABLE_COMMENT Alias for log_slow_query_file_name. Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options +VARIABLE_COMMENT Alias for log_slow_query_file. Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_file_func.test b/mysql-test/suite/sys_vars/t/slow_query_log_file_func.test index c14fa148b2f06..c83c7f186cf2b 100644 --- a/mysql-test/suite/sys_vars/t/slow_query_log_file_func.test +++ b/mysql-test/suite/sys_vars/t/slow_query_log_file_func.test @@ -33,8 +33,8 @@ let $MYSQLD_DATADIR= `select @@datadir`; --echo ## This case should pass because we have set this filename in opt file ## set @oldval= @@global.slow_query_log_file; -evalp set global log_slow_query_file_name='$MYSQLTEST_VARDIR/tmp/slow-7567.log'; +evalp set global log_slow_query_file='$MYSQLTEST_VARDIR/tmp/slow-7567.log'; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -select @@global.log_slow_query_file_name; +select @@global.log_slow_query_file; --file_exists $MYSQLTEST_VARDIR/tmp/slow-7567.log -set @@global.log_slow_query_file_name=@oldval; +set @@global.log_slow_query_file=@oldval; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 719f7b347f02d..b89dc4237b1aa 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6551,7 +6551,7 @@ struct my_option my_long_options[]= "names at once (in 'datadir') and is normally the only option you need " "for specifying log files. Sets names for --log-bin, --log-bin-index, " "--relay-log, --relay-log-index, --general-log-file, " - "--log-slow-query-log-file, --log-error-file, and --pid-file", + "--log-slow-query-file, --log-error-file, and --pid-file", &opt_log_basename, &opt_log_basename, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"log-bin", OPT_BIN_LOG, diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index e86b95c870b54..e3a8261ca1046 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -5161,7 +5161,7 @@ static bool fix_slow_log_file(sys_var *self, THD *thd, enum_var_type type) static Sys_var_charptr_fscs Sys_slow_log_path( "slow_query_log_file", - "Alias for log_slow_query_file_name. " + "Alias for log_slow_query_file. " "Log slow queries to given log file. " "Defaults logging to 'hostname'-slow.log. Must be enabled to activate " "other slow log options", @@ -5170,7 +5170,7 @@ static Sys_var_charptr_fscs Sys_slow_log_path( ON_CHECK(check_log_path), ON_UPDATE(fix_slow_log_file)); static Sys_var_charptr_fscs Sys_log_slow_query_file_name( - "log_slow_query_file_name", "Log slow queries to given log file. " + "log_slow_query_file", "Log slow queries to given log file. " "Defaults logging to 'hostname'-slow.log. Must be enabled to activate " "other slow log options", PREALLOCATED GLOBAL_VAR(opt_slow_logname), CMD_LINE(REQUIRED_ARG), From 8759967d1c53603ee63b7e28bdf6c76b80635073 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 26 Sep 2022 19:21:24 +0200 Subject: [PATCH 037/113] MDEV-29625 Some clients/scripts refer to old slow log variables --- client/mysqlbinlog.cc | 2 +- client/mysqldump.c | 4 +- debian/additions/mariadb.conf.d/50-server.cnf | 6 +- man/mysqladmin.1 | 2 +- man/mysqlbinlog.1 | 2 +- mysql-test/main/mysqlbinlog-innodb.result | 4 +- mysql-test/main/mysqlbinlog.result | 40 ++-- .../main/mysqlbinlog_row_compressed.result | 2 +- .../main/mysqlbinlog_row_minimal.result | 4 +- .../main/mysqlbinlog_stmt_compressed.result | 2 +- mysql-test/main/openssl_1.result | 2 +- mysql-test/main/user_var-binlog.result | 2 +- .../binlog/include/ctype_ucs_binlog.result | 212 ----------------- .../suite/binlog/r/binlog_base64_flag.result | 2 +- .../suite/binlog/r/binlog_mysqlbinlog2.result | 54 ++--- .../binlog/r/binlog_mysqlbinlog_row.result | 6 +- .../r/binlog_mysqlbinlog_row_innodb.result | 8 +- .../r/binlog_mysqlbinlog_row_myisam.result | 8 +- .../r/binlog_mysqlbinlog_row_trans.result | 2 +- .../suite/binlog/r/binlog_row_annotate.result | 12 +- .../binlog/r/binlog_row_ctype_ucs.result | 4 +- .../r/binlog_row_mysqlbinlog_options.result | 4 +- .../binlog/r/binlog_stm_ctype_ucs.result | 4 +- .../r/binlog_truncate_multi_engine.result | 2 +- mysql-test/suite/binlog/r/flashback.result | 4 +- .../binlog_row_annotate.result | 6 +- .../suite/engines/funcs/r/rpl_sp.result | 2 +- .../suite/galera/r/galera_gra_log.result | 2 +- .../rpl/r/rpl_blackhole_row_annotate.result | 2 +- mysql-test/suite/rpl/r/rpl_bug31076.result | 2 +- mysql-test/suite/rpl/r/rpl_hrtime.result | 2 +- mysql-test/suite/rpl/r/rpl_mdev382.result | 6 +- .../suite/rpl/r/rpl_old_master_29078.result | 2 +- .../suite/rpl/r/rpl_parallel_29322.result | 4 +- .../suite/rpl/r/rpl_row_mysqlbinlog.result | 10 +- mysql-test/suite/rpl/r/rpl_sp.result | 2 +- mysql-test/suite/rpl/r/rpl_timestamp.result | 2 +- mysql-test/suite/rpl/t/rpl_bug31076.test | 2 +- .../r/max_insert_delayed_threads_basic.result | 189 --------------- .../t/max_insert_delayed_threads_basic.test | 222 ------------------ scripts/mysql_system_tables_fix.sql | 6 +- .../sys_schema/procedures/ps_trace_thread.sql | 2 +- .../procedures/ps_trace_thread_57.sql | 2 +- scripts/wsrep_sst_mysqldump.sh | 6 +- ...inlog_gtid_skip_empty_trans_rocksdb.result | 6 +- 45 files changed, 124 insertions(+), 747 deletions(-) delete mode 100644 mysql-test/suite/binlog/include/ctype_ucs_binlog.result delete mode 100644 mysql-test/suite/sys_vars/r/max_insert_delayed_threads_basic.result delete mode 100644 mysql-test/suite/sys_vars/t/max_insert_delayed_threads_basic.test diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index f0a813442062c..2c9a2cc99f181 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -3690,7 +3690,7 @@ int main(int argc, char** argv) fprintf(result_file, "/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;\n"); fprintf(result_file, - "/*!40019 SET @@session.max_insert_delayed_threads=0*/;\n"); + "/*!40019 SET @@session.max_delayed_threads=0*/;\n"); if (disable_log_bin) fprintf(result_file, diff --git a/client/mysqldump.c b/client/mysqldump.c index 6a9669122e8f0..ca5d89bfd5868 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -784,7 +784,7 @@ static void write_header(FILE *sql_file, const char *db_name) if (!opt_logging) fprintf(sql_file, -"\n/*M!100101 SET LOCAL SQL_LOG_OFF=0, LOCAL SLOW_QUERY_LOG=0 */;"); +"\n/*M!100101 SET LOCAL SQL_LOG_OFF=0, LOCAL LOG_SLOW_QUERY=0 */;"); if (opt_set_charset) fprintf(sql_file, @@ -5445,7 +5445,7 @@ static int init_dumping_mysql_tables(char *qdatabase) if (opt_drop_database) fprintf(md_result_file, "\n/*!50106 SET @save_log_output=@@LOG_OUTPUT*/;\n" - "/*M!100203 EXECUTE IMMEDIATE IF(@@LOG_OUTPUT='TABLE' AND (@@SLOW_QUERY_LOG=1 OR @@GENERAL_LOG=1)," + "/*M!100203 EXECUTE IMMEDIATE IF(@@LOG_OUTPUT='TABLE' AND (@@LOG_SLOW_QUERY=1 OR @@GENERAL_LOG=1)," "\"SET GLOBAL LOG_OUTPUT='NONE'\", \"DO 0\") */;\n"); DBUG_RETURN(init_dumping_tables(qdatabase)); diff --git a/debian/additions/mariadb.conf.d/50-server.cnf b/debian/additions/mariadb.conf.d/50-server.cnf index 76e93e2bd3001..5e958e9e697b5 100644 --- a/debian/additions/mariadb.conf.d/50-server.cnf +++ b/debian/additions/mariadb.conf.d/50-server.cnf @@ -56,11 +56,11 @@ bind-address = 127.0.0.1 # Enable this if you want to have error logging into a separate file #log_error = /var/log/mysql/error.log # Enable the slow query log to see queries with especially long duration -#slow_query_log_file = /var/log/mysql/mariadb-slow.log -#long_query_time = 10 +#log_slow_query_file = /var/log/mysql/mariadb-slow.log +#log_slow_query_time = 10 #log_slow_verbosity = query_plan,explain #log-queries-not-using-indexes -#min_examined_row_limit = 1000 +#log_slow_min_examined_row_limit = 1000 # The following can be used as easy to replay backup logs or for replication. # note: if you are setting up a replication slave, see README.Debian about diff --git a/man/mysqladmin.1 b/man/mysqladmin.1 index a3b6b167179fd..da25123a219c2 100644 --- a/man/mysqladmin.1 +++ b/man/mysqladmin.1 @@ -676,7 +676,7 @@ The number of questions (queries) from clients since the server was started\&. Slow queries .sp The number of queries that have taken more than -long_query_time +log_slow_query_time seconds\&. .RE .sp diff --git a/man/mysqlbinlog.1 b/man/mysqlbinlog.1 index 05376046259a0..8dd814d34ab8f 100644 --- a/man/mysqlbinlog.1 +++ b/man/mysqlbinlog.1 @@ -1381,7 +1381,7 @@ The hex output consists of comment lines beginning with .RS 4 .\} .nf -/*!40019 SET @@session\&.max_insert_delayed_threads=0*/; +/*!40019 SET @@session\&.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; # at 4 #051024 17:24:13 server id 1 end_log_pos 98 diff --git a/mysql-test/main/mysqlbinlog-innodb.result b/mysql-test/main/mysqlbinlog-innodb.result index 6f0b4dd40b664..522bbd6227687 100644 --- a/mysql-test/main/mysqlbinlog-innodb.result +++ b/mysql-test/main/mysqlbinlog-innodb.result @@ -20,7 +20,7 @@ a 2 FLUSH LOGS; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -51,7 +51,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/main/mysqlbinlog.result b/mysql-test/main/mysqlbinlog.result index c476c3c65e28e..83b5421c82386 100644 --- a/mysql-test/main/mysqlbinlog.result +++ b/mysql-test/main/mysqlbinlog.result @@ -15,7 +15,7 @@ flush logs; --- Local -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -94,7 +94,7 @@ ROLLBACK /* added by mysqlbinlog */; --- Broken LOAD DATA -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; START TRANSACTION @@ -130,7 +130,7 @@ ROLLBACK /* added by mysqlbinlog */; --- --database -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -181,7 +181,7 @@ ROLLBACK /* added by mysqlbinlog */; --- --start-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; START TRANSACTION @@ -209,7 +209,7 @@ ROLLBACK /* added by mysqlbinlog */; --- Remote -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -288,7 +288,7 @@ ROLLBACK /* added by mysqlbinlog */; --- Broken LOAD DATA -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; START TRANSACTION @@ -324,7 +324,7 @@ ROLLBACK /* added by mysqlbinlog */; --- --database -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -375,7 +375,7 @@ ROLLBACK /* added by mysqlbinlog */; --- --start-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; START TRANSACTION @@ -403,7 +403,7 @@ ROLLBACK /* added by mysqlbinlog */; --- reading stdin -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -424,7 +424,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; SET TIMESTAMP=1108844556/*!*/; @@ -486,7 +486,7 @@ drop procedure p1; call p1(); ERROR 42000: PROCEDURE test.p1 does not exist /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; use `test`/*!*/; @@ -538,7 +538,7 @@ D0AA drop table t1; flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; use `test`/*!*/; @@ -717,7 +717,7 @@ FLUSH LOGS; # # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified exists /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -772,7 +772,7 @@ ROLLBACK /* added by mysqlbinlog */; # # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified does not exist /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -808,7 +808,7 @@ ROLLBACK /* added by mysqlbinlog */; # # Test if the 'SAVEPOINT', 'ROLLBACK TO' are output if the database specified exists /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; SET TIMESTAMP=1266652094/*!*/; @@ -850,7 +850,7 @@ ROLLBACK /* added by mysqlbinlog */; # # Test if the 'SAVEPOINT', 'ROLLBACK TO' are output if the database specified does not exist /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; SET TIMESTAMP=1266652094/*!*/; @@ -936,7 +936,7 @@ SET GLOBAL SERVER_ID = 1; # FDE corrupted in relay log # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 @@ -1019,7 +1019,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 @@ -1102,7 +1102,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 @@ -1185,7 +1185,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result index ca815a518c7c5..fe82520490d02 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.result +++ b/mysql-test/main/mysqlbinlog_row_compressed.result @@ -12,7 +12,7 @@ DELETE FROM t1; DELETE FROM t2; FLUSH BINARY LOGS; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result index 4d9ca93012bbe..eb9def13ca751 100644 --- a/mysql-test/main/mysqlbinlog_row_minimal.result +++ b/mysql-test/main/mysqlbinlog_row_minimal.result @@ -10,7 +10,7 @@ DELETE FROM t1; DELETE FROM t2; FLUSH BINARY LOGS; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 @@ -366,7 +366,7 @@ SET t1.is_deleted = TRUE WHERE t1.id = 1; FLUSH BINARY LOGS; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at POS diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.result b/mysql-test/main/mysqlbinlog_stmt_compressed.result index 5f3e82648c625..d2968cd795c18 100644 --- a/mysql-test/main/mysqlbinlog_stmt_compressed.result +++ b/mysql-test/main/mysqlbinlog_stmt_compressed.result @@ -12,7 +12,7 @@ DELETE FROM t1; DELETE FROM t2; FLUSH BINARY LOGS; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 diff --git a/mysql-test/main/openssl_1.result b/mysql-test/main/openssl_1.result index 8554da4f6be1b..28d685242fed9 100644 --- a/mysql-test/main/openssl_1.result +++ b/mysql-test/main/openssl_1.result @@ -199,7 +199,7 @@ DROP USER bug42158@localhost; set global sql_mode=default; End of 5.1 tests /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ERROR: Failed on connect: TLS/SSL error \ No newline at end of file diff --git a/mysql-test/main/user_var-binlog.result b/mysql-test/main/user_var-binlog.result index 6743f340a1924..cfe5192155430 100644 --- a/mysql-test/main/user_var-binlog.result +++ b/mysql-test/main/user_var-binlog.result @@ -19,7 +19,7 @@ master-bin.000001 # Query # # use `test`; insert into t1 values (@var1),(@var2) master-bin.000001 # Query # # COMMIT flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/binlog/include/ctype_ucs_binlog.result b/mysql-test/suite/binlog/include/ctype_ucs_binlog.result deleted file mode 100644 index c358cfcd4f28f..0000000000000 --- a/mysql-test/suite/binlog/include/ctype_ucs_binlog.result +++ /dev/null @@ -1,212 +0,0 @@ -SET TIMESTAMP=10000; -create table t2 (c char(30)) charset=ucs2; -set @v=convert('abc' using ucs2); -reset master; -insert into t2 values (@v); -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 # User var # # @`v`=_ucs2 X'006100620063' COLLATE ucs2_general_ci -master-bin.000001 # Query # # use `test`; insert into t2 values (@v) -master-bin.000001 # Query # # COMMIT -flush logs; -/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; -/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; -DELIMITER /*!*/; -ROLLBACK/*!*/; -BEGIN -/*!*/; -SET @`v`:=_ucs2 X'006100620063' COLLATE `ucs2_general_ci`/*!*/; -use `test`/*!*/; -SET TIMESTAMP=10000/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -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/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; -insert into t2 values (@v) -/*!*/; -SET TIMESTAMP=10000/*!*/; -COMMIT -/*!*/; -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; -drop table t2; -# -# Start of 10.2 tests -# -# -# MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions -# -FLUSH LOGS; -SET NAMES utf8; -CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8); -EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (''ä(i1)'')'; -EXECUTE IMMEDIATE CONVERT('INSERT INTO t1 VALUES (''ä(i2)'')' USING ucs2); -SET @stmt=CONVERT('INSERT INTO t1 VALUES (''ä(i3)'')' USING ucs2); -EXECUTE IMMEDIATE @stmt; -PREPARE stmt FROM 'INSERT INTO t1 VALUES (''ä(p1)'')'; -EXECUTE stmt; -PREPARE stmt FROM CONVERT('INSERT INTO t1 VALUES (''ä(p2)'')' USING ucs2); -EXECUTE stmt; -SET @stmt=CONVERT('INSERT INTO t1 VALUES (''ä(p3)'')' USING ucs2); -PREPARE stmt FROM @stmt; -EXECUTE stmt; -DEALLOCATE PREPARE stmt; -SELECT * FROM t1; -a -ä(i1) -ä(i2) -ä(i3) -ä(p1) -ä(p2) -ä(p3) -DROP TABLE t1; -FLUSH LOGS; -/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; -/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; -DELIMITER /*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Start: binlog v 4, server v #.##.## created 700101 6:46:40 -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Gtid list [#-#-#] -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Binlog checkpoint master-bin.000002 -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Binlog checkpoint master-bin.000003 -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# ddl -/*!100101 SET @@session.skip_parallel_replication=0*//*!*/; -/*!100001 SET @@session.gtid_domain_id=#*//*!*/; -/*!100001 SET @@session.server_id=#*//*!*/; -/*!100001 SET @@session.gtid_seq_no=#*//*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -use `test`/*!*/; -SET TIMESTAMP=10000/*!*/; -SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1342177280/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C utf8 *//*!*/; -SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; -CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8) -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# -/*!100001 SET @@session.gtid_seq_no=#*//*!*/; -BEGIN -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -INSERT INTO t1 VALUES ('ä(i1)') -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -COMMIT -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# -/*!100001 SET @@session.gtid_seq_no=#*//*!*/; -BEGIN -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -INSERT INTO t1 VALUES ('ä(i2)') -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -COMMIT -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# -/*!100001 SET @@session.gtid_seq_no=#*//*!*/; -BEGIN -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -INSERT INTO t1 VALUES ('ä(i3)') -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -COMMIT -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# -/*!100001 SET @@session.gtid_seq_no=#*//*!*/; -BEGIN -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -INSERT INTO t1 VALUES ('ä(p1)') -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -COMMIT -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# -/*!100001 SET @@session.gtid_seq_no=#*//*!*/; -BEGIN -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -INSERT INTO t1 VALUES ('ä(p2)') -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -COMMIT -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# -/*!100001 SET @@session.gtid_seq_no=#*//*!*/; -BEGIN -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -INSERT INTO t1 VALUES ('ä(p3)') -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -COMMIT -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# ddl -/*!100001 SET @@session.gtid_seq_no=#*//*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 -SET TIMESTAMP=10000/*!*/; -DROP TABLE `t1` /* generated by server */ -/*!*/; -# at # -#700101 6:46:40 server id # end_log_pos # CRC32 XXX Rotate to master-bin.000004 pos: 4 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; -# -# End of 10.2 tests -# diff --git a/mysql-test/suite/binlog/r/binlog_base64_flag.result b/mysql-test/suite/binlog/r/binlog_base64_flag.result index a79ae45981e61..8b6f767be6d52 100644 --- a/mysql-test/suite/binlog/r/binlog_base64_flag.result +++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result @@ -51,7 +51,7 @@ SELECT @binlog_fragment_0, @binlog_fragment_1 as 'NULL','NULL'; NULL NULL NULL ==== Test --base64-output=never on a binlog with row events ==== /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; <#> diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result index 11abd6e897321..a78db4386a917 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result @@ -18,7 +18,7 @@ insert into t1 values(null, "f"); --- Local -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -87,7 +87,7 @@ ROLLBACK /* added by mysqlbinlog */; --- offset -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -153,7 +153,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -201,7 +201,7 @@ ROLLBACK /* added by mysqlbinlog */; --- stop-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -243,7 +243,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start and stop positions --- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -270,7 +270,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start-datetime -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -318,7 +318,7 @@ ROLLBACK /* added by mysqlbinlog */; --- stop-datetime -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -361,7 +361,7 @@ ROLLBACK /* added by mysqlbinlog */; --- Local with 2 binlogs on command line -- flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -450,7 +450,7 @@ ROLLBACK /* added by mysqlbinlog */; --- offset -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -536,7 +536,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -604,7 +604,7 @@ ROLLBACK /* added by mysqlbinlog */; --- stop-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -677,7 +677,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start-datetime -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -745,7 +745,7 @@ ROLLBACK /* added by mysqlbinlog */; --- stop-datetime -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -787,7 +787,7 @@ ROLLBACK /* added by mysqlbinlog */; --- Remote -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -856,7 +856,7 @@ ROLLBACK /* added by mysqlbinlog */; --- offset -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -922,7 +922,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; START TRANSACTION @@ -969,7 +969,7 @@ ROLLBACK /* added by mysqlbinlog */; --- stop-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -1011,7 +1011,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start and stop positions --- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; START TRANSACTION @@ -1037,7 +1037,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start-datetime -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -1085,7 +1085,7 @@ ROLLBACK /* added by mysqlbinlog */; --- stop-datetime -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -1127,7 +1127,7 @@ ROLLBACK /* added by mysqlbinlog */; --- Remote with 2 binlogs on command line -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -1216,7 +1216,7 @@ ROLLBACK /* added by mysqlbinlog */; --- offset -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -1302,7 +1302,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; START TRANSACTION @@ -1369,7 +1369,7 @@ ROLLBACK /* added by mysqlbinlog */; --- stop-position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -1440,7 +1440,7 @@ ROLLBACK /* added by mysqlbinlog */; --- start-datetime -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -1508,7 +1508,7 @@ ROLLBACK /* added by mysqlbinlog */; --- stop-datetime -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -1550,7 +1550,7 @@ ROLLBACK /* added by mysqlbinlog */; --- to-last-log -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result index 816084d7464d0..ebbb23ed17128 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result @@ -355,7 +355,7 @@ INSERT INTO t1 VALUES (POINT(10,10)); DROP TABLE t1; FLUSH LOGS; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -5335,7 +5335,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -5364,7 +5364,7 @@ START TRANSACTION Error: Found Old DECIMAL (mysql-4.1 or earlier). Not enough metadata to display the value. /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result index 65e2f824e39b8..b5e817dbaab7a 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result @@ -2249,7 +2249,7 @@ FLUSH LOGS; # Call mysqlbinlog to display the log file contents. # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -5258,7 +5258,7 @@ FLUSH LOGS; # Call mysqlbinlog to display the log file contents. # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -5658,7 +5658,7 @@ FLUSH LOGS; # Call mysqlbinlog to display the log file contents. # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -6296,7 +6296,7 @@ FLUSH LOGS; # Call mysqlbinlog to display the log file contents. # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result index 3f838c8c3694c..d99764a1365a3 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result @@ -2247,7 +2247,7 @@ FLUSH LOGS; # Call mysqlbinlog to display the log file contents. # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -5279,7 +5279,7 @@ FLUSH LOGS; # Call mysqlbinlog to display the log file contents. # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -5685,7 +5685,7 @@ FLUSH LOGS; # Call mysqlbinlog to display the log file contents. # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -6333,7 +6333,7 @@ FLUSH LOGS; # Call mysqlbinlog to display the log file contents. # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result index 5a27afaae711f..1bb9d5efbdd21 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result @@ -125,7 +125,7 @@ FLUSH LOGS; # Call mysqlbinlog to display the log file contents. # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/binlog/r/binlog_row_annotate.result b/mysql-test/suite/binlog/r/binlog_row_annotate.result index bf114d8cfa97f..bf19e999d51a4 100644 --- a/mysql-test/suite/binlog/r/binlog_row_annotate.result +++ b/mysql-test/suite/binlog/r/binlog_row_annotate.result @@ -96,7 +96,7 @@ master-bin.000001 # Rotate # # master-bin.000002;pos=POS # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map) ##################################################################################### /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -334,7 +334,7 @@ ROLLBACK /* added by mysqlbinlog */; # - DELETE test1.t1, test2.t2 FROM <...> ##################################################################################### /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -493,7 +493,7 @@ ROLLBACK /* added by mysqlbinlog */; # No Annotates should appear in this output ##################################################################################### /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -719,7 +719,7 @@ ROLLBACK /* added by mysqlbinlog */; # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map) ##################################################################################### /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -957,7 +957,7 @@ ROLLBACK /* added by mysqlbinlog */; # - DELETE test1.t1, test2.t2 FROM <...> ##################################################################################### /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -1116,7 +1116,7 @@ ROLLBACK /* added by mysqlbinlog */; # No Annotates should appear in this output ##################################################################################### /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result index 6d10d5420e457..0e153116b15b6 100644 --- a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result +++ b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result @@ -12,7 +12,7 @@ master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # COMMIT flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -70,7 +70,7 @@ a DROP TABLE t1; FLUSH LOGS; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result index fe08f6e9fe91e..6161ae4044154 100644 --- a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result +++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result @@ -29,7 +29,7 @@ flush logs; # --rewrite-db = test3->new_test3 # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -270,7 +270,7 @@ ROLLBACK /* added by mysqlbinlog */; # --read-from-remote-server # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result index c78365a847ef5..dc525b2869ca6 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result @@ -11,7 +11,7 @@ master-bin.000001 # Query # # use `test`; insert into t2 values (@v) master-bin.000001 # Query # # COMMIT flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -72,7 +72,7 @@ a DROP TABLE t1; FLUSH LOGS; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/binlog/r/binlog_truncate_multi_engine.result b/mysql-test/suite/binlog/r/binlog_truncate_multi_engine.result index 13de367a9b892..412ab88ffab63 100644 --- a/mysql-test/suite/binlog/r/binlog_truncate_multi_engine.result +++ b/mysql-test/suite/binlog/r/binlog_truncate_multi_engine.result @@ -63,7 +63,7 @@ disconnect con1; # Proof of the truncated binlog file is readable (two transactions must be seen): /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; START TRANSACTION diff --git a/mysql-test/suite/binlog/r/flashback.result b/mysql-test/suite/binlog/r/flashback.result index da08f81478312..7b3fc0d58d3fa 100644 --- a/mysql-test/suite/binlog/r/flashback.result +++ b/mysql-test/suite/binlog/r/flashback.result @@ -39,7 +39,7 @@ FLUSH LOGS; # Show mysqlbinlog result without -B # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -267,7 +267,7 @@ ROLLBACK /* added by mysqlbinlog */; # Show mysqlbinlog result with -B # /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; #010909 9:46:40 server id 1 end_log_pos # CRC32 XXX Start: binlog v 4, server v #.##.## created 010909 9:46:40 at startup diff --git a/mysql-test/suite/binlog_encryption/binlog_row_annotate.result b/mysql-test/suite/binlog_encryption/binlog_row_annotate.result index 2614020b7a98b..8d2c279c35f1f 100644 --- a/mysql-test/suite/binlog_encryption/binlog_row_annotate.result +++ b/mysql-test/suite/binlog_encryption/binlog_row_annotate.result @@ -97,7 +97,7 @@ master-bin.000001 # Rotate # # master-bin.000002;pos=POS # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map) ##################################################################################### /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -338,7 +338,7 @@ ROLLBACK /* added by mysqlbinlog */; # - DELETE test1.t1, test2.t2 FROM <...> ##################################################################################### /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # @@ -500,7 +500,7 @@ ROLLBACK /* added by mysqlbinlog */; # No Annotates should appear in this output ##################################################################################### /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/engines/funcs/r/rpl_sp.result b/mysql-test/suite/engines/funcs/r/rpl_sp.result index 3108f45be0ade..18f6a5cc687b9 100644 --- a/mysql-test/suite/engines/funcs/r/rpl_sp.result +++ b/mysql-test/suite/engines/funcs/r/rpl_sp.result @@ -765,7 +765,7 @@ test mysqltestbug36570_f1 FUNCTION root@localhost t t DEFINER latin1 latin1_swe connection master; flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/galera/r/galera_gra_log.result b/mysql-test/suite/galera/r/galera_gra_log.result index 4146192bb551a..66190c1ca236a 100644 --- a/mysql-test/suite/galera/r/galera_gra_log.result +++ b/mysql-test/suite/galera/r/galera_gra_log.result @@ -10,7 +10,7 @@ connection node_1; CREATE TABLE t1 (f1 INTEGER); connection node_2; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result b/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result index 2c602ea53aaa1..25804b60da508 100644 --- a/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result +++ b/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result @@ -179,7 +179,7 @@ slave-bin.000001 # Gtid 1 # GTID 0-1-16 slave-bin.000001 # Query 1 # use `test`; DROP TABLE IF EXISTS `t1`,`t2` /* generated by server */ slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at # diff --git a/mysql-test/suite/rpl/r/rpl_bug31076.result b/mysql-test/suite/rpl/r/rpl_bug31076.result index 8fcbba1c4cd65..2d0512ceb82be 100644 --- a/mysql-test/suite/rpl/r/rpl_bug31076.result +++ b/mysql-test/suite/rpl/r/rpl_bug31076.result @@ -36,7 +36,7 @@ KEY `visit_id` (`visit_id`), KEY `data` (`data`) ) ENGINE=MyISAM AUTO_INCREMENT=33900731 DEFAULT CHARSET=latin1; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; BINLOG ' O1ZVRw8BAAAAZgAAAGoAAAAAAAQANS4xLjIzLXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA diff --git a/mysql-test/suite/rpl/r/rpl_hrtime.result b/mysql-test/suite/rpl/r/rpl_hrtime.result index 230029d911975..5e7a306c7c656 100644 --- a/mysql-test/suite/rpl/r/rpl_hrtime.result +++ b/mysql-test/suite/rpl/r/rpl_hrtime.result @@ -30,7 +30,7 @@ connection master; drop table t1; include/rpl_end.inc /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_mdev382.result b/mysql-test/suite/rpl/r/rpl_mdev382.result index 6a91d9d89dec0..c71ea1d79a0c9 100644 --- a/mysql-test/suite/rpl/r/rpl_mdev382.result +++ b/mysql-test/suite/rpl/r/rpl_mdev382.result @@ -172,7 +172,7 @@ master-bin.000001 # Begin_load_query 1 # ;file_id=#;block_len=14 master-bin.000001 # Execute_load_query 1 # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; select 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!") ;file_id=# master-bin.000001 # Query 1 # COMMIT /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -272,7 +272,7 @@ master-bin.000001 # User var 1 # @```d```=_latin1 X'7878787878787878787878787878 master-bin.000001 # Query 1 # use `db1``; select 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98)) master-bin.000001 # Query 1 # COMMIT /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -379,7 +379,7 @@ master-bin.000002 # Gtid 1 # BEGIN GTID #-#-# master-bin.000002 # Query 1 # use `test`; INSERT INTO t1 VALUES(1) master-bin.000002 # Query 1 # COMMIT /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_old_master_29078.result b/mysql-test/suite/rpl/r/rpl_old_master_29078.result index 093e2ae0c2464..434727e12920b 100644 --- a/mysql-test/suite/rpl/r/rpl_old_master_29078.result +++ b/mysql-test/suite/rpl/r/rpl_old_master_29078.result @@ -9,7 +9,7 @@ connection master; flush binary logs; create table t2 (a timestamp); /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_parallel_29322.result b/mysql-test/suite/rpl/r/rpl_parallel_29322.result index 205a7dbc9cfc8..8ef68e2958713 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_29322.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_29322.result @@ -35,7 +35,7 @@ flush binary logs; flush binary logs; insert into t2 values (null, 2); /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -130,7 +130,7 @@ flush binary logs; flush binary logs; insert into t2 values (null, 2); /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result index 67251e2ef72b8..9ac5f6e888e33 100644 --- a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result +++ b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result @@ -161,7 +161,7 @@ c1 c3 c4 c5 connection master; --- Test 2 position test -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -184,7 +184,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; --- Test 3 First Remote test -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -289,7 +289,7 @@ c1 c3 c4 c5 connection master; --- Test 5 LOAD DATA -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; DELIMITER ; @@ -299,7 +299,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; --- Test 6 reading stdin -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -328,7 +328,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; --- Test 7 reading stdin w/position -- /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result index 1e5203e016de9..4aa357af06de1 100644 --- a/mysql-test/suite/rpl/r/rpl_sp.result +++ b/mysql-test/suite/rpl/r/rpl_sp.result @@ -778,7 +778,7 @@ test mysqltestbug36570_f1 FUNCTION root@localhost t t DEFINER latin1 latin1_swe connection master; flush logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_timestamp.result b/mysql-test/suite/rpl/r/rpl_timestamp.result index d287bad449253..7a2b3efcdf660 100644 --- a/mysql-test/suite/rpl/r/rpl_timestamp.result +++ b/mysql-test/suite/rpl/r/rpl_timestamp.result @@ -21,7 +21,7 @@ connection master; drop table t1; flush binary logs; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; diff --git a/mysql-test/suite/rpl/t/rpl_bug31076.test b/mysql-test/suite/rpl/t/rpl_bug31076.test index 5ef2b345eaba6..7e5232974f97c 100644 --- a/mysql-test/suite/rpl/t/rpl_bug31076.test +++ b/mysql-test/suite/rpl/t/rpl_bug31076.test @@ -46,7 +46,7 @@ CREATE TABLE `visits_events` ( ) ENGINE=MyISAM AUTO_INCREMENT=33900731 DEFAULT CHARSET=latin1; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; --delimiter /*!*/; diff --git a/mysql-test/suite/sys_vars/r/max_insert_delayed_threads_basic.result b/mysql-test/suite/sys_vars/r/max_insert_delayed_threads_basic.result deleted file mode 100644 index aa79a5a7b9da7..0000000000000 --- a/mysql-test/suite/sys_vars/r/max_insert_delayed_threads_basic.result +++ /dev/null @@ -1,189 +0,0 @@ -SET @start_global_value = @@global.max_insert_delayed_threads; -SELECT @start_global_value; -@start_global_value -20 -SET @start_session_value = @@session.max_insert_delayed_threads; -SELECT @start_session_value; -@start_session_value -20 -'#--------------------FN_DYNVARS_075_01-------------------------#' -SET @@global.max_insert_delayed_threads = 1000; -SET @@global.max_insert_delayed_threads = DEFAULT; -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -20 -SET @@session.max_insert_delayed_threads = 1000; -ERROR 42000: Variable 'max_insert_delayed_threads' can't be set to the value of '1000' -SET @@session.max_insert_delayed_threads = DEFAULT; -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -20 -'#--------------------FN_DYNVARS_075_02-------------------------#' -SET @@global.max_insert_delayed_threads = DEFAULT; -SELECT @@global.max_insert_delayed_threads = 20; -@@global.max_insert_delayed_threads = 20 -1 -SET @@session.max_insert_delayed_threads = DEFAULT; -SELECT @@session.max_insert_delayed_threads = 20; -@@session.max_insert_delayed_threads = 20 -1 -'#--------------------FN_DYNVARS_075_03-------------------------#' -SET @@global.max_insert_delayed_threads = 1; -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -1 -SET @@global.max_insert_delayed_threads = 1025; -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -1025 -SET @@global.max_insert_delayed_threads = 0; -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -0 -SET @@global.max_insert_delayed_threads = 16384; -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -16384 -SET @@global.max_insert_delayed_threads = 16383; -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -16383 -'#--------------------FN_DYNVARS_075_04-------------------------#' -SET @@session.max_insert_delayed_threads = 1; -ERROR 42000: Variable 'max_insert_delayed_threads' can't be set to the value of '1' -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -20 -SET @@session.max_insert_delayed_threads = 1025; -ERROR 42000: Variable 'max_insert_delayed_threads' can't be set to the value of '1025' -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -20 -SET @@session.max_insert_delayed_threads = 0; -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -0 -SET @@session.max_insert_delayed_threads = 16384; -ERROR 42000: Variable 'max_insert_delayed_threads' can't be set to the value of '16384' -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -0 -SET @@session.max_insert_delayed_threads = 16383; -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -16383 -'#------------------FN_DYNVARS_075_05-----------------------#' -SET @@global.max_insert_delayed_threads = -1024; -Warnings: -Warning 1292 Truncated incorrect max_insert_delayed_threads value: '-1024' -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -0 -SET @@global.max_insert_delayed_threads = -1; -Warnings: -Warning 1292 Truncated incorrect max_insert_delayed_threads value: '-1' -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -0 -SET @@global.max_insert_delayed_threads = 16385; -Warnings: -Warning 1292 Truncated incorrect max_insert_delayed_threads value: '16385' -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -16384 -SET @@global.max_insert_delayed_threads = 65530.34; -ERROR 42000: Incorrect argument type to variable 'max_insert_delayed_threads' -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -16384 -SET @@global.max_insert_delayed_threads = test; -ERROR 42000: Incorrect argument type to variable 'max_insert_delayed_threads' -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -16384 -SET @@session.max_insert_delayed_threads = 16385; -Warnings: -Warning 1292 Truncated incorrect max_insert_delayed_threads value: '16385' -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -16384 -SET @@session.max_insert_delayed_threads = -1; -Warnings: -Warning 1292 Truncated incorrect max_insert_delayed_threads value: '-1' -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -0 -SET @@session.max_insert_delayed_threads = -2; -Warnings: -Warning 1292 Truncated incorrect max_insert_delayed_threads value: '-2' -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -0 -SET @@session.max_insert_delayed_threads = 65530.34; -ERROR 42000: Incorrect argument type to variable 'max_insert_delayed_threads' -SET @@session.max_insert_delayed_threads = 10737418241; -Warnings: -Warning 1292 Truncated incorrect max_insert_delayed_threads value: '10737418241' -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -16384 -SET @@session.max_insert_delayed_threads = test; -ERROR 42000: Incorrect argument type to variable 'max_insert_delayed_threads' -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -16384 -'#------------------FN_DYNVARS_075_06-----------------------#' -SELECT @@global.max_insert_delayed_threads = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='max_insert_delayed_threads'; -@@global.max_insert_delayed_threads = VARIABLE_VALUE -1 -'#------------------FN_DYNVARS_075_07-----------------------#' -SELECT @@session.max_insert_delayed_threads = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES -WHERE VARIABLE_NAME='max_insert_delayed_threads'; -@@session.max_insert_delayed_threads = VARIABLE_VALUE -1 -'#------------------FN_DYNVARS_075_08-----------------------#' -SET @@global.max_insert_delayed_threads = TRUE; -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -1 -SET @@global.max_insert_delayed_threads = FALSE; -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -0 -'#---------------------FN_DYNVARS_001_09----------------------#' -SET @@global.max_insert_delayed_threads = 2048; -SELECT @@max_insert_delayed_threads = @@global.max_insert_delayed_threads; -@@max_insert_delayed_threads = @@global.max_insert_delayed_threads -0 -'#---------------------FN_DYNVARS_001_10----------------------#' -SET @@max_insert_delayed_threads = 100000; -ERROR 42000: Variable 'max_insert_delayed_threads' can't be set to the value of '100000' -SELECT @@max_insert_delayed_threads = @@local.max_insert_delayed_threads; -@@max_insert_delayed_threads = @@local.max_insert_delayed_threads -1 -SELECT @@local.max_insert_delayed_threads = @@session.max_insert_delayed_threads; -@@local.max_insert_delayed_threads = @@session.max_insert_delayed_threads -1 -'#---------------------FN_DYNVARS_001_11----------------------#' -SET max_insert_delayed_threads = 1024; -ERROR 42000: Variable 'max_insert_delayed_threads' can't be set to the value of '1024' -SELECT @@max_insert_delayed_threads; -@@max_insert_delayed_threads -16384 -SELECT local.max_insert_delayed_threads; -ERROR 42S02: Unknown table 'local' in field list -SELECT session.max_insert_delayed_threads; -ERROR 42S02: Unknown table 'session' in field list -SELECT max_insert_delayed_threads = @@session.max_insert_delayed_threads; -ERROR 42S22: Unknown column 'max_insert_delayed_threads' in 'field list' -SET @@global.max_insert_delayed_threads = @start_global_value; -SELECT @@global.max_insert_delayed_threads; -@@global.max_insert_delayed_threads -20 -SET @@session.max_insert_delayed_threads = @start_session_value; -SELECT @@session.max_insert_delayed_threads; -@@session.max_insert_delayed_threads -20 diff --git a/mysql-test/suite/sys_vars/t/max_insert_delayed_threads_basic.test b/mysql-test/suite/sys_vars/t/max_insert_delayed_threads_basic.test deleted file mode 100644 index 3646743a9aef1..0000000000000 --- a/mysql-test/suite/sys_vars/t/max_insert_delayed_threads_basic.test +++ /dev/null @@ -1,222 +0,0 @@ -############## mysql-test\t\max_insert_delayed_threads_basic.test ############### -# # -# Variable Name: max_insert_delayed_threads # -# Scope: GLOBAL | SESSION # -# Access Type: Dynamic # -# Data Type: numeric # -# Default Value: 20 # -# Range: 0-16384 # -# # -# # -# Creation Date: 2008-02-07 # -# Author: Salman # -# # -# Description: Test Cases of Dynamic System Variable max_insert_delayed_threads # -# that checks the behavior of this variable in the following ways# -# * Default Value # -# * Valid & Invalid values # -# * Scope & Access method # -# * Data Integrity # -# # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html # -# # -############################################################################### - ---source include/load_sysvars.inc - -################################################################## -# START OF max_insert_delayed_threads TESTS # -################################################################## - - -############################################################# -# Save initial value # -############################################################# - -SET @start_global_value = @@global.max_insert_delayed_threads; -SELECT @start_global_value; -SET @start_session_value = @@session.max_insert_delayed_threads; -SELECT @start_session_value; - - ---echo '#--------------------FN_DYNVARS_075_01-------------------------#' -################################################################## -# Display the DEFAULT value of max_insert_delayed_threads # -################################################################## - -SET @@global.max_insert_delayed_threads = 1000; -SET @@global.max_insert_delayed_threads = DEFAULT; -SELECT @@global.max_insert_delayed_threads; - ---Error ER_WRONG_VALUE_FOR_VAR -SET @@session.max_insert_delayed_threads = 1000; -SET @@session.max_insert_delayed_threads = DEFAULT; -SELECT @@session.max_insert_delayed_threads; - - ---echo '#--------------------FN_DYNVARS_075_02-------------------------#' -################################################################## -# Check the DEFAULT value of max_insert_delayed_threads # -################################################################## - -SET @@global.max_insert_delayed_threads = DEFAULT; -SELECT @@global.max_insert_delayed_threads = 20; - -SET @@session.max_insert_delayed_threads = DEFAULT; -SELECT @@session.max_insert_delayed_threads = 20; - - ---echo '#--------------------FN_DYNVARS_075_03-------------------------#' -############################################################################ -# Change the value of max_insert_delayed_threads to a valid value for GLOBAL Scope # -############################################################################ - -SET @@global.max_insert_delayed_threads = 1; -SELECT @@global.max_insert_delayed_threads; -SET @@global.max_insert_delayed_threads = 1025; -SELECT @@global.max_insert_delayed_threads; -SET @@global.max_insert_delayed_threads = 0; -SELECT @@global.max_insert_delayed_threads; -SET @@global.max_insert_delayed_threads = 16384; -SELECT @@global.max_insert_delayed_threads; -SET @@global.max_insert_delayed_threads = 16383; -SELECT @@global.max_insert_delayed_threads; - ---echo '#--------------------FN_DYNVARS_075_04-------------------------#' -############################################################################# -# Change the value of max_insert_delayed_threads to a valid value for SESSION Scope # -############################################################################# - ---Error ER_WRONG_VALUE_FOR_VAR -SET @@session.max_insert_delayed_threads = 1; -SELECT @@session.max_insert_delayed_threads; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@session.max_insert_delayed_threads = 1025; -SELECT @@session.max_insert_delayed_threads; - -SET @@session.max_insert_delayed_threads = 0; -SELECT @@session.max_insert_delayed_threads; ---Error ER_WRONG_VALUE_FOR_VAR -SET @@session.max_insert_delayed_threads = 16384; -SELECT @@session.max_insert_delayed_threads; - -SET @@session.max_insert_delayed_threads = 16383; -SELECT @@session.max_insert_delayed_threads; - - ---echo '#------------------FN_DYNVARS_075_05-----------------------#' -############################################################## -# Change the value of max_insert_delayed_threads to an invalid value # -############################################################## - -SET @@global.max_insert_delayed_threads = -1024; -SELECT @@global.max_insert_delayed_threads; -SET @@global.max_insert_delayed_threads = -1; -SELECT @@global.max_insert_delayed_threads; -SET @@global.max_insert_delayed_threads = 16385; -SELECT @@global.max_insert_delayed_threads; ---Error ER_WRONG_TYPE_FOR_VAR -SET @@global.max_insert_delayed_threads = 65530.34; -SELECT @@global.max_insert_delayed_threads; ---Error ER_WRONG_TYPE_FOR_VAR -SET @@global.max_insert_delayed_threads = test; -SELECT @@global.max_insert_delayed_threads; -SET @@session.max_insert_delayed_threads = 16385; -SELECT @@session.max_insert_delayed_threads; -SET @@session.max_insert_delayed_threads = -1; -SELECT @@session.max_insert_delayed_threads; -SET @@session.max_insert_delayed_threads = -2; -SELECT @@session.max_insert_delayed_threads; ---Error ER_WRONG_TYPE_FOR_VAR -SET @@session.max_insert_delayed_threads = 65530.34; -SET @@session.max_insert_delayed_threads = 10737418241; -SELECT @@session.max_insert_delayed_threads; - - ---Error ER_WRONG_TYPE_FOR_VAR -SET @@session.max_insert_delayed_threads = test; -SELECT @@session.max_insert_delayed_threads; - - ---echo '#------------------FN_DYNVARS_075_06-----------------------#' -#################################################################### -# Check if the value in GLOBAL Table matches value in variable # -#################################################################### - - -SELECT @@global.max_insert_delayed_threads = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='max_insert_delayed_threads'; - ---echo '#------------------FN_DYNVARS_075_07-----------------------#' -#################################################################### -# Check if the value in SESSION Table matches value in variable # -#################################################################### - -SELECT @@session.max_insert_delayed_threads = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES -WHERE VARIABLE_NAME='max_insert_delayed_threads'; - - ---echo '#------------------FN_DYNVARS_075_08-----------------------#' -#################################################################### -# Check if TRUE and FALSE values can be used on variable # -#################################################################### - -SET @@global.max_insert_delayed_threads = TRUE; -SELECT @@global.max_insert_delayed_threads; -SET @@global.max_insert_delayed_threads = FALSE; -SELECT @@global.max_insert_delayed_threads; - - ---echo '#---------------------FN_DYNVARS_001_09----------------------#' -################################################################################# -# Check if accessing variable with and without GLOBAL point to same variable # -################################################################################# - -SET @@global.max_insert_delayed_threads = 2048; -SELECT @@max_insert_delayed_threads = @@global.max_insert_delayed_threads; - - ---echo '#---------------------FN_DYNVARS_001_10----------------------#' -######################################################################################################## -# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable # -######################################################################################################## - ---Error ER_WRONG_VALUE_FOR_VAR -SET @@max_insert_delayed_threads = 100000; -SELECT @@max_insert_delayed_threads = @@local.max_insert_delayed_threads; -SELECT @@local.max_insert_delayed_threads = @@session.max_insert_delayed_threads; - - ---echo '#---------------------FN_DYNVARS_001_11----------------------#' -############################################################################# -# Check if max_insert_delayed_threads can be accessed with and without @@ sign # -############################################################################# - ---Error ER_WRONG_VALUE_FOR_VAR -SET max_insert_delayed_threads = 1024; -SELECT @@max_insert_delayed_threads; ---Error ER_UNKNOWN_TABLE -SELECT local.max_insert_delayed_threads; ---Error ER_UNKNOWN_TABLE -SELECT session.max_insert_delayed_threads; ---Error ER_BAD_FIELD_ERROR -SELECT max_insert_delayed_threads = @@session.max_insert_delayed_threads; - - -#################################### -# Restore initial value # -#################################### - -SET @@global.max_insert_delayed_threads = @start_global_value; -SELECT @@global.max_insert_delayed_threads; -SET @@session.max_insert_delayed_threads = @start_session_value; -SELECT @@session.max_insert_delayed_threads; - - -####################################################### -# END OF max_insert_delayed_threads TESTS # -####################################################### - diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index dbcd6dd9af538..de8a9c9690f9f 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -295,8 +295,8 @@ ALTER TABLE general_log MODIFY thread_id BIGINT(21) UNSIGNED NOT NULL; SET GLOBAL general_log = @old_log_state; -SET @old_log_state = @@global.slow_query_log; -SET GLOBAL slow_query_log = 'OFF'; +SET @old_log_state = @@global.log_slow_query; +SET GLOBAL log_slow_query = 'OFF'; ALTER TABLE slow_log ADD COLUMN thread_id BIGINT(21) UNSIGNED NOT NULL AFTER sql_text; ALTER TABLE slow_log @@ -314,7 +314,7 @@ ALTER TABLE slow_log MODIFY server_id INTEGER UNSIGNED NOT NULL, MODIFY sql_text MEDIUMTEXT NOT NULL, MODIFY thread_id BIGINT(21) UNSIGNED NOT NULL; -SET GLOBAL slow_query_log = @old_log_state; +SET GLOBAL log_slow_query = @old_log_state; ALTER TABLE plugin MODIFY name varchar(64) COLLATE utf8_general_ci NOT NULL DEFAULT '', diff --git a/scripts/sys_schema/procedures/ps_trace_thread.sql b/scripts/sys_schema/procedures/ps_trace_thread.sql index 6e5666c2dea8c..1a2ede79a77a6 100644 --- a/scripts/sys_schema/procedures/ps_trace_thread.sql +++ b/scripts/sys_schema/procedures/ps_trace_thread.sql @@ -151,7 +151,7 @@ BEGIN ELSE -- Use long query time from the server to -- flag long running statements in red - IF((timer_wait/1000000000000) > @@long_query_time, + IF((timer_wait/1000000000000) > @@log_slow_query_time, ' style=filled, color=red', ' style=filled, color=lightblue') END diff --git a/scripts/sys_schema/procedures/ps_trace_thread_57.sql b/scripts/sys_schema/procedures/ps_trace_thread_57.sql index 9aae53ba16135..33dc796108977 100644 --- a/scripts/sys_schema/procedures/ps_trace_thread_57.sql +++ b/scripts/sys_schema/procedures/ps_trace_thread_57.sql @@ -154,7 +154,7 @@ BEGIN ELSE -- Use long query time from the server to -- flag long running statements in red - IF((timer_wait/1000000000000) > @@long_query_time, + IF((timer_wait/1000000000000) > @@log_slow_query_time, ' style=filled, color=red', ' style=filled, color=lightblue') END diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh index e1efcbf11ad96..82d8d4edd7188 100644 --- a/scripts/wsrep_sst_mysqldump.sh +++ b/scripts/wsrep_sst_mysqldump.sh @@ -150,13 +150,13 @@ then # reason is that dump contains ALTER TABLE for log tables, and # this causes an error if logging is enabled GENERAL_LOG_OPT=$($MYSQL --skip-column-names -e "$STOP_WSREP SELECT @@GENERAL_LOG") - SLOW_LOG_OPT=$($MYSQL --skip-column-names -e "$STOP_WSREP SELECT @@SLOW_QUERY_LOG") + SLOW_LOG_OPT=$($MYSQL --skip-column-names -e "$STOP_WSREP SELECT @@LOG_SLOW_QUERY") - LOG_OFF="SET GLOBAL GENERAL_LOG=OFF; SET GLOBAL SLOW_QUERY_LOG=OFF;" + LOG_OFF="SET GLOBAL GENERAL_LOG=OFF; SET GLOBAL LOG_SLOW_QUERY=OFF;" # commands to restore log settings RESTORE_GENERAL_LOG="SET GLOBAL GENERAL_LOG=$GENERAL_LOG_OPT;" - RESTORE_SLOW_QUERY_LOG="SET GLOBAL SLOW_QUERY_LOG=$SLOW_LOG_OPT;" + RESTORE_SLOW_QUERY_LOG="SET GLOBAL LOG_SLOW_QUERY=$SLOW_LOG_OPT;" (echo "$STOP_WSREP" && echo "$LOG_OFF" && echo "$RESET_MASTER" && \ echo "$SET_GTID_BINLOG_STATE" && echo "$SQL_LOG_BIN_OFF" && \ diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_gtid_skip_empty_trans_rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_gtid_skip_empty_trans_rocksdb.result index 835361eea352e..f128567efc9c4 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_gtid_skip_empty_trans_rocksdb.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_gtid_skip_empty_trans_rocksdb.result @@ -39,7 +39,7 @@ commit; FLUSH LOGS; ==== Output of mysqlbinlog with --short-form --skip-empty-trans, --database and --skip-gtids options ==== /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; @@ -90,7 +90,7 @@ FLUSH LOGS; ==== Output of mysqlbinlog with --short-form --skip-empty-trans, --database and --skip-gtids options ==== ==== DB changed in the middle of the transaction, which belongs to the selected database /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; SET TIMESTAMP=1000000000/*!*/; @@ -121,7 +121,7 @@ FLUSH LOGS; ==== Output of mysqlbinlog with --short-form --skip-empty-trans, --database and --skip-gtids options ==== ==== DB changed in the middle of the transaction, which belongs to the non-selected database /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; -/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; DELIMITER ; From beb9a5459d4fc21c7d3a3bf1bbc9f461d8f7e51c Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Mon, 12 Sep 2022 14:28:00 +0700 Subject: [PATCH 038/113] MDEV-20609 Full table scan in INFORMATION_SCHEMA.PARAMETERS/ROUTINES Queries to INFORMATION_SCHEMA.PARAMETERS and ROUTINES tables are always performed using full index scan of the mysql.proc primary key on fields (`db`,`name`,`type`). This can be done in a much more effective way if `db` and `name` field values can be derived from the WHERE statement, like here: SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_SCHEMA = 'test' AND SPECIFIC_NAME = 'my_func' or here: SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA='test' AND ROUTINE_NAME='my_func'. In such cases index range scan may be employed instead of full index scan. This commit makes the server retrieve lookup field values from the SQL statement and perform index range scan instead of full index scan if possible. --- .../main/information_schema_parameters.result | 165 ++++++++++++ .../main/information_schema_parameters.test | 53 ++++ .../main/information_schema_routines.result | 254 ++++++++++++++++++ .../main/information_schema_routines.test | 76 ++++++ sql/sql_show.cc | 124 ++++++--- 5 files changed, 636 insertions(+), 36 deletions(-) diff --git a/mysql-test/main/information_schema_parameters.result b/mysql-test/main/information_schema_parameters.result index 7c73c312bd7df..eff68bb816d72 100644 --- a/mysql-test/main/information_schema_parameters.result +++ b/mysql-test/main/information_schema_parameters.result @@ -626,3 +626,168 @@ DTD_IDENTIFIER ROW ROUTINE_TYPE PROCEDURE -------- -------- DROP PROCEDURE p1; +# +# MDEV-20609 Full table scan in INFORMATION_SCHEMA.PARAMETERS/ROUTINES +# +DROP DATABASE IF EXISTS i_s_parameters_test; +CREATE DATABASE i_s_parameters_test; +USE i_s_parameters_test; +CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) +RETURN CONCAT('XYZ, ' ,s); +# +# We cannot use the index due to CONCAT() +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.PARAMETERS +WHERE CONCAT(SPECIFIC_SCHEMA) = 'i_s_parameters_test' + AND SPECIFIC_NAME = 'test_func5'; +SPECIFIC_CATALOG def +SPECIFIC_SCHEMA i_s_parameters_test +SPECIFIC_NAME test_func5 +ORDINAL_POSITION 0 +PARAMETER_MODE NULL +PARAMETER_NAME NULL +DATA_TYPE varchar +CHARACTER_MAXIMUM_LENGTH 30 +CHARACTER_OCTET_LENGTH 30 +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME latin1 +COLLATION_NAME latin1_swedish_ci +DTD_IDENTIFIER varchar(30) +ROUTINE_TYPE FUNCTION +SPECIFIC_CATALOG def +SPECIFIC_SCHEMA i_s_parameters_test +SPECIFIC_NAME test_func5 +ORDINAL_POSITION 1 +PARAMETER_MODE IN +PARAMETER_NAME s +DATA_TYPE char +CHARACTER_MAXIMUM_LENGTH 20 +CHARACTER_OCTET_LENGTH 20 +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME latin1 +COLLATION_NAME latin1_swedish_ci +DTD_IDENTIFIER char(20) +ROUTINE_TYPE FUNCTION +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 54 +Handler_read_rnd_next 97 +# +# Now the index must be used +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.PARAMETERS +WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' + AND SPECIFIC_NAME = 'test_func5'; +SPECIFIC_CATALOG def +SPECIFIC_SCHEMA i_s_parameters_test +SPECIFIC_NAME test_func5 +ORDINAL_POSITION 0 +PARAMETER_MODE NULL +PARAMETER_NAME NULL +DATA_TYPE varchar +CHARACTER_MAXIMUM_LENGTH 30 +CHARACTER_OCTET_LENGTH 30 +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME latin1 +COLLATION_NAME latin1_swedish_ci +DTD_IDENTIFIER varchar(30) +ROUTINE_TYPE FUNCTION +SPECIFIC_CATALOG def +SPECIFIC_SCHEMA i_s_parameters_test +SPECIFIC_NAME test_func5 +ORDINAL_POSITION 1 +PARAMETER_MODE IN +PARAMETER_NAME s +DATA_TYPE char +CHARACTER_MAXIMUM_LENGTH 20 +CHARACTER_OCTET_LENGTH 20 +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME latin1 +COLLATION_NAME latin1_swedish_ci +DTD_IDENTIFIER char(20) +ROUTINE_TYPE FUNCTION +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 1 +Handler_read_rnd_next 3 +# +# Using the first key part of the index +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.PARAMETERS +WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test'; +SPECIFIC_CATALOG def +SPECIFIC_SCHEMA i_s_parameters_test +SPECIFIC_NAME test_func5 +ORDINAL_POSITION 0 +PARAMETER_MODE NULL +PARAMETER_NAME NULL +DATA_TYPE varchar +CHARACTER_MAXIMUM_LENGTH 30 +CHARACTER_OCTET_LENGTH 30 +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME latin1 +COLLATION_NAME latin1_swedish_ci +DTD_IDENTIFIER varchar(30) +ROUTINE_TYPE FUNCTION +SPECIFIC_CATALOG def +SPECIFIC_SCHEMA i_s_parameters_test +SPECIFIC_NAME test_func5 +ORDINAL_POSITION 1 +PARAMETER_MODE IN +PARAMETER_NAME s +DATA_TYPE char +CHARACTER_MAXIMUM_LENGTH 20 +CHARACTER_OCTET_LENGTH 20 +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME latin1 +COLLATION_NAME latin1_swedish_ci +DTD_IDENTIFIER char(20) +ROUTINE_TYPE FUNCTION +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 1 +Handler_read_rnd_next 3 +# +# Test non-latin letters in procedure name +SET NAMES koi8r; +CREATE PROCEDURE `процедурка`(a INT) SELECT a; +# +# The index must be used +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.PARAMETERS +WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' + AND SPECIFIC_NAME = 'процедурка'; +SPECIFIC_CATALOG def +SPECIFIC_SCHEMA i_s_parameters_test +SPECIFIC_NAME процедурка +ORDINAL_POSITION 1 +PARAMETER_MODE IN +PARAMETER_NAME a +DATA_TYPE int +CHARACTER_MAXIMUM_LENGTH NULL +CHARACTER_OCTET_LENGTH NULL +NUMERIC_PRECISION 10 +NUMERIC_SCALE 0 +DATETIME_PRECISION NULL +CHARACTER_SET_NAME NULL +COLLATION_NAME NULL +DTD_IDENTIFIER int(11) +ROUTINE_TYPE PROCEDURE +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 1 +Handler_read_rnd_next 2 +DROP DATABASE i_s_parameters_test; +USE test; diff --git a/mysql-test/main/information_schema_parameters.test b/mysql-test/main/information_schema_parameters.test index 81aef66bfcd01..c53ecce8b2bb9 100644 --- a/mysql-test/main/information_schema_parameters.test +++ b/mysql-test/main/information_schema_parameters.test @@ -276,3 +276,56 @@ DELIMITER ;$$ SELECT *, '--------' FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'p1'; --horizontal_results DROP PROCEDURE p1; + + +--echo # +--echo # MDEV-20609 Full table scan in INFORMATION_SCHEMA.PARAMETERS/ROUTINES +--echo # +--disable_warnings +DROP DATABASE IF EXISTS i_s_parameters_test; +--enable_warnings + +CREATE DATABASE i_s_parameters_test; +USE i_s_parameters_test; + +CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) + RETURN CONCAT('XYZ, ' ,s); + +--echo # +--echo # We cannot use the index due to CONCAT() +FLUSH STATUS; +query_vertical SELECT * FROM INFORMATION_SCHEMA.PARAMETERS + WHERE CONCAT(SPECIFIC_SCHEMA) = 'i_s_parameters_test' + AND SPECIFIC_NAME = 'test_func5'; +SHOW STATUS LIKE 'handler_read%next'; + +--echo # +--echo # Now the index must be used +FLUSH STATUS; +query_vertical SELECT * FROM INFORMATION_SCHEMA.PARAMETERS + WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' + AND SPECIFIC_NAME = 'test_func5'; +SHOW STATUS LIKE 'handler_read%next'; + +--echo # +--echo # Using the first key part of the index +FLUSH STATUS; +query_vertical SELECT * FROM INFORMATION_SCHEMA.PARAMETERS + WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test'; +SHOW STATUS LIKE 'handler_read%next'; + +--echo # +--echo # Test non-latin letters in procedure name +SET NAMES koi8r; +CREATE PROCEDURE `процедурка`(a INT) SELECT a; +--echo # +--echo # The index must be used +FLUSH STATUS; +query_vertical SELECT * FROM INFORMATION_SCHEMA.PARAMETERS + WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' + AND SPECIFIC_NAME = 'процедурка'; +SHOW STATUS LIKE 'handler_read%next'; + +# Cleanup +DROP DATABASE i_s_parameters_test; +USE test; diff --git a/mysql-test/main/information_schema_routines.result b/mysql-test/main/information_schema_routines.result index 35f12510556a9..74c867ca2ca78 100644 --- a/mysql-test/main/information_schema_routines.result +++ b/mysql-test/main/information_schema_routines.result @@ -851,3 +851,257 @@ WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func5'; SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION test_func5 def i_s_routines_test test_func5 FUNCTION varchar 30 90 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(30) SQL RETURN CONCAT('XYZ, ' ,s) NULL NULL SQL NO CONTAINS SQL NULL DEFINER root@localhost latin1 latin1_swedish_ci utf8mb3_general_ci DROP DATABASE i_s_routines_test; +# +# MDEV-20609 Full table scan in INFORMATION_SCHEMA.PARAMETERS/ROUTINES +# +DROP DATABASE IF EXISTS i_s_routines_test; +CREATE DATABASE i_s_routines_test; +USE i_s_routines_test; +CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) +RETURN CONCAT('XYZ, ' ,s); +# +# We cannot use the index due to CONCAT() +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.ROUTINES +WHERE CONCAT(ROUTINE_SCHEMA) = 'i_s_routines_test' + AND ROUTINE_NAME = 'test_func5'; +SPECIFIC_NAME test_func5 +ROUTINE_CATALOG def +ROUTINE_SCHEMA i_s_routines_test +ROUTINE_NAME test_func5 +ROUTINE_TYPE FUNCTION +DATA_TYPE varchar +CHARACTER_MAXIMUM_LENGTH 30 +CHARACTER_OCTET_LENGTH 30 +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME latin1 +COLLATION_NAME latin1_swedish_ci +DTD_IDENTIFIER varchar(30) +ROUTINE_BODY SQL +ROUTINE_DEFINITION RETURN CONCAT('XYZ, ' ,s) +EXTERNAL_NAME NULL +EXTERNAL_LANGUAGE NULL +PARAMETER_STYLE SQL +IS_DETERMINISTIC NO +SQL_DATA_ACCESS CONTAINS SQL +SQL_PATH NULL +SECURITY_TYPE DEFINER +CREATED +LAST_ALTERED +SQL_MODE +ROUTINE_COMMENT +DEFINER root@localhost +CHARACTER_SET_CLIENT latin1 +COLLATION_CONNECTION latin1_swedish_ci +DATABASE_COLLATION latin1_swedish_ci +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 54 +Handler_read_rnd_next 55 +# +# Now the index must be used +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = 'i_s_routines_test' + AND ROUTINE_NAME = 'test_func5'; +SPECIFIC_NAME test_func5 +ROUTINE_CATALOG def +ROUTINE_SCHEMA i_s_routines_test +ROUTINE_NAME test_func5 +ROUTINE_TYPE FUNCTION +DATA_TYPE varchar +CHARACTER_MAXIMUM_LENGTH 30 +CHARACTER_OCTET_LENGTH 30 +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME latin1 +COLLATION_NAME latin1_swedish_ci +DTD_IDENTIFIER varchar(30) +ROUTINE_BODY SQL +ROUTINE_DEFINITION RETURN CONCAT('XYZ, ' ,s) +EXTERNAL_NAME NULL +EXTERNAL_LANGUAGE NULL +PARAMETER_STYLE SQL +IS_DETERMINISTIC NO +SQL_DATA_ACCESS CONTAINS SQL +SQL_PATH NULL +SECURITY_TYPE DEFINER +CREATED +LAST_ALTERED +SQL_MODE +ROUTINE_COMMENT +DEFINER root@localhost +CHARACTER_SET_CLIENT latin1 +COLLATION_CONNECTION latin1_swedish_ci +DATABASE_COLLATION latin1_swedish_ci +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 1 +Handler_read_rnd_next 2 +# +# Using the first key part of the index +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = 'i_s_routines_test'; +SPECIFIC_NAME test_func5 +ROUTINE_CATALOG def +ROUTINE_SCHEMA i_s_routines_test +ROUTINE_NAME test_func5 +ROUTINE_TYPE FUNCTION +DATA_TYPE varchar +CHARACTER_MAXIMUM_LENGTH 30 +CHARACTER_OCTET_LENGTH 30 +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME latin1 +COLLATION_NAME latin1_swedish_ci +DTD_IDENTIFIER varchar(30) +ROUTINE_BODY SQL +ROUTINE_DEFINITION RETURN CONCAT('XYZ, ' ,s) +EXTERNAL_NAME NULL +EXTERNAL_LANGUAGE NULL +PARAMETER_STYLE SQL +IS_DETERMINISTIC NO +SQL_DATA_ACCESS CONTAINS SQL +SQL_PATH NULL +SECURITY_TYPE DEFINER +CREATED +LAST_ALTERED +SQL_MODE +ROUTINE_COMMENT +DEFINER root@localhost +CHARACTER_SET_CLIENT latin1 +COLLATION_CONNECTION latin1_swedish_ci +DATABASE_COLLATION latin1_swedish_ci +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 1 +Handler_read_rnd_next 2 +# +# Test non-latin letters in procedure name +SET NAMES koi8r; +CREATE PROCEDURE `процедурка`(a INT) SELECT a; +# +# The index must be used +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = 'i_s_routines_test' + AND ROUTINE_NAME = 'процедурка'; +SPECIFIC_NAME процедурка +ROUTINE_CATALOG def +ROUTINE_SCHEMA i_s_routines_test +ROUTINE_NAME процедурка +ROUTINE_TYPE PROCEDURE +DATA_TYPE +CHARACTER_MAXIMUM_LENGTH NULL +CHARACTER_OCTET_LENGTH NULL +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION NULL +CHARACTER_SET_NAME NULL +COLLATION_NAME NULL +DTD_IDENTIFIER NULL +ROUTINE_BODY SQL +ROUTINE_DEFINITION SELECT a +EXTERNAL_NAME NULL +EXTERNAL_LANGUAGE NULL +PARAMETER_STYLE SQL +IS_DETERMINISTIC NO +SQL_DATA_ACCESS CONTAINS SQL +SQL_PATH NULL +SECURITY_TYPE DEFINER +CREATED +LAST_ALTERED +SQL_MODE +ROUTINE_COMMENT +DEFINER root@localhost +CHARACTER_SET_CLIENT koi8r +COLLATION_CONNECTION koi8r_general_ci +DATABASE_COLLATION latin1_swedish_ci +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 1 +Handler_read_rnd_next 2 +# +# Test SHOW PROCEDURE STATUS. It's impossible to use the index here +# so don't check Handler_read counters, only the results correctness +SHOW FUNCTION STATUS LIKE 'test_func5'; +Db i_s_routines_test +Name test_func5 +Type FUNCTION +Definer root@localhost +Modified +Created +Security_type DEFINER +Comment +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +SHOW FUNCTION STATUS LIKE 'test_%'; +Db i_s_routines_test +Name test_func5 +Type FUNCTION +Definer root@localhost +Modified +Created +Security_type DEFINER +Comment +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +SHOW FUNCTION STATUS LIKE '%func%'; +Db i_s_routines_test +Name test_func5 +Type FUNCTION +Definer root@localhost +Modified +Created +Security_type DEFINER +Comment +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +SHOW FUNCTION STATUS LIKE 'test'; +SHOW PROCEDURE STATUS LIKE 'процедурка'; +Db i_s_routines_test +Name процедурка +Type PROCEDURE +Definer root@localhost +Modified +Created +Security_type DEFINER +Comment +character_set_client koi8r +collation_connection koi8r_general_ci +Database Collation latin1_swedish_ci +SHOW PROCEDURE STATUS LIKE '%оцедурка'; +Db i_s_routines_test +Name процедурка +Type PROCEDURE +Definer root@localhost +Modified +Created +Security_type DEFINER +Comment +character_set_client koi8r +collation_connection koi8r_general_ci +Database Collation latin1_swedish_ci +SHOW PROCEDURE STATUS LIKE '%оцедур%'; +Db i_s_routines_test +Name процедурка +Type PROCEDURE +Definer root@localhost +Modified +Created +Security_type DEFINER +Comment +character_set_client koi8r +collation_connection koi8r_general_ci +Database Collation latin1_swedish_ci +SHOW PROCEDURE STATUS LIKE 'такой_нет'; +DROP DATABASE i_s_routines_test; +USE test; diff --git a/mysql-test/main/information_schema_routines.test b/mysql-test/main/information_schema_routines.test index a07e54cd70b0a..bf8e4dd78943b 100644 --- a/mysql-test/main/information_schema_routines.test +++ b/mysql-test/main/information_schema_routines.test @@ -249,3 +249,79 @@ WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func5'; # final clean up DROP DATABASE i_s_routines_test; + +--echo # +--echo # MDEV-20609 Full table scan in INFORMATION_SCHEMA.PARAMETERS/ROUTINES +--echo # +--disable_warnings +DROP DATABASE IF EXISTS i_s_routines_test; +--enable_warnings + +CREATE DATABASE i_s_routines_test; +USE i_s_routines_test; + +CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) + RETURN CONCAT('XYZ, ' ,s); + +--echo # +--echo # We cannot use the index due to CONCAT() +FLUSH STATUS; +--replace_column 24 25 +query_vertical SELECT * FROM INFORMATION_SCHEMA.ROUTINES + WHERE CONCAT(ROUTINE_SCHEMA) = 'i_s_routines_test' + AND ROUTINE_NAME = 'test_func5'; +SHOW STATUS LIKE 'handler_read%next'; + +--echo # +--echo # Now the index must be used +FLUSH STATUS; +--replace_column 24 25 +query_vertical SELECT * FROM INFORMATION_SCHEMA.ROUTINES + WHERE ROUTINE_SCHEMA = 'i_s_routines_test' + AND ROUTINE_NAME = 'test_func5'; +SHOW STATUS LIKE 'handler_read%next'; + +--echo # +--echo # Using the first key part of the index +FLUSH STATUS; +--replace_column 24 25 +query_vertical SELECT * FROM INFORMATION_SCHEMA.ROUTINES + WHERE ROUTINE_SCHEMA = 'i_s_routines_test'; +SHOW STATUS LIKE 'handler_read%next'; + +--echo # +--echo # Test non-latin letters in procedure name +SET NAMES koi8r; +CREATE PROCEDURE `процедурка`(a INT) SELECT a; +--echo # +--echo # The index must be used +FLUSH STATUS; +--replace_column 24 25 +query_vertical SELECT * FROM INFORMATION_SCHEMA.ROUTINES + WHERE ROUTINE_SCHEMA = 'i_s_routines_test' + AND ROUTINE_NAME = 'процедурка'; +SHOW STATUS LIKE 'handler_read%next'; + +--echo # +--echo # Test SHOW PROCEDURE STATUS. It's impossible to use the index here +--echo # so don't check Handler_read counters, only the results correctness +--replace_column 5 6 +query_vertical SHOW FUNCTION STATUS LIKE 'test_func5'; +--replace_column 5 6 +query_vertical SHOW FUNCTION STATUS LIKE 'test_%'; +--replace_column 5 6 +query_vertical SHOW FUNCTION STATUS LIKE '%func%'; +--replace_column 5 6 +query_vertical SHOW FUNCTION STATUS LIKE 'test'; +--replace_column 5 6 +query_vertical SHOW PROCEDURE STATUS LIKE 'процедурка'; +--replace_column 5 6 +query_vertical SHOW PROCEDURE STATUS LIKE '%оцедурка'; +--replace_column 5 6 +query_vertical SHOW PROCEDURE STATUS LIKE '%оцедур%'; +--replace_column 5 6 +query_vertical SHOW PROCEDURE STATUS LIKE 'такой_нет'; + +# Cleanup +DROP DATABASE i_s_routines_test; +USE test; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2e7001f1e66dd..bafd3b000e655 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -65,7 +65,7 @@ #include "transaction.h" #include "opt_trace.h" #include "my_cpu.h" - +#include "key.h" #include "lex_symbol.h" #define KEYWORD_SIZE 64 @@ -150,7 +150,8 @@ static int show_create_sequence(THD *thd, TABLE_LIST *table_list, static const LEX_CSTRING *view_algorithm(TABLE_LIST *table); -bool get_lookup_field_values(THD *, COND *, TABLE_LIST *, LOOKUP_FIELD_VALUES *); +bool get_lookup_field_values(THD *, COND *, bool, TABLE_LIST *, + LOOKUP_FIELD_VALUES *); /** Try to lock a mutex, but give up after a short while to not cause deadlocks @@ -340,7 +341,7 @@ int fill_all_plugins(THD *thd, TABLE_LIST *tables, COND *cond) TABLE *table= tables->table; LOOKUP_FIELD_VALUES lookup; - if (get_lookup_field_values(thd, cond, tables, &lookup)) + if (get_lookup_field_values(thd, cond, true, tables, &lookup)) DBUG_RETURN(0); if (lookup.db_value.str && !lookup.db_value.str[0]) @@ -4257,7 +4258,8 @@ COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table) 1 error, there can be no matching records for the condition */ -bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables, +bool get_lookup_field_values(THD *thd, COND *cond, bool fix_table_name_case, + TABLE_LIST *tables, LOOKUP_FIELD_VALUES *lookup_field_values) { LEX *lex= thd->lex; @@ -4292,7 +4294,7 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables, lex->first_select_lex()->db.length); if (wild) { - thd->make_lex_string(&lookup_field_values->table_value, + thd->make_lex_string(&lookup_field_values->table_value, wild->ptr(), wild->length()); lookup_field_values->wild_table_value= 1; } @@ -4315,7 +4317,8 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables, if (lookup_field_values->db_value.str && lookup_field_values->db_value.str[0]) my_casedn_str(system_charset_info, (char*) lookup_field_values->db_value.str); - if (lookup_field_values->table_value.str && + if (fix_table_name_case && + lookup_field_values->table_value.str && lookup_field_values->table_value.str[0]) my_casedn_str(system_charset_info, (char*) lookup_field_values->table_value.str); @@ -5470,7 +5473,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond) #endif DBUG_ENTER("fill_schema_shemata"); - if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals)) + if (get_lookup_field_values(thd, cond, true, tables, &lookup_field_vals)) DBUG_RETURN(0); DBUG_PRINT("INDEX VALUES",("db_name: %s table_name: %s", lookup_field_vals.db_value.str, @@ -6448,19 +6451,18 @@ static inline void copy_field_as_string(Field *to_field, Field *from_field) @param[in] thd thread handler @param[in] table I_S table @param[in] proc_table 'mysql.proc' table - @param[in] wild wild string, not used for now, - will be useful - if we add 'SHOW PARAMETERs' @param[in] full_access if 1 user has privileges on the routine @param[in] sp_user user in 'user@host' format @return Operation status @retval 0 ok - @retval 1 error + @retval != 0 error / HA_ERR_END_OF_FILE + (if there are no more + matching records) */ -bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, - const char *wild, bool full_access, +int store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, + LOOKUP_FIELD_VALUES *lookup, bool full_access, const char *sp_user) { TABLE_SHARE share; @@ -6482,6 +6484,15 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, proc_table->field[MYSQL_PROC_FIELD_DB]->val_str_nopad(thd->mem_root, &db); proc_table->field[MYSQL_PROC_FIELD_NAME]->val_str_nopad(thd->mem_root, &name); + + if (lookup->db_value.str) + { + if (cmp(lookup->db_value, db)) + DBUG_RETURN(HA_ERR_END_OF_FILE); + if (lookup->table_value.str && cmp(lookup->table_value, name)) + DBUG_RETURN(HA_ERR_END_OF_FILE); + } + proc_table->field[MYSQL_PROC_FIELD_DEFINER]->val_str_nopad(thd->mem_root, &definer); sql_mode= (sql_mode_t) proc_table->field[MYSQL_PROC_FIELD_SQL_MODE]->val_int(); sph= Sp_handler::handler_mysql_proc((enum_sp_type) @@ -6585,16 +6596,33 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, } -bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, - const char *wild, bool full_access, const char *sp_user) +int store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, + LOOKUP_FIELD_VALUES *lookup, bool full_access, + const char *sp_user) { LEX *lex= thd->lex; CHARSET_INFO *cs= system_charset_info; const Sp_handler *sph; LEX_CSTRING db, name, definer, returns= empty_clex_str; + const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; proc_table->field[MYSQL_PROC_FIELD_DB]->val_str_nopad(thd->mem_root, &db); proc_table->field[MYSQL_PROC_FIELD_NAME]->val_str_nopad(thd->mem_root, &name); + + if (lookup->db_value.str) + { + if (cmp(lookup->db_value, db)) + return HA_ERR_END_OF_FILE; + if (lookup->table_value.str) + { + CHARSET_INFO *cs= proc_table->field[MYSQL_PROC_FIELD_NAME]->charset(); + if (my_ci_strnncoll(cs, (const uchar*)lookup->table_value.str, + lookup->table_value.length, + (const uchar*) name.str, name.length, 0)) + return HA_ERR_END_OF_FILE; + } + } + proc_table->field[MYSQL_PROC_FIELD_DEFINER]->val_str_nopad(thd->mem_root, &definer); sph= Sp_handler::handler_mysql_proc((enum_sp_type) proc_table->field[MYSQL_PROC_MYSQL_TYPE]-> @@ -6706,7 +6734,6 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) { TABLE *proc_table; TABLE_LIST proc_tables; - const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; int res= 0; TABLE *table= tables->table; bool full_access; @@ -6726,6 +6753,13 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) full_access= !check_table_access(thd, SELECT_ACL, &proc_tables, FALSE, 1, TRUE); + LOOKUP_FIELD_VALUES lookup; + if (get_lookup_field_values(thd, cond, false, tables, &lookup)) + { + // There can be no matching records for the condition + return 0; + } + start_new_trans new_trans(thd); if (!(proc_table= open_proc_table_for_read(thd))) @@ -6744,34 +6778,51 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) goto err; } - if ((res= proc_table->file->ha_index_first(proc_table->record[0]))) + if (lookup.db_value.str) { - res= (res == HA_ERR_END_OF_FILE) ? 0 : 1; - goto err; + KEY *keyinfo= proc_table->key_info; + uint keylen= keyinfo->key_part[0].length; + key_part_map keypart_map= 1; + enum ha_rkey_function find_flag= HA_READ_PREFIX; + uchar keybuf[NAME_CHAR_LEN * 2 * 4 * 64]; + proc_table->field[0]->store(lookup.db_value.str, lookup.db_value.length, + system_charset_info); + if (lookup.table_value.str) + { + proc_table->field[1]->store(lookup.table_value.str, + lookup.table_value.length, + system_charset_info); + keylen+= keyinfo->key_part[1].length; + keypart_map= 3; + find_flag= HA_READ_KEY_EXACT; + } + key_copy(keybuf, proc_table->record[0], keyinfo, keylen, 0); + res= proc_table->file->ha_index_read_map(proc_table->record[0], keybuf, + keypart_map, find_flag); } + else + res= proc_table->file->ha_index_first(proc_table->record[0]); - if (schema_table_idx == SCH_PROCEDURES ? - store_schema_proc(thd, table, proc_table, wild, full_access, definer) : - store_schema_params(thd, table, proc_table, wild, full_access, definer)) - { - res= 1; + if (res) goto err; - } - while (!proc_table->file->ha_index_next(proc_table->record[0])) + + res= schema_table_idx == SCH_PROCEDURES ? + store_schema_proc(thd, table, proc_table, &lookup, full_access,definer) : + store_schema_params(thd, table, proc_table, &lookup, full_access, definer); + while (!res && !proc_table->file->ha_index_next(proc_table->record[0])) { - if (schema_table_idx == SCH_PROCEDURES ? - store_schema_proc(thd, table, proc_table, wild, full_access, definer): - store_schema_params(thd, table, proc_table, wild, full_access, definer)) - { - res= 1; - goto err; - } + res= schema_table_idx == SCH_PROCEDURES ? + store_schema_proc(thd, table, proc_table, &lookup, full_access, definer) : + store_schema_params(thd, table, proc_table, &lookup, full_access, definer); } err: if (proc_table->file->inited) (void) proc_table->file->ha_index_end(); + if (res == HA_ERR_END_OF_FILE || res == HA_ERR_KEY_NOT_FOUND) + res= 0; + thd->commit_whole_transaction_and_close_tables(); new_trans.restore_old_transaction(); @@ -8669,7 +8720,8 @@ static bool optimize_for_get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond goto end; } - if (get_lookup_field_values(thd, cond, tables, &plan->lookup_field_vals)) + if (get_lookup_field_values(thd, cond, true, tables, + &plan->lookup_field_vals)) { plan->no_rows= true; goto end; @@ -9861,7 +9913,7 @@ ST_SCHEMA_TABLE schema_tables[]= {"OPTIMIZER_TRACE", Show::optimizer_trace_info, 0, fill_optimizer_trace_info, NULL, NULL, -1, -1, false, 0}, {"PARAMETERS", Show::parameters_fields_info, 0, - fill_schema_proc, 0, 0, -1, -1, 0, 0}, + fill_schema_proc, 0, 0, 1, 2, 0, 0}, {"PARTITIONS", Show::partitions_fields_info, 0, get_all_tables, 0, get_schema_partitions_record, 1, 2, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY}, @@ -9876,7 +9928,7 @@ ST_SCHEMA_TABLE schema_tables[]= 0, get_all_tables, 0, get_referential_constraints_record, 1, 9, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY}, {"ROUTINES", Show::proc_fields_info, 0, - fill_schema_proc, make_proc_old_format, 0, -1, -1, 0, 0}, + fill_schema_proc, make_proc_old_format, 0, 2, 3, 0, 0}, {"SCHEMATA", Show::schema_fields_info, 0, fill_schema_schemata, make_schemata_old_format, 0, 1, -1, 0, 0}, {"SCHEMA_PRIVILEGES", Show::schema_privileges_fields_info, 0, From 035feae610c6ab88154d9858914da66e25945e03 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Fri, 16 Sep 2022 15:04:54 +0400 Subject: [PATCH 039/113] MDEV-29550 Fix Valgrind/MSAN uninitialised value errors --- sql/sql_show.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index bafd3b000e655..b2c4fdda9539f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6784,7 +6784,10 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) uint keylen= keyinfo->key_part[0].length; key_part_map keypart_map= 1; enum ha_rkey_function find_flag= HA_READ_PREFIX; - uchar keybuf[NAME_CHAR_LEN * 2 * 4 * 64]; + const auto sp_name_len= NAME_LEN * 2 + 1 /*for type*/; + StringBuffer keybuf; + keybuf.alloc(proc_table->key_info->key_length); + keybuf.length(proc_table->key_info->key_length); proc_table->field[0]->store(lookup.db_value.str, lookup.db_value.length, system_charset_info); if (lookup.table_value.str) @@ -6796,8 +6799,9 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) keypart_map= 3; find_flag= HA_READ_KEY_EXACT; } - key_copy(keybuf, proc_table->record[0], keyinfo, keylen, 0); - res= proc_table->file->ha_index_read_map(proc_table->record[0], keybuf, + key_copy((uchar*)keybuf.ptr(), proc_table->record[0], keyinfo, keylen, 0); + res= proc_table->file->ha_index_read_map(proc_table->record[0], + (const uchar*) keybuf.ptr(), keypart_map, find_flag); } else From d9092e3de7b6868403f2611508249aa0bcd9022a Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Mon, 19 Sep 2022 21:36:09 +0700 Subject: [PATCH 040/113] MDEV-29104 Optimize queries to INFORMATION_SCHEMA.PARAMETERS/ROUTINES For queries like "SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME='proc_name'" and "SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME='proc_name'" there is a possibility to avoid loading of the stored procedure code and parsing it to retrieve parameters. If the name of the procedure/function is specified explicitly then it is possible to filter out routines that do not match at an early stage. --- .../main/information_schema_parameters.result | 20 ++++- .../main/information_schema_parameters.test | 14 ++- .../main/information_schema_routines.result | 20 ++++- .../main/information_schema_routines.test | 15 +++- sql/sql_show.cc | 87 ++++++++++++++----- 5 files changed, 124 insertions(+), 32 deletions(-) diff --git a/mysql-test/main/information_schema_parameters.result b/mysql-test/main/information_schema_parameters.result index eff68bb816d72..69a777d6db0c4 100644 --- a/mysql-test/main/information_schema_parameters.result +++ b/mysql-test/main/information_schema_parameters.result @@ -635,11 +635,11 @@ USE i_s_parameters_test; CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) RETURN CONCAT('XYZ, ' ,s); # -# We cannot use the index due to CONCAT() +# We cannot use the index due to missing condition on SPECIFIC_SCHEMA, +# but we will use SPECIFIC_NAME for filtering records from mysql.proc FLUSH STATUS; SELECT * FROM INFORMATION_SCHEMA.PARAMETERS -WHERE CONCAT(SPECIFIC_SCHEMA) = 'i_s_parameters_test' - AND SPECIFIC_NAME = 'test_func5'; +WHERE SPECIFIC_NAME = 'test_func5'; SPECIFIC_CATALOG def SPECIFIC_SCHEMA i_s_parameters_test SPECIFIC_NAME test_func5 @@ -675,7 +675,19 @@ ROUTINE_TYPE FUNCTION SHOW STATUS LIKE 'handler_read%next'; Variable_name Value Handler_read_next 54 -Handler_read_rnd_next 97 +Handler_read_rnd_next 3 +# +# We cannot use the index due to CONCAT(), and filtering by SPECIFIC_NAME +# does not work either since SPECIFIC_NAME = 'not_existing_proc'. See +# the difference in counters in comparison to the previous test +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.PARAMETERS +WHERE CONCAT(SPECIFIC_SCHEMA) = 'i_s_parameters_test' + AND SPECIFIC_NAME = 'not_existing_proc'; +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 54 +Handler_read_rnd_next 1 # # Now the index must be used FLUSH STATUS; diff --git a/mysql-test/main/information_schema_parameters.test b/mysql-test/main/information_schema_parameters.test index c53ecce8b2bb9..0c9d94e97f646 100644 --- a/mysql-test/main/information_schema_parameters.test +++ b/mysql-test/main/information_schema_parameters.test @@ -292,11 +292,21 @@ CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) RETURN CONCAT('XYZ, ' ,s); --echo # ---echo # We cannot use the index due to CONCAT() +--echo # We cannot use the index due to missing condition on SPECIFIC_SCHEMA, +--echo # but we will use SPECIFIC_NAME for filtering records from mysql.proc +FLUSH STATUS; +query_vertical SELECT * FROM INFORMATION_SCHEMA.PARAMETERS + WHERE SPECIFIC_NAME = 'test_func5'; +SHOW STATUS LIKE 'handler_read%next'; + +--echo # +--echo # We cannot use the index due to CONCAT(), and filtering by SPECIFIC_NAME +--echo # does not work either since SPECIFIC_NAME = 'not_existing_proc'. See +--echo # the difference in counters in comparison to the previous test FLUSH STATUS; query_vertical SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE CONCAT(SPECIFIC_SCHEMA) = 'i_s_parameters_test' - AND SPECIFIC_NAME = 'test_func5'; + AND SPECIFIC_NAME = 'not_existing_proc'; SHOW STATUS LIKE 'handler_read%next'; --echo # diff --git a/mysql-test/main/information_schema_routines.result b/mysql-test/main/information_schema_routines.result index 74c867ca2ca78..d316dd7acee04 100644 --- a/mysql-test/main/information_schema_routines.result +++ b/mysql-test/main/information_schema_routines.result @@ -860,11 +860,11 @@ USE i_s_routines_test; CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) RETURN CONCAT('XYZ, ' ,s); # -# We cannot use the index due to CONCAT() +# We cannot use the index due to missing condition on SPECIFIC_SCHEMA, +# but we will use ROUTINE_NAME for filtering records from mysql.proc FLUSH STATUS; SELECT * FROM INFORMATION_SCHEMA.ROUTINES -WHERE CONCAT(ROUTINE_SCHEMA) = 'i_s_routines_test' - AND ROUTINE_NAME = 'test_func5'; +WHERE ROUTINE_NAME = 'test_func5'; SPECIFIC_NAME test_func5 ROUTINE_CATALOG def ROUTINE_SCHEMA i_s_routines_test @@ -899,7 +899,19 @@ DATABASE_COLLATION latin1_swedish_ci SHOW STATUS LIKE 'handler_read%next'; Variable_name Value Handler_read_next 54 -Handler_read_rnd_next 55 +Handler_read_rnd_next 2 +# +# We cannot use the index due to CONCAT(), and filtering by ROUTINE_NAME +# does not work either since ROUTINE_NAME = 'not_existing_proc'. See +# the difference in counters in comparison to the previous test +FLUSH STATUS; +SELECT * FROM INFORMATION_SCHEMA.ROUTINES +WHERE CONCAT(ROUTINE_SCHEMA) = 'i_s_routines_test' + AND ROUTINE_NAME = 'not_existing_proc'; +SHOW STATUS LIKE 'handler_read%next'; +Variable_name Value +Handler_read_next 54 +Handler_read_rnd_next 1 # # Now the index must be used FLUSH STATUS; diff --git a/mysql-test/main/information_schema_routines.test b/mysql-test/main/information_schema_routines.test index bf8e4dd78943b..ea64c8b0d0240 100644 --- a/mysql-test/main/information_schema_routines.test +++ b/mysql-test/main/information_schema_routines.test @@ -263,13 +263,24 @@ USE i_s_routines_test; CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) RETURN CONCAT('XYZ, ' ,s); + --echo # ---echo # We cannot use the index due to CONCAT() +--echo # We cannot use the index due to missing condition on SPECIFIC_SCHEMA, +--echo # but we will use ROUTINE_NAME for filtering records from mysql.proc FLUSH STATUS; --replace_column 24 25 +query_vertical SELECT * FROM INFORMATION_SCHEMA.ROUTINES + WHERE ROUTINE_NAME = 'test_func5'; +SHOW STATUS LIKE 'handler_read%next'; + +--echo # +--echo # We cannot use the index due to CONCAT(), and filtering by ROUTINE_NAME +--echo # does not work either since ROUTINE_NAME = 'not_existing_proc'. See +--echo # the difference in counters in comparison to the previous test +FLUSH STATUS; query_vertical SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE CONCAT(ROUTINE_SCHEMA) = 'i_s_routines_test' - AND ROUTINE_NAME = 'test_func5'; + AND ROUTINE_NAME = 'not_existing_proc'; SHOW STATUS LIKE 'handler_read%next'; --echo # diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b2c4fdda9539f..a9eb876fb9978 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6445,6 +6445,64 @@ static inline void copy_field_as_string(Field *to_field, Field *from_field) } +/** + @brief When scanning mysql.proc check if we should skip this record or even + stop the scan + + @param name_field_charset mysql.proc.name field charset info + @param lookup values from the WHERE clause which are + used for the index lookup + @param db mysql.proc.db field value of + the current record + @param name mysql.proc.name field value of + the current record + + @return Result + @retval -1 The record is match (do further processing) + @retval 0 Skip this record, it doesn't match. + @retval HA_ERR_END_OF_FILE Stop scanning, no further matches possible +*/ + +int check_proc_record(const CHARSET_INFO *name_field_charset, + const LOOKUP_FIELD_VALUES *lookup, + const LEX_CSTRING &db, + const LEX_CSTRING &name) +{ + if (lookup->db_value.str && cmp(lookup->db_value, db)) + { + /* + We have the name of target database. If we got a non-matching + record, this means we've finished reading matching mysql.proc records + */ + return HA_ERR_END_OF_FILE; + } + + if (lookup->table_value.str) + { + if ((my_ci_strnncoll(name_field_charset, + (const uchar *) lookup->table_value.str, + lookup->table_value.length, + (const uchar *) name.str, name.length, 0))) + { + /* Routine name doesn't match. */ + if (lookup->db_value.str) + { + /* + We're using index lookup. A non-matching record means we've + finished reading matches. + */ + return HA_ERR_END_OF_FILE; + } + else + { + /* The routine name doesn't match, but we're scanning all databases */ + return 0; /* Continue scanning */ + } + } + } + return -1; /* This is a match */ +} + /** @brief Store record into I_S.PARAMETERS table @@ -6476,6 +6534,7 @@ int store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, bool free_sp_head; bool error= 0; sql_mode_t sql_mode; + int rc; DBUG_ENTER("store_schema_params"); bzero((char*) &tbl, sizeof(TABLE)); @@ -6485,13 +6544,10 @@ int store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, proc_table->field[MYSQL_PROC_FIELD_DB]->val_str_nopad(thd->mem_root, &db); proc_table->field[MYSQL_PROC_FIELD_NAME]->val_str_nopad(thd->mem_root, &name); - if (lookup->db_value.str) - { - if (cmp(lookup->db_value, db)) - DBUG_RETURN(HA_ERR_END_OF_FILE); - if (lookup->table_value.str && cmp(lookup->table_value, name)) - DBUG_RETURN(HA_ERR_END_OF_FILE); - } + CHARSET_INFO *name_cs= proc_table->field[MYSQL_PROC_FIELD_NAME]->charset(); + + if ((rc= check_proc_record(name_cs, lookup, db, name)) != -1) + DBUG_RETURN(rc); /* either HA_ERR_END_OF_FILE or 0 if name didn't match */ proc_table->field[MYSQL_PROC_FIELD_DEFINER]->val_str_nopad(thd->mem_root, &definer); sql_mode= (sql_mode_t) proc_table->field[MYSQL_PROC_FIELD_SQL_MODE]->val_int(); @@ -6605,23 +6661,14 @@ int store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, const Sp_handler *sph; LEX_CSTRING db, name, definer, returns= empty_clex_str; const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; + int rc; proc_table->field[MYSQL_PROC_FIELD_DB]->val_str_nopad(thd->mem_root, &db); proc_table->field[MYSQL_PROC_FIELD_NAME]->val_str_nopad(thd->mem_root, &name); - if (lookup->db_value.str) - { - if (cmp(lookup->db_value, db)) - return HA_ERR_END_OF_FILE; - if (lookup->table_value.str) - { - CHARSET_INFO *cs= proc_table->field[MYSQL_PROC_FIELD_NAME]->charset(); - if (my_ci_strnncoll(cs, (const uchar*)lookup->table_value.str, - lookup->table_value.length, - (const uchar*) name.str, name.length, 0)) - return HA_ERR_END_OF_FILE; - } - } + CHARSET_INFO *name_cs= proc_table->field[MYSQL_PROC_FIELD_NAME]->charset(); + if ((rc= check_proc_record(name_cs, lookup, db, name)) != -1) + return rc; /* either HA_ERR_END_OF_FILE or 0 if name didn't match */ proc_table->field[MYSQL_PROC_FIELD_DEFINER]->val_str_nopad(thd->mem_root, &definer); sph= Sp_handler::handler_mysql_proc((enum_sp_type) From 950e4f584da2ee937d98ea824e34aa895d737ea3 Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe <50832275+hartmut-mariadb@users.noreply.github.com> Date: Sun, 16 Oct 2022 19:18:40 +0200 Subject: [PATCH 041/113] MDEV-6655: mysqld_multi default log location in wrong directory (#2285) The mysqld_multi script template used @datadir@ as default log destination, this is not the MariaDB datadir in this context though but rather the -- typically write-only -- /share dir. The correct placeholder to use here is @localstatedir@ which gets replaced with the actual MariaDB datadir Co-authored-by: Hartmut Holzgraefe --- scripts/mysqld_multi.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 28c39090d03de..9a1f3920f6771 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -227,7 +227,7 @@ sub defaults_for_group #### #### Init log file. Check for appropriate place for log file, in the following -#### order: my_print_defaults mysqld datadir, @datadir@ +#### order: my_print_defaults mysqld datadir, @localstatedir@ #### sub init_log @@ -241,7 +241,7 @@ sub init_log } if (!defined($logdir)) { - $logdir= "@datadir@" if (-d "@datadir@" && -w "@datadir@"); + $logdir= "@localstatedir@" if (-d "@localstatedir@" && -w "@localstatedir@"); } if (!defined($logdir)) { From ccf0e27f28911229a588368121ca214b0afad3c6 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Mon, 17 Oct 2022 19:34:25 +0200 Subject: [PATCH 042/113] version change --- VERSION | 4 ++-- mysql-test/suite/sys_vars/r/sysvars_star.result | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index b93fbcee673a5..7594fbe488f99 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=11 -MYSQL_VERSION_PATCH=0 -SERVER_MATURITY=alpha +MYSQL_VERSION_PATCH=1 +SERVER_MATURITY=gamma diff --git a/mysql-test/suite/sys_vars/r/sysvars_star.result b/mysql-test/suite/sys_vars/r/sysvars_star.result index 65a391828b27d..b3357fda3afab 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_star.result +++ b/mysql-test/suite/sys_vars/r/sysvars_star.result @@ -60,7 +60,7 @@ VARIABLE_NAME PLUGIN_MATURITY SESSION_VALUE NULL GLOBAL_VALUE alpha GLOBAL_VALUE_ORIGIN CONFIG -DEFAULT_VALUE experimental +DEFAULT_VALUE beta VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded From 1a057a923ba8e7cdf9c065624f9a24c02dcecdd2 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Tue, 9 Aug 2022 13:50:12 +0200 Subject: [PATCH 043/113] MDEV-15530: Variable replicate_rewrite_db cannot be found in "show global variables" - Add `replicate_rewrite_db` status variable, that may accept comma separated key-value pairs. - Note that option `OPT_REPLICATE_REWRITE_DB` already existed in `mysqld.h` from this commit 23d8586dbfdf Reviewer:Brandon Nesterenko --- client/mysqlbinlog.cc | 41 +---- mysql-test/include/check-testcase.test | 3 +- mysql-test/main/mysqlbinlog.result | 15 +- .../suite/multi_source/info_logs.result | 12 +- .../multi_source_slave_alias_replica.result | 2 + .../replicate_rewrite_db_dynamic.cnf | 19 ++ .../replicate_rewrite_db_dynamic.result | 67 +++++++ .../replicate_rewrite_db_dynamic.test | 96 +++++++++++ .../suite/multi_source/reset_slave.result | 8 +- mysql-test/suite/multi_source/simple.result | 7 + mysql-test/suite/multi_source/syntax.result | 6 +- .../rpl/r/rpl_rewrite_db_sys_vars.result | 163 ++++++++++++++++++ .../rpl/t/rpl_rewrite_db_sys_vars-slave.opt | 2 + .../suite/rpl/t/rpl_rewrite_db_sys_vars.test | 163 ++++++++++++++++++ .../sys_vars/r/replicate_rewrite_db.result | 99 +++++++++++ .../r/sysvars_server_notembedded.result | 10 ++ .../suite/sys_vars/t/replicate_rewrite_db.opt | 3 + .../sys_vars/t/replicate_rewrite_db.test | 84 +++++++++ sql/mysqld.cc | 38 +--- sql/privilege.h | 2 + sql/protocol.cc | 38 +++- sql/protocol.h | 1 + sql/rpl_filter.cc | 152 +++++++++++++--- sql/rpl_filter.h | 11 +- sql/rpl_mi.cc | 8 +- sql/slave.cc | 4 + sql/sql_list.cc | 7 - sql/sql_list.h | 1 - sql/sys_vars.cc | 13 ++ tests/mysql_client_test.c | 2 +- 30 files changed, 936 insertions(+), 141 deletions(-) create mode 100644 mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.cnf create mode 100644 mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.result create mode 100644 mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.test create mode 100644 mysql-test/suite/rpl/r/rpl_rewrite_db_sys_vars.result create mode 100644 mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars-slave.opt create mode 100644 mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars.test create mode 100644 mysql-test/suite/sys_vars/r/replicate_rewrite_db.result create mode 100644 mysql-test/suite/sys_vars/t/replicate_rewrite_db.opt create mode 100644 mysql-test/suite/sys_vars/t/replicate_rewrite_db.test diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index d885bc08af0a8..75fc7268b0d84 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -2394,48 +2394,11 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi case OPT_REWRITE_DB: // db_from->db_to { /* See also handling of OPT_REPLICATE_REWRITE_DB in sql/mysqld.cc */ - const char* ptr; - const char* key= argument; // db-from - const char* val; // db-to - - // Skipp pre-space in key - while (*key && my_isspace(&my_charset_latin1, *key)) - key++; - - // Where val begins - if (!(ptr= strstr(key, "->"))) - { - sql_print_error("Bad syntax in rewrite-db: missing '->'\n"); - return 1; - } - val= ptr + 2; - - // Skip blanks at the end of key - while (ptr > key && my_isspace(&my_charset_latin1, ptr[-1])) - ptr--; - - if (ptr == key) + if (binlog_filter->add_rewrite_db(argument)) { - sql_print_error("Bad syntax in rewrite-db: empty FROM db\n"); + sql_print_error("Bad syntax in rewrite-db. Expected syntax is FROM->TO."); return 1; } - key= strmake_root(&glob_root, key, (size_t) (ptr-key)); - - /* Skipp pre space in value */ - while (*val && my_isspace(&my_charset_latin1, *val)) - val++; - - // Value ends with \0 or space - for (ptr= val; *ptr && !my_isspace(&my_charset_latin1, *ptr) ; ptr++) - {} - if (ptr == val) - { - sql_print_error("Bad syntax in rewrite-db: empty TO db\n"); - return 1; - } - val= strmake_root(&glob_root, val, (size_t) (ptr-val)); - - binlog_filter->add_db_rewrite(key, val); break; } case OPT_PRINT_ROW_COUNT: diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test index 4a1af2a4553bb..078f6572bed28 100644 --- a/mysql-test/include/check-testcase.test +++ b/mysql-test/include/check-testcase.test @@ -32,6 +32,7 @@ if ($tmp) --echo Relay_Master_Log_File # --echo Slave_IO_Running No --echo Slave_SQL_Running No + --echo Replicate_Rewrite_DB # --echo Replicate_Do_DB # --echo Replicate_Ignore_DB # --echo Replicate_Do_Table # @@ -76,7 +77,7 @@ if ($tmp) } if (!$tmp) { # Note: after WL#5177, fields 13-18 shall not be filtered-out. - --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 # 41 # 42 # 44 # 51 # 52 # 53 # + --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 19 # 23 # 24 # 25 # 26 # 27 # 41 # 42 # 43 # 45 # 52 # 53 # 54 # query_vertical SHOW SLAVE STATUS; } diff --git a/mysql-test/main/mysqlbinlog.result b/mysql-test/main/mysqlbinlog.result index a5732caf76e68..034d48791aa99 100644 --- a/mysql-test/main/mysqlbinlog.result +++ b/mysql-test/main/mysqlbinlog.result @@ -1276,13 +1276,8 @@ CREATE TABLE t1 (a int); INSERT INTO t1 values(1); DROP TABLE t1; FLUSH LOGS; -ERROR: Bad syntax in rewrite-db: missing '->' - -ERROR: Bad syntax in rewrite-db: empty TO db - -ERROR: Bad syntax in rewrite-db: empty TO db - -ERROR: Bad syntax in rewrite-db: empty FROM db - -ERROR: Bad syntax in rewrite-db: empty FROM db - +ERROR: Bad syntax in rewrite-db. Expected syntax is FROM->TO. +ERROR: Bad syntax in rewrite-db. Expected syntax is FROM->TO. +ERROR: Bad syntax in rewrite-db. Expected syntax is FROM->TO. +ERROR: Bad syntax in rewrite-db. Expected syntax is FROM->TO. +ERROR: Bad syntax in rewrite-db. Expected syntax is FROM->TO. diff --git a/mysql-test/suite/multi_source/info_logs.result b/mysql-test/suite/multi_source/info_logs.result index c19620b46ccea..a35a20bdbf764 100644 --- a/mysql-test/suite/multi_source/info_logs.result +++ b/mysql-test/suite/multi_source/info_logs.result @@ -94,17 +94,17 @@ MASTER 2.2 # EOF # show all slaves status; -Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos - Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 relay.000002 master-bin.000001 Yes Yes 0 0 None 0 No 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 -MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 relay-master@00202@002e2.000002 master-bin.000001 Yes Yes 0 0 None 0 No 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos + Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 relay.000002 master-bin.000001 Yes Yes 0 0 None 0 No 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 +MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 relay-master@00202@002e2.000002 master-bin.000001 Yes Yes 0 0 None 0 No 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 include/wait_for_slave_to_start.inc set default_master_connection = 'MASTER 2.2'; include/wait_for_slave_to_start.inc set default_master_connection = ''; show all slaves status; -Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos - Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 relay.000004 master-bin.000001 Yes Yes 0 0 None 0 No 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 -MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 relay-master@00202@002e2.000004 master-bin.000001 Yes Yes 0 0 None 0 No 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos + Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 relay.000004 master-bin.000001 Yes Yes 0 0 None 0 No 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 +MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 relay-master@00202@002e2.000004 master-bin.000001 Yes Yes 0 0 None 0 No 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 # # List of files matching '*info*' pattern # after slave server restart diff --git a/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result b/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result index 25cd85d70183e..355919def5a0d 100644 --- a/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result +++ b/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result @@ -34,6 +34,7 @@ Relay_Log_Pos Relay_Master_Log_File master-bin.000001 Slave_IO_Running Yes Slave_SQL_Running Yes +Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table @@ -95,6 +96,7 @@ Relay_Log_Pos Relay_Master_Log_File master-bin.000001 Slave_IO_Running Yes Slave_SQL_Running Yes +Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table diff --git a/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.cnf b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.cnf new file mode 100644 index 0000000000000..a22ddacd30f2b --- /dev/null +++ b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.cnf @@ -0,0 +1,19 @@ +!include my.cnf + +[mysqld.1] +gtid-domain-id=1 +server-id=1 +log-bin +log-slave-updates + +[mysqld.2] +gtid-domain-id=2 +server-id=2 +log-bin +log-slave-updates + +[mysqld.3] +gtid-domain-id=3 +server-id=3 +log-bin +log-slave-updates diff --git a/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.result b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.result new file mode 100644 index 0000000000000..3be8b36459374 --- /dev/null +++ b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.result @@ -0,0 +1,67 @@ +connect server_1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect server_2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connect server_3,127.0.0.1,root,,,$SERVER_MYPORT_3; +# Connect the slave (server_3) to two masters (server_1 and server_2) +connection server_3; +CHANGE MASTER 'm1' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root'; +CHANGE MASTER 'm2' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root'; +# Apply events from server_1 (m1) into m1_test +create database m1_test; +SET @@global.'m1'.replicate_rewrite_db='test->m1_test'; +# Apply events from server_2 (m2) into m2_test +create database m2_test; +SET @@global.'m2'.replicate_rewrite_db='test->m2_test'; +start all slaves; +Warnings: +Note 1937 SLAVE 'm2' started +Note 1937 SLAVE 'm1' started +set default_master_connection = 'm1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +include/wait_for_slave_to_start.inc +# Create test data for servers 1 and 2 with different data +connection server_1; +create table t (a int); +insert into t values (1); +insert into t values (2); +insert into t values (3); +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +connection server_2; +create table t (a int); +insert into t values (4); +insert into t values (5); +insert into t values (6); +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +# Ensure the slave correctly replicates data from each master into its +# respective database +include/diff_tables.inc [server_1:test.t,server_3:m1_test.t] +include/diff_tables.inc [server_2:test.t,server_3:m2_test.t] +# +# Cleanup +connection server_1; +DROP TABLE t; +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +connection server_2; +DROP TABLE t; +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +connection server_3; +stop all slaves; +Warnings: +Note 1938 SLAVE 'm2' stopped +Note 1938 SLAVE 'm1' stopped +SET default_master_connection = "m1"; +include/wait_for_slave_to_stop.inc +SET default_master_connection = "m2"; +include/wait_for_slave_to_stop.inc +RESET SLAVE ALL; +DROP DATABASE m1_test; +DROP DATABASE m2_test; +# End of replicate_rewrite_db_dynamic.test diff --git a/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.test b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.test new file mode 100644 index 0000000000000..e1bbfabe18068 --- /dev/null +++ b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.test @@ -0,0 +1,96 @@ +# +# Test multi-source dynamically setting of replication filter +# "replicate_rewrite_db" +# +# This test ensures that setting a replica's replicate_rewrite_db works on a +# per-master basis. To ensure this, this test connects a replica to two +# different primary server instances. Each primary uses the same database +# name and table name. To ensure the data operations don't interfere with one +# another on the replica, it sets replicate_rewrite_db individually per +# connection to apply the events from each primary into a database specific to +# that connection. +# + +--source include/not_embedded.inc +--source include/have_innodb.inc + +--connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connect (server_3,127.0.0.1,root,,,$SERVER_MYPORT_3) + + +--echo # Connect the slave (server_3) to two masters (server_1 and server_2) +--connection server_3 +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval CHANGE MASTER 'm1' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval CHANGE MASTER 'm2' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root'; + +--echo # Apply events from server_1 (m1) into m1_test +create database m1_test; +SET @@global.'m1'.replicate_rewrite_db='test->m1_test'; + +--echo # Apply events from server_2 (m2) into m2_test +create database m2_test; +SET @@global.'m2'.replicate_rewrite_db='test->m2_test'; + +start all slaves; +set default_master_connection = 'm1'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +--source include/wait_for_slave_to_start.inc + +--echo # Create test data for servers 1 and 2 with different data +--connection server_1 +create table t (a int); +insert into t values (1); +insert into t values (2); +insert into t values (3); +--source include/save_master_gtid.inc +--connection server_3 +--source include/sync_with_master_gtid.inc + +--connection server_2 +create table t (a int); +insert into t values (4); +insert into t values (5); +insert into t values (6); +--source include/save_master_gtid.inc +--connection server_3 +--source include/sync_with_master_gtid.inc + +--echo # Ensure the slave correctly replicates data from each master into its +--echo # respective database +--let $diff_tables=server_1:test.t,server_3:m1_test.t +--source include/diff_tables.inc + +--let $diff_tables=server_2:test.t,server_3:m2_test.t +--source include/diff_tables.inc + + +--echo # +--echo # Cleanup + +--connection server_1 +DROP TABLE t; +--source include/save_master_gtid.inc +--connection server_3 +--source include/sync_with_master_gtid.inc + +--connection server_2 +DROP TABLE t; +--source include/save_master_gtid.inc +--connection server_3 +--source include/sync_with_master_gtid.inc + +--connection server_3 +stop all slaves; +SET default_master_connection = "m1"; +--source include/wait_for_slave_to_stop.inc +SET default_master_connection = "m2"; +--source include/wait_for_slave_to_stop.inc +RESET SLAVE ALL; +DROP DATABASE m1_test; +DROP DATABASE m2_test; + +--echo # End of replicate_rewrite_db_dynamic.test diff --git a/mysql-test/suite/multi_source/reset_slave.result b/mysql-test/suite/multi_source/reset_slave.result index a55a6ec235fa4..2e9ce5e896f36 100644 --- a/mysql-test/suite/multi_source/reset_slave.result +++ b/mysql-test/suite/multi_source/reset_slave.result @@ -13,15 +13,15 @@ insert into t1 values (1),(2); connection slave; stop slave 'master1'; show slave 'master1' status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups - 127.0.0.1 root MYPORT_1 60 master-bin.000001 mysqld-relay-bin-master1.000002 master-bin.000001 No No 0 0 None 0 No NULL No 0 0 1 Slave_Pos 0-1-3 optimistic 0 NULL 2 1 0 +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups + 127.0.0.1 root MYPORT_1 60 master-bin.000001 mysqld-relay-bin-master1.000002 master-bin.000001 No No 0 0 None 0 No NULL No 0 0 1 Slave_Pos 0-1-3 optimistic 0 NULL 2 1 0 mysqld-relay-bin-master1.000001 mysqld-relay-bin-master1.000002 mysqld-relay-bin-master1.index reset slave 'master1'; show slave 'master1' status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups - 127.0.0.1 root MYPORT_1 60 4 No No 0 0 0 None 0 No NULL No 0 0 1 Slave_Pos optimistic 0 NULL 2 1 0 +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups + 127.0.0.1 root MYPORT_1 60 4 No No 0 0 0 None 0 No NULL No 0 0 1 Slave_Pos optimistic 0 NULL 2 1 0 reset slave 'master1' all; show slave 'master1' status; ERROR HY000: There is no master connection 'master1' diff --git a/mysql-test/suite/multi_source/simple.result b/mysql-test/suite/multi_source/simple.result index 5a167907b3b8a..65c25b88e44e7 100644 --- a/mysql-test/suite/multi_source/simple.result +++ b/mysql-test/suite/multi_source/simple.result @@ -32,6 +32,7 @@ Relay_Log_Pos Relay_Master_Log_File master-bin.000001 Slave_IO_Running Yes Slave_SQL_Running Yes +Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table @@ -93,6 +94,7 @@ Relay_Log_Pos Relay_Master_Log_File master-bin.000001 Slave_IO_Running Yes Slave_SQL_Running Yes +Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table @@ -219,6 +221,7 @@ Relay_Log_Pos Relay_Master_Log_File master-bin.000001 Slave_IO_Running No Slave_SQL_Running No +Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table @@ -276,6 +279,7 @@ Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running No Slave_SQL_Running No +Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table @@ -337,6 +341,7 @@ Relay_Log_Pos Relay_Master_Log_File master-bin.000001 Slave_IO_Running Yes Slave_SQL_Running Yes +Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table @@ -400,6 +405,7 @@ Relay_Log_Pos Relay_Master_Log_File master-bin.000001 Slave_IO_Running Yes Slave_SQL_Running Yes +Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table @@ -465,6 +471,7 @@ Relay_Log_Pos Relay_Master_Log_File master-bin.000001 Slave_IO_Running No Slave_SQL_Running No +Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table diff --git a/mysql-test/suite/multi_source/syntax.result b/mysql-test/suite/multi_source/syntax.result index 35f4b3048adef..3c7c91c35c807 100644 --- a/mysql-test/suite/multi_source/syntax.result +++ b/mysql-test/suite/multi_source/syntax.result @@ -1,11 +1,11 @@ include/master-slave.inc [connection master] show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups show slave '' status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups show all slaves status; -Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Rewrite_DB Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos # # Check error handling # diff --git a/mysql-test/suite/rpl/r/rpl_rewrite_db_sys_vars.result b/mysql-test/suite/rpl/r/rpl_rewrite_db_sys_vars.result new file mode 100644 index 0000000000000..5720f647b90cf --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_rewrite_db_sys_vars.result @@ -0,0 +1,163 @@ +include/master-slave.inc +[connection master] +# +# MDEV-15530 Variable replicate_rewrite_db cannot be found +# in "show global variables" +# +# Create DBs and verify that slave has to be stopped before setting sys var +connection slave; +select @@session.server_id; +@@session.server_id +2 +create database replica_db1; +create database y; +create database test_replica; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +primary_db1->replica_db1,x->y +# Ensuring SHOW SLAVE STATUS produces correct value for Replicate_Rewrite_DB... +# ...success +# Create DBs and tables on primary +connection master; +create database primary_db1; +create database x; +use primary_db1; +create table my_table (t int); +insert into my_table values (2),(4); +use x; +create table my_table (t int); +insert into my_table values (654),(532); +include/save_master_gtid.inc +# Check replica +connection slave; +include/sync_with_master_gtid.inc +include/diff_tables.inc [master:primary_db1.my_table,slave:replica_db1.my_table] +include/diff_tables.inc [master:x.my_table,slave:y.my_table] +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +primary_db1->replica_db1,x->y +show tables from replica_db1; +Tables_in_replica_db1 +my_table +select * from replica_db1.my_table; +t +2 +4 +show tables from y; +Tables_in_y +my_table +select * from y.my_table; +t +654 +532 +# Set replica sys var replicate_rewrite_db +connection slave; +SET @@GLOBAL.replicate_rewrite_db="test_master->test_replica"; +ERROR HY000: This operation cannot be performed as you have a running slave ''; run STOP SLAVE '' first +include/stop_slave.inc +SET @save_replicate_rewrite_db = @@GLOBAL.replicate_rewrite_db; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +primary_db1->replica_db1,x->y +SET @@GLOBAL.replicate_rewrite_db="test_master->test_replica"; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +test_master->test_replica +SHOW DATABASES like 'test_replica'; +Database (test_replica) +test_replica +include/start_slave.inc +# Ensuring SHOW SLAVE STATUS produces correct value for Replicate_Rewrite_DB... +# ...success +# Create DB and tables on primary +connection master; +create database test_master; +use test_master; +create table my_table (t int); +insert into my_table values (1),(3); +include/save_master_gtid.inc +# Ensure that the replica receives all of the primary's events without +# error +connection slave; +include/sync_with_master_gtid.inc +Last_SQL_Error = +Last_SQL_Errno = 0 +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +test_master->test_replica +SHOW tables from test_replica; +Tables_in_test_replica +my_table +select * from test_replica.my_table; +t +1 +3 +include/diff_tables.inc [master:test_master.my_table,slave:test_replica.my_table] +# Update of values on primary for DB not set in replication_rewrite_db +connection master; +use x; +insert into my_table values (314); +select * from my_table; +t +654 +532 +314 +include/save_master_gtid.inc +connection slave; +include/stop_slave.inc +include/reset_slave.inc +include/start_slave.inc +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +test_master->test_replica +include/sync_with_master_gtid.inc +select * from y.my_table; +t +654 +532 +# Dynamic updates to the replication filter should be lost after server restart +connection slave; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +test_master->test_replica +connection master; +use x; +insert into my_table values (1000); +select * from my_table; +t +654 +532 +314 +1000 +include/save_master_gtid.inc +connection slave; +include/stop_slave.inc +include/reset_slave.inc +include/rpl_restart_server.inc [server_number=2] +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_MYPORT, MASTER_USER='root'; +connection slave; +include/start_slave.inc +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +primary_db1->replica_db1,x->y +include/sync_with_master_gtid.inc +select * from y.my_table; +t +654 +532 +314 +1000 +# Cleanup +connection master; +drop database test_master; +drop database primary_db1; +drop database x; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +drop database test_replica; +drop database replica_db1; +drop database y; +include/stop_slave.inc +include/start_slave.inc +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars-slave.opt b/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars-slave.opt new file mode 100644 index 0000000000000..5a8f8233a634d --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars-slave.opt @@ -0,0 +1,2 @@ +"--replicate-rewrite-db=primary_db1->replica_db1" +"--replicate-rewrite-db=x->y" diff --git a/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars.test b/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars.test new file mode 100644 index 0000000000000..b06899bb12e06 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars.test @@ -0,0 +1,163 @@ +-- source include/have_binlog_format_mixed.inc +-- source include/master-slave.inc + +# Testing rpl option replicate_rewrite_db + +--echo # +--echo # MDEV-15530 Variable replicate_rewrite_db cannot be found +--echo # in "show global variables" +--echo # + +--echo # Create DBs and verify that slave has to be stopped before setting sys var + +connection slave; +--let $rpl_server_id= `select @@session.server_id` +select @@session.server_id; + +# These DBs will be rewrited from opt file +create database replica_db1; +create database y; +# This DB will be rewrited from test case +create database test_replica; +SELECT @@GLOBAL.replicate_rewrite_db; +let $rewrite_db_sss= query_get_value(SHOW SLAVE STATUS, Replicate_Rewrite_DB, 1); +--echo # Ensuring SHOW SLAVE STATUS produces correct value for Replicate_Rewrite_DB... +if (`SELECT strcmp(@@global.replicate_rewrite_db, "$rewrite_db_sss") != 0`) +{ + die SHOW SLAVE STATUS Replicate_Rewrite_DB value $rewrite_db_sss does not match variable @@GLOBAL.replicate_rewrite_db; +} +--echo # ...success + + +--echo # Create DBs and tables on primary +connection master; +--enable_warnings +create database primary_db1; +create database x; +use primary_db1; +create table my_table (t int); +insert into my_table values (2),(4); +use x; +create table my_table (t int); +insert into my_table values (654),(532); +--source include/save_master_gtid.inc + +--echo # Check replica +--connection slave +--source include/sync_with_master_gtid.inc +--let $diff_tables=master:primary_db1.my_table,slave:replica_db1.my_table +--source include/diff_tables.inc +--let $diff_tables=master:x.my_table,slave:y.my_table +--source include/diff_tables.inc +SELECT @@GLOBAL.replicate_rewrite_db; +show tables from replica_db1; +select * from replica_db1.my_table; +show tables from y; +select * from y.my_table; + +--echo # Set replica sys var replicate_rewrite_db +connection slave; +--error ER_SLAVE_MUST_STOP +SET @@GLOBAL.replicate_rewrite_db="test_master->test_replica"; +source include/stop_slave.inc; +SET @save_replicate_rewrite_db = @@GLOBAL.replicate_rewrite_db; +SELECT @@GLOBAL.replicate_rewrite_db; +SET @@GLOBAL.replicate_rewrite_db="test_master->test_replica"; +SELECT @@GLOBAL.replicate_rewrite_db; +SHOW DATABASES like 'test_replica'; +source include/start_slave.inc; +let $rewrite_db_sss= query_get_value(SHOW SLAVE STATUS, Replicate_Rewrite_DB, 1); +--echo # Ensuring SHOW SLAVE STATUS produces correct value for Replicate_Rewrite_DB... +if (`SELECT strcmp(@@global.replicate_rewrite_db, "$rewrite_db_sss") != 0`) +{ + die SHOW SLAVE STATUS Replicate_Rewrite_DB value $rewrite_db_sss does not match variable @@GLOBAL.replicate_rewrite_db; +} +--echo # ...success + +--echo # Create DB and tables on primary +connection master; +--enable_warnings +create database test_master; +use test_master; +create table my_table (t int); +insert into my_table values (1),(3); +--source include/save_master_gtid.inc + +--echo # Ensure that the replica receives all of the primary's events without +--echo # error +--connection slave +--source include/sync_with_master_gtid.inc +let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1); +--echo Last_SQL_Error = $error +let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1); +--echo Last_SQL_Errno = $errno + +SELECT @@GLOBAL.replicate_rewrite_db; +SHOW tables from test_replica; +select * from test_replica.my_table; + +# Additional check for tables +--let $diff_tables=master:test_master.my_table,slave:test_replica.my_table +--source include/diff_tables.inc + +--echo # Update of values on primary for DB not set in replication_rewrite_db +connection master; +use x; +insert into my_table values (314); +select * from my_table; +--source include/save_master_gtid.inc + +connection slave; +--source include/stop_slave.inc +--source include/reset_slave.inc +--source include/start_slave.inc +SELECT @@GLOBAL.replicate_rewrite_db; +--source include/sync_with_master_gtid.inc +# This shouldn't get the new values from x DB on master +select * from y.my_table; + +--echo # Dynamic updates to the replication filter should be lost after server restart +# Old value +connection slave; +SELECT @@GLOBAL.replicate_rewrite_db; + +connection master; +use x; +insert into my_table values (1000); +select * from my_table; +--source include/save_master_gtid.inc + +connection slave; +--source include/stop_slave.inc +--source include/reset_slave.inc +--let $rpl_server_number= 2 +--source include/rpl_restart_server.inc +--replace_result $MASTER_MYPORT MASTER_MYPORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root'; + +# New value +connection slave; +--source include/start_slave.inc +SELECT @@GLOBAL.replicate_rewrite_db; +--source include/sync_with_master_gtid.inc +# This should update values with 314 and 1000 from primary +select * from y.my_table; + +--echo # Cleanup +connection master; +drop database test_master; +drop database primary_db1; +drop database x; +--source include/save_master_gtid.inc + + +--connection slave +--source include/sync_with_master_gtid.inc +drop database test_replica; +drop database replica_db1; +drop database y; +source include/stop_slave.inc; +source include/start_slave.inc; + +--source include/rpl_end.inc +# end of 10.11 tests diff --git a/mysql-test/suite/sys_vars/r/replicate_rewrite_db.result b/mysql-test/suite/sys_vars/r/replicate_rewrite_db.result new file mode 100644 index 0000000000000..2dfe3a65133a5 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/replicate_rewrite_db.result @@ -0,0 +1,99 @@ +# +# MDEV-15530: Variable replicate_rewrite_db +# cannot be found in "show global variables" +# +SET @save_replicate_rewrite_db = @@GLOBAL.replicate_rewrite_db; +SELECT @save_replicate_rewrite_db; +@save_replicate_rewrite_db +test->rewrite,mysqltest1->test,a->b +# Test session/Scope (it is global variable) +select @@global.replicate_rewrite_db; +@@global.replicate_rewrite_db +test->rewrite,mysqltest1->test,a->b +SELECT @@SESSION.replicate_rewrite_db; +ERROR HY000: Variable 'replicate_rewrite_db' is a GLOBAL variable +SET @@SESSION.replicate_rewrite_db = ""; +ERROR HY000: Variable 'replicate_rewrite_db' is a GLOBAL variable and should be set with SET GLOBAL +show global variables like 'replicate_rewrite_db'; +Variable_name Value +replicate_rewrite_db test->rewrite,mysqltest1->test,a->b +show session variables like 'replicate_rewrite_db'; +Variable_name Value +replicate_rewrite_db test->rewrite,mysqltest1->test,a->b +select * from information_schema.global_variables where variable_name='replicate_rewrite_db'; +VARIABLE_NAME VARIABLE_VALUE +REPLICATE_REWRITE_DB test->rewrite,mysqltest1->test,a->b +select * from information_schema.session_variables where variable_name='replicate_rewrite_db'; +VARIABLE_NAME VARIABLE_VALUE +REPLICATE_REWRITE_DB test->rewrite,mysqltest1->test,a->b +# Incorrect type +SET @@GLOBAL.replicate_rewrite_db=1; +ERROR 42000: Incorrect argument type to variable 'replicate_rewrite_db' +SET @@GLOBAL.replicate_rewrite_db="->"; +ERROR HY000: Incorrect arguments to SET +SET @@GLOBAL.replicate_rewrite_db=" "; +ERROR HY000: Incorrect arguments to SET +SET @@GLOBAL.replicate_rewrite_db="a->"; +ERROR HY000: Incorrect arguments to SET +SET @@GLOBAL.replicate_rewrite_db="->b"; +ERROR HY000: Incorrect arguments to SET +# Check arguments +set session replicate_rewrite_db=1; +ERROR HY000: Variable 'replicate_rewrite_db' is a GLOBAL variable and should be set with SET GLOBAL +set global replicate_rewrite_db=1; +ERROR 42000: Incorrect argument type to variable 'replicate_rewrite_db' +SET @@SESSION.replicate_do_db = ""; +ERROR HY000: Variable 'replicate_do_db' is a GLOBAL variable and should be set with SET GLOBAL +SET @@GLOBAL.replicate_rewrite_db=""; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db + +SET @@GLOBAL.replicate_rewrite_db=null; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db + +SET @@GLOBAL.replicate_rewrite_db=DEFAULT; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db + +SET @@GLOBAL.replicate_rewrite_db="db1->db3"; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +db1->db3 +SET @@GLOBAL.replicate_rewrite_db="db2 ->db4"; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +db2->db4 +SET @@GLOBAL.replicate_rewrite_db=" db5 ->db7 "; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +db5->db7 +SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_rewrite_db'; +VARIABLE_NAME VARIABLE_VALUE +REPLICATE_REWRITE_DB db5->db7 +select * from information_schema.session_variables where variable_name='replicate_rewrite_db'; +VARIABLE_NAME VARIABLE_VALUE +REPLICATE_REWRITE_DB db5->db7 +show global variables like 'replicate_rewrite_db'; +Variable_name Value +replicate_rewrite_db db5->db7 +SET @@GLOBAL.replicate_rewrite_db="db1->db2, db3->db4"; +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +db1->db2,db3->db4 +SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_rewrite_db'; +VARIABLE_NAME VARIABLE_VALUE +REPLICATE_REWRITE_DB db1->db2,db3->db4 +# Check restart with appending the value +# restart: --replicate_rewrite_db=X->Y +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +test->rewrite,mysqltest1->test,a->b,X->Y +# Check restart with wrong value on CLI +[ERROR] Bad syntax in replicate-rewrite-db.Expected syntax is FROM->TO. +# restart: +SELECT @@GLOBAL.replicate_rewrite_db; +@@GLOBAL.replicate_rewrite_db +test->rewrite,mysqltest1->test,a->b +# Cleanup. +SET @@GLOBAL.replicate_rewrite_db = @save_replicate_rewrite_db; 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 eab383a30acbf..0221ecb386112 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -3382,6 +3382,16 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT NULL +VARIABLE_NAME REPLICATE_REWRITE_DB +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE VARCHAR +VARIABLE_COMMENT Tells the slave to replicate binlog events into a different database than their original target on the master.Example: replicate-rewrite-db=master_db_name->slave_db_name. +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME REPLICATE_WILD_DO_TABLE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR diff --git a/mysql-test/suite/sys_vars/t/replicate_rewrite_db.opt b/mysql-test/suite/sys_vars/t/replicate_rewrite_db.opt new file mode 100644 index 0000000000000..27468051e624c --- /dev/null +++ b/mysql-test/suite/sys_vars/t/replicate_rewrite_db.opt @@ -0,0 +1,3 @@ +"--replicate-rewrite-db=test->rewrite" +"--replicate-rewrite-db= mysqltest1 -> test" +"--replicate-rewrite-db=a -> b" diff --git a/mysql-test/suite/sys_vars/t/replicate_rewrite_db.test b/mysql-test/suite/sys_vars/t/replicate_rewrite_db.test new file mode 100644 index 0000000000000..7fbaab1f2609f --- /dev/null +++ b/mysql-test/suite/sys_vars/t/replicate_rewrite_db.test @@ -0,0 +1,84 @@ +--source include/not_embedded.inc + +--echo # +--echo # MDEV-15530: Variable replicate_rewrite_db +--echo # cannot be found in "show global variables" +--echo # + +SET @save_replicate_rewrite_db = @@GLOBAL.replicate_rewrite_db; +SELECT @save_replicate_rewrite_db; + +--echo # Test session/Scope (it is global variable) + +select @@global.replicate_rewrite_db; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@SESSION.replicate_rewrite_db; +--error ER_GLOBAL_VARIABLE +SET @@SESSION.replicate_rewrite_db = ""; +show global variables like 'replicate_rewrite_db'; +show session variables like 'replicate_rewrite_db'; +select * from information_schema.global_variables where variable_name='replicate_rewrite_db'; +select * from information_schema.session_variables where variable_name='replicate_rewrite_db'; + +--echo # Incorrect type + +--error ER_WRONG_TYPE_FOR_VAR +SET @@GLOBAL.replicate_rewrite_db=1; +--error ER_WRONG_ARGUMENTS +SET @@GLOBAL.replicate_rewrite_db="->"; +--error ER_WRONG_ARGUMENTS +SET @@GLOBAL.replicate_rewrite_db=" "; +--error ER_WRONG_ARGUMENTS +SET @@GLOBAL.replicate_rewrite_db="a->"; +--error ER_WRONG_ARGUMENTS +SET @@GLOBAL.replicate_rewrite_db="->b"; + +--echo # Check arguments + +--error ER_GLOBAL_VARIABLE +set session replicate_rewrite_db=1; +--error ER_WRONG_TYPE_FOR_VAR +set global replicate_rewrite_db=1; +--error ER_GLOBAL_VARIABLE +SET @@SESSION.replicate_do_db = ""; +# This should work +SET @@GLOBAL.replicate_rewrite_db=""; +SELECT @@GLOBAL.replicate_rewrite_db; +SET @@GLOBAL.replicate_rewrite_db=null; +SELECT @@GLOBAL.replicate_rewrite_db; +SET @@GLOBAL.replicate_rewrite_db=DEFAULT; +SELECT @@GLOBAL.replicate_rewrite_db; +SET @@GLOBAL.replicate_rewrite_db="db1->db3"; +SELECT @@GLOBAL.replicate_rewrite_db; +SET @@GLOBAL.replicate_rewrite_db="db2 ->db4"; +SELECT @@GLOBAL.replicate_rewrite_db; +SET @@GLOBAL.replicate_rewrite_db=" db5 ->db7 "; +SELECT @@GLOBAL.replicate_rewrite_db; +SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_rewrite_db'; +select * from information_schema.session_variables where variable_name='replicate_rewrite_db'; +show global variables like 'replicate_rewrite_db'; + +SET @@GLOBAL.replicate_rewrite_db="db1->db2, db3->db4"; +SELECT @@GLOBAL.replicate_rewrite_db; +SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='replicate_rewrite_db'; + +--echo # Check restart with appending the value +--let $restart_parameters = "--replicate_rewrite_db='X->Y'" +--source include/restart_mysqld.inc +SELECT @@GLOBAL.replicate_rewrite_db; + +--echo # Check restart with wrong value on CLI +--source include/shutdown_mysqld.inc +# Expect the server to fail to come up with these options +--let $args="--replicate_rewrite_db=x-" --log-warnings=1 --silent-startup --help --verbose +--error 1 +--exec $MYSQLD_CMD $args > $MYSQL_TMP_DIR/mysqld--replicate.txt 2> $MYSQL_TMP_DIR/mysqld--replicate.err +--replace_regex /mysqld/mariadbd/ /\d\d\d\d-\d*-\d* *\d*:\d*:\d* \d* // +--cat_file $MYSQL_TMP_DIR/mysqld--replicate.err +# Restart the server with the default options +--let $restart_parameters = "" +--source include/start_mysqld.inc +SELECT @@GLOBAL.replicate_rewrite_db; + +--echo # Cleanup. +SET @@GLOBAL.replicate_rewrite_db = @save_replicate_rewrite_db; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 609b8e264159c..8e40149ee72a2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8091,45 +8091,11 @@ mysqld_get_one_option(const struct my_option *opt, const char *argument, case (int)OPT_REPLICATE_REWRITE_DB: { /* See also OPT_REWRITE_DB handling in client/mysqlbinlog.cc */ - const char* key= argument, *ptr, *val; - - // Skipp pre-space in key - while (*key && my_isspace(mysqld_charset, *key)) - key++; - - // Where val begins - if (!(ptr= strstr(key, "->"))) + if (cur_rpl_filter->add_rewrite_db(argument)) { - sql_print_error("Bad syntax in replicate-rewrite-db: missing '->'"); + sql_print_error("Bad syntax in replicate-rewrite-db.Expected syntax is FROM->TO."); return 1; } - val= ptr+2; - - // Skip blanks at the end of key - while (ptr > key && my_isspace(mysqld_charset, ptr[-1])) - ptr--; - if (ptr == key) - { - sql_print_error("Bad syntax in replicate-rewrite-db - empty FROM db"); - return 1; - } - key= strmake_root(&startup_root, key, (size_t) (ptr-key)); - - /* Skipp pre space in value */ - while (*val && my_isspace(mysqld_charset, *val)) - val++; - - // Value ends with \0 or space - for (ptr= val; *ptr && !my_isspace(&my_charset_latin1, *ptr) ; ptr++) - {} - if (ptr == val) - { - sql_print_error("Bad syntax in replicate-rewrite-db - empty TO db"); - return 1; - } - val= strmake_root(&startup_root, val, (size_t) (ptr-val)); - - cur_rpl_filter->add_db_rewrite(key, val); break; } case (int)OPT_SLAVE_PARALLEL_MODE: diff --git a/sql/privilege.h b/sql/privilege.h index 57bbc95840e86..89d77ae9a091e 100644 --- a/sql/privilege.h +++ b/sql/privilege.h @@ -546,6 +546,8 @@ constexpr privilege_t PRIV_SET_SYSTEM_SESSION_VAR_GTID_DOMAIN_ID= */ constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_EVENTS_MARKED_FOR_SKIP= REPL_SLAVE_ADMIN_ACL | SUPER_ACL; +constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_REWRITE_DB= + REPL_SLAVE_ADMIN_ACL | SUPER_ACL; constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_DO_DB= REPL_SLAVE_ADMIN_ACL | SUPER_ACL; constexpr privilege_t PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_DO_TABLE= diff --git a/sql/protocol.cc b/sql/protocol.cc index eee6236ffe71a..26bc94c146320 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1374,21 +1374,49 @@ bool Protocol::store(I_List* str_list) { char buf[256]; String tmp(buf, sizeof(buf), &my_charset_bin); - uint32 len; + size_t len= 0; I_List_iterator it(*str_list); i_string* s; + const char *delimiter= ","; tmp.length(0); while ((s=it++)) { + tmp.append(delimiter, len); tmp.append(s->ptr, strlen(s->ptr)); - tmp.append(','); + len= 1; } - if ((len= tmp.length())) - len--; // Remove last ',' - return store((char*) tmp.ptr(), len, tmp.charset()); + + return store((char*) tmp.ptr(), tmp.length(), tmp.charset()); +} + + +/** + Send a set of strings as a string of key-value pairs with ',' in between. +*/ + +bool Protocol::store(I_List* str_list) +{ + char buf[256]; + const char *delimiter= ","; + String tmp(buf, sizeof(buf), &my_charset_bin); + size_t delim_len= 0; + I_List_iterator it(*str_list); + i_string_pair* s; + + tmp.length(0); + while ((s=it++)) + { + tmp.append(delimiter, delim_len); + tmp.append(s->key, strlen(s->key)); + tmp.append(STRING_WITH_LEN("->")); + tmp.append(s->val, strlen(s->val)); + delim_len= 1; + } + return store((char*) tmp.ptr(), tmp.length(), tmp.charset()); } + /**************************************************************************** Functions to handle the simple (default) protocol where everything is This protocol is the one that is used by default between the MySQL server diff --git a/sql/protocol.h b/sql/protocol.h index f095ad68a345c..39569a825d573 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -99,6 +99,7 @@ class Protocol bool send_result_set_row(List *row_items); bool store(I_List *str_list); + bool store(I_List *str_list); bool store_string_or_null(const char *from, CHARSET_INFO *cs); bool store_warning(const char *from, size_t length); String *storage_packet() { return packet; } diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc index 1e1f98c1e3e51..982c0c9482df7 100644 --- a/sql/rpl_filter.cc +++ b/sql/rpl_filter.cc @@ -48,7 +48,7 @@ Rpl_filter::~Rpl_filter() free_string_array(&wild_ignore_table); free_string_list(&do_db); free_string_list(&ignore_db); - free_list(&rewrite_db); + free_string_pair_list(&rewrite_db); } @@ -470,14 +470,6 @@ Rpl_filter::set_wild_ignore_table(const char* table_spec) } -void -Rpl_filter::add_db_rewrite(const char* from_db, const char* to_db) -{ - i_string_pair *db_pair = new i_string_pair(from_db, to_db); - rewrite_db.push_back(db_pair); -} - - int Rpl_filter::add_table_rule(HASH* h, const char* table_spec) { @@ -520,6 +512,70 @@ Rpl_filter::add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec) } +int +Rpl_filter::add_string_pair_list(const char* spec) +{ + /* See also OPT_REWRITE_DB handling in client/mysqlbinlog.cc */ + char* from_db, *to_db; + const char *ptr, *val_ptr; + size_t len; + + // Remove pre-space in key + while(*spec && my_isspace(system_charset_info, (unsigned char)*spec)) spec++; + + if (!(ptr= strstr(spec, "->"))) + { + // Bad syntax, missing -> + return 1; + } + + // value + val_ptr= ptr + 2; + + // Skip blanks at the end of spec + while(ptr > spec && my_isspace(system_charset_info, ptr[-1])) ptr--; + + if (ptr == spec) + { + // Bad syntax: empty FROM db (key) + return 1; + } + + // key + len= (size_t)(ptr - spec); + if (! (from_db= (char *) my_malloc(PSI_NOT_INSTRUMENTED, len + 1, MYF(0)))) + { + return 1; + } + memcpy(from_db, spec, len); + from_db[len]='\0'; + + // Remove pre-space in val + while(*val_ptr && my_isspace(system_charset_info, (unsigned char)*val_ptr)) val_ptr++; + // Value ends with \0 or space + if (!strlen(val_ptr)) + { + // Bad syntax: Empty value \n" + my_free(from_db); + return 1; + } + + for (ptr= val_ptr; *ptr && !my_isspace(system_charset_info, *ptr); ptr++){} + // value + len= (size_t)(ptr - val_ptr); + if(! (to_db= (char *) my_malloc(PSI_NOT_INSTRUMENTED, len + 1, MYF(0)))) + { + my_free(from_db); + return 1; + } + memcpy(to_db, val_ptr, len); + to_db[len]='\0'; + i_string_pair *db_pair = new i_string_pair(from_db, to_db); + rewrite_db.push_back(db_pair); + return false; +} + + int Rpl_filter::add_string_list(I_List *list, const char* spec) { @@ -541,6 +597,14 @@ Rpl_filter::add_string_list(I_List *list, const char* spec) } +int +Rpl_filter::add_rewrite_db(const char* table_spec) +{ + DBUG_ENTER("Rpl_filter::add_rewrite_db"); + DBUG_RETURN(add_string_pair_list(table_spec)); +} + + int Rpl_filter::add_do_db(const char* table_spec) { @@ -557,6 +621,14 @@ Rpl_filter::add_ignore_db(const char* table_spec) } +int +Rpl_filter::set_rewrite_db(const char* db_spec) +{ + free_string_pair_list(&rewrite_db); + return parse_filter_rule(db_spec, &Rpl_filter::add_rewrite_db); +} + + int Rpl_filter::set_do_db(const char* db_spec) { @@ -665,6 +737,21 @@ Rpl_filter::free_string_list(I_List *l) } +void +Rpl_filter::free_string_pair_list(I_List *l) +{ + i_string_pair *tmp; + + while ((tmp= l->get())) + { + my_free((void *) tmp->key); + my_free((void *) tmp->val); + delete tmp; + } + + l->empty(); +} + /* Builds a String from a HASH of TABLE_RULE_ENT. Cannot be used for any other hash, as it assumes that the hash entries are TABLE_RULE_ENT. @@ -749,6 +836,34 @@ Rpl_filter::rewrite_db_is_empty() } +I_List* +Rpl_filter::get_rewrite_db() +{ + return &rewrite_db; +} + + +void +Rpl_filter::db_rewrite_rule_ent_list_to_str(String* str, I_List* list) +{ + I_List_iterator it(*list); + i_string_pair* s; + + str->length(0); + + const char *delimiter= ","; + size_t delim_len= 0; + while ((s= it++)) + { + str->append(delimiter, delim_len); + str->append(s->key, strlen(s->key)); + str->append(STRING_WITH_LEN("->")); + str->append(s->val, strlen(s->val)); + delim_len= 1; + } +} + + const char* Rpl_filter::get_rewrite_db(const char* db, size_t *new_len) { @@ -769,18 +884,6 @@ Rpl_filter::get_rewrite_db(const char* db, size_t *new_len) } -void -Rpl_filter::copy_rewrite_db(Rpl_filter *from) -{ - I_List_iterator it(from->rewrite_db); - i_string_pair* tmp; - DBUG_ASSERT(rewrite_db.is_empty()); - - /* TODO: Add memory checking here and in all add_xxxx functions ! */ - while ((tmp=it++)) - add_db_rewrite(tmp->key, tmp->val); -} - I_List* Rpl_filter::get_do_db() { @@ -815,6 +918,13 @@ Rpl_filter::db_rule_ent_list_to_str(String* str, I_List* list) } +void +Rpl_filter::get_rewrite_db(String* str) +{ + db_rewrite_rule_ent_list_to_str(str, get_rewrite_db()); +} + + void Rpl_filter::get_do_db(String* str) { diff --git a/sql/rpl_filter.h b/sql/rpl_filter.h index f22ec8a0ce4f0..ee3b9d516b710 100644 --- a/sql/rpl_filter.h +++ b/sql/rpl_filter.h @@ -71,9 +71,11 @@ class Rpl_filter int set_wild_do_table(const char* table_spec); int set_wild_ignore_table(const char* table_spec); + int add_rewrite_db(const char* table_spec); int add_do_db(const char* db_spec); int add_ignore_db(const char* db_spec); + int set_rewrite_db(const char* db_spec); int set_do_db(const char* db_spec); int set_ignore_db(const char* db_spec); @@ -87,8 +89,6 @@ class Rpl_filter return parallel_mode; } - void add_db_rewrite(const char* from_db, const char* to_db); - /* Getters - to get information about current rules */ void get_do_table(String* str); @@ -98,8 +98,9 @@ class Rpl_filter void get_wild_ignore_table(String* str); bool rewrite_db_is_empty(); + I_List* get_rewrite_db(); + void get_rewrite_db(String *str); const char* get_rewrite_db(const char* db, size_t *new_len); - void copy_rewrite_db(Rpl_filter *from); I_List* get_do_db(); I_List* get_ignore_db(); @@ -121,15 +122,17 @@ class Rpl_filter void free_string_array(DYNAMIC_ARRAY *a); void free_string_list(I_List *l); + void free_string_pair_list(I_List *l); void table_rule_ent_hash_to_str(String* s, HASH* h, bool inited); void table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a, bool inited); + void db_rewrite_rule_ent_list_to_str(String*, I_List*); void db_rule_ent_list_to_str(String* s, I_List* l); TABLE_RULE_ENT* find_wild(DYNAMIC_ARRAY *a, const char* key, int len); int add_string_list(I_List *list, const char* spec); - + int add_string_pair_list(const char* my_spec); /* Those 4 structures below are uninitialized memory unless the corresponding *_inited variables are "true". diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index ab2523d960b65..3c698f27a19f4 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -1024,10 +1024,12 @@ void copy_filter_setting(Rpl_filter* dst_filter, Rpl_filter* src_filter) dst_filter->set_wild_ignore_table(tmp.ptr()); } - if (dst_filter->rewrite_db_is_empty()) + dst_filter->get_rewrite_db(&tmp); + if (tmp.is_empty()) { - if (!src_filter->rewrite_db_is_empty()) - dst_filter->copy_rewrite_db(src_filter); + src_filter->get_rewrite_db(&tmp); + if (!tmp.is_empty()) + dst_filter->set_rewrite_db(tmp.ptr()); } } diff --git a/sql/slave.cc b/sql/slave.cc index e39efcc6bbc61..a9a3189ec0f83 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2954,6 +2954,9 @@ void show_master_info_get_fields(THD *thd, List *field_list, field_list->push_back(new (mem_root) Item_empty_string(thd, "Slave_SQL_Running", 3), mem_root); + field_list->push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Rewrite_DB", 23), + mem_root); field_list->push_back(new (mem_root) Item_empty_string(thd, "Replicate_Do_DB", 20), mem_root); @@ -3209,6 +3212,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, &my_charset_bin); protocol->store(&slave_running[mi->slave_running], &my_charset_bin); protocol->store(mi->rli.slave_running ? &msg_yes : &msg_no, &my_charset_bin); + protocol->store(rpl_filter->get_rewrite_db()); protocol->store(rpl_filter->get_do_db()); protocol->store(rpl_filter->get_ignore_db()); diff --git a/sql/sql_list.cc b/sql/sql_list.cc index 92664898718d4..6ccec9b5f2a44 100644 --- a/sql/sql_list.cc +++ b/sql/sql_list.cc @@ -23,13 +23,6 @@ list_node end_of_list; -void free_list(I_List *list) -{ - i_string_pair *tmp; - while ((tmp= list->get())) - delete tmp; -} - void free_list(I_List *list) { diff --git a/sql/sql_list.h b/sql/sql_list.h index 9d159071ff341..edecb0f0be4c5 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -869,7 +869,6 @@ list_copy_and_replace_each_value(List &list, MEM_ROOT *mem_root) it.replace(el->clone(mem_root)); } -void free_list(I_List *list); void free_list(I_List *list); #endif // INCLUDES_MYSQL_SQL_LIST_H diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index e3a8261ca1046..de7390f9500a6 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -5460,6 +5460,9 @@ bool Sys_var_rpl_filter::set_filter_value(const char *value, Master_info *mi) /* Proctect against other threads */ mysql_mutex_lock(&LOCK_active_mi); switch (opt_id) { + case OPT_REPLICATE_REWRITE_DB: + status= rpl_filter->set_rewrite_db(value); + break; case OPT_REPLICATE_DO_DB: status= rpl_filter->set_do_db(value); break; @@ -5508,6 +5511,9 @@ Sys_var_rpl_filter::global_value_ptr(THD *thd, mysql_mutex_lock(&LOCK_active_mi); switch (opt_id) { + case OPT_REPLICATE_REWRITE_DB: + rpl_filter->get_rewrite_db(&tmp); + break; case OPT_REPLICATE_DO_DB: rpl_filter->get_do_db(&tmp); break; @@ -5547,6 +5553,13 @@ static Sys_var_rpl_filter Sys_replicate_do_db( "actual names of table(s) being updated are checked.", PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_DO_DB); +static Sys_var_rpl_filter Sys_replicate_rewrite_db( + "replicate_rewrite_db", OPT_REPLICATE_REWRITE_DB, + "Tells the slave to replicate binlog events " + "into a different database than their original target on the master." + "Example: replicate-rewrite-db=master_db_name->slave_db_name.", + PRIV_SET_SYSTEM_GLOBAL_VAR_REPLICATE_REWRITE_DB); + static Sys_var_rpl_filter Sys_replicate_do_table( "replicate_do_table", OPT_REPLICATE_DO_TABLE, "Tells the slave to restrict replication to tables in the " diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index e342aad532b5c..29aa2d001ddf8 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -469,7 +469,7 @@ static void test_prepare_simple() strmov(query, "SHOW SLAVE STATUS"); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - DIE_UNLESS(mysql_stmt_field_count(stmt) == 53); + DIE_UNLESS(mysql_stmt_field_count(stmt) == 54); mysql_stmt_close(stmt); /* show master status */ From 50c5743adc87e1cdec1431a02558f6540fe5a6d5 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Mon, 12 Sep 2022 18:20:12 +0200 Subject: [PATCH 044/113] MDEV-15530: Variable replicate_rewrite_db cannot be found in "show global variables" - Cosmetic fixes Reviewer:Brandon Nesterenko --- .../suite/binlog/t/binlog_row_mysqlbinlog_options.test | 2 +- mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options.test b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options.test index 25889bb59ad7b..6aab8f0eb8fa7 100644 --- a/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options.test +++ b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_options.test @@ -25,7 +25,7 @@ SET timestamp=1000000000; # Delete all existing binary logs. RESET MASTER; -# Whe'll call mysqlbinlog with two rewrite rules: +# We'll call mysqlbinlog with two rewrite rules: # --rewrite-db="test1->new_test1" # --rewrite-db="test3->new_test3" diff --git a/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt b/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt index 84059110136cc..cb165442c2370 100644 --- a/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt +++ b/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt @@ -1 +1,6 @@ -"--replicate-rewrite-db=test->rewrite" "--replicate-rewrite-db=mysqltest1 -> test" "--replicate-rewrite-db=x -> y" "--replicate-rewrite-db=database_master_temp_01->database_slave_temp_01" "--replicate-rewrite-db=database_master_temp_02->database_slave_temp_02" "--replicate-rewrite-db=database_master_temp_03->database_slave_temp_03" +"--replicate-rewrite-db=test->rewrite" +"--replicate-rewrite-db=mysqltest1 -> test" +"--replicate-rewrite-db=x -> y" +"--replicate-rewrite-db=database_master_temp_01->database_slave_temp_01" +"--replicate-rewrite-db=database_master_temp_02->database_slave_temp_02" +"--replicate-rewrite-db=database_master_temp_03->database_slave_temp_03" From af59b677ea2d07981200f556d24863a69577fe4f Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 22 Oct 2022 01:18:00 +0200 Subject: [PATCH 045/113] MDEV-29104 - fix test cases, for compilation without performance schema. Fix test cases to remove hardcoded expected number for 'handler_next_read' status variable. Apparently, number of rows in I_S.routines depends on whether or not 'sys' schema is loaded, and this depends on whether or not perfschema is compiled in. --- mysql-test/main/information_schema_parameters.result | 4 ++-- mysql-test/main/information_schema_parameters.test | 5 ++++- mysql-test/main/information_schema_routines.result | 4 ++-- mysql-test/main/information_schema_routines.test | 4 ++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/information_schema_parameters.result b/mysql-test/main/information_schema_parameters.result index 69a777d6db0c4..a265f73d7889d 100644 --- a/mysql-test/main/information_schema_parameters.result +++ b/mysql-test/main/information_schema_parameters.result @@ -674,7 +674,7 @@ DTD_IDENTIFIER char(20) ROUTINE_TYPE FUNCTION SHOW STATUS LIKE 'handler_read%next'; Variable_name Value -Handler_read_next 54 +Handler_read_next count_routines Handler_read_rnd_next 3 # # We cannot use the index due to CONCAT(), and filtering by SPECIFIC_NAME @@ -686,7 +686,7 @@ WHERE CONCAT(SPECIFIC_SCHEMA) = 'i_s_parameters_test' AND SPECIFIC_NAME = 'not_existing_proc'; SHOW STATUS LIKE 'handler_read%next'; Variable_name Value -Handler_read_next 54 +Handler_read_next count_routines Handler_read_rnd_next 1 # # Now the index must be used diff --git a/mysql-test/main/information_schema_parameters.test b/mysql-test/main/information_schema_parameters.test index 0c9d94e97f646..f689ee4eddc6f 100644 --- a/mysql-test/main/information_schema_parameters.test +++ b/mysql-test/main/information_schema_parameters.test @@ -291,12 +291,15 @@ USE i_s_parameters_test; CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) RETURN CONCAT('XYZ, ' ,s); +--let count_routines = `select count(*) from information_schema.routines` + --echo # --echo # We cannot use the index due to missing condition on SPECIFIC_SCHEMA, --echo # but we will use SPECIFIC_NAME for filtering records from mysql.proc FLUSH STATUS; query_vertical SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'test_func5'; +--replace_result $count_routines count_routines SHOW STATUS LIKE 'handler_read%next'; --echo # @@ -307,8 +310,8 @@ FLUSH STATUS; query_vertical SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE CONCAT(SPECIFIC_SCHEMA) = 'i_s_parameters_test' AND SPECIFIC_NAME = 'not_existing_proc'; +--replace_result $count_routines count_routines SHOW STATUS LIKE 'handler_read%next'; - --echo # --echo # Now the index must be used FLUSH STATUS; diff --git a/mysql-test/main/information_schema_routines.result b/mysql-test/main/information_schema_routines.result index d316dd7acee04..b5b43db71cec4 100644 --- a/mysql-test/main/information_schema_routines.result +++ b/mysql-test/main/information_schema_routines.result @@ -898,7 +898,7 @@ COLLATION_CONNECTION latin1_swedish_ci DATABASE_COLLATION latin1_swedish_ci SHOW STATUS LIKE 'handler_read%next'; Variable_name Value -Handler_read_next 54 +Handler_read_next count_routines Handler_read_rnd_next 2 # # We cannot use the index due to CONCAT(), and filtering by ROUTINE_NAME @@ -910,7 +910,7 @@ WHERE CONCAT(ROUTINE_SCHEMA) = 'i_s_routines_test' AND ROUTINE_NAME = 'not_existing_proc'; SHOW STATUS LIKE 'handler_read%next'; Variable_name Value -Handler_read_next 54 +Handler_read_next count_routines Handler_read_rnd_next 1 # # Now the index must be used diff --git a/mysql-test/main/information_schema_routines.test b/mysql-test/main/information_schema_routines.test index ea64c8b0d0240..f95124098113c 100644 --- a/mysql-test/main/information_schema_routines.test +++ b/mysql-test/main/information_schema_routines.test @@ -264,6 +264,8 @@ CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30) RETURN CONCAT('XYZ, ' ,s); +--let count_routines = `select count(*) from information_schema.routines` + --echo # --echo # We cannot use the index due to missing condition on SPECIFIC_SCHEMA, --echo # but we will use ROUTINE_NAME for filtering records from mysql.proc @@ -271,6 +273,7 @@ FLUSH STATUS; --replace_column 24 25 query_vertical SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'test_func5'; +--replace_result $count_routines count_routines SHOW STATUS LIKE 'handler_read%next'; --echo # @@ -281,6 +284,7 @@ FLUSH STATUS; query_vertical SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE CONCAT(ROUTINE_SCHEMA) = 'i_s_routines_test' AND ROUTINE_NAME = 'not_existing_proc'; +--replace_result $count_routines count_routines SHOW STATUS LIKE 'handler_read%next'; --echo # From 307d935e2d366cef879f7bc4ce259bf1029b4918 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Mon, 24 Oct 2022 19:59:58 +0700 Subject: [PATCH 046/113] MDEV-29858 Missing DBUG_RETURN or DBUG_VOID_RETURN in fill_schema_proc --- mysql-test/main/information_schema_parameters.result | 4 ++++ mysql-test/main/information_schema_parameters.test | 4 ++++ sql/sql_show.cc | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/information_schema_parameters.result b/mysql-test/main/information_schema_parameters.result index a265f73d7889d..1d00c992e5c8f 100644 --- a/mysql-test/main/information_schema_parameters.result +++ b/mysql-test/main/information_schema_parameters.result @@ -801,5 +801,9 @@ SHOW STATUS LIKE 'handler_read%next'; Variable_name Value Handler_read_next 1 Handler_read_rnd_next 2 +SELECT COUNT(*) FROM information_schema.PARAMETERS +WHERE SPECIFIC_CATALOG = NULL; +COUNT(*) +# DROP DATABASE i_s_parameters_test; USE test; diff --git a/mysql-test/main/information_schema_parameters.test b/mysql-test/main/information_schema_parameters.test index f689ee4eddc6f..e1c64d4bacd37 100644 --- a/mysql-test/main/information_schema_parameters.test +++ b/mysql-test/main/information_schema_parameters.test @@ -339,6 +339,10 @@ query_vertical SELECT * FROM INFORMATION_SCHEMA.PARAMETERS AND SPECIFIC_NAME = 'процедурка'; SHOW STATUS LIKE 'handler_read%next'; +--replace_column 1 # +SELECT COUNT(*) FROM information_schema.PARAMETERS + WHERE SPECIFIC_CATALOG = NULL; + # Cleanup DROP DATABASE i_s_parameters_test; USE test; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a9eb876fb9978..c77759c3e8bcd 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6804,7 +6804,7 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) if (get_lookup_field_values(thd, cond, false, tables, &lookup)) { // There can be no matching records for the condition - return 0; + DBUG_RETURN(0); } start_new_trans new_trans(thd); From baf276e6d4a44fe7cdf3b435c0153da0a42af2b6 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 24 Oct 2022 20:46:43 +0530 Subject: [PATCH 047/113] MDEV-19229 Allow innodb_undo_tablespaces to be changed after database creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit trx_sys_t::undo_log_nonempty: Set to true if there are undo logs to rollback and purge. The algorithm for re-creating the undo tablespace when trx_sys_t::undo_log_nonempty is disabled: 1) trx_sys_t::reset_page(): Reset the TRX_SYS page and assign all rollback segment slots from 1..127 to FIL_NULL 2) Free the rollback segment header page of system tablespace for the slots 1..127 3) Update the binlog and WSREP information in system tablespace rollback segment header Step (1), (2) and Step (3) should happen atomically within a single mini-transaction. 4) srv_undo_delete_old_tablespaces(): Delete the old undo tablespaces present in the undo log directory 5) Make checkpoint to get rid of old undo log tablespaces redo logs 6) Assign new start space id for the undo log tablespaces 7) Re-create the specified undo log tablespaces. InnoDB uses same mtr for this one and step (6) 8) Make checkpoint again, so that server or mariabackup can read the undo log tablespace page0 before applying the redo logs srv_undo_tablespaces_reinit(): Recreate the undo log tablespaces. It does reset trx_sys page, delete the old undo tablespaces, update the binlog offset, write set replication checkpoint in system rollback segment page trx_rseg_update_binlog_offset(): Added 2 new parameters to pass binlog file name and binlog offset trx_rseg_array_init(): Return error if the rollback segment slot points to non-existent tablespace srv_undo_tablespaces_init(): Added new parameter mtr to initialize all undo tablespaces trx_assign_rseg_low(): Allow the transaction to use the rollback segment slots(1..127) even if InnoDB failed to change to the requested innodb_undo_tablespaces=0 srv_start(): Override the user specified value of innodb_undo_tablespaces variable with already existing actual undo tablespaces wf_incremental_process(): Detects whether TRX_SYS page has been modified since last backup. If it is then incremental backup fails and throws the information about taking full backup again xb_assign_undo_space_start(): Removed the function. Because undo001 has first undo space id value in page0 Added test case to test the scenario during startup and mariabackup incremental process too. Reviewed-by : Marko Mäkelä Tested-by : Matthias Leich --- extra/mariabackup/write_filt.cc | 12 + extra/mariabackup/xtrabackup.cc | 92 +---- .../innodb/include/have_undo_tablespaces.inc | 4 - mysql-test/suite/innodb/r/log_file.result | 4 +- .../suite/innodb/r/undo_truncate.result | 2 + .../innodb/r/undo_truncate_recover.result | 2 + mysql-test/suite/innodb/r/undo_upgrade.result | 80 +++++ .../suite/innodb/r/undo_upgrade_debug.result | 43 +++ mysql-test/suite/innodb/t/log_file.test | 4 +- mysql-test/suite/innodb/t/undo_truncate.test | 7 +- .../suite/innodb/t/undo_truncate_recover.test | 6 +- mysql-test/suite/innodb/t/undo_upgrade.opt | 2 + mysql-test/suite/innodb/t/undo_upgrade.test | 94 +++++ .../suite/innodb/t/undo_upgrade_debug.test | 70 ++++ .../suite/mariabackup/undo_upgrade.result | 19 + .../suite/mariabackup/undo_upgrade.test | 50 +++ storage/innobase/include/srv0start.h | 6 +- storage/innobase/include/trx0rseg.h | 7 +- storage/innobase/include/trx0sys.h | 16 + storage/innobase/srv/srv0start.cc | 330 +++++++++++++++--- storage/innobase/trx/trx0purge.cc | 4 +- storage/innobase/trx/trx0rseg.cc | 65 ++-- storage/innobase/trx/trx0sys.cc | 5 +- storage/innobase/trx/trx0trx.cc | 12 +- 24 files changed, 757 insertions(+), 179 deletions(-) delete mode 100644 mysql-test/suite/innodb/include/have_undo_tablespaces.inc create mode 100644 mysql-test/suite/innodb/r/undo_upgrade.result create mode 100644 mysql-test/suite/innodb/r/undo_upgrade_debug.result create mode 100644 mysql-test/suite/innodb/t/undo_upgrade.opt create mode 100644 mysql-test/suite/innodb/t/undo_upgrade.test create mode 100644 mysql-test/suite/innodb/t/undo_upgrade_debug.test create mode 100644 mysql-test/suite/mariabackup/undo_upgrade.result create mode 100644 mysql-test/suite/mariabackup/undo_upgrade.test diff --git a/extra/mariabackup/write_filt.cc b/extra/mariabackup/write_filt.cc index 01e4d83e344aa..086d4078e317c 100644 --- a/extra/mariabackup/write_filt.cc +++ b/extra/mariabackup/write_filt.cc @@ -129,6 +129,18 @@ wf_incremental_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile) incremental_lsn >= mach_read_from_8(page + FIL_PAGE_LSN)) continue; + /* Check whether TRX_SYS page has been changed */ + if (mach_read_from_4(page + FIL_PAGE_SPACE_ID) + == TRX_SYS_SPACE + && mach_read_from_4(page + FIL_PAGE_OFFSET) + == TRX_SYS_PAGE_NO) { + msg(cursor->thread_n, + "--incremental backup is impossible if " + "the server had been restarted with " + "different innodb_undo_tablespaces."); + return false; + } + /* updated page */ if (cp->npages == page_size / 4) { /* flush buffer */ diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 2783064cf387e..ac15d98321e17 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3826,89 +3826,6 @@ static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback) return(err); } -/** 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() -{ - - pfs_os_file_t file; - bool ret; - dberr_t error = DB_SUCCESS; - uint32_t space; - uint32_t fsp_flags; - int n_retries = 5; - - if (srv_undo_tablespaces == 0) { - return error; - } - - file = os_file_create(0, srv_sys_space.first_datafile()->filepath(), - OS_FILE_OPEN, OS_FILE_NORMAL, OS_DATA_FILE, true, &ret); - - if (!ret) { - msg("Error opening %s", srv_sys_space.first_datafile()->filepath()); - return DB_ERROR; - } - - byte* page = static_cast - (aligned_malloc(srv_page_size, srv_page_size)); - - if (os_file_read(IORequestRead, file, page, 0, srv_page_size) - != DB_SUCCESS) { - msg("Reading first page failed.\n"); - error = DB_ERROR; - goto func_exit; - } - - fsp_flags = mach_read_from_4( - page + FSP_HEADER_OFFSET + FSP_SPACE_FLAGS); -retry: - if (os_file_read(IORequestRead, file, page, - TRX_SYS_PAGE_NO << srv_page_size_shift, - srv_page_size) != DB_SUCCESS) { - msg("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, fsp_flags)) { - if (n_retries--) { - std::this_thread::sleep_for( - std::chrono::milliseconds(1)); - goto retry; - } else { - msg("mariabackup: TRX_SYS page corrupted.\n"); - error = DB_ERROR; - goto func_exit; - } - } - - /* 0th slot always points to system tablespace. - 1st slot should point to first undotablespace which is minimum. */ - - ut_ad(mach_read_from_4(TRX_SYS + TRX_SYS_RSEGS - + TRX_SYS_RSEG_SLOT_SIZE - + TRX_SYS_RSEG_PAGE_NO + page) - != FIL_NULL); - - space = mach_read_from_4(TRX_SYS + TRX_SYS_RSEGS - + TRX_SYS_RSEG_SLOT_SIZE - + TRX_SYS_RSEG_SPACE + page); - - srv_undo_space_id_start = space; - -func_exit: - aligned_free(page); - 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.*/ @@ -3946,14 +3863,7 @@ xb_load_tablespaces() } /* 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); + err = srv_undo_tablespaces_init(false, nullptr); if (err != DB_SUCCESS) { return(err); diff --git a/mysql-test/suite/innodb/include/have_undo_tablespaces.inc b/mysql-test/suite/innodb/include/have_undo_tablespaces.inc deleted file mode 100644 index 87830a4a5f0dd..0000000000000 --- a/mysql-test/suite/innodb/include/have_undo_tablespaces.inc +++ /dev/null @@ -1,4 +0,0 @@ -if (`select count(*) = 0 from information_schema.global_variables where variable_name like 'innodb_undo_tablespaces' and variable_value >= 2`) -{ - --skip Test requires InnoDB with at-least 2 undo tablespaces. -} diff --git a/mysql-test/suite/innodb/r/log_file.result b/mysql-test/suite/innodb/r/log_file.result index 734e9b0768717..f5e98d30b30ff 100644 --- a/mysql-test/suite/innodb/r/log_file.result +++ b/mysql-test/suite/innodb/r/log_file.result @@ -184,7 +184,7 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Expected to open innodb_undo_tablespaces=3 but was able to find only 1/ in mysqld.1.err +FOUND 1 /InnoDB: Failed to open the undo tablespace/ in mysqld.1.err bak_ib_logfile0 bak_ibdata1 bak_ibdata2 @@ -214,7 +214,7 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Expected to open innodb_undo_tablespaces=3 but was able to find only 0/ in mysqld.1.err +FOUND 2 /InnoDB: Failed to open the undo tablespace/ in mysqld.1.err bak_ib_logfile0 bak_ibdata1 bak_ibdata2 diff --git a/mysql-test/suite/innodb/r/undo_truncate.result b/mysql-test/suite/innodb/r/undo_truncate.result index 5be1e5c342661..b7729020acac6 100644 --- a/mysql-test/suite/innodb/r/undo_truncate.result +++ b/mysql-test/suite/innodb/r/undo_truncate.result @@ -1,3 +1,5 @@ +SET GLOBAL innodb_fast_shutdown=0; +# restart: --innodb_undo_tablespaces=2 SET GLOBAL innodb_undo_log_truncate = 0; SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; create table t1(keyc int primary key, c char(100)) engine = innodb; diff --git a/mysql-test/suite/innodb/r/undo_truncate_recover.result b/mysql-test/suite/innodb/r/undo_truncate_recover.result index 909771e6a17cc..4d75712060a59 100644 --- a/mysql-test/suite/innodb/r/undo_truncate_recover.result +++ b/mysql-test/suite/innodb/r/undo_truncate_recover.result @@ -1,3 +1,5 @@ +SET GLOBAL innodb_fast_shutdown=0; +# restart: --innodb_undo_tablespaces=2 SET GLOBAL innodb_undo_log_truncate = 1; SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; create table t1(keyc int primary key, c char(100)) engine = innodb; diff --git a/mysql-test/suite/innodb/r/undo_upgrade.result b/mysql-test/suite/innodb/r/undo_upgrade.result new file mode 100644 index 0000000000000..12d6f30e1d80f --- /dev/null +++ b/mysql-test/suite/innodb/r/undo_upgrade.result @@ -0,0 +1,80 @@ +# +# MDEV-19229 Allow innodb_undo_tablespaces to be changed +# after database creation +# +call mtr.add_suppression("Found .* prepared XA transactions"); +call mtr.add_suppression("InnoDB: Plugin initialization aborted"); +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: Cannot change innodb_undo_tablespaces=\\d+ because previous shutdown was not with innodb_fast_shutdown=0"); +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +connect con_purge,localhost,root,,,; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; +INSERT INTO t1 VALUES(1); +UPDATE t1 SET f1=100; +# case 1: Undo log left to purge +# restart: --innodb_undo_tablespaces=2 +# Display 4 undo tablespaces +select @@global.innodb_undo_tablespaces; +@@global.innodb_undo_tablespaces +4 +# Should list 4 undo log tablespaces +undo001 +undo002 +undo003 +undo004 +# case 2: XA transaction alone left +InnoDB 0 transactions not purged +XA START 'zombie'; +INSERT INTO t1 VALUES(2); +XA END 'zombie'; +XA PREPARE 'zombie'; +# restart: --innodb_undo_tablespaces=2 +# Display 4 undo tablespaces +select @@global.innodb_undo_tablespaces; +@@global.innodb_undo_tablespaces +4 +# Should list 4 undo log tablespaces +undo001 +undo002 +undo003 +undo004 +XA COMMIT 'zombie'; +# case 3: Successful innodb_undo_tablespace upgrade +SET GLOBAL innodb_fast_shutdown=0; +# restart: --innodb_undo_tablespaces=2 +# Display 2 undo tablespaces +SELECT @@global.innodb_undo_tablespaces; +@@global.innodb_undo_tablespaces +2 +# Should list 2 undo log tablespaces +undo001 +undo002 +DROP TABLE t1; +InnoDB 0 transactions not purged +# case 4: Reduce the innodb_undo_tablespace to 0 +# restart: --innodb_undo_tablespaces=0 +# Display 0 undo tablespace +SELECT @@global.innodb_undo_tablespaces; +@@global.innodb_undo_tablespaces +0 +# Shouldn't list any undo log tablespaces +# case 5: Change undo tablespace when force_recovery < 5 +# restart: --innodb_undo_tablespaces=2 --innodb_force_recovery=4 +# Display 2 undo tablespace +SELECT @@global.innodb_undo_tablespaces; +@@global.innodb_undo_tablespaces +2 +# Should list 2 undo log tablespaces +undo001 +undo002 +# case 6: Fail to change undo tablespace when force_recovery > 4 +# restart: --innodb_undo_tablespaces=4 --innodb_force_recovery=5 +# Display 2 undo tablespace +SELECT @@global.innodb_undo_tablespaces; +@@global.innodb_undo_tablespaces +2 +# Should list 2 undo log tablespaces, not 4 +undo001 +undo002 diff --git a/mysql-test/suite/innodb/r/undo_upgrade_debug.result b/mysql-test/suite/innodb/r/undo_upgrade_debug.result new file mode 100644 index 0000000000000..9c464459b98b7 --- /dev/null +++ b/mysql-test/suite/innodb/r/undo_upgrade_debug.result @@ -0,0 +1,43 @@ +# +# MDEV-19229 Allow innodb_undo_tablespaces to be changed +# after database creation +# +call mtr.add_suppression("InnoDB: Plugin initialization aborted"); +call mtr.add_suppression("Plugin 'InnoDB' init function returned error"); +call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); +set global innodb_fast_shutdown=0; +# case 1: Abort after resetting TRX_SYS page rollback segments +# restart: --innodb_undo_tablespaces=4 --debug_dbug=+d,after_rseg_reset_abort +# restart: --innodb_undo_tablespaces=4 +# Should list 4 undo log tablespaces +undo001 +undo002 +undo003 +undo004 +# case 2: Abort after deleting the old undo tablespaces +# restart: --innodb_undo_tablespaces=2 --debug_dbug=+d,after_deleting_old_undo_abort +# restart: --innodb_undo_tablespaces=2 +# Should list 2 undo log tablespaces +undo001 +undo002 +# case 3: Abort after successfully deleting the old undo tablespace +# restart: --innodb_undo_tablespaces=3 --debug_dbug=+d,after_deleting_old_undo_success +# restart: --innodb_undo_tablespaces=3 +# Should list 3 undo log tablespaces +undo001 +undo002 +undo003 +# case 4: Abort after re-creating new undo tablespaces +# restart: --innodb_undo_tablespaces=4 --debug_dbug=+d,after_reinit_undo_abort +# restart: --innodb_undo_tablespaces=4 +# Should list 4 undo log tablespaces +undo001 +undo002 +undo003 +undo004 +# case 5: Abort after re-creating new undo tablespaces successfully +# restart: --innodb_undo_tablespaces=2 --debug_dbug=+d,after_reinit_undo_success +# restart: --innodb_undo_tablespaces=2 +# Should list 2 undo log tablespaces +undo001 +undo002 diff --git a/mysql-test/suite/innodb/t/log_file.test b/mysql-test/suite/innodb/t/log_file.test index 438fbe1a6e1fa..805a4b4cd5664 100644 --- a/mysql-test/suite/innodb/t/log_file.test +++ b/mysql-test/suite/innodb/t/log_file.test @@ -164,7 +164,7 @@ let SEARCH_PATTERN=undo tablespace .*undo003.* exists\. Creating system tablespa --source include/start_mysqld.inc eval $check_no_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=InnoDB: Expected to open innodb_undo_tablespaces=3 but was able to find only 1; +let SEARCH_PATTERN=InnoDB: Failed to open the undo tablespace; --source include/search_pattern_in_file.inc # clean up & Restore --source ../include/log_file_cleanup.inc @@ -176,7 +176,7 @@ let SEARCH_PATTERN=InnoDB: Expected to open innodb_undo_tablespaces=3 but was ab --source include/start_mysqld.inc eval $check_no_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=InnoDB: Expected to open innodb_undo_tablespaces=3 but was able to find only 0; +let SEARCH_PATTERN=InnoDB: Failed to open the undo tablespace; --source include/search_pattern_in_file.inc # clean up & Restore diff --git a/mysql-test/suite/innodb/t/undo_truncate.test b/mysql-test/suite/innodb/t/undo_truncate.test index 19829ce21e75d..a5e0a52f798fc 100644 --- a/mysql-test/suite/innodb/t/undo_truncate.test +++ b/mysql-test/suite/innodb/t/undo_truncate.test @@ -1,6 +1,5 @@ --source include/have_innodb.inc --source include/innodb_page_size.inc ---source include/have_undo_tablespaces.inc --source include/not_embedded.inc --source include/have_sequence.inc --source include/no_valgrind_without_big.inc @@ -12,6 +11,11 @@ call mtr.add_suppression("InnoDB: Difficult to find free blocks in the buffer po call mtr.add_suppression("InnoDB: Trying to delete tablespace.*pending operations"); --enable_query_log +# Re-create the undo log tablespaces after slow shutdown +SET GLOBAL innodb_fast_shutdown=0; +let $restart_parameters="--innodb_undo_tablespaces=2"; +--source include/restart_mysqld.inc + SET GLOBAL innodb_undo_log_truncate = 0; SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; @@ -53,6 +57,7 @@ let $trx_before= `select substr('$trx_before',9)+2`; SET GLOBAL innodb_purge_rseg_truncate_frequency=1; SET GLOBAL innodb_max_purge_lag_wait=0; set global innodb_fast_shutdown=0; +let $restart_parameters=; --source include/restart_mysqld.inc --replace_regex /.*Trx id counter ([0-9]+).*/\1/ let $trx_after= `SHOW ENGINE INNODB STATUS`; diff --git a/mysql-test/suite/innodb/t/undo_truncate_recover.test b/mysql-test/suite/innodb/t/undo_truncate_recover.test index e499ff3dfbe3f..1b27b0fe6e4d8 100644 --- a/mysql-test/suite/innodb/t/undo_truncate_recover.test +++ b/mysql-test/suite/innodb/t/undo_truncate_recover.test @@ -8,10 +8,14 @@ --source include/innodb_page_size_small.inc --source include/have_innodb.inc --source include/have_debug.inc ---source include/have_undo_tablespaces.inc # Tests with embedded server do not support restarting --source include/not_embedded.inc +# Re-create the undo log tablespaces after slow shutdown +SET GLOBAL innodb_fast_shutdown=0; +let $restart_parameters="--innodb_undo_tablespaces=2"; +--source include/restart_mysqld.inc + SET GLOBAL innodb_undo_log_truncate = 1; SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; diff --git a/mysql-test/suite/innodb/t/undo_upgrade.opt b/mysql-test/suite/innodb/t/undo_upgrade.opt new file mode 100644 index 0000000000000..87bc4c4d7f7d7 --- /dev/null +++ b/mysql-test/suite/innodb/t/undo_upgrade.opt @@ -0,0 +1,2 @@ +--log-bin=1 +--innodb_undo_tablespaces=4 diff --git a/mysql-test/suite/innodb/t/undo_upgrade.test b/mysql-test/suite/innodb/t/undo_upgrade.test new file mode 100644 index 0000000000000..952d8b72b6904 --- /dev/null +++ b/mysql-test/suite/innodb/t/undo_upgrade.test @@ -0,0 +1,94 @@ +--source include/have_innodb.inc +--source include/innodb_page_size.inc +--source include/not_embedded.inc + +--echo # +--echo # MDEV-19229 Allow innodb_undo_tablespaces to be changed +--echo # after database creation +--echo # +call mtr.add_suppression("Found .* prepared XA transactions"); +call mtr.add_suppression("InnoDB: Plugin initialization aborted"); +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: Cannot change innodb_undo_tablespaces=\\d+ because previous shutdown was not with innodb_fast_shutdown=0"); + +let $MYSQLD_DATADIR= `select @@datadir`; + +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +connect(con_purge,localhost,root,,,); +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +connection default; +INSERT INTO t1 VALUES(1); +UPDATE t1 SET f1=100; + +let $restart_parameters=--innodb_undo_tablespaces=2; +--echo # case 1: Undo log left to purge +--source include/restart_mysqld.inc +--echo # Display 4 undo tablespaces +select @@global.innodb_undo_tablespaces; + +--echo # Should list 4 undo log tablespaces +list_files $MYSQLD_DATADIR undo*; + +--echo # case 2: XA transaction alone left +--source include/wait_all_purged.inc +XA START 'zombie'; +INSERT INTO t1 VALUES(2); +XA END 'zombie'; +XA PREPARE 'zombie'; + +--source include/restart_mysqld.inc + +--echo # Display 4 undo tablespaces +select @@global.innodb_undo_tablespaces; + +--echo # Should list 4 undo log tablespaces +list_files $MYSQLD_DATADIR undo*; + +XA COMMIT 'zombie'; + +--echo # case 3: Successful innodb_undo_tablespace upgrade +SET GLOBAL innodb_fast_shutdown=0; + +let $restart_parameters=--innodb_undo_tablespaces=2; +--source include/restart_mysqld.inc + +--echo # Display 2 undo tablespaces +SELECT @@global.innodb_undo_tablespaces; + +--echo # Should list 2 undo log tablespaces +list_files $MYSQLD_DATADIR undo*; + +DROP TABLE t1; +--source include/wait_all_purged.inc + +--echo # case 4: Reduce the innodb_undo_tablespace to 0 +let $restart_parameters=--innodb_undo_tablespaces=0; +--source include/restart_mysqld.inc + +--echo # Display 0 undo tablespace +SELECT @@global.innodb_undo_tablespaces; + +--echo # Shouldn't list any undo log tablespaces +list_files $MYSQLD_DATADIR undo*; + +--echo # case 5: Change undo tablespace when force_recovery < 5 +let $restart_parameters=--innodb_undo_tablespaces=2 --innodb_force_recovery=4; +--source include/restart_mysqld.inc + +--echo # Display 2 undo tablespace +SELECT @@global.innodb_undo_tablespaces; + +--echo # Should list 2 undo log tablespaces +list_files $MYSQLD_DATADIR undo*; + +--echo # case 6: Fail to change undo tablespace when force_recovery > 4 +let $restart_parameters=--innodb_undo_tablespaces=4 --innodb_force_recovery=5; +--source include/restart_mysqld.inc + +--echo # Display 2 undo tablespace +SELECT @@global.innodb_undo_tablespaces; + +--echo # Should list 2 undo log tablespaces, not 4 +list_files $MYSQLD_DATADIR undo*; diff --git a/mysql-test/suite/innodb/t/undo_upgrade_debug.test b/mysql-test/suite/innodb/t/undo_upgrade_debug.test new file mode 100644 index 0000000000000..e274d6c020d99 --- /dev/null +++ b/mysql-test/suite/innodb/t/undo_upgrade_debug.test @@ -0,0 +1,70 @@ +--source include/have_innodb.inc +--source include/innodb_page_size.inc +--source include/have_debug.inc +--source include/not_embedded.inc + +--echo # +--echo # MDEV-19229 Allow innodb_undo_tablespaces to be changed +--echo # after database creation +--echo # +let $MYSQLD_DATADIR= `select @@datadir`; +call mtr.add_suppression("InnoDB: Plugin initialization aborted"); +call mtr.add_suppression("Plugin 'InnoDB' init function returned error"); +call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); + +set global innodb_fast_shutdown=0; + +--echo # case 1: Abort after resetting TRX_SYS page rollback segments +let $restart_parameters=--innodb_undo_tablespaces=4 --debug_dbug="+d,after_rseg_reset_abort"; + +--source include/restart_mysqld.inc + +let $restart_parameters=--innodb_undo_tablespaces=4; +--source include/restart_mysqld.inc + +--echo # Should list 4 undo log tablespaces +list_files $MYSQLD_DATADIR undo*; + +--echo # case 2: Abort after deleting the old undo tablespaces +let $restart_parameters=--innodb_undo_tablespaces=2 --debug_dbug="+d,after_deleting_old_undo_abort"; + +--source include/restart_mysqld.inc + +let $restart_parameters=--innodb_undo_tablespaces=2; +--source include/restart_mysqld.inc + +--echo # Should list 2 undo log tablespaces +list_files $MYSQLD_DATADIR undo*; + +--echo # case 3: Abort after successfully deleting the old undo tablespace +let $restart_parameters=--innodb_undo_tablespaces=3 --debug_dbug="+d,after_deleting_old_undo_success"; + +--source include/restart_mysqld.inc + +let $restart_parameters=--innodb_undo_tablespaces=3; +--source include/restart_mysqld.inc + +--echo # Should list 3 undo log tablespaces +list_files $MYSQLD_DATADIR undo*; + +--echo # case 4: Abort after re-creating new undo tablespaces +let $restart_parameters=--innodb_undo_tablespaces=4 --debug_dbug="+d,after_reinit_undo_abort"; + +--source include/restart_mysqld.inc + +let $restart_parameters=--innodb_undo_tablespaces=4; +--source include/restart_mysqld.inc + +--echo # Should list 4 undo log tablespaces +list_files $MYSQLD_DATADIR undo*; + +--echo # case 5: Abort after re-creating new undo tablespaces successfully +let $restart_parameters=--innodb_undo_tablespaces=2 --debug_dbug="+d,after_reinit_undo_success"; + +--source include/restart_mysqld.inc + +let $restart_parameters=--innodb_undo_tablespaces=2; +--source include/restart_mysqld.inc + +--echo # Should list 2 undo log tablespaces +list_files $MYSQLD_DATADIR undo*; diff --git a/mysql-test/suite/mariabackup/undo_upgrade.result b/mysql-test/suite/mariabackup/undo_upgrade.result new file mode 100644 index 0000000000000..7b77e9ff6e697 --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_upgrade.result @@ -0,0 +1,19 @@ +set global innodb_fast_shutdown=0; +# restart: --innodb_undo_tablespaces=2 +CREATE TABLE t1(a varchar(60)) ENGINE INNODB; +start transaction; +INSERT INTO t1 VALUES(1); +# xtrabackup backup +# Restart the server with 4 undo tablespaces +set global innodb_fast_shutdown=0; +# restart: --innodb_undo_tablespaces=4 +# incremental backup should fail +FOUND 1 /--incremental backup is impossible if the server had been restarted with different innodb_undo_tablespaces/ in backup.log +# Take full backup again +# Prepare full backup +# Display 4 undo log files from target directory +undo001 +undo002 +undo003 +undo004 +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/undo_upgrade.test b/mysql-test/suite/mariabackup/undo_upgrade.test new file mode 100644 index 0000000000000..3d59926978266 --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_upgrade.test @@ -0,0 +1,50 @@ +--source include/have_innodb.inc +--source include/innodb_page_size.inc + +let basedir=$MYSQLTEST_VARDIR/tmp/backup; +let incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +set global innodb_fast_shutdown=0; +let $restart_parameters=--innodb_undo_tablespaces=2; +--source include/restart_mysqld.inc + +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 # Restart the server with 4 undo tablespaces +let $restart_parameters=--innodb_undo_tablespaces=4; +set global innodb_fast_shutdown=0; +--source include/restart_mysqld.inc + +let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; +--echo # incremental backup should fail +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir 2> $backuplog; + +--let SEARCH_PATTERN=--incremental backup is impossible if the server had been restarted with different innodb_undo_tablespaces +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +remove_file $backuplog; +rmdir $incremental_dir; +rmdir $basedir; + +--echo # Take full backup again +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log +--disable_result_log + +echo # Prepare full backup; +exec $XTRABACKUP --prepare --target-dir=$basedir; + +--echo # Display 4 undo log files from target directory +list_files $basedir undo*; + +DROP TABLE t1; +rmdir $basedir; diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h index 44b19aa666bda..c18cf1ceb63d1 100644 --- a/storage/innobase/include/srv0start.h +++ b/storage/innobase/include/srv0start.h @@ -33,10 +33,10 @@ Created 10/10/1995 Heikki Tuuri struct dict_table_t; /** Open the configured number of dedicated undo tablespaces. -@param[in] create_new_db whether the database is being initialized +@param[in] create_new_undo whether the undo tablespaces has to be created +@param[in,out] mtr mini-transaction @return DB_SUCCESS or error code */ -dberr_t -srv_undo_tablespaces_init(bool create_new_db); +dberr_t srv_undo_tablespaces_init(bool create_new_undo, mtr_t *mtr); /** Start InnoDB. @param[in] create_new_db whether to create a new database diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index 7ad20b0fff0e1..6ea4b8cb1cc5a 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -306,7 +306,10 @@ which corresponds to the transaction just being committed. In a replication slave, this updates the master binlog position up to which replication has proceeded. @param[in,out] rseg_header rollback segment header -@param[in] trx committing transaction +@param[in] log_file_name binlog file name +@param[in] log_offset binlog offset value @param[in,out] mtr mini-transaction */ -void trx_rseg_update_binlog_offset(buf_block_t *rseg_header, const trx_t *trx, +void trx_rseg_update_binlog_offset(buf_block_t *rseg_header, + const char *log_file_name, + ulonglong log_offset, mtr_t *mtr); diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index 4d231077b12d7..2ed9566c21502 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -855,6 +855,8 @@ class trx_sys_t bool m_initialised; + /** False if there is no undo log to purge or rollback */ + bool undo_log_nonempty; public: /** List of all transactions. */ thread_safe_trx_ilist_t trx_list; @@ -1165,6 +1167,20 @@ class trx_sys_t return count; } + /** Set the undo log empty value */ + void set_undo_non_empty(bool val) + { + if (!undo_log_nonempty) + undo_log_nonempty= val; + } + + /** Get the undo log empty value */ + bool is_undo_empty() const { return !undo_log_nonempty; } + + /* Reset the trx_sys page and retain the dblwr information, + system rollback segment header page + @return error code */ + inline dberr_t reset_page(mtr_t *mtr); private: static my_bool find_same_or_older_callback(rw_trx_hash_element_t *element, trx_id_t *id) diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 4954a07c64e89..fbe370bbfd902 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -326,11 +326,246 @@ static dberr_t srv_undo_tablespace_create(const char* name) return(err); } -/* Validate the number of undo opened undo tablespace and user given -undo tablespace +inline dberr_t trx_sys_t::reset_page(mtr_t *mtr) +{ + dberr_t err= DB_SUCCESS; + buf_block_t *sys_header= buf_page_get_gen( + page_id_t(TRX_SYS_SPACE, TRX_SYS_PAGE_NO), 0, RW_X_LATCH, nullptr, + BUF_GET, mtr, &err); + + if (!sys_header) return err; + + const bool dblwr_enabled= + mach_read_from_4(TRX_SYS_DOUBLEWRITE_MAGIC + TRX_SYS_DOUBLEWRITE + + sys_header->page.frame) + == TRX_SYS_DOUBLEWRITE_MAGIC_N; + + char doublewrite[TRX_SYS_DOUBLEWRITE_BLOCK2 + 4]; + memcpy(doublewrite, TRX_SYS_DOUBLEWRITE + sys_header->page.frame, + sizeof doublewrite); + + fsp_init_file_page(fil_system.sys_space, sys_header, mtr); + + mtr->write<2>(*sys_header, FIL_PAGE_TYPE + sys_header->page.frame, + FIL_PAGE_TYPE_TRX_SYS); + + mtr->write<4>(*sys_header, + TRX_SYS + TRX_SYS_RSEGS + TRX_SYS_RSEG_PAGE_NO + + sys_header->page.frame, FSP_FIRST_RSEG_PAGE_NO); + mtr->memset(sys_header, + TRX_SYS + TRX_SYS_RSEGS + TRX_SYS_RSEG_SLOT_SIZE, + 254 * TRX_SYS_RSEG_SLOT_SIZE, 0xff); + + static_assert(TRX_SYS_RSEG_SLOT_SIZE == 8, ""); + + if (dblwr_enabled) + { + mtr->memcpy( + *sys_header, sys_header->page.frame + TRX_SYS_DOUBLEWRITE, + doublewrite, sizeof doublewrite); + mtr->memmove( + *sys_header, + TRX_SYS_DOUBLEWRITE + FSEG_HEADER_SIZE + TRX_SYS_DOUBLEWRITE_REPEAT, + TRX_SYS_DOUBLEWRITE + FSEG_HEADER_SIZE, 12); + memcpy( + sys_header->page.frame + TRX_SYS_DOUBLEWRITE + + FSEG_HEADER_SIZE + TRX_SYS_DOUBLEWRITE_REPEAT, + sys_header->page.frame + TRX_SYS_DOUBLEWRITE + FSEG_HEADER_SIZE, 12); + } + + return DB_SUCCESS; +} + +/** Delete the old undo tablespaces present in the undo log directory */ +static dberr_t srv_undo_delete_old_tablespaces() +{ + /* Delete the old undo tablespaces*/ + for (uint32_t i= 0; i < srv_undo_tablespaces_open; ++i) + fil_close_tablespace(srv_undo_space_id_start + i); + + DBUG_EXECUTE_IF("after_deleting_old_undo_abort", return DB_ERROR;); + + /* Do checkpoint to get rid of old undo log tablespaces redo logs */ + log_make_checkpoint(); + + DBUG_EXECUTE_IF("after_deleting_old_undo_success", return DB_ERROR;); + + for (uint32_t i= 0; i < srv_undo_tablespaces_open; ++i) + { + char name[OS_FILE_MAX_PATH]; + snprintf(name, sizeof name, "%s/undo%03" PRIu32, srv_undo_dir, i + 1); + os_file_delete_if_exists(innodb_data_file_key, name, nullptr); + } + + return DB_SUCCESS; +} + +/** Recreate the undo log tablespaces */ +static dberr_t srv_undo_tablespaces_reinit() +{ + mtr_t mtr; + dberr_t err; + buf_block_t *first_rseg_hdr; + uint32_t latest_space_id; + + mtr.start(); + + buf_block_t *dict_hdr= buf_page_get_gen( + page_id_t(DICT_HDR_SPACE, DICT_HDR_PAGE_NO), 0, RW_X_LATCH, + nullptr, BUF_GET, &mtr, &err); + + if (!dict_hdr) + goto func_exit; + + /* Assign the new space id for the first undo tablespace */ + latest_space_id= mach_read_from_4( + DICT_HDR + DICT_HDR_MAX_SPACE_ID + dict_hdr->page.frame); + + if (latest_space_id + srv_undo_tablespaces > SRV_SPACE_ID_UPPER_BOUND) + { + err= DB_ERROR; + sql_print_error("InnoDB: Running out of tablespace id"); + goto func_exit; + } + + first_rseg_hdr= + buf_page_get_gen(trx_sys.rseg_array[0].page_id(), 0, RW_X_LATCH, + nullptr, BUF_GET, &mtr, &err); + if (!first_rseg_hdr) + goto func_exit; + + /* Reset TRX_SYS page */ + err= trx_sys.reset_page(&mtr); + + if (err) + goto func_exit; + + if (srv_undo_tablespaces_open == 0) + { + /* Free the system rollback segment */ + for (ulint i= 1; i < TRX_SYS_N_RSEGS; i++) + { + trx_rseg_t *rseg= &trx_sys.rseg_array[i]; + if (rseg->space != fil_system.sys_space) + continue; + buf_block_t *block= buf_page_get_gen( + rseg->page_id(), 0, RW_X_LATCH, nullptr, BUF_GET, &mtr); + if (!block) break; + while (!fseg_free_step(TRX_RSEG + TRX_RSEG_FSEG_HEADER + + block->page.frame, &mtr)); + } + } + + for (ulint rseg_id= 1; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) + { + trx_rseg_t *rseg= &trx_sys.rseg_array[rseg_id]; + rseg->destroy(); + rseg->init(nullptr, FIL_NULL); + } + + if (trx_sys.recovered_binlog_lsn +#ifdef WITH_WSREP + || !trx_sys.recovered_wsrep_xid.is_null() +#endif /* WITH_WSREP */ + ) + { + /* Update binlog offset, binlog file name & wsrep xid in + system tablespace rollback segment */ + if (trx_sys.recovered_binlog_lsn) + { + ut_d(const size_t len = strlen(trx_sys.recovered_binlog_filename) + 1); + ut_ad(len > 1); + ut_ad(len <= TRX_RSEG_BINLOG_NAME_LEN); + trx_rseg_update_binlog_offset( + first_rseg_hdr, trx_sys.recovered_binlog_filename, + trx_sys.recovered_binlog_offset, &mtr); + } + +#ifdef WITH_WSREP + if (!trx_sys.recovered_wsrep_xid.is_null()) + trx_rseg_update_wsrep_checkpoint( + first_rseg_hdr, &trx_sys.recovered_wsrep_xid, &mtr); +#endif /* WITH_WSREP */ + } + + dict_hdr->page.fix(); + + mtr.commit(); + + DBUG_EXECUTE_IF("after_rseg_reset_abort", + log_write_up_to(mtr.commit_lsn(), true); + dict_hdr->page.unfix(); + return DB_ERROR;); + + sql_print_information( + "InnoDB: Reinitializing innodb_undo_tablespaces= %u from %u", + srv_undo_tablespaces, srv_undo_tablespaces_open); + + /* Delete the old undo tablespaces */ + err= srv_undo_delete_old_tablespaces(); + if (err) + { + dict_hdr->page.unfix(); + return err; + } + + mtr.start(); + + dict_hdr->page.lock.x_lock(); + mtr.memo_push(dict_hdr, MTR_MEMO_PAGE_X_FIX); + + if (srv_undo_tablespaces == 0) + { + srv_undo_space_id_start= 0; + srv_undo_tablespaces_open= 0; + goto func_exit; + } + + srv_undo_space_id_start= latest_space_id; + if (fil_assign_new_space_id(&srv_undo_space_id_start)) + mtr.write<4>(*dict_hdr, DICT_HDR + DICT_HDR_MAX_SPACE_ID + + dict_hdr->page.frame, srv_undo_space_id_start); + + /* Re-create the new undo tablespaces */ + err= srv_undo_tablespaces_init(true, &mtr); +func_exit: + mtr.commit(); + + DBUG_EXECUTE_IF("after_reinit_undo_abort", + log_write_up_to(mtr.commit_lsn(), true); + err= DB_ERROR;); + + if (err == DB_SUCCESS) + { + /* Usually, recovery must work no matter when + log_checkpoints are triggered. This is a special case, + because this code is executed as part of InnoDB startup. + Backup requires that the server has been started up, + backup should never observe the log records that + were written in mtr and also srv_undo_tablespaces_init() + initializes the undo tablespace start id based on page0 + content before reading the redo log */ + log_make_checkpoint(); + + DBUG_EXECUTE_IF("after_reinit_undo_success", err= DB_ERROR;); + srv_undo_tablespaces_active= srv_undo_tablespaces; + } + return err; +} + +/** Reinitialize the undo tablespaces when there is no undo log +left to purge/rollback and validate the number of undo opened +undo tablespace and user given undo tablespace @return DB_SUCCESS if it is valid */ -static dberr_t srv_validate_undo_tablespaces() +static dberr_t srv_undo_tablespaces_reinitialize() { + + /* Re-create the undo tablespaces if it has no undo logs + left to purge/rollback */ + if (srv_undo_tablespaces != srv_undo_tablespaces_open && + trx_sys.is_undo_empty()) + return srv_undo_tablespaces_reinit(); + /* If the user says that there are fewer than what we find we tolerate that discrepancy but not the inverse. Because there could be unused undo tablespaces for future use. */ @@ -344,15 +579,14 @@ static dberr_t srv_validate_undo_tablespaces() return DB_ERROR; } + else if (srv_undo_tablespaces < srv_undo_tablespaces_open) + sql_print_warning("InnoDB: Cannot change innodb_undo_tablespaces=%u " + "because previous shutdown was not with " + "innodb_fast_shutdown=0", srv_undo_tablespaces); else if (srv_undo_tablespaces_open > 0) - { - ib::info() << "Opened " << srv_undo_tablespaces_open - << " undo tablespaces"; + sql_print_information("InnoDB: Opened " UINT32PF " undo tablespaces", + srv_undo_tablespaces_open); - if (srv_undo_tablespaces == 0) - ib::warn() << "innodb_undo_tablespaces=0 disables" - " dedicated undo log tablespaces"; - } return DB_SUCCESS; } @@ -539,25 +773,25 @@ srv_check_undo_redo_logs_exists() return(DB_SUCCESS); } -static dberr_t srv_all_undo_tablespaces_open(bool create_new_db, - uint32_t n_undo) +static dberr_t srv_all_undo_tablespaces_open(bool create_new_undo, + uint32_t n_undo) { /* Open all the undo tablespaces that are currently in use. If we fail to open any of these it is a fatal error. The tablespace ids should be contiguous. It is a fatal error because they are required for recovery and are referenced by the UNDO logs (a.k.a RBS). */ - uint32_t prev_id= create_new_db ? srv_undo_space_id_start - 1 : 0; + uint32_t prev_id= create_new_undo ? srv_undo_space_id_start - 1 : 0; for (uint32_t i= 0; i < n_undo; ++i) { char name[OS_FILE_MAX_PATH]; snprintf(name, sizeof name, "%s/undo%03u", srv_undo_dir, i + 1); - uint32_t space_id= srv_undo_tablespace_open(create_new_db, name, i); + uint32_t space_id= srv_undo_tablespace_open(create_new_undo, name, i); if (!space_id) { - if (!create_new_db) - break; + if (!create_new_undo) + break; ib::error() << "Unable to open create tablespace '" << name << "'."; return DB_ERROR; } @@ -583,23 +817,25 @@ static dberr_t srv_all_undo_tablespaces_open(bool create_new_db, { char name[OS_FILE_MAX_PATH]; snprintf(name, sizeof name, "%s/undo%03u", srv_undo_dir, i); - if (!srv_undo_tablespace_open(create_new_db, name, i)) + if (!srv_undo_tablespace_open(create_new_undo, name, i)) break; ++srv_undo_tablespaces_open; } - return srv_validate_undo_tablespaces(); + return DB_SUCCESS; } /** Open the configured number of dedicated undo tablespaces. -@param[in] create_new_db whether the database is being initialized +@param[in] create_new_undo whether the undo tablespaces has to be created +@param[in,out] mtr mini-transaction @return DB_SUCCESS or error code */ -dberr_t srv_undo_tablespaces_init(bool create_new_db) +dberr_t srv_undo_tablespaces_init(bool create_new_undo, mtr_t *mtr) { srv_undo_tablespaces_open= 0; + ut_ad(!create_new_undo || mtr); ut_a(srv_undo_tablespaces <= TRX_SYS_N_RSEGS); - ut_a(!create_new_db || srv_operation == SRV_OPERATION_NORMAL); + ut_a(!create_new_undo || srv_operation == SRV_OPERATION_NORMAL); if (srv_undo_tablespaces == 1) srv_undo_tablespaces= 0; @@ -607,9 +843,8 @@ dberr_t srv_undo_tablespaces_init(bool create_new_db) /* Create the undo spaces only if we are creating a new instance. We don't allow creating of new undo tablespaces in an existing instance (yet). */ - if (create_new_db) + if (create_new_undo) { - srv_undo_space_id_start= 1; DBUG_EXECUTE_IF("innodb_undo_upgrade", srv_undo_space_id_start= 3;); for (ulint i= 0; i < srv_undo_tablespaces; ++i) @@ -630,11 +865,11 @@ dberr_t srv_undo_tablespaces_init(bool create_new_db) already exist. */ srv_undo_tablespaces_active= srv_undo_tablespaces; - uint32_t n_undo= (create_new_db || srv_operation == SRV_OPERATION_BACKUP || - srv_operation == SRV_OPERATION_RESTORE_DELTA) + uint32_t n_undo= (create_new_undo || srv_operation == SRV_OPERATION_BACKUP || + srv_operation == SRV_OPERATION_RESTORE_DELTA) ? srv_undo_tablespaces : TRX_SYS_N_RSEGS; - if (dberr_t err= srv_all_undo_tablespaces_open(create_new_db, n_undo)) + if (dberr_t err= srv_all_undo_tablespaces_open(create_new_undo, n_undo)) return err; /* Initialize srv_undo_space_id_start=0 when there are no @@ -642,17 +877,13 @@ dberr_t srv_undo_tablespaces_init(bool create_new_db) if (srv_undo_tablespaces_open == 0) srv_undo_space_id_start= 0; - if (create_new_db) + if (create_new_undo) { - mtr_t mtr; for (uint32_t i= 0; i < srv_undo_tablespaces; ++i) { - mtr.start(); dberr_t err= fsp_header_init(fil_space_get(srv_undo_space_id_start + i), - SRV_UNDO_TABLESPACE_SIZE_IN_PAGES, &mtr); - mtr.commit(); - if (err) - return err; + SRV_UNDO_TABLESPACE_SIZE_IN_PAGES, mtr); + if (err) return err; } } @@ -1121,15 +1352,23 @@ dberr_t srv_start(bool create_new_db) } return srv_init_abort(err); } + + srv_undo_space_id_start= 1; } /* Open log file and data files in the systemtablespace: we keep them open until database shutdown */ ut_d(fil_system.sys_space->recv_size = srv_sys_space_size_debug); - err = fil_system.sys_space->open(create_new_db) - ? srv_undo_tablespaces_init(create_new_db) - : DB_ERROR; + if (fil_system.sys_space->open(create_new_db)) { + mtr_t mtr; + mtr.start(); + err= srv_undo_tablespaces_init(create_new_db, &mtr); + mtr.commit(); + } + else { + err= DB_ERROR; + } /* If the force recovery is set very high then we carry on regardless of all errors. Basically this is fingers crossed mode. */ @@ -1226,10 +1465,7 @@ dberr_t srv_start(bool create_new_db) /* This must precede recv_sys.apply(true). */ srv_undo_tablespaces_active = trx_rseg_get_n_undo_tablespaces(); - err = srv_validate_undo_tablespaces(); - if (err != DB_SUCCESS) { - return srv_init_abort(err); - } + if (srv_operation != SRV_OPERATION_RESTORE) { dict_sys.load_sys_tables(); } @@ -1269,8 +1505,8 @@ dberr_t srv_start(bool create_new_db) if (!srv_read_only_mode) { const uint32_t flags = FSP_FLAGS_PAGE_SSIZE(); - for (uint32_t id = 0; id <= srv_undo_tablespaces; - id++) { + for (uint32_t id = srv_undo_space_id_start; + id <= srv_undo_tablespaces; id++) { if (fil_space_t* space = fil_space_get(id)) { fsp_flags_try_adjust(space, flags); } @@ -1416,6 +1652,16 @@ dberr_t srv_start(bool create_new_db) return(srv_init_abort(DB_ERROR)); } + /* Recreate the undo tablespaces */ + if (!high_level_read_only) { + err = srv_undo_tablespaces_reinitialize(); + if (err) { + return srv_init_abort(err); + } + } + + srv_undo_tablespaces = srv_undo_tablespaces_open; + /* Here the double write buffer has already been created and so any new rollback segments will be allocated after the double write buffer. The default segment should already exist. diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 1707f2885bad8..7849ae3d6b2d5 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -306,7 +306,9 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr) /* Update the latest MySQL binlog name and offset info in rollback segment header if MySQL binlogging is on or the database server is a MySQL replication save. */ - trx_rseg_update_binlog_offset(rseg_header, trx, mtr); + trx_rseg_update_binlog_offset( + rseg_header, trx->mysql_log_file_name, + trx->mysql_log_offset, mtr); } /* Add the log as the first in the history list */ diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index 760c4e707ce52..0dc82fd21bc47 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -30,6 +30,7 @@ Created 3/26/1996 Heikki Tuuri #include "srv0srv.h" #include "trx0purge.h" #include "srv0mon.h" +#include "log.h" #ifdef WITH_WSREP # include @@ -369,7 +370,7 @@ void trx_rseg_t::destroy() void trx_rseg_t::init(fil_space_t *space, uint32_t page) { latch.SRW_LOCK_INIT(trx_rseg_latch_key); - ut_ad(!this->space); + ut_ad(!this->space || this->space != space); this->space= space; page_no= page; last_page_no= FIL_NULL; @@ -414,6 +415,7 @@ static dberr_t trx_undo_lists_init(trx_rseg_t *rseg, trx_id_t &max_trx_id, const buf_block_t *rseg_header) { ut_ad(srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN); + bool is_undo_empty= true; for (ulint i= 0; i < TRX_RSEG_N_SLOTS; i++) { @@ -424,11 +426,14 @@ static dberr_t trx_undo_lists_init(trx_rseg_t *rseg, trx_id_t &max_trx_id, max_trx_id); if (!undo) return DB_CORRUPTION; + if (is_undo_empty) + is_undo_empty= !undo->size || undo->state == TRX_UNDO_CACHED; rseg->curr_size+= undo->size; MONITOR_INC(MONITOR_NUM_UNDO_SLOT_USED); } } + trx_sys.set_undo_non_empty(!is_undo_empty); return DB_SUCCESS; } @@ -532,6 +537,7 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, trx_id_t &max_trx_id, purge_sys.purge_queue.push(*rseg); } + trx_sys.set_undo_non_empty(rseg->history_size > 0); return err; } @@ -592,10 +598,24 @@ dberr_t trx_rseg_array_init() sys, rseg_id); if (page_no != FIL_NULL) { trx_rseg_t& rseg = trx_sys.rseg_array[rseg_id]; - rseg.init(fil_space_get( - trx_sysf_rseg_get_space( - sys, rseg_id)), - page_no); + uint32_t space_id= + trx_sysf_rseg_get_space( + sys, rseg_id); + + fil_space_t *rseg_space = + fil_space_get(space_id); + if (!rseg_space) { + mtr.commit(); + err = DB_ERROR; + sql_print_error( + "InnoDB: Failed to open the undo " + "tablespace undo%03" PRIu32, + (space_id - + srv_undo_space_id_start + 1)); + break; + } + + rseg.init(rseg_space, page_no); ut_ad(rseg.is_persistent()); if ((err = trx_rseg_mem_restore( &rseg, max_trx_id, &mtr)) @@ -685,29 +705,28 @@ which corresponds to the transaction just being committed. In a replication slave, this updates the master binlog position up to which replication has proceeded. @param[in,out] rseg_header rollback segment header -@param[in] trx committing transaction +@param[in] log_file_name binlog file name +@param[in] log_offset binlog file offset @param[in,out] mtr mini-transaction */ -void trx_rseg_update_binlog_offset(buf_block_t *rseg_header, const trx_t *trx, +void trx_rseg_update_binlog_offset(buf_block_t *rseg_header, + const char *log_file_name, + ulonglong log_offset, mtr_t *mtr) { - DBUG_LOG("trx", "trx_mysql_binlog_offset: " << trx->mysql_log_offset); + DBUG_PRINT("trx", ("trx_mysql_binlog_offset %llu", log_offset)); + const size_t len= strlen(log_file_name) + 1; + ut_ad(len > 1); - const size_t len = strlen(trx->mysql_log_file_name) + 1; + if (UNIV_UNLIKELY(len > TRX_RSEG_BINLOG_NAME_LEN)) + return; - ut_ad(len > 1); + mtr->write<8,mtr_t::MAYBE_NOP>( + *rseg_header, + TRX_RSEG + TRX_RSEG_BINLOG_OFFSET + rseg_header->page.frame, + log_offset); - if (UNIV_UNLIKELY(len > TRX_RSEG_BINLOG_NAME_LEN)) { - return; - } - - mtr->write<8,mtr_t::MAYBE_NOP>(*rseg_header, - TRX_RSEG + TRX_RSEG_BINLOG_OFFSET - + rseg_header->page.frame, - trx->mysql_log_offset); + byte *name= TRX_RSEG + TRX_RSEG_BINLOG_NAME + rseg_header->page.frame; - void* name = TRX_RSEG + TRX_RSEG_BINLOG_NAME + rseg_header->page.frame; - - if (memcmp(trx->mysql_log_file_name, name, len)) { - mtr->memcpy(*rseg_header, name, trx->mysql_log_file_name, len); - } + if (memcmp(log_file_name, name, len)) + mtr->memcpy(*rseg_header, name, log_file_name, len); } diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 1113c72fcbb08..4355e11cc49fd 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -325,10 +325,9 @@ bool trx_sys_create_rsegs() /* Increase the number of active undo tablespace in case new rollback segment assigned to new undo tablespace. */ - if (space > srv_undo_tablespaces_active) { + if (space > (srv_undo_space_id_start + + srv_undo_tablespaces_active - 1)) { srv_undo_tablespaces_active++; - - ut_ad(srv_undo_tablespaces_active == space); } } diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 900039d1408c0..901c0f6a26a0d 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -725,6 +725,12 @@ dberr_t trx_lists_init_at_db_start() return err; } + if (trx_sys.is_undo_empty()) { +func_exit: + purge_sys.clone_oldest_view(); + return DB_SUCCESS; + } + /* Look from the rollback segments if there exist undo logs for transactions. */ const time_t start_time = time(NULL); @@ -785,8 +791,7 @@ dberr_t trx_lists_init_at_db_start() ib::info() << "Trx id counter is " << trx_sys.get_max_trx_id(); } - purge_sys.clone_oldest_view(); - return DB_SUCCESS; + goto func_exit; } /** Assign a persistent rollback segment in a round-robin fashion, @@ -843,8 +848,7 @@ static trx_rseg_t* trx_assign_rseg_low() ut_ad(rseg->is_persistent()); if (rseg->space != fil_system.sys_space) { - if (rseg->skip_allocation() - || !srv_undo_tablespaces) { + if (rseg->skip_allocation()) { continue; } } else if (const fil_space_t *space = From f45f60636f9b983e927ae81cf6386624e81af822 Mon Sep 17 00:00:00 2001 From: rmfalves Date: Thu, 20 Oct 2022 18:42:48 +0100 Subject: [PATCH 048/113] MDEV-22200: maridb-dump add --header option This adds a header row in txt files exported by mariadb-dump --tab Reviewed by: Daniel Black and Dan Lenski --- client/mysqldump.c | 78 +++++++++++++++-- man/mysqldump.1 | 15 ++++ mysql-test/main/mysqldump-header.result | 90 +++++++++++++++++++ mysql-test/main/mysqldump-header.test | 112 ++++++++++++++++++++++++ 4 files changed, 287 insertions(+), 8 deletions(-) create mode 100644 mysql-test/main/mysqldump-header.result create mode 100644 mysql-test/main/mysqldump-header.test diff --git a/client/mysqldump.c b/client/mysqldump.c index ca5d89bfd5868..d74e694ddcdaf 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -129,6 +129,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_no_data_m opt_include_master_host_port= 0, opt_events= 0, opt_comments_used= 0, opt_alltspcs=0, opt_notspcs= 0, opt_logging, + opt_header=0, opt_drop_trigger= 0; #define OPT_SYSTEM_ALL 1 #define OPT_SYSTEM_USERS 2 @@ -150,7 +151,7 @@ static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0, static ulong opt_max_allowed_packet, opt_net_buffer_length; static double opt_max_statement_time= 0.0; static MYSQL mysql_connection,*mysql=0; -static DYNAMIC_STRING insert_pat, select_field_names; +static DYNAMIC_STRING insert_pat, select_field_names, select_field_names_for_header; static char *opt_password=0,*current_user=0, *current_host=0,*path=0,*fields_terminated=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0, @@ -412,6 +413,8 @@ static struct my_option my_long_options[] = "output, but only commented.", &opt_use_gtid, &opt_use_gtid, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"header", 0, "Used together with --tab. When enabled, adds header with column names to the top of output txt files.", + &opt_header, &opt_header, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"hex-blob", OPT_HEXBLOB, "Dump binary strings (BINARY, " @@ -1297,6 +1300,12 @@ static int get_options(int *argc, char ***argv) "%s: You must use option --tab with --fields-...\n", my_progname_short); return(EX_USAGE); } + if (!path && opt_header) + { + fprintf(stderr, + "%s: You must use option --tab with --header\n", my_progname_short); + return(EX_USAGE); + } /* We don't delete master logs if slave data option */ if (opt_slave_data) @@ -1952,6 +1961,7 @@ static void free_resources() dynstr_free(&dynamic_where); dynstr_free(&insert_pat); dynstr_free(&select_field_names); + dynstr_free(&select_field_names_for_header); if (defaults_argv) free_defaults(defaults_argv); mysql_library_end(); @@ -2092,7 +2102,7 @@ static my_bool test_if_special_chars(const char *str) /* - quote_name(name, buff, force) + quote(name, buff, force, quote_c) Quotes a string, if it requires quoting. To force quoting regardless of the characters within the string, the force flag can be set to true. @@ -2102,16 +2112,17 @@ static my_bool test_if_special_chars(const char *str) name Unquoted string containing that which will be quoted buff The buffer that contains the quoted value, also returned force Flag to make it ignore 'test_if_special_chars' + quote_c Charater to use as the enclosing quote Returns A pointer to the quoted string, or the original string if nothing has changed. */ -static char *quote_name(const char *name, char *buff, my_bool force) +static char *quote(const char *name, char *buff, my_bool force, char quote_c) { char *to= buff; - char qtype= (opt_compatible_mode & MASK_ANSI_QUOTES) ? '\"' : '`'; + char qtype= (opt_compatible_mode & MASK_ANSI_QUOTES) ? '\"' : quote_c; if (!force && !opt_quoted && !test_if_special_chars(name)) return (char*) name; @@ -2125,7 +2136,29 @@ static char *quote_name(const char *name, char *buff, my_bool force) to[0]= qtype; to[1]= 0; return buff; -} /* quote_name */ +} /* quote */ + + +/* + quote_name(name, buff, force) + + quote() with the ` character +*/ +static char *quote_name(const char *name, char *buff, my_bool force) +{ + return quote(name, buff, force, '`'); +} + + +/* + quote_string(name, buff, force) + + quote() with the ' character +*/ +static char *quote_string(const char *name, char *buff) +{ + return quote(name, buff, 0, '\''); +} /* @@ -3126,9 +3159,15 @@ static uint get_table_structure(const char *table, const char *db, char *table_t { select_field_names_inited= 1; init_dynamic_string_checked(&select_field_names, "", 1024, 1024); + if (opt_header) + init_dynamic_string_checked(&select_field_names_for_header, "", 1024, 1024); } else + { dynstr_set_checked(&select_field_names, ""); + if (opt_header) + dynstr_set_checked(&select_field_names_for_header, ""); + } insert_option= ((delayed && opt_ignore) ? " DELAYED IGNORE " : delayed ? " DELAYED " : opt_ignore ? " IGNORE " : ""); @@ -3382,10 +3421,15 @@ static uint get_table_structure(const char *table, const char *db, char *table_t if (init) { dynstr_append_checked(&select_field_names, ", "); + if (opt_header) + dynstr_append_checked(&select_field_names_for_header, ", "); } init=1; dynstr_append_checked(&select_field_names, quote_name(row[SHOW_FIELDNAME], name_buff, 0)); + if (opt_header) + dynstr_append_checked(&select_field_names_for_header, + quote_string(row[SHOW_FIELDNAME], name_buff)); } init=0; /* @@ -3482,9 +3526,15 @@ static uint get_table_structure(const char *table, const char *db, char *table_t if (init) { dynstr_append_checked(&select_field_names, ", "); + if (opt_header) + dynstr_append_checked(&select_field_names_for_header, ", "); + } dynstr_append_checked(&select_field_names, quote_name(row[SHOW_FIELDNAME], name_buff, 0)); + if (opt_header) + dynstr_append_checked(&select_field_names_for_header, + quote_string(row[SHOW_FIELDNAME], name_buff)); init=1; } init=0; @@ -4132,7 +4182,6 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, if (path) { char filename[FN_REFLEN], tmp_path[FN_REFLEN]; - /* Convert the path to native os format and resolve to the full filepath. @@ -4163,15 +4212,23 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, if (fields_terminated || enclosed || opt_enclosed || escaped) dynstr_append_checked(&query_string, " FIELDS"); - + add_load_option(&query_string, " TERMINATED BY ", fields_terminated); add_load_option(&query_string, " ENCLOSED BY ", enclosed); add_load_option(&query_string, " OPTIONALLY ENCLOSED BY ", opt_enclosed); add_load_option(&query_string, " ESCAPED BY ", escaped); add_load_option(&query_string, " LINES TERMINATED BY ", lines_terminated); + if (opt_header) + { + dynstr_append_checked(&query_string, " FROM (SELECT 0 AS `_$is_data_row$_`,"); + dynstr_append_checked(&query_string, select_field_names_for_header.str); + dynstr_append_checked(&query_string, " UNION ALL SELECT 1 AS `_$is_data_row$_`,"); + dynstr_append_checked(&query_string, select_field_names.str); + } dynstr_append_checked(&query_string, " FROM "); dynstr_append_checked(&query_string, result_table); + if (versioned) vers_append_system_time(&query_string); @@ -4180,10 +4237,15 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, dynstr_append_checked(&query_string, " WHERE "); dynstr_append_checked(&query_string, where); } + if (opt_header) + dynstr_append_checked(&query_string, ") s ORDER BY `_$is_data_row$_`"); if (order_by) { - dynstr_append_checked(&query_string, " ORDER BY "); + if (opt_header) + dynstr_append_checked(&query_string, ","); + else + dynstr_append_checked(&query_string, " ORDER BY "); dynstr_append_checked(&query_string, order_by); my_free(order_by); order_by= 0; diff --git a/man/mysqldump.1 b/man/mysqldump.1 index 04efe7e4de7ed..9bb6fdadca11c 100644 --- a/man/mysqldump.1 +++ b/man/mysqldump.1 @@ -1003,6 +1003,21 @@ Available from MariaDB 10.0.13, and is used together with \fB\-\-master\-data\fR .sp -1 .IP \(bu 2.3 .\} +.\" mysqldump: header option +.\" header option: mysqldump +\fB\-\-header\fR +.sp +Used together with --tab. When enabled, adds header with column names to the top of output txt files. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} .\" mysqldump: hex-blob option .\" hex-blob option: mysqldump \fB\-\-hex\-blob\fR diff --git a/mysql-test/main/mysqldump-header.result b/mysql-test/main/mysqldump-header.result new file mode 100644 index 0000000000000..6b59b062f35ad --- /dev/null +++ b/mysql-test/main/mysqldump-header.result @@ -0,0 +1,90 @@ +CREATE TABLE `courses` ( +`course_id` smallint(20) PRIMARY KEY, +`name` varchar(50), +`description` varchar(100), +`num_years` tinyint(1), +`escape_çÇÁá!#%"'` varchar(10) +); +desc courses; +Field Type Null Key Default Extra +course_id smallint(20) NO PRI NULL +name varchar(50) YES NULL +description varchar(100) YES NULL +num_years tinyint(1) YES NULL +escape_çÇÁá!#%"' varchar(10) YES NULL +INSERT INTO `courses` VALUES (5, 'Course 1', 'Course Description 1', 3, NULL); +# +# Dump only data rows into outfile with default options +# +5 Course 1 Course Description 1 3 \N +# +# Dump header and data rows into outfile with default options +# +course_id name description num_years escape_çÇÁá!#%"' +5 Course 1 Course Description 1 3 \N +# +# Dump header and data rows into outfile with comma delimited fields +# +course_id,name,description,num_years,escape_çÇÁá!#%"' +5,Course 1,Course Description 1,3,\N +# +# Dump header and data rows into outfile with single quote enclosed fields +# +'course_id' 'name' 'description' 'num_years' 'escape_çÇÁá!#%"\'' +'5' 'Course 1' 'Course Description 1' '3' \N +# +# Dump header and data rows into outfile with optional single quote enclosed fields +# +'course_id' 'name' 'description' 'num_years' 'escape_çÇÁá!#%"\'' +'5' 'Course 1' 'Course Description 1' '3' \N +# +# Dump header and data rows into outfile with semicolon terminated data rows +# +course_id name description num_years escape_çÇÁá!#%"';5 Course 1 Course Description 1 3 \N; +# +# Dump header and data rows into outfile with several options above combined +# +'course_id','name','description','num_years','escape_çÇÁá!#%"\'';'5','Course 1','Course Description 1','3',\N; +'course_id','name','description','num_years','escape_çÇÁá!#%"\'';'5','Course 1','Course Description 1','3',\N;INSERT INTO `courses` VALUES (4, 'Course 2', 'Course Description 2', 4, NULL); +INSERT INTO `courses` VALUES (3, 'Course 3', 'Course Description 3', 3, NULL); +INSERT INTO `courses` VALUES (2, 'Course 4', 'Course Description 4', 5, NULL); +INSERT INTO `courses` VALUES (1, 'Course 5', 'Course Description 5', 3, NULL); + +# +# Dump data rows into outfile with --where clause +# +2 Course 4 Course Description 4 5 \N +# +# Dump header and data rows into outfile with --where clause. The header must remain on top and not meddle among data rows +# +course_id name description num_years escape_çÇÁá!#%"' +2 Course 4 Course Description 4 5 \N +# +# Dump data rows ordered by primary key. +# +1 Course 5 Course Description 5 3 \N +2 Course 4 Course Description 4 5 \N +3 Course 3 Course Description 3 3 \N +4 Course 2 Course Description 2 4 \N +5 Course 1 Course Description 1 3 \N +# +# Dump header and data rows ordered by primary key. The header must remain on top and not meddle among data rows +# +course_id name description num_years escape_çÇÁá!#%"' +1 Course 5 Course Description 5 3 \N +2 Course 4 Course Description 4 5 \N +3 Course 3 Course Description 3 3 \N +4 Course 2 Course Description 2 4 \N +5 Course 1 Course Description 1 3 \N +# +# Dump data rows from an empty table, must generate no output +# +DELETE FROM `courses`; +# +# Dump header and data rows from an empty table, must generate a single header line as output +# +course_id name description num_years escape_çÇÁá!#%"' +# +# Use header without the --tab option. Must produce an error +# +DROP TABLE `courses`; diff --git a/mysql-test/main/mysqldump-header.test b/mysql-test/main/mysqldump-header.test new file mode 100644 index 0000000000000..7c59fee611503 --- /dev/null +++ b/mysql-test/main/mysqldump-header.test @@ -0,0 +1,112 @@ +--source include/not_embedded.inc + +CREATE TABLE `courses` ( + `course_id` smallint(20) PRIMARY KEY, + `name` varchar(50), + `description` varchar(100), + `num_years` tinyint(1), + `escape_çÇÁá!#%"'` varchar(10) +); + +desc courses; + +INSERT INTO `courses` VALUES (5, 'Course 1', 'Course Description 1', 3, NULL); + +--echo # +--echo # Dump only data rows into outfile with default options +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump header and data rows into outfile with default options +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump header and data rows into outfile with comma delimited fields +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-terminated-by , test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump header and data rows into outfile with single quote enclosed fields +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-enclosed-by \' test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump header and data rows into outfile with optional single quote enclosed fields +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-optionally-enclosed-by \' test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump header and data rows into outfile with semicolon terminated data rows +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --lines-terminated-by \; test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo +--echo # +--echo # Dump header and data rows into outfile with several options above combined +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-terminated-by , --fields-enclosed-by \' --lines-terminated-by \; test +--cat_file $MYSQLTEST_VARDIR/courses.txt +--echo +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-terminated-by , --fields-optionally-enclosed-by \' --lines-terminated-by \; test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +INSERT INTO `courses` VALUES (4, 'Course 2', 'Course Description 2', 4, NULL); +INSERT INTO `courses` VALUES (3, 'Course 3', 'Course Description 3', 3, NULL); +INSERT INTO `courses` VALUES (2, 'Course 4', 'Course Description 4', 5, NULL); +INSERT INTO `courses` VALUES (1, 'Course 5', 'Course Description 5', 3, NULL); + +--echo +--echo # +--echo # Dump data rows into outfile with --where clause +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --where "num_years=5" test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump header and data rows into outfile with --where clause. The header must remain on top and not meddle among data rows +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --where "num_years=5" --header test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump data rows ordered by primary key. +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --order-by-primary test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump header and data rows ordered by primary key. The header must remain on top and not meddle among data rows +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --order-by-primary --header test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump data rows from an empty table, must generate no output +--echo # +DELETE FROM `courses`; +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Dump header and data rows from an empty table, must generate a single header line as output +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # Use header without the --tab option. Must produce an error +--echo # +--error 1 +--exec $MYSQL_DUMP -u root --header test + +DROP TABLE `courses`; +--remove_file $MYSQLTEST_VARDIR/courses.txt +--remove_file $MYSQLTEST_VARDIR/courses.sql From ad7631bdce1c25afa8de32d2062cb27bfaf539da Mon Sep 17 00:00:00 2001 From: Luis Eduardo Oliveira Lizardo <108760288+mariadb-LuisLizardo@users.noreply.github.com> Date: Mon, 18 Jul 2022 17:48:01 +0200 Subject: [PATCH 049/113] MDEV-28926 Add time spent on query optimizer to JSON ANALYZE (#2193) * Add query optimizer timer to ANALYZE FORMAT=JSON * Adapt tests and results * Change logic to always close the writer after printing query blocks --- mysql-test/main/analyze_format_json.result | 57 +++++++++++++++ mysql-test/main/analyze_stmt_orderby.result | 27 +++++++ mysql-test/main/cte_recursive.result | 12 ++++ mysql-test/main/derived_cond_pushdown.result | 3 + mysql-test/main/except.result | 12 ++++ mysql-test/main/except_all.result | 12 ++++ mysql-test/main/explain_json.result | 18 +++++ mysql-test/main/explain_json.test | 1 + .../explain_json_format_partitions.result | 9 +++ mysql-test/main/intersect.result | 12 ++++ mysql-test/main/intersect_all.result | 12 ++++ mysql-test/main/order_by.result | 21 ++++++ mysql-test/main/order_by_pack_big.result | 12 ++++ mysql-test/main/rowid_filter.result | 42 +++++++++++ mysql-test/main/rowid_filter_innodb.result | 45 ++++++++++++ mysql-test/main/show_analyze.result | 3 + mysql-test/main/show_analyze_json.result | 66 +++++++++++++++++ mysql-test/main/subselect4.result | 3 + mysql-test/main/subselect_cache.result | 6 ++ mysql-test/main/table_value_constr.result | 27 +++++++ mysql-test/main/table_value_constr.test | 9 +++ mysql-test/main/win.result | 3 + .../compat/oracle/r/table_value_constr.result | 27 +++++++ .../compat/oracle/t/table_value_constr.test | 9 +++ .../encryption/r/tempfiles_encrypted.result | 3 + .../federatedx_create_handlers.result | 6 ++ sql/sql_explain.cc | 71 ++++++++++++++----- sql/sql_explain.h | 6 ++ 28 files changed, 518 insertions(+), 16 deletions(-) diff --git a/mysql-test/main/analyze_format_json.result b/mysql-test/main/analyze_format_json.result index 6c9b8ce298293..9a756782f96f5 100644 --- a/mysql-test/main/analyze_format_json.result +++ b/mysql-test/main/analyze_format_json.result @@ -5,6 +5,9 @@ INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); analyze format=json select * from t0 where a<3; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -38,6 +41,9 @@ analyze format=json select * from t0, t1 where t1.a=t0.a and t0.a > 9; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -85,6 +91,9 @@ analyze format=json select * from t0, t1 where t1.a=t0.a and t1.b<4; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -135,6 +144,9 @@ analyze format=json select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -181,6 +193,9 @@ analyze format=json select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60 and tbl1.c > tbl2.c; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -236,6 +251,9 @@ insert into t2 values (0),(1); analyze format=json select * from t1 straight_join t2 force index(a) where t2.a=t1.a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -294,6 +312,9 @@ NULL analyze format=json select * from test.t1 where t1.a<5; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -334,6 +355,9 @@ analyze format=json update t1 set b=pk; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_total_time_ms": "REPLACED", @@ -352,6 +376,9 @@ analyze format=json select * from t1 where pk < 10 and b > 4; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -383,6 +410,9 @@ analyze format=json delete from t1 where pk < 10 and b > 4; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_total_time_ms": "REPLACED", @@ -426,6 +456,9 @@ select * from t1, t2 where (t2.key1 between t1.lb1 and t1.rb1) and (t2.key3=t1.c1 OR t2.key4=t1.c2); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -485,6 +518,9 @@ INSERT INTO t1 select * from t0; analyze format=json (select * from t1 tbl1 where a<5) union (select * from t1 tbl2 where a in (2,3)); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -561,6 +597,9 @@ insert into t2 select A.a*1000 + B.a, A.a*1000 + B.a from t0 A, t1 B; analyze format=json select a, max(b) as TOP from t2 group by a having TOP > a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -598,6 +637,9 @@ ANALYZE analyze format=json select a, max(b) as TOP from t2 group by a having 1<>2; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -634,6 +676,9 @@ ANALYZE analyze format=json select a, max(b) as TOP from t2 group by a having 1=2; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "table": { @@ -645,6 +690,9 @@ ANALYZE analyze format=json select a, max(b) as TOP from t2 group by a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -688,6 +736,9 @@ INSERT INTO t2 VALUES (3),(4); ANALYZE FORMAT=JSON SELECT STRAIGHT_JOIN * FROM t1, t2 WHERE b IN ( SELECT a FROM t1 ); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -771,6 +822,9 @@ WHERE f3 IN ( 1, 2 ) GROUP BY sq ORDER BY gc; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -888,6 +942,9 @@ create table t2 as select * from t1; analyze format=json select a, (select t2.b from t2 where t2.a 0 and t5.a <= 5 group by t5.a order by sum limit 1; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -635,6 +659,9 @@ analyze format=json select col1 f1, col2 f2, col1 f3 from t2 group by f1; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index 10da4b21763d4..5cc12aac77f42 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -2455,6 +2455,9 @@ select counter+1 from src where counter<10 ) select * from src; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -3861,6 +3864,9 @@ where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2' select a2 from cte); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -4120,6 +4126,9 @@ select t1.* from t1, r_cte as r where t1.c = r.a ) select 0 as b FROM dual union all select b FROM r_cte as t; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "query_specifications": [ @@ -4285,6 +4294,9 @@ select 0 as b FROM dual union all select b FROM r_cte as t) select * from t1 as tt; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 9bbd32a9c8444..e07f2550297db 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -19643,6 +19643,9 @@ CREATE VIEW v1 AS SELECT a FROM t1 UNION VALUES (3),(4); ANALYZE FORMAT=JSON SELECT * from v1 WHERE a=3; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result index 3dc4e1c94706b..d83623370d5a3 100644 --- a/mysql-test/main/except.result +++ b/mysql-test/main/except.result @@ -72,6 +72,9 @@ EXPLAIN ANALYZE format=json (select a,b from t1) except (select c,d from t2); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -131,6 +134,9 @@ ANALYZE ANALYZE format=json select * from ((select a,b from t1) except (select c,d from t2)) a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -336,6 +342,9 @@ EXPLAIN ANALYZE format=json (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -434,6 +443,9 @@ ANALYZE format=json select * from ((select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4)) a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/except_all.result b/mysql-test/main/except_all.result index ac032221cc583..df19abda07781 100644 --- a/mysql-test/main/except_all.result +++ b/mysql-test/main/except_all.result @@ -115,6 +115,9 @@ Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from ((/* select#2 ANALYZE format=json select * from ((select a,b from t1) except all (select c,d from t2)) a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -196,6 +199,9 @@ ANALYZE ANALYZE format=json select * from ((select a from t1) except all (select c from t2)) a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -463,6 +469,9 @@ EXPLAIN ANALYZE format=json (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -560,6 +569,9 @@ ANALYZE ANALYZE format=json select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index cf1aa172146bc..3c3c0688ab8b7 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -1148,6 +1148,9 @@ EXPLAIN analyze format=json select count(distinct b) from t1 group by a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1446,6 +1449,9 @@ analyze format=json select * from t1; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "table": { @@ -1497,6 +1503,9 @@ analyze format=json select * from t1 left join t2 on t2.pk > 10 and t2.pk < 0; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1576,6 +1585,9 @@ analyze format=json select * from t1 left join t2 on t2.pk=t1.a where t2.pk is null; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1664,6 +1676,9 @@ analyze format=json select distinct t1.a from t1 join t2 on t2.pk=t1.a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1770,6 +1785,9 @@ analyze format=json select * from t3,t4 where t3.a=t4.a and (t4.b+1 <= t3.b+1); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/explain_json.test b/mysql-test/main/explain_json.test index 07e4ec09ad4d2..17e2da4754c60 100644 --- a/mysql-test/main/explain_json.test +++ b/mysql-test/main/explain_json.test @@ -329,6 +329,7 @@ explain select * from t1; explain format=json select * from t1; +--source include/analyze-format.inc analyze format=json select * from t1; drop table t1; diff --git a/mysql-test/main/explain_json_format_partitions.result b/mysql-test/main/explain_json_format_partitions.result index f164006d75648..b76fe29625e23 100644 --- a/mysql-test/main/explain_json_format_partitions.result +++ b/mysql-test/main/explain_json_format_partitions.result @@ -29,6 +29,9 @@ EXPLAIN analyze format=json select * from t1 where a in (2,3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -55,6 +58,9 @@ ANALYZE analyze format=json update t1 set a=a+10 where a in (2,3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_total_time_ms": "REPLACED", @@ -76,6 +82,9 @@ ANALYZE analyze format=json delete from t1 where a in (20,30,40); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_total_time_ms": "REPLACED", diff --git a/mysql-test/main/intersect.result b/mysql-test/main/intersect.result index c7858b49cd445..425f6940a354c 100644 --- a/mysql-test/main/intersect.result +++ b/mysql-test/main/intersect.result @@ -102,6 +102,9 @@ EXPLAIN ANALYZE format=json (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -184,6 +187,9 @@ ANALYZE ANALYZE format=json select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -388,6 +394,9 @@ EXPLAIN ANALYZE format=json (select a,b from t1) intersect (select c,e from t2,t3); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -466,6 +475,9 @@ ANALYZE ANALYZE format=json select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/intersect_all.result b/mysql-test/main/intersect_all.result index 6c7a9c1cdd26a..aecd5b1ac18ad 100644 --- a/mysql-test/main/intersect_all.result +++ b/mysql-test/main/intersect_all.result @@ -114,6 +114,9 @@ EXPLAIN ANALYZE format=json (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -196,6 +199,9 @@ ANALYZE ANALYZE format=json select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -419,6 +425,9 @@ EXPLAIN ANALYZE format=json (select a,b from t1) intersect all (select c,e from t2,t3); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -497,6 +506,9 @@ ANALYZE ANALYZE format=json select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index b6345cd142e4d..1311f42dac21f 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -3396,6 +3396,9 @@ INSERT INTO t1 SELECT seq,seq from seq_1_to_100; ANALYZE FORMAT=JSON SELECT * FROM t1 ORDER BY a LIMIT 5; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -3750,6 +3753,9 @@ insert into t1 select seq, seq, seq from seq_1_to_100; ANALYZE FORMAT=JSON select * from t1 order by a,b,c; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -3913,6 +3919,9 @@ analyze format=json select a, substr(b, @save_max_sort_length+1) from t1 order by b desc; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -3959,6 +3968,9 @@ insert into t1 values ('def', 4, 4) , ('efg', 5, 5), ('fgh', 6, 6); ANALYZE FORMAT=JSON select a, b, c from t1 order by a, b; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -4011,6 +4023,9 @@ Warning 1292 Truncated incorrect max_sort_length value: '5' ANALYZE FORMAT=JSON select a, b, c from t1 order by a, b; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -4077,6 +4092,9 @@ a b analyze format=json select * from t1 order by a; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -4256,6 +4274,9 @@ ANALYZE FORMAT=JSON SELECT (SELECT sum(t2.b) FROM t2 WHERE t1.b=t2.b GROUP BY t2.a) FROM t1; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/order_by_pack_big.result b/mysql-test/main/order_by_pack_big.result index e34b1a4a90a4a..6b33d7d820288 100644 --- a/mysql-test/main/order_by_pack_big.result +++ b/mysql-test/main/order_by_pack_big.result @@ -89,6 +89,9 @@ FROM t3 GROUP BY x; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -250,6 +253,9 @@ FROM t3 GROUP BY x; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -409,6 +415,9 @@ set sort_buffer_size= 2097152; ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -462,6 +471,9 @@ set sort_buffer_size= 1097152; ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index 47961ab6c9d33..3b8c726943564 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -113,6 +113,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -256,6 +259,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -419,6 +425,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -561,6 +570,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -713,6 +725,9 @@ l_quantity > 45 AND o_totalprice between 180000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -881,6 +896,9 @@ l_quantity > 45 AND o_totalprice between 180000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1027,6 +1045,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1195,6 +1216,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1368,6 +1392,9 @@ l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND o_totalprice BETWEEN 200000 AND 250000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1502,6 +1529,9 @@ l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND o_totalprice BETWEEN 200000 AND 250000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1642,6 +1672,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1777,6 +1810,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1920,6 +1956,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -2065,6 +2104,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index d6ba961072a1d..5838dba434a46 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -116,6 +116,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -259,6 +262,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -415,6 +421,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -547,6 +556,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND o_totalprice between 200000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -692,6 +704,9 @@ l_quantity > 45 AND o_totalprice between 180000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -848,6 +863,9 @@ l_quantity > 45 AND o_totalprice between 180000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -987,6 +1005,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1145,6 +1166,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND o_totalprice between 200000 and 230000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1319,6 +1343,9 @@ l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND o_totalprice BETWEEN 200000 AND 250000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1453,6 +1480,9 @@ l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND o_totalprice BETWEEN 200000 AND 250000; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1593,6 +1623,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1728,6 +1761,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1871,6 +1907,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -2016,6 +2055,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -3052,6 +3094,9 @@ fi.fh in (6311439873746261694,-397087483897438286, 8518228073041491534,-5420422472375069774); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/show_analyze.result b/mysql-test/main/show_analyze.result index 56dac487117b9..5595fadd60b89 100644 --- a/mysql-test/main/show_analyze.result +++ b/mysql-test/main/show_analyze.result @@ -400,6 +400,9 @@ ANALYZE format=json SELECT 1 FROM t1 GROUP BY convert_tz('1969-12-31 22:00:00',a,'+10:00'); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/show_analyze_json.result b/mysql-test/main/show_analyze_json.result index dc8ae2aa66b5e..8506c4b94027b 100644 --- a/mysql-test/main/show_analyze_json.result +++ b/mysql-test/main/show_analyze_json.result @@ -39,6 +39,9 @@ show analyze format=JSON for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -69,6 +72,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -100,6 +106,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -138,6 +147,9 @@ show analyze FORMAT= json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -204,6 +216,9 @@ show analyze format=JSON for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -271,6 +286,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -340,6 +358,9 @@ show analyze FORMAT=JSON for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -415,6 +436,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -472,6 +496,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -535,6 +562,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "nested_loop": [ @@ -594,6 +624,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -655,6 +688,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -737,6 +773,9 @@ show analyze FORMAT=JSON for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "table": { @@ -777,6 +816,9 @@ show analyze FORMAT=JSON for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "table": { @@ -829,6 +871,9 @@ show analyze FORMAT=JSON for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "table": { @@ -869,6 +914,9 @@ show analyze FORMAT=JSON for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "table": { @@ -921,6 +969,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -970,6 +1021,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1020,6 +1074,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1084,6 +1141,9 @@ show analyze format=JSON for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1140,6 +1200,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -1186,6 +1249,9 @@ show analyze format=json for $thr2; SHOW ANALYZE { "r_query_time_in_progress_ms": "REPLACED", + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index d00f7ccd69024..5589272d066ce 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -2917,6 +2917,9 @@ SELECT DISTINCT FROM t1; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/subselect_cache.result b/mysql-test/main/subselect_cache.result index e859ebbd2e8ee..5c2fd3e66fcd5 100644 --- a/mysql-test/main/subselect_cache.result +++ b/mysql-test/main/subselect_cache.result @@ -44,6 +44,9 @@ analyze format=json select a, (select d from t2 where b=c) from t1; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, @@ -98,6 +101,9 @@ analyze format=json select a, (select d from t2 where b=c), (select d from t2 where b=c union select 1 order by 1 limit 1) from t1; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result index b90b5c86c15e8..e6d973d53eec1 100644 --- a/mysql-test/main/table_value_constr.result +++ b/mysql-test/main/table_value_constr.result @@ -1667,6 +1667,9 @@ analyze format=json values (1,2); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "query_specifications": [ @@ -1713,6 +1716,9 @@ union values (1,2),(3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1747,6 +1753,9 @@ union select 1,2; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1781,6 +1790,9 @@ union values (1,2),(3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1828,6 +1840,9 @@ union values (1,2); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1894,6 +1909,9 @@ union all select 1,2; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "query_specifications": [ @@ -1924,6 +1942,9 @@ union values (1,2),(3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1958,6 +1979,9 @@ union all values (1,2),(3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "query_specifications": [ @@ -2000,6 +2024,9 @@ union all values (1,2); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "query_specifications": [ diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test index 07197329e1064..331cfb8b7db10 100644 --- a/mysql-test/main/table_value_constr.test +++ b/mysql-test/main/table_value_constr.test @@ -932,6 +932,7 @@ values (1,2); analyze values (1,2); +--source include/analyze-format.inc analyze format=json values (1,2); @@ -952,16 +953,19 @@ values (5,6) union values (1,2),(3,4); +--source include/analyze-format.inc analyze format=json select 1,2 union values (1,2),(3,4); +--source include/analyze-format.inc analyze format=json values (1,2),(3,4) union select 1,2; +--source include/analyze-format.inc analyze format=json values (5,6) union @@ -974,6 +978,7 @@ values (3,4) union values (1,2); +--source include/analyze-format.inc analyze format=json select 1,2 union @@ -998,16 +1003,19 @@ values (1,2) union all values (1,2),(3,4); +--source include/analyze-format.inc analyze format=json values (1,2),(3,4) union all select 1,2; +--source include/analyze-format.inc analyze format=json select 1,2 union values (1,2),(3,4); +--source include/analyze-format.inc analyze format=json values (1,2) union all @@ -1020,6 +1028,7 @@ values (3,4) union all values (1,2); +--source include/analyze-format.inc analyze format=json select 1,2 union all diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index ffdec0140e867..08e6c62c8436b 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -3822,6 +3822,9 @@ INSERT INTO t1 VALUES (1,1),(2,2),(3,3); ANALYZE FORMAT=JSON SELECT row_number() OVER() FROM t1; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/suite/compat/oracle/r/table_value_constr.result b/mysql-test/suite/compat/oracle/r/table_value_constr.result index 365edaa7757d8..af071433d0f03 100644 --- a/mysql-test/suite/compat/oracle/r/table_value_constr.result +++ b/mysql-test/suite/compat/oracle/r/table_value_constr.result @@ -1665,6 +1665,9 @@ analyze format=json values (1,2); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "query_specifications": [ @@ -1711,6 +1714,9 @@ union values (1,2),(3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1745,6 +1751,9 @@ union select 1,2; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1779,6 +1788,9 @@ union values (1,2),(3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1826,6 +1838,9 @@ union values (1,2); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1892,6 +1907,9 @@ union all select 1,2; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "query_specifications": [ @@ -1922,6 +1940,9 @@ union values (1,2),(3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "table_name": "", @@ -1956,6 +1977,9 @@ union all values (1,2),(3,4); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "query_specifications": [ @@ -1998,6 +2022,9 @@ union all values (1,2); ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "union_result": { "query_specifications": [ diff --git a/mysql-test/suite/compat/oracle/t/table_value_constr.test b/mysql-test/suite/compat/oracle/t/table_value_constr.test index 4e0dcc0551491..ca3c40bb7f933 100644 --- a/mysql-test/suite/compat/oracle/t/table_value_constr.test +++ b/mysql-test/suite/compat/oracle/t/table_value_constr.test @@ -934,6 +934,7 @@ values (1,2); analyze values (1,2); +--source include/analyze-format.inc analyze format=json values (1,2); @@ -954,16 +955,19 @@ values (5,6) union values (1,2),(3,4); +--source include/analyze-format.inc analyze format=json select 1,2 union values (1,2),(3,4); +--source include/analyze-format.inc analyze format=json values (1,2),(3,4) union select 1,2; +--source include/analyze-format.inc analyze format=json values (5,6) union @@ -976,6 +980,7 @@ values (3,4) union values (1,2); +--source include/analyze-format.inc analyze format=json select 1,2 union @@ -1000,16 +1005,19 @@ values (1,2) union all values (1,2),(3,4); +--source include/analyze-format.inc analyze format=json values (1,2),(3,4) union all select 1,2; +--source include/analyze-format.inc analyze format=json select 1,2 union values (1,2),(3,4); +--source include/analyze-format.inc analyze format=json values (1,2) union all @@ -1022,6 +1030,7 @@ values (3,4) union all values (1,2); +--source include/analyze-format.inc analyze format=json select 1,2 union all diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index 0bcbfffad2ad4..e6cd4d697d028 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -3828,6 +3828,9 @@ INSERT INTO t1 VALUES (1,1),(2,2),(3,3); ANALYZE FORMAT=JSON SELECT row_number() OVER() FROM t1; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 6dcd53e77c721..8a82df0ddfcbc 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -117,6 +117,9 @@ ANALYZE FORMAT=JSON SELECT id FROM federated.t1 WHERE id < 5; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "table": { @@ -223,6 +226,9 @@ FROM federated.t2 GROUP BY name)) t WHERE federated.t3.name=t.name; ANALYZE { + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, "query_block": { "select_id": 1, "r_loops": 1, diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 7c3918bfd20b3..ede486fc29781 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -44,9 +44,10 @@ static void append_item_to_str(String *out, Item *item, bool no_tmp_tbl); Explain_query::Explain_query(THD *thd_arg, MEM_ROOT *root) : mem_root(root), upd_del_plan(nullptr), insert_plan(nullptr), - unions(root), selects(root), stmt_thd(thd_arg), apc_enabled(false), + unions(root), selects(root), stmt_thd(thd_arg), apc_enabled(false), operations(0) { + optimization_time_tracker.start_tracking(stmt_thd); } static void print_json_array(Json_writer *writer, @@ -154,6 +155,8 @@ void Explain_query::add_upd_del_plan(Explain_update *upd_del_plan_arg) void Explain_query::query_plan_ready() { + optimization_time_tracker.stop_tracking(stmt_thd); + if (!apc_enabled) stmt_thd->apc_target.enable(); apc_enabled= true; @@ -256,44 +259,80 @@ int Explain_query::print_explain_json(select_result_sink *output, #endif writer.start_object(); - if (is_analyze && query_time_in_progress_ms > 0) - writer.add_member("r_query_time_in_progress_ms"). - add_ull(query_time_in_progress_ms); - + /* If we are printing ANALYZE FORMAT=JSON output, take into account that query's temporary tables have already been freed. See sql_explain.h, sql_explain.h:ExplainDataStructureLifetime for details. */ if (is_analyze) - is_show_cmd= true; + { + if (query_time_in_progress_ms > 0){ + writer.add_member("r_query_time_in_progress_ms"). + add_ull(query_time_in_progress_ms); + } + + print_query_optimization_json(&writer); + is_show_cmd = true; + } + + bool plan_found = print_query_blocks_json(&writer, is_analyze, is_show_cmd); + + writer.end_object(); + + if( plan_found ) + { + send_explain_json_to_output(&writer, output); + } + + return 0; +} +void Explain_query::print_query_optimization_json(Json_writer *writer) +{ + if (optimization_time_tracker.has_timed_statistics()) + { + // if more timers are added, move the query_optimization member + // outside the if statement + writer->add_member("query_optimization").start_object(); + writer->add_member("r_total_time_ms"). + add_double(optimization_time_tracker.get_time_ms()); + writer->end_object(); + } +} + +bool Explain_query::print_query_blocks_json(Json_writer *writer, + const bool is_analyze, + const bool is_show_cmd) +{ if (upd_del_plan) - upd_del_plan->print_explain_json(this, &writer, is_analyze, is_show_cmd); + upd_del_plan->print_explain_json(this, writer, is_analyze, is_show_cmd); else if (insert_plan) - insert_plan->print_explain_json(this, &writer, is_analyze, is_show_cmd); + insert_plan->print_explain_json(this, writer, is_analyze, is_show_cmd); else { - /* Start printing from node with id=1 */ + /* Start printing from root node with id=1 */ Explain_node *node= get_node(1); if (!node) - return 1; /* No query plan */ - node->print_explain_json(this, &writer, is_analyze, is_show_cmd); + return false; /* No query plan */ + node->print_explain_json(this, writer, is_analyze, is_show_cmd); } - writer.end_object(); + return true; +} +void Explain_query::send_explain_json_to_output(Json_writer *writer, + select_result_sink *output) +{ CHARSET_INFO *cs= system_charset_info; List item_list; - const String *buf= writer.output.get_string(); + const String *buf= writer->output.get_string(); THD *thd= output->thd; item_list.push_back(new (thd->mem_root) Item_string(thd, buf->ptr(), buf->length(), cs), thd->mem_root); output->send_data(item_list); - return 0; -} - +} bool print_explain_for_slow_log(LEX *lex, THD *thd, String *str) { diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 919d51aef8ba0..38c5c3e659525 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -512,6 +512,10 @@ class Explain_query : public Sql_alloc Explain_update *get_upd_del_plan() { return upd_del_plan; } private: + bool print_query_blocks_json(Json_writer *writer, const bool is_analyze, const bool is_show_cmd); + void print_query_optimization_json(Json_writer *writer); + void send_explain_json_to_output(Json_writer *writer, select_result_sink *output); + /* Explain_delete inherits from Explain_update */ Explain_update *upd_del_plan; @@ -533,6 +537,8 @@ class Explain_query : public Sql_alloc #ifndef DBUG_OFF bool can_print_json= false; #endif + + Exec_time_tracker optimization_time_tracker; }; From 768a10d02aac5955f154c6d5be30fedbae0f3b3c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 26 Oct 2022 14:54:53 +0200 Subject: [PATCH 050/113] MDEV-22200 maridb-dump add --header option fix quoting --- client/mysqldump.c | 33 ++++--------------------- mysql-test/main/mysqldump-header.result | 13 +++++++++- mysql-test/main/mysqldump-header.test | 13 ++++++++++ 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index d74e694ddcdaf..20c20a964b02c 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2112,17 +2112,16 @@ static my_bool test_if_special_chars(const char *str) name Unquoted string containing that which will be quoted buff The buffer that contains the quoted value, also returned force Flag to make it ignore 'test_if_special_chars' - quote_c Charater to use as the enclosing quote Returns A pointer to the quoted string, or the original string if nothing has changed. */ -static char *quote(const char *name, char *buff, my_bool force, char quote_c) +static char *quote_name(const char *name, char *buff, my_bool force) { char *to= buff; - char qtype= (opt_compatible_mode & MASK_ANSI_QUOTES) ? '\"' : quote_c; + char qtype= (opt_compatible_mode & MASK_ANSI_QUOTES) ? '\"' : '`'; if (!force && !opt_quoted && !test_if_special_chars(name)) return (char*) name; @@ -2136,29 +2135,7 @@ static char *quote(const char *name, char *buff, my_bool force, char quote_c) to[0]= qtype; to[1]= 0; return buff; -} /* quote */ - - -/* - quote_name(name, buff, force) - - quote() with the ` character -*/ -static char *quote_name(const char *name, char *buff, my_bool force) -{ - return quote(name, buff, force, '`'); -} - - -/* - quote_string(name, buff, force) - - quote() with the ' character -*/ -static char *quote_string(const char *name, char *buff) -{ - return quote(name, buff, 0, '\''); -} +} /* quote_name */ /* @@ -3429,7 +3406,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t quote_name(row[SHOW_FIELDNAME], name_buff, 0)); if (opt_header) dynstr_append_checked(&select_field_names_for_header, - quote_string(row[SHOW_FIELDNAME], name_buff)); + quote_for_equal(row[SHOW_FIELDNAME], name_buff)); } init=0; /* @@ -3534,7 +3511,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t quote_name(row[SHOW_FIELDNAME], name_buff, 0)); if (opt_header) dynstr_append_checked(&select_field_names_for_header, - quote_string(row[SHOW_FIELDNAME], name_buff)); + quote_for_equal(row[SHOW_FIELDNAME], name_buff)); init=1; } init=0; diff --git a/mysql-test/main/mysqldump-header.result b/mysql-test/main/mysqldump-header.result index 6b59b062f35ad..945791790c0db 100644 --- a/mysql-test/main/mysqldump-header.result +++ b/mysql-test/main/mysqldump-header.result @@ -45,7 +45,18 @@ course_id name description num_years escape_çÇÁá!#%"';5 Course 1 Course Desc # Dump header and data rows into outfile with several options above combined # 'course_id','name','description','num_years','escape_çÇÁá!#%"\'';'5','Course 1','Course Description 1','3',\N; -'course_id','name','description','num_years','escape_çÇÁá!#%"\'';'5','Course 1','Course Description 1','3',\N;INSERT INTO `courses` VALUES (4, 'Course 2', 'Course Description 2', 4, NULL); +'course_id','name','description','num_years','escape_çÇÁá!#%"\'';'5','Course 1','Course Description 1','3',\N; +# +# --skip-quote-names +# +course_id name description num_years escape_çÇÁá!#%"' +5 Course 1 Course Description 1 3 \N +# +# --compatible=ansi +# +course_id name description num_years escape_çÇÁá!#%"' +5 Course 1 Course Description 1 3 \N +INSERT INTO `courses` VALUES (4, 'Course 2', 'Course Description 2', 4, NULL); INSERT INTO `courses` VALUES (3, 'Course 3', 'Course Description 3', 3, NULL); INSERT INTO `courses` VALUES (2, 'Course 4', 'Course Description 4', 5, NULL); INSERT INTO `courses` VALUES (1, 'Course 5', 'Course Description 5', 3, NULL); diff --git a/mysql-test/main/mysqldump-header.test b/mysql-test/main/mysqldump-header.test index 7c59fee611503..b1886174153c1 100644 --- a/mysql-test/main/mysqldump-header.test +++ b/mysql-test/main/mysqldump-header.test @@ -58,6 +58,19 @@ INSERT INTO `courses` VALUES (5, 'Course 1', 'Course Description 1', 3, NULL); --exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --fields-terminated-by , --fields-optionally-enclosed-by \' --lines-terminated-by \; test --cat_file $MYSQLTEST_VARDIR/courses.txt +--echo +--echo # +--echo # --skip-quote-names +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --skip-quote-names test +--cat_file $MYSQLTEST_VARDIR/courses.txt + +--echo # +--echo # --compatible=ansi +--echo # +--exec $MYSQL_DUMP -u root --tab $MYSQLTEST_VARDIR/ --header --compatible=ansi test +--cat_file $MYSQLTEST_VARDIR/courses.txt + INSERT INTO `courses` VALUES (4, 'Course 2', 'Course Description 2', 4, NULL); INSERT INTO `courses` VALUES (3, 'Course 3', 'Course Description 3', 3, NULL); INSERT INTO `courses` VALUES (2, 'Course 4', 'Course Description 4', 5, NULL); From 1f7840088f4916d48c371395e4cf1a1d8086cce9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 20 Oct 2022 12:34:33 +0200 Subject: [PATCH 051/113] MDEV-29833 CREATE ... SELECT system_versioned_table causes invalid defaults ROW START/END fields shold have no default value --- mysql-test/suite/versioning/r/create.result | 37 ++++++++++----------- mysql-test/suite/versioning/t/create.test | 4 --- sql/handler.cc | 2 +- sql/sql_insert.cc | 7 ++-- sql/sql_lex.cc | 2 +- sql/sql_table.cc | 3 +- 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/mysql-test/suite/versioning/r/create.result b/mysql-test/suite/versioning/r/create.result index 5e68d4df2e82e..c9d68f15e575a 100644 --- a/mysql-test/suite/versioning/r/create.result +++ b/mysql-test/suite/versioning/r/create.result @@ -1,4 +1,3 @@ -drop table if exists t1; create table t1 ( x1 int unsigned, Sys_start SYS_DATATYPE as row start invisible comment 'start', @@ -266,8 +265,8 @@ show create table t3; Table Create Table t3 CREATE TABLE `t3` ( `y` int(11) DEFAULT NULL, - `st` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `en` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `st` timestamp(6) NOT NULL, + `en` timestamp(6) NOT NULL ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ## For versioned table insert into t1 values (1); @@ -296,8 +295,8 @@ show create table t3; Table Create Table t3 CREATE TABLE `t3` ( `y` int(11) DEFAULT NULL, - `st` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `en` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `st` timestamp(6) NOT NULL, + `en` timestamp(6) NOT NULL ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING select * from t3 where y > 2; y st en @@ -385,8 +384,8 @@ show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `x25` int(11) DEFAULT NULL, - `row_start` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `row_end` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `row_start` timestamp(6) NOT NULL, + `row_end` timestamp(6) NOT NULL ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci create or replace table t2 with system versioning as select x25, row_start rs, row_end re from t1; @@ -394,8 +393,8 @@ show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `x25` int(11) DEFAULT NULL, - `rs` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `re` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `rs` timestamp(6) NOT NULL, + `re` timestamp(6) NOT NULL ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING create or replace table t1 ( x26 int, @@ -409,8 +408,8 @@ show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `x26` int(11) DEFAULT NULL, - `st` bigint(20) unsigned NOT NULL DEFAULT 0, - `en` bigint(20) unsigned NOT NULL DEFAULT 0 + `st` bigint(20) unsigned NOT NULL, + `en` bigint(20) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING create or replace table t1 (x27 int, id int) with system versioning engine NON_DEFAULT_ENGINE; create or replace table t2 (b int, id int); @@ -421,8 +420,8 @@ Table Create Table t3 CREATE TABLE `t3` ( `b` int(11) DEFAULT NULL, `x27` int(11) DEFAULT NULL, - `rs` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `re` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `rs` timestamp(6) NOT NULL, + `re` timestamp(6) NOT NULL ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING ## Errors create or replace temporary table t (x28 int) with system versioning; @@ -458,10 +457,10 @@ Table Create Table t3 CREATE TABLE `t3` ( `x30` int(11) DEFAULT NULL, `y` int(11) DEFAULT NULL, - `row_start` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `row_end` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `st` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `en` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' + `row_start` timestamp(6) NOT NULL, + `row_end` timestamp(6) NOT NULL, + `st` timestamp(6) NOT NULL, + `en` timestamp(6) NOT NULL ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci create or replace table t3 ( y int, @@ -475,8 +474,8 @@ Table Create Table t3 CREATE TABLE `t3` ( `x30` int(11) DEFAULT NULL, `y` int(11) DEFAULT NULL, - `row_start` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', - `row_end` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `row_start` timestamp(6) NOT NULL, + `row_end` timestamp(6) NOT NULL, `st` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE, `en` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE, PERIOD FOR SYSTEM_TIME (`st`, `en`) diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test index 6f5153b4ec179..46ed8fad4cbf5 100644 --- a/mysql-test/suite/versioning/t/create.test +++ b/mysql-test/suite/versioning/t/create.test @@ -1,10 +1,6 @@ --source suite/versioning/engines.inc --source suite/versioning/common.inc ---disable_warnings -drop table if exists t1; ---enable_warnings - --enable_prepare_warnings --replace_result $default_engine DEFAULT_ENGINE $sys_datatype_expl SYS_DATATYPE NULL '' diff --git a/sql/handler.cc b/sql/handler.cc index ce52df005da78..4a8b58951d394 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -8084,7 +8084,7 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name, int f f->field_name.str= field_name; f->field_name.length= strlen(field_name); f->charset= system_charset_info; - f->flags= flags | NOT_NULL_FLAG; + f->flags= flags | NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG; if (integer) { DBUG_ASSERT(0); // Not implemented yet diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c850bdbe34f02..1e5d64885c19f 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -320,7 +320,8 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list, static bool has_no_default_value(THD *thd, Field *field, TABLE_LIST *table_list) { - if ((field->flags & NO_DEFAULT_VALUE_FLAG) && field->real_type() != MYSQL_TYPE_ENUM) + if ((field->flags & (NO_DEFAULT_VALUE_FLAG | VERS_ROW_START | VERS_ROW_END)) + == NO_DEFAULT_VALUE_FLAG && field->real_type() != MYSQL_TYPE_ENUM) { bool view= false; if (table_list) @@ -2257,9 +2258,7 @@ int check_that_all_fields_are_given_values(THD *thd, TABLE *entry, TABLE_LIST *t for (Field **field=entry->field ; *field ; field++) { if (!bitmap_is_set(write_set, (*field)->field_index) && - !(*field)->vers_sys_field() && - has_no_default_value(thd, *field, table_list) && - ((*field)->real_type() != MYSQL_TYPE_ENUM)) + has_no_default_value(thd, *field, table_list)) err=1; } return thd->abort_on_warning ? err : 0; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2c91b4cc9c6b0..215bd4ab085e2 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -9810,7 +9810,7 @@ bool LEX::last_field_generated_always_as_row_start_or_end(Lex_ident *p, last_field->field_name.str); return true; } - last_field->flags|= (flag | NOT_NULL_FLAG); + last_field->flags|= (flag | NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG); DBUG_ASSERT(p); *p= last_field->field_name; return false; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 5a35baddf93c5..ad58dd620d97b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3793,7 +3793,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, } if (sql_field->invisible == INVISIBLE_USER && sql_field->flags & NOT_NULL_FLAG && - sql_field->flags & NO_DEFAULT_VALUE_FLAG) + sql_field->flags & NO_DEFAULT_VALUE_FLAG && + !sql_field->vers_sys_field()) { my_error(ER_INVISIBLE_NOT_NULL_WITHOUT_DEFAULT, MYF(0), sql_field->field_name.str); From bf62d8e7e78c5db4de35ce4fff79247ca3459905 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 21 Oct 2022 17:16:05 +0200 Subject: [PATCH 052/113] cleanup --- plugin/feedback/sender_thread.cc | 2 +- sql/sql_lex.cc | 9 +++------ sql/sql_parse.cc | 19 ++----------------- sql/sql_parse.h | 1 - sql/sql_tvc.cc | 4 ++-- sql/sql_yacc.yy | 16 ++++++++-------- 6 files changed, 16 insertions(+), 35 deletions(-) diff --git a/plugin/feedback/sender_thread.cc b/plugin/feedback/sender_thread.cc index 1aac71b132a5a..6b5be475e9776 100644 --- a/plugin/feedback/sender_thread.cc +++ b/plugin/feedback/sender_thread.cc @@ -108,7 +108,7 @@ static int prepare_for_fill(TABLE_LIST *tables) thd->security_ctx->master_access= ALL_KNOWN_ACL; bzero((char*) &thd->net, sizeof(thd->net)); lex_start(thd); - mysql_init_select(thd->lex); + thd->lex->init_select(); LEX_CSTRING tbl_name= {i_s_feedback->table_name, strlen(i_s_feedback->table_name) }; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 215bd4ab085e2..ad526656c9083 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -6402,7 +6402,7 @@ bool LEX::sf_return_fill_definition(const Lex_field_type_st &def) void LEX::set_stmt_init() { sql_command= SQLCOM_SET_OPTION; - mysql_init_select(this); + init_select(); option_type= OPT_SESSION; autocommit= 0; var_list.empty(); @@ -10384,8 +10384,7 @@ bool LEX::parsed_TVC_start() save_values_list_state(); many_values.empty(); insert_list= 0; - if (!(sel= alloc_select(TRUE)) || - push_select(sel)) + if (!(sel= alloc_select(TRUE)) || push_select(sel)) return true; sel->init_select(); sel->braces= FALSE; // just initialisation @@ -10397,9 +10396,7 @@ SELECT_LEX *LEX::parsed_TVC_end() { SELECT_LEX *res= pop_select(); // above TVC select if (!(res->tvc= - new (thd->mem_root) table_value_constr(many_values, - res, - res->options))) + new (thd->mem_root) table_value_constr(many_values, res, res->options))) return NULL; restore_values_list_state(); return res; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 60940f3b2d665..2394207ea2d4b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7610,21 +7610,6 @@ void THD::reset_for_next_command(bool do_clear_error) } -/** - Resets the lex->current_select object. - @note It is assumed that lex->current_select != NULL - - This function is a wrapper around select_lex->init_select() with an added - check for the special situation when using INTO OUTFILE and LOAD DATA. -*/ - -void -mysql_init_select(LEX *lex) -{ - lex->init_select(); -} - - /** Used to allocate a new SELECT_LEX object on the current thd mem_root and link it into the relevant lists. @@ -7741,7 +7726,7 @@ void create_select_for_variable(THD *thd, LEX_CSTRING *var_name) DBUG_ENTER("create_select_for_variable"); lex= thd->lex; - mysql_init_select(lex); + lex->init_select(); lex->sql_command= SQLCOM_SELECT; /* We set the name of Item to @@session.var_name because that then is used @@ -7760,7 +7745,7 @@ void create_select_for_variable(THD *thd, LEX_CSTRING *var_name) void mysql_init_multi_delete(LEX *lex) { lex->sql_command= SQLCOM_DELETE_MULTI; - mysql_init_select(lex); + lex->init_select(); lex->first_select_lex()->limit_params.clear(); lex->unit.lim.clear(); lex->first_select_lex()->table_list. diff --git a/sql/sql_parse.h b/sql/sql_parse.h index d3cf83b6e08c5..eeb7f832adb26 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -87,7 +87,6 @@ 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, size_t packet_length); -void mysql_init_select(LEX *lex); void mysql_parse(THD *thd, char *rawbuf, uint length, Parser_state *parser_state); bool mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *sel); diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index a045d0e390836..1538a9c5ac027 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -985,7 +985,7 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd, */ if (mysql_new_select(lex, 1, NULL)) goto err; - mysql_init_select(lex); + lex->init_select(); /* Create item list as '*' for the subquery SQ */ Item *item; SELECT_LEX *sq_select; // select for IN subquery; @@ -1003,7 +1003,7 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd, SELECT_LEX_UNIT *derived_unit; // unit for tvc_select if (mysql_new_select(lex, 1, NULL)) goto err; - mysql_init_select(lex); + lex->init_select(); tvc_select= lex->current_select; derived_unit= tvc_select->master_unit(); tvc_select->set_linkage(DERIVED_TABLE_TYPE); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 76c6270d95e71..774f92197f9ec 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -12761,7 +12761,7 @@ do: lex->sql_command = SQLCOM_DO; if (lex->main_select_push(true)) MYSQL_YYABORT; - mysql_init_select(lex); + lex->init_select(); } expr_list { @@ -12985,7 +12985,7 @@ replace: insert_start: { if (Lex->main_select_push()) MYSQL_YYABORT; - mysql_init_select(Lex); + Lex->init_select(); Lex->inc_select_stack_outer_barrier(); Lex->current_select->parsing_place= BEFORE_OPT_LIST; } @@ -13252,7 +13252,7 @@ update: LEX *lex= Lex; if (Lex->main_select_push()) MYSQL_YYABORT; - mysql_init_select(lex); + lex->init_select(); lex->sql_command= SQLCOM_UPDATE; lex->duplicates= DUP_ERROR; } @@ -13334,7 +13334,7 @@ delete: YYPS->m_mdl_type= MDL_SHARED_WRITE; if (Lex->main_select_push()) MYSQL_YYABORT; - mysql_init_select(lex); + lex->init_select(); lex->ignore= 0; lex->first_select_lex()->order_list.empty(); } @@ -13611,7 +13611,7 @@ show: lex->ident= null_clex_str; if (Lex->main_select_push()) MYSQL_YYABORT; - mysql_init_select(lex); + lex->init_select(); lex->current_select->parsing_place= SELECT_LIST; lex->create_info.init(); } @@ -14111,7 +14111,7 @@ describe: LEX *lex= Lex; if (lex->main_select_push()) MYSQL_YYABORT; - mysql_init_select(lex); + lex->init_select(); lex->current_select->parsing_place= SELECT_LIST; lex->sql_command= SQLCOM_SHOW_FIELDS; lex->first_select_lex()->db= null_clex_str; @@ -14202,7 +14202,7 @@ explain_for_connection: lex->ident= null_clex_str; if (Lex->main_select_push()) MYSQL_YYABORT; - mysql_init_select(lex); + lex->init_select(); lex->current_select->parsing_place= SELECT_LIST; lex->create_info.init(); Select->parsing_place= NO_MATTER; @@ -14572,7 +14572,7 @@ load: } if (lex->main_select_push()) MYSQL_YYABORT; - mysql_init_select(lex); + lex->init_select(); } load_data_lock opt_local INFILE TEXT_STRING_filesystem { From adcbf015c94c0b7ab03d5cf9f79c7913d4e6589e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 15 Sep 2022 18:28:51 +0200 Subject: [PATCH 053/113] cleanup: read_set/write_set are based on metadata they should be set once, not for every row --- sql/log_event_server.cc | 12 ++++++------ sql/table.cc | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 98325fe74981f..3aac06a3410a5 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -6047,6 +6047,12 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) &m_cols_ai : &m_cols); bitmap_intersect(table->write_set, after_image); + if (table->versioned()) + { + bitmap_set_bit(table->write_set, table->s->vers.start_fieldno); + bitmap_set_bit(table->write_set, table->s->vers.end_fieldno); + } + this->slave_exec_mode= slave_exec_mode_options; // fix the mode // Do event specific preparations @@ -7681,8 +7687,6 @@ Rows_log_event::write_row(rpl_group_info *rgi, if (table->versioned(VERS_TIMESTAMP)) { ulong sec_part; - bitmap_set_bit(table->read_set, table->vers_start_field()->field_index); - table->file->column_bitmaps_signal(); // Check whether a row came from unversioned table and fix vers fields. if (table->vers_start_field()->get_timestamp(&sec_part) == 0 && sec_part == 0) table->vers_update_fields(); @@ -8207,18 +8211,15 @@ int Rows_log_event::find_row(rpl_group_info *rgi) { Field *row_end= table->vers_end_field(); DBUG_ASSERT(table->read_set); - bitmap_set_bit(table->read_set, row_end->field_index); // check whether master table is unversioned if (row_end->val_int() == 0) { - bitmap_set_bit(table->write_set, row_end->field_index); // Plain source table may have a PRIMARY KEY. And row_end is always // a part of PRIMARY KEY. Set it to max value for engine to find it in // index. Needed for an UPDATE/DELETE cases. table->vers_end_field()->set_max(); m_vers_from_plain= true; } - table->file->column_bitmaps_signal(); } DBUG_PRINT("info",("looking for the following record")); @@ -8578,7 +8579,6 @@ int Delete_rows_log_event::do_exec_row(rpl_group_info *rgi) if (m_vers_from_plain && m_table->versioned(VERS_TIMESTAMP)) { Field *end= m_table->vers_end_field(); - bitmap_set_bit(m_table->write_set, end->field_index); store_record(m_table, record[1]); end->set_time(); error= m_table->file->ha_update_row(m_table->record[1], diff --git a/sql/table.cc b/sql/table.cc index 0476d8f2bd05f..e94c8eabed0f0 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -7614,6 +7614,8 @@ void TABLE::mark_columns_needed_for_update() } if (s->versioned) { + bitmap_set_bit(write_set, s->vers.start_fieldno); + bitmap_set_bit(write_set, s->vers.end_fieldno); /* For System Versioning we have to read all columns since we store a copy of previous row with modified row_end back to a table. @@ -7671,6 +7673,12 @@ void TABLE::mark_columns_needed_for_insert() mark_auto_increment_column(); if (default_field) mark_default_fields_for_write(TRUE); + if (s->versioned) + { + bitmap_set_bit(write_set, s->vers.start_fieldno); + bitmap_set_bit(write_set, s->vers.end_fieldno); + bitmap_set_bit(read_set, s->vers.end_fieldno); + } /* Mark virtual columns for insert */ if (vfield) mark_virtual_columns_for_write(TRUE); @@ -9148,29 +9156,21 @@ bool TABLE::check_period_overlaps(const KEY &key, void TABLE::vers_update_fields() { if (!vers_write) - { - file->column_bitmaps_signal(); return; - } if (versioned(VERS_TIMESTAMP)) { - bitmap_set_bit(write_set, vers_start_field()->field_index); if (vers_start_field()->store_timestamp(in_use->query_start(), in_use->query_start_sec_part())) { DBUG_ASSERT(0); } vers_start_field()->set_has_explicit_value(); - bitmap_set_bit(read_set, vers_start_field()->field_index); } - bitmap_set_bit(write_set, vers_end_field()->field_index); vers_end_field()->set_max(); vers_end_field()->set_has_explicit_value(); - bitmap_set_bit(read_set, vers_end_field()->field_index); - file->column_bitmaps_signal(); if (vfield) update_virtual_fields(file, VCOL_UPDATE_FOR_READ); } From d9b0c9ad2bc35b951e84d5c040eb2af86ff2d8cf Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 16 Sep 2022 11:29:46 +0200 Subject: [PATCH 054/113] cleanup: warnings, comments, whitespaces --- sql/sql_base.cc | 66 ++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 49fc886cf5bb3..d78968190e011 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6376,12 +6376,10 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length, */ Field * -find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, - const char *name, size_t length, - const char *item_name, const char *db_name, - const char *table_name, - ignored_tables_list_t ignored_tables, - Item **ref, +find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, const char *name, + size_t length, const char *item_name, + const char *db_name, const char *table_name, + ignored_tables_list_t ignored_tables, Item **ref, bool check_privileges, bool allow_rowid, field_index_t *cached_field_index_ptr, bool register_tree_change, TABLE_LIST **actual_table) @@ -6454,8 +6452,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, /* 'table_list' is a stored table. */ DBUG_ASSERT(table_list->table); if ((fld= find_field_in_table(thd, table_list->table, name, length, - allow_rowid, - cached_field_index_ptr))) + allow_rowid, cached_field_index_ptr))) *actual_table= table_list; } else @@ -6685,18 +6682,16 @@ find_field_in_tables(THD *thd, Item_ident *item, #ifndef NO_EMBEDDED_ACCESS_CHECKS /* Check if there are sufficient access rights to the found field. */ if (found && check_privileges && !is_temporary_table(table_ref) && - check_column_grant_in_table_ref(thd, table_ref, name, length, - found)) + check_column_grant_in_table_ref(thd, table_ref, name, length, found)) found= WRONG_GRANT; #endif } else - found= find_field_in_table_ref(thd, table_ref, name, length, item->name.str, - NULL, NULL, ignored_tables, ref, - check_privileges, TRUE, - &(item->cached_field_index), - register_tree_change, - &actual_table); + found= find_field_in_table_ref(thd, table_ref, name, length, + item->name.str, NULL, NULL, + ignored_tables, ref, check_privileges, + TRUE, &(item->cached_field_index), + register_tree_change, &actual_table); if (found) { if (found == WRONG_GRANT) @@ -6706,8 +6701,7 @@ find_field_in_tables(THD *thd, Item_ident *item, Only views fields should be marked as dependent, not an underlying fields. */ - if (!table_ref->belong_to_view && - !table_ref->belong_to_derived) + if (!table_ref->belong_to_view && !table_ref->belong_to_derived) { SELECT_LEX *current_sel= item->context->select_lex; SELECT_LEX *last_select= table_ref->select_lex; @@ -7912,8 +7906,9 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, bool allow_sum_func) { Item *item; + LEX * const lex= thd->lex; enum_column_usage saved_column_usage= thd->column_usage; - nesting_map save_allow_sum_func= thd->lex->allow_sum_func; + nesting_map save_allow_sum_func= lex->allow_sum_func; List_iterator it(fields); bool save_is_item_list_lookup; bool make_pre_fix= (pre_fix && (pre_fix->elements == 0)); @@ -7929,15 +7924,14 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, 2) nest level of all SELECTs on the same level shoud be equal first SELECT on this level (and each other). */ - DBUG_ASSERT(thd->lex->current_select->nest_level >= 0); - DBUG_ASSERT(thd->lex->current_select->master_unit()->first_select() - ->nest_level == - thd->lex->current_select->nest_level); + DBUG_ASSERT(lex->current_select->nest_level >= 0); + DBUG_ASSERT(lex->current_select->master_unit()->first_select()->nest_level == + lex->current_select->nest_level); if (allow_sum_func) - thd->lex->allow_sum_func.set_bit(thd->lex->current_select->nest_level); + lex->allow_sum_func.set_bit(lex->current_select->nest_level); thd->where= THD::DEFAULT_WHERE; - save_is_item_list_lookup= thd->lex->current_select->is_item_list_lookup; - thd->lex->current_select->is_item_list_lookup= 0; + save_is_item_list_lookup= lex->current_select->is_item_list_lookup; + lex->current_select->is_item_list_lookup= 0; /* To prevent fail on forward lookup we fill it with zeroes, @@ -7967,13 +7961,13 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, items we have to refresh their entries before fixing of Item_func_get_user_var items. */ - List_iterator li(thd->lex->set_var_list); + List_iterator li(lex->set_var_list); Item_func_set_user_var *var; while ((var= li++)) var->set_entry(thd, FALSE); Ref_ptr_array ref= ref_pointer_array; - thd->lex->current_select->cur_pos_in_select_list= 0; + lex->current_select->cur_pos_in_select_list= 0; while ((item= it++)) { if (make_pre_fix) @@ -7981,8 +7975,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, if (item->fix_fields_if_needed_for_scalar(thd, it.ref())) { - thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; - thd->lex->allow_sum_func= save_allow_sum_func; + lex->current_select->is_item_list_lookup= save_is_item_list_lookup; + lex->allow_sum_func= save_allow_sum_func; thd->column_usage= saved_column_usage; DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage)); DBUG_RETURN(TRUE); /* purecov: inspected */ @@ -8004,14 +7998,14 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, item->split_sum_func(thd, ref_pointer_array, *sum_func_list, SPLIT_SUM_SELECT); } - thd->lex->current_select->select_list_tables|= item->used_tables(); - thd->lex->used_tables|= item->used_tables(); - thd->lex->current_select->cur_pos_in_select_list++; + lex->current_select->select_list_tables|= item->used_tables(); + lex->used_tables|= item->used_tables(); + lex->current_select->cur_pos_in_select_list++; } - thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; - thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS; + lex->current_select->is_item_list_lookup= save_is_item_list_lookup; + lex->current_select->cur_pos_in_select_list= UNDEF_POS; - thd->lex->allow_sum_func= save_allow_sum_func; + lex->allow_sum_func= save_allow_sum_func; thd->column_usage= saved_column_usage; DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage)); DBUG_RETURN(MY_TEST(thd->is_error())); From a2cda88631b47aaeec53a8fdd5ced48e04b8ceb0 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Sun, 28 Aug 2022 22:44:56 +0300 Subject: [PATCH 055/113] MDEV-16546 System versioning setting to allow history modification 1. system_versioning_insert_history session variable allows pseudocolumns ROW_START and ROW_END be specified in INSERT, INSERT..SELECT and LOAD DATA. 2. Cleaned up select_insert::send_data() from setting vers_write as this parameter is now set on TABLE initialization. 4. Replication of system_versioning_insert_history via option_bits in OPTIONS_WRITTEN_TO_BIN_LOG. --- mysql-test/main/mysqld--help.result | 3 + .../sys_vars/r/sysvars_server_embedded.result | 10 + .../r/sysvars_server_notembedded.result | 10 + mysql-test/suite/versioning/r/insert.result | 189 ++++++++++++++++++ mysql-test/suite/versioning/r/rpl.result | 52 +++++ mysql-test/suite/versioning/t/insert.test | 157 +++++++++++++++ mysql-test/suite/versioning/t/rpl.test | 44 ++++ sql/handler.cc | 24 +++ sql/item.cc | 7 + sql/log_event.cc | 3 + sql/log_event.h | 3 +- sql/log_event_server.cc | 3 +- sql/share/errmsg-utf8.txt | 5 +- sql/sql_base.cc | 11 +- sql/sql_class.h | 33 +++ sql/sql_insert.cc | 26 ++- sql/sql_prepare.cc | 4 +- sql/sql_priv.h | 5 +- sql/sql_select.cc | 2 +- sql/sql_select.h | 2 +- sql/sql_union.cc | 2 +- sql/sql_union.h | 2 +- sql/sys_vars.cc | 7 + 23 files changed, 581 insertions(+), 23 deletions(-) diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 6121ac791f358..5a91d06a7686b 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -1384,6 +1384,8 @@ The following specify which files/extra groups are read (specified before remain Versioning ALTER TABLE mode. ERROR: Fail ALTER with error; KEEP: Keep historical system rows and subject them to ALTER + --system-versioning-insert-history + Allows direct inserts into ROW_START and ROW_END columns --table-cache=# Deprecated; use --table-open-cache instead. --table-definition-cache=# The number of cached table definitions @@ -1856,6 +1858,7 @@ sync-relay-log 10000 sync-relay-log-info 10000 sysdate-is-now FALSE system-versioning-alter-history ERROR +system-versioning-insert-history FALSE table-definition-cache 400 tc-heuristic-recover OFF tcp-keepalive-interval 0 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 8a9f1d942f01a..b0174607ce221 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -3552,6 +3552,16 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT NULL +VARIABLE_NAME SYSTEM_VERSIONING_INSERT_HISTORY +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Allows direct inserts into ROW_START and ROW_END columns +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 TABLE_DEFINITION_CACHE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED 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 0221ecb386112..831db50d52e42 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -4272,6 +4272,16 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT NULL +VARIABLE_NAME SYSTEM_VERSIONING_INSERT_HISTORY +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Allows direct inserts into ROW_START and ROW_END columns +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 TABLE_DEFINITION_CACHE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED diff --git a/mysql-test/suite/versioning/r/insert.result b/mysql-test/suite/versioning/r/insert.result index 2645d0184e8dc..c2ca4392a9f94 100644 --- a/mysql-test/suite/versioning/r/insert.result +++ b/mysql-test/suite/versioning/r/insert.result @@ -112,3 +112,192 @@ x y 9 9001 drop table t1; drop table t2; +# +# MDEV-16546 System versioning setting to allow history modification +# +set @@session.time_zone='+00:00'; +create table t1(x int primary key) with system versioning; +create table t2(y int primary key, +row_start timestamp(6) as row start invisible, +row_end timestamp(6) as row end invisible, +period for system_time (row_start, row_end)) +with system versioning; +create table t3(z int primary key, +row_start timestamp(6) as row start, +row_end timestamp(6) as row end, +period for system_time (row_start, row_end)) +with system versioning; +insert into t1(x, row_start, row_end) values (2, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42S22: Unknown column 'row_start' in 'field list' +insert into t2(y, row_start, row_end) values (2, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR HY000: The value specified for generated column 'row_start' in table 't2' has been ignored +set @@system_versioning_insert_history= 1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x` int(11) NOT NULL, + PRIMARY KEY (`x`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +insert into t1(x, row_start, row_end) values (3, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into t2(y, row_start, row_end) values (4, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into t3 values (5, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +select x, row_start, row_end from t1 for system_time all; +x row_start row_end +3 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +select y, row_start, row_end from t2 for system_time all; +y row_start row_end +4 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +select z, row_start, row_end from t3 for system_time all; +z row_start row_end +5 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +insert into t1(x) values (1); +insert into t2(y) values (1); +update t1 set x= x + 1; +update t1 set row_start= '1971-01-01 00:00:00'; +ERROR 42S22: Unknown column 'row_start' in 'field list' +update t2 set row_start= '1971-01-01 00:00:00'; +ERROR HY000: The value specified for generated column 'row_start' in table 't2' has been ignored +insert t1 (x) values (2) on duplicate key update x= 3, row_end= '1970-01-01 00:00:00'; +ERROR 42S22: Unknown column 'row_end' in 'field list' +insert t2 (y) values (1) on duplicate key update y= 3, row_end= '1970-01-01 00:00:00'; +ERROR HY000: The value specified for generated column 'row_end' in table 't2' has been ignored +insert into t1 values (4); +insert into t1 set x= 5, row_start= '1980-01-01 00:00:00', row_end= '1980-01-01 00:00:01'; +insert into t1(x, row_start, row_end) values (6, '1980-01-01 00:00:01', '1980-01-01 00:00:00'); +ERROR HY000: Incorrect row_start value: '1980-01-01 00:00:01.000000' +insert into t1(x, row_start, row_end) values (7, '1980-01-01 00:00:11', '1980-01-01 00:00:11'); +ERROR HY000: Incorrect row_start value: '1980-01-01 00:00:11.000000' +insert into t1(x, row_start) values (8, '1980-01-01 00:00:22'); +ERROR HY000: Incorrect row_start value: '1980-01-01 00:00:22.000000' +insert into t1(x, row_end) values (9, '1980-01-01 00:00:33'); +ERROR HY000: Incorrect row_start value: '0000-00-00 00:00:00.000000' +insert into t1(x, row_end) values (10, TIMESTAMP'2038-01-19 03:14:07.999999'); +ERROR HY000: Incorrect row_start value: '0000-00-00 00:00:00.000000' +select x, check_row_ts(row_start, row_end) from t1 for system_time all order by x; +x check_row_ts(row_start, row_end) +1 HISTORICAL ROW +2 CURRENT ROW +3 HISTORICAL ROW +4 CURRENT ROW +5 HISTORICAL ROW +select x, row_start, row_end from t1 for system_time all +where x > 1 and row_end < TIMESTAMP'2038-01-19 03:14:07.999999' order by x, row_start, row_end; +x row_start row_end +3 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +5 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +# Direct insert is not possible for TRX_ID versioning +create or replace table t2(y int primary key, +row_start bigint unsigned as row start, +row_end bigint unsigned as row end, +period for system_time (row_start, row_end)) +with system versioning engine innodb; +insert into t2(y, row_start, row_end) values (0, 1, 2); +ERROR HY000: The value specified for generated column 'row_start' in table 't2' has been ignored +set @@system_versioning_insert_history= 0; +## INSERT..SELECT +create or replace table t2 like t1; +set @@system_versioning_insert_history= 1; +insert into t2 (x, row_start, row_end) select x, row_start, row_end from t1 for system_time all; +select x, check_row_ts(row_start, row_end) from t2 for system_time all order by x; +x check_row_ts(row_start, row_end) +1 HISTORICAL ROW +2 CURRENT ROW +3 HISTORICAL ROW +4 CURRENT ROW +5 HISTORICAL ROW +select x, row_start, row_end from t2 for system_time all +where x > 1 and row_end < TIMESTAMP'2038-01-19 03:14:07.999999' order by x, row_start, row_end; +x row_start row_end +3 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +5 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +set @@system_versioning_insert_history= 0; +# REPLACE / REPLACE .. SELECT +create or replace table t2(a int primary key, +row_start timestamp(6) as row start invisible, +row_end timestamp(6) as row end invisible, +period for system_time (row_start, row_end)) +with system versioning; +replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR HY000: The value specified for generated column 'row_start' in table 't2' has been ignored +replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1; +ERROR HY000: The value specified for generated column 'row_start' in table 't2' has been ignored +create or replace table t2 (a int primary key) with system versioning; +replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42S22: Unknown column 'row_start' in 'field list' +replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1; +ERROR 42S22: Unknown column 'row_start' in 'field list' +set @@system_versioning_insert_history= 1; +replace into t2 (a, row_start) values (1, '1980-01-01 00:00:00'); +ERROR HY000: Incorrect row_start value: '1980-01-01 00:00:00.000000' +replace into t2 (a, row_end) values (0, '1980-01-01 00:00:00'); +ERROR HY000: Incorrect row_start value: '0000-00-00 00:00:00.000000' +replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; +a row_start row_end +1 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +# Changing row_end via REPLACE is NOT possible, we just insert new row: +replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1990-01-01 00:00:01'); +select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; +a row_start row_end +1 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +1 1980-01-01 00:00:00.000000 1990-01-01 00:00:01.000000 +# But changing row_start via REPLACE is possible: +replace into t2 (a, row_start, row_end) values (1, '1971-01-01 00:00:00', '1980-01-01 00:00:01'); +select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; +a row_start row_end +1 1971-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +1 1980-01-01 00:00:00.000000 1990-01-01 00:00:01.000000 +replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1 for system_time all +where x > 1 and row_end < TIMESTAMP'2038-01-19 03:14:07.999999'; +select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; +a row_start row_end +1 1971-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +1 1980-01-01 00:00:00.000000 1990-01-01 00:00:01.000000 +3 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +5 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +# LOAD DATA +select x, row_start, row_end into outfile 'DATAFILE' from t1 for system_time all; +create or replace table t3 like t1; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `x` int(11) NOT NULL, + PRIMARY KEY (`x`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +set @@system_versioning_insert_history= 1; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `x` int(11) NOT NULL, + PRIMARY KEY (`x`) +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +load data infile 'DATAFILE' into table t3 (x, row_start, row_end); +select x, check_row_ts(row_start, row_end) from t3 for system_time all order by x; +x check_row_ts(row_start, row_end) +1 HISTORICAL ROW +2 CURRENT ROW +3 HISTORICAL ROW +4 CURRENT ROW +5 HISTORICAL ROW +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t3 for system_time all where x = 3; +row_start = '1980-01-01 00:00:00' row_end = '1980-01-01 00:00:01' +1 1 +# Honor secure_timestamp option +# restart: --secure-timestamp=YES +set @@system_versioning_insert_history= 1; +insert into t1(x, row_start, row_end) values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42S22: Unknown column 'row_start' in 'field list' +# restart: --secure-timestamp=REPLICATION +set @@system_versioning_insert_history= 1; +insert into t1(x, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42S22: Unknown column 'row_start' in 'field list' +# restart: --secure-timestamp=SUPER +set @@system_versioning_insert_history= 1; +insert into t1(x, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +create user nobody; +use test; +insert into t1(x, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42S22: Unknown column 'row_start' in 'field list' +use test; +# restart: --secure-timestamp=NO +drop tables t1, t2, t3; diff --git a/mysql-test/suite/versioning/r/rpl.result b/mysql-test/suite/versioning/r/rpl.result index 3e0bc85cea770..f342cd725a2e0 100644 --- a/mysql-test/suite/versioning/r/rpl.result +++ b/mysql-test/suite/versioning/r/rpl.result @@ -1,6 +1,7 @@ include/master-slave.inc [connection master] connection slave; +set @@session.time_zone='+00:00'; connection master; CREATE TABLE t1 (x int) with system versioning; insert into t1 values (1); @@ -384,4 +385,55 @@ connection slave; connection master; drop tables t, t2; set timestamp= default; +# +# MDEV-16546 System versioning setting to allow history modification +# +create table t1(x int) with system versioning; +insert into t1(x) values (1); +insert into t1(x, row_start, row_end) values (2, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42S22: Unknown column 'row_start' in 'field list' +set @@system_versioning_insert_history= 1; +insert into t1(x, row_start, row_end) values (3, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +update t1 set x= x + 1; +connection slave; +set @@session.time_zone='+00:00'; +select x, check_row_ts(row_start, row_end) from t1 for system_time all order by x; +x check_row_ts(row_start, row_end) +1 HISTORICAL ROW +2 CURRENT ROW +3 HISTORICAL ROW +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t1 for system_time all where x = 3; +row_start = '1980-01-01 00:00:00' row_end = '1980-01-01 00:00:01' +1 1 +## INSERT..SELECT +connection master; +create or replace table t2 like t1; +set @@system_versioning_insert_history= 1; +insert into t2 (x, row_start, row_end) select x, row_start, row_end from t1 for system_time all; +connection slave; +select x, check_row_ts(row_start, row_end) from t2 for system_time all order by x; +x check_row_ts(row_start, row_end) +1 HISTORICAL ROW +2 CURRENT ROW +3 HISTORICAL ROW +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t2 for system_time all where x = 3; +row_start = '1980-01-01 00:00:00' row_end = '1980-01-01 00:00:01' +1 1 +# LOAD DATA +connection master; +select x, row_start, row_end into outfile 'DATAFILE' from t1 for system_time all; +create or replace table t3 like t1; +set @@system_versioning_insert_history= 1; +load data infile 'DATAFILE' into table t3 (x, row_start, row_end); +connection slave; +select x, check_row_ts(row_start, row_end) from t3 for system_time all order by x; +x check_row_ts(row_start, row_end) +1 HISTORICAL ROW +2 CURRENT ROW +3 HISTORICAL ROW +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t3 for system_time all where x = 3; +row_start = '1980-01-01 00:00:00' row_end = '1980-01-01 00:00:01' +1 1 +connection master; +drop tables t1, t2, t3; include/rpl_end.inc diff --git a/mysql-test/suite/versioning/t/insert.test b/mysql-test/suite/versioning/t/insert.test index 4e8c91315c671..37307b3bf9708 100644 --- a/mysql-test/suite/versioning/t/insert.test +++ b/mysql-test/suite/versioning/t/insert.test @@ -81,4 +81,161 @@ select x, y from t2; drop table t1; drop table t2; +--echo # +--echo # MDEV-16546 System versioning setting to allow history modification +--echo # +set @@session.time_zone='+00:00'; +let $MAX_TIMESTAMP= TIMESTAMP'2038-01-19 03:14:07.999999'; + +create table t1(x int primary key) with system versioning; +create table t2(y int primary key, + row_start timestamp(6) as row start invisible, + row_end timestamp(6) as row end invisible, + period for system_time (row_start, row_end)) +with system versioning; +create table t3(z int primary key, + row_start timestamp(6) as row start, + row_end timestamp(6) as row end, + period for system_time (row_start, row_end)) +with system versioning; +--error ER_BAD_FIELD_ERROR +insert into t1(x, row_start, row_end) values (2, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN +insert into t2(y, row_start, row_end) values (2, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +set @@system_versioning_insert_history= 1; +--replace_result $default_engine DEFAULT_ENGINE +show create table t1; +insert into t1(x, row_start, row_end) values (3, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into t2(y, row_start, row_end) values (4, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into t3 values (5, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); + +select x, row_start, row_end from t1 for system_time all; +select y, row_start, row_end from t2 for system_time all; +select z, row_start, row_end from t3 for system_time all; + +insert into t1(x) values (1); +insert into t2(y) values (1); + +update t1 set x= x + 1; +--error ER_BAD_FIELD_ERROR +update t1 set row_start= '1971-01-01 00:00:00'; +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN +update t2 set row_start= '1971-01-01 00:00:00'; +--error ER_BAD_FIELD_ERROR +insert t1 (x) values (2) on duplicate key update x= 3, row_end= '1970-01-01 00:00:00'; +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN +insert t2 (y) values (1) on duplicate key update y= 3, row_end= '1970-01-01 00:00:00'; +# this should work, row_start/row_end must be mentioned explicitly: +insert into t1 values (4); +insert into t1 set x= 5, row_start= '1980-01-01 00:00:00', row_end= '1980-01-01 00:00:01'; +--error ER_WRONG_VALUE +insert into t1(x, row_start, row_end) values (6, '1980-01-01 00:00:01', '1980-01-01 00:00:00'); +--error ER_WRONG_VALUE +insert into t1(x, row_start, row_end) values (7, '1980-01-01 00:00:11', '1980-01-01 00:00:11'); +--error ER_WRONG_VALUE +insert into t1(x, row_start) values (8, '1980-01-01 00:00:22'); +# NOTE: having row_start=0 might be useful and can mean +# "there is no information on when history was started" (an opposite to row_end=MAX_TIMESTAMP) +--error ER_WRONG_VALUE +insert into t1(x, row_end) values (9, '1980-01-01 00:00:33'); +--error ER_WRONG_VALUE +eval insert into t1(x, row_end) values (10, $MAX_TIMESTAMP); +select x, check_row_ts(row_start, row_end) from t1 for system_time all order by x; +eval select x, row_start, row_end from t1 for system_time all +where x > 1 and row_end < $MAX_TIMESTAMP order by x, row_start, row_end; +--echo # Direct insert is not possible for TRX_ID versioning +create or replace table t2(y int primary key, + row_start bigint unsigned as row start, + row_end bigint unsigned as row end, + period for system_time (row_start, row_end)) +with system versioning engine innodb; +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN +insert into t2(y, row_start, row_end) values (0, 1, 2); +set @@system_versioning_insert_history= 0; + +--echo ## INSERT..SELECT +create or replace table t2 like t1; +set @@system_versioning_insert_history= 1; +insert into t2 (x, row_start, row_end) select x, row_start, row_end from t1 for system_time all; +select x, check_row_ts(row_start, row_end) from t2 for system_time all order by x; +eval select x, row_start, row_end from t2 for system_time all +where x > 1 and row_end < $MAX_TIMESTAMP order by x, row_start, row_end; +set @@system_versioning_insert_history= 0; + +--echo # REPLACE / REPLACE .. SELECT +create or replace table t2(a int primary key, + row_start timestamp(6) as row start invisible, + row_end timestamp(6) as row end invisible, + period for system_time (row_start, row_end)) +with system versioning; +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN +replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN +replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1; +create or replace table t2 (a int primary key) with system versioning; +--error ER_BAD_FIELD_ERROR +replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--error ER_BAD_FIELD_ERROR +replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1; +set @@system_versioning_insert_history= 1; +--error ER_WRONG_VALUE +replace into t2 (a, row_start) values (1, '1980-01-01 00:00:00'); +--error ER_WRONG_VALUE +replace into t2 (a, row_end) values (0, '1980-01-01 00:00:00'); +replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; +--echo # Changing row_end via REPLACE is NOT possible, we just insert new row: +# NOTE: because multiple versions of history row with a=1 may exist, so what REPLACE should change? +replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1990-01-01 00:00:01'); +select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; +--echo # But changing row_start via REPLACE is possible: +replace into t2 (a, row_start, row_end) values (1, '1971-01-01 00:00:00', '1980-01-01 00:00:01'); +select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; +eval replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1 for system_time all +where x > 1 and row_end < $MAX_TIMESTAMP; +select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; + +--echo # LOAD DATA +--let DATAFILE= $MYSQLTEST_VARDIR/tmp/test_versioning_t3.data +--replace_result $DATAFILE DATAFILE +eval select x, row_start, row_end into outfile '$DATAFILE' from t1 for system_time all; +create or replace table t3 like t1; +--replace_result $default_engine DEFAULT_ENGINE +show create table t3; +set @@system_versioning_insert_history= 1; +--replace_result $default_engine DEFAULT_ENGINE +show create table t3; +--replace_result $DATAFILE DATAFILE +eval load data infile '$DATAFILE' into table t3 (x, row_start, row_end); +select x, check_row_ts(row_start, row_end) from t3 for system_time all order by x; +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t3 for system_time all where x = 3; +--remove_file $DATAFILE + +--echo # Honor secure_timestamp option +--let $restart_parameters= --secure-timestamp=YES +--source include/restart_mysqld.inc +set @@system_versioning_insert_history= 1; +--error ER_BAD_FIELD_ERROR +insert into t1(x, row_start, row_end) values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--let $restart_parameters= --secure-timestamp=REPLICATION +--source include/restart_mysqld.inc +set @@system_versioning_insert_history= 1; +--error ER_BAD_FIELD_ERROR +insert into t1(x, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--let $restart_parameters= --secure-timestamp=SUPER +--source include/restart_mysqld.inc +set @@system_versioning_insert_history= 1; +insert into t1(x, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +create user nobody; +change_user nobody; +use test; +--error ER_BAD_FIELD_ERROR +insert into t1(x, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +change_user root; +use test; +--let $restart_parameters= --secure-timestamp=NO +--source include/restart_mysqld.inc + +drop tables t1, t2, t3; + -- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/rpl.test b/mysql-test/suite/versioning/t/rpl.test index 45ac3e62d7f32..3096bd60cd447 100644 --- a/mysql-test/suite/versioning/t/rpl.test +++ b/mysql-test/suite/versioning/t/rpl.test @@ -1,6 +1,7 @@ --source suite/versioning/engines.inc --source include/have_partition.inc --source include/master-slave.inc +--source suite/versioning/common.inc #BUG#12662190 - COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS #Testing command counters -BEFORE. @@ -10,6 +11,7 @@ let $slave_com_commit_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_commi let $slave_com_insert_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_insert', Value, 1); let $slave_com_delete_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_delete', Value, 1); let $slave_com_update_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_update', Value, 1); +set @@session.time_zone='+00:00'; connection master; CREATE TABLE t1 (x int) with system versioning; @@ -296,4 +298,46 @@ alter table t drop partition p0; drop tables t, t2; set timestamp= default; +--echo # +--echo # MDEV-16546 System versioning setting to allow history modification +--echo # +create table t1(x int) with system versioning; +insert into t1(x) values (1); +--error ER_BAD_FIELD_ERROR +insert into t1(x, row_start, row_end) values (2, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +set @@system_versioning_insert_history= 1; +insert into t1(x, row_start, row_end) values (3, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +update t1 set x= x + 1; +sync_slave_with_master; +set @@session.time_zone='+00:00'; +select x, check_row_ts(row_start, row_end) from t1 for system_time all order by x; +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t1 for system_time all where x = 3; + +--echo ## INSERT..SELECT +connection master; +create or replace table t2 like t1; +set @@system_versioning_insert_history= 1; +insert into t2 (x, row_start, row_end) select x, row_start, row_end from t1 for system_time all; +sync_slave_with_master; +select x, check_row_ts(row_start, row_end) from t2 for system_time all order by x; +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t2 for system_time all where x = 3; + +--echo # LOAD DATA +connection master; +--let DATAFILE= $MYSQLTEST_VARDIR/tmp/test_versioning_t3.data +--replace_result $DATAFILE DATAFILE +eval select x, row_start, row_end into outfile '$DATAFILE' from t1 for system_time all; +create or replace table t3 like t1; +set @@system_versioning_insert_history= 1; +--replace_result $DATAFILE DATAFILE +eval load data infile '$DATAFILE' into table t3 (x, row_start, row_end); +sync_slave_with_master; +select x, check_row_ts(row_start, row_end) from t3 for system_time all order by x; +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t3 for system_time all where x = 3; +--remove_file $DATAFILE + +connection master; +drop tables t1, t2, t3; + +--source suite/versioning/common_finish.inc --source include/rpl_end.inc diff --git a/sql/handler.cc b/sql/handler.cc index 4a8b58951d394..99bfc8c5c7280 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7573,6 +7573,30 @@ int handler::ha_write_row(const uchar *buf) DBUG_RETURN(error); } + if (table->versioned() && !table->vers_write) + { + Field *row_start= table->vers_start_field(); + Field *row_end= table->vers_end_field(); + MYSQL_TIME ltime; + + bitmap_set_bit(table->read_set, row_start->field_index); + bitmap_set_bit(table->read_set, row_end->field_index); + + /* + Inserting the history row directly, check ROW_START <= ROW_END and + ROW_START is non-zero. + */ + if ((row_start->cmp(row_start->ptr, row_end->ptr) >= 0) || + row_start->get_date(<ime, Datetime::Options( + TIME_NO_ZERO_DATE, time_round_mode_t(time_round_mode_t::FRAC_NONE)))) + { + String val; + row_start->val_str(&val); + my_error(ER_WRONG_VALUE, MYF(0), row_start->field_name.str, val.ptr()); + DBUG_RETURN(HA_ERR_GENERIC); + } + } + MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str); mark_trx_read_write(); increment_statistics(&SSV::ha_write_count); diff --git a/sql/item.cc b/sql/item.cc index 8bba7b65f2ef6..0021acfa8f559 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6127,6 +6127,13 @@ bool Item_field::fix_fields(THD *thd, Item **reference) else if (!from_field) goto error; + if (thd->column_usage == MARK_COLUMNS_WRITE && + from_field != view_ref_found && + thd->vers_insert_history(from_field)) + { + DBUG_ASSERT(from_field->table->versioned()); + from_field->table->vers_write= false; + } table_list= (cached_table ? cached_table : from_field != view_ref_found ? from_field->table->pos_in_table_list : 0); diff --git a/sql/log_event.cc b/sql/log_event.cc index d4d672e1dca68..eb51e89748016 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2357,6 +2357,9 @@ void Format_description_log_event::deduct_options_written_to_bin_log() return; } options_written_to_bin_log|= OPTION_EXPLICIT_DEF_TIMESTAMP; + if (server_version_split < Version(10, 11, 0)) + return; + options_written_to_bin_log|= OPTION_INSERT_HISTORY; DBUG_ASSERT(options_written_to_bin_log == OPTIONS_WRITTEN_TO_BIN_LOG); } diff --git a/sql/log_event.h b/sql/log_event.h index fb18e17aaf049..5267227b37344 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -529,7 +529,8 @@ class String; */ #define OPTIONS_WRITTEN_TO_BIN_LOG (OPTION_EXPLICIT_DEF_TIMESTAMP |\ OPTION_AUTO_IS_NULL | OPTION_NO_FOREIGN_KEY_CHECKS | \ - OPTION_RELAXED_UNIQUE_CHECKS | OPTION_NOT_AUTOCOMMIT | OPTION_IF_EXISTS) + OPTION_RELAXED_UNIQUE_CHECKS | OPTION_NOT_AUTOCOMMIT | OPTION_IF_EXISTS |\ + OPTION_INSERT_HISTORY) #define CHECKSUM_CRC32_SIGNATURE_LEN 4 /** diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 3aac06a3410a5..7036c5bf1d059 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -1042,7 +1042,8 @@ void Query_log_event::pack_info(Protocol *protocol) if (flags2 & (OPTION_NO_FOREIGN_KEY_CHECKS | OPTION_AUTO_IS_NULL | OPTION_RELAXED_UNIQUE_CHECKS | OPTION_NO_CHECK_CONSTRAINT_CHECKS | - OPTION_IF_EXISTS)) + OPTION_IF_EXISTS | + OPTION_INSERT_HISTORY)) { buf.append(STRING_WITH_LEN("set ")); if (flags2 & OPTION_NO_FOREIGN_KEY_CHECKS) diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 1338d85865f9d..1e9aeafb1c213 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -9995,9 +9995,8 @@ ER_UNKNOWN_DATA_TYPE ER_UNKNOWN_OPERATOR eng "Operator does not exists: '%-.128s'" spa "El operador no existe: '%-.128s'" -ER_WARN_HISTORY_ROW_START_TIME - eng "Table `%s.%s` history row start '%s' is later than row end '%s'" - spa "En la historia de la tabla `%s.%s` el inicio de fila '%s' es posterior al fin de fila '%s'" +ER_UNUSED_29 + eng "You should never see it" ER_PART_STARTS_BEYOND_INTERVAL eng "%`s: STARTS is later than query time, first history partition may exceed INTERVAL value" spa "%`s: STARTS es posterior al momento de consulta (query), la primera partición de historia puede exceder el valor INTERVAL" diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d78968190e011..4638674ba5249 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6311,7 +6311,8 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length, if (field->invisible == INVISIBLE_SYSTEM && thd->column_usage != MARK_COLUMNS_READ && - thd->column_usage != COLUMNS_READ) + thd->column_usage != COLUMNS_READ && + !thd->vers_insert_history(field)) DBUG_RETURN((Field*)0); } else @@ -8895,7 +8896,8 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, if (table->next_number_field && rfield->field_index == table->next_number_field->field_index) table->auto_increment_field_not_null= TRUE; - const bool skip_sys_field= rfield->vers_sys_field(); // TODO: && !thd->vers_modify_history() [MDEV-16546] + const bool skip_sys_field= rfield->vers_sys_field() && + (update || !thd->vers_insert_history(rfield)); if ((rfield->vcol_info || skip_sys_field) && !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) @@ -9180,7 +9182,10 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List &values, if (field->field_index == autoinc_index) table->auto_increment_field_not_null= TRUE; - if ((unlikely(field->vcol_info) || (vers_sys_field && !ignore_errors)) && + if ((unlikely(field->vcol_info) || + (vers_sys_field && + !ignore_errors && + !thd->vers_insert_history(field))) && !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) { diff --git a/sql/sql_class.h b/sql/sql_class.h index 08e88308347b0..f048ef22f9bc7 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5574,6 +5574,39 @@ class THD: public THD_count, /* this must be first */ { lex= backup_lex; } + + bool vers_insert_history(const Field *field) const + { + if (!field->vers_sys_field()) + return false; + DBUG_ASSERT(field->table->versioned()); + if (field->table->versioned(VERS_TRX_ID)) + return false; + if (!(variables.option_bits & OPTION_INSERT_HISTORY)) + return false; + if (lex->sql_command != SQLCOM_INSERT && + lex->sql_command != SQLCOM_INSERT_SELECT && + lex->sql_command != SQLCOM_REPLACE && + lex->sql_command != SQLCOM_REPLACE_SELECT && + lex->sql_command != SQLCOM_LOAD) + return false; + switch (opt_secure_timestamp) + { + case SECTIME_NO: + return true; + case SECTIME_SUPER: + if (security_ctx->master_access & SUPER_ACL) + return true; + return false; + case SECTIME_REPL: + if (slave_thread) + return true; + return false; + case SECTIME_YES: + return false; + } + return false; + } }; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 1e5d64885c19f..930001714f395 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -373,6 +373,7 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list, { TABLE *table= insert_table_list->table; my_bool UNINIT_VAR(autoinc_mark); + enum_sql_command sql_command_save= thd->lex->sql_command; table->next_number_field_updated= FALSE; @@ -387,10 +388,17 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list, field_index); } + thd->lex->sql_command= SQLCOM_UPDATE; + /* Check the fields we are going to modify */ if (setup_fields(thd, Ref_ptr_array(), update_fields, MARK_COLUMNS_WRITE, 0, NULL, 0)) + { + thd->lex->sql_command= sql_command_save; return -1; + } + + thd->lex->sql_command= sql_command_save; if (insert_table_list->is_view() && insert_table_list->is_merged_derived() && @@ -1735,11 +1743,17 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, if (check_duplic_insert_without_overlaps(thd, table, duplic) != 0) DBUG_RETURN(true); - if (table->versioned(VERS_TIMESTAMP) && duplic == DUP_REPLACE) + if (table->versioned(VERS_TIMESTAMP)) { // Additional memory may be required to create historical items. - if (table_list->set_insert_values(thd->mem_root)) + if (duplic == DUP_REPLACE && table_list->set_insert_values(thd->mem_root)) DBUG_RETURN(1); + + Field *row_start= table->vers_start_field(); + Field *row_end= table->vers_end_field(); + if (!fields.elements && !(row_start->invisible && row_end->invisible) && + thd->vers_insert_history(row_start)) + table->vers_write= false; } if (!select_insert) @@ -1802,8 +1816,7 @@ static int last_uniq_key(TABLE *table,uint keynr) int vers_insert_history_row(TABLE *table) { DBUG_ASSERT(table->versioned(VERS_TIMESTAMP)); - if (!table->vers_write) - return 0; + DBUG_ASSERT(table->vers_write); restore_record(table,record[1]); // Set Sys_end to now() @@ -2102,6 +2115,7 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, select_result *sink) { if (table->versioned(VERS_TRX_ID)) { + DBUG_ASSERT(table->vers_write); bitmap_set_bit(table->write_set, table->vers_start_field()->field_index); table->file->column_bitmaps_signal(); table->vers_start_field()->store(0, false); @@ -2115,7 +2129,7 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, select_result *sink) info->deleted++; if (!table->file->has_transactions()) thd->transaction->stmt.modified_non_trans_table= TRUE; - if (table->versioned(VERS_TIMESTAMP)) + if (table->versioned(VERS_TIMESTAMP) && table->vers_write) { store_record(table, record[2]); error= vers_insert_history_row(table); @@ -4191,7 +4205,6 @@ int select_insert::send_data(List &values) DBUG_RETURN(1); } - table->vers_write= table->versioned(); if (table_list) // Not CREATE ... SELECT { switch (table_list->view_check_option(thd, info.ignore)) { @@ -4203,7 +4216,6 @@ int select_insert::send_data(List &values) } error= write_record(thd, table, &info, sel_result); - table->vers_write= table->versioned(); table->auto_increment_field_not_null= FALSE; if (likely(!error)) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2f9e8eb81ff33..b61d2609aed07 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1773,7 +1773,7 @@ static bool mysql_test_call_fields(Prepared_statement *stmt, static bool select_like_stmt_test(Prepared_statement *stmt, int (*specific_prepare)(THD *thd), - ulong setup_tables_done_option) + ulonglong setup_tables_done_option) { DBUG_ENTER("select_like_stmt_test"); THD *thd= stmt->thd; @@ -1810,7 +1810,7 @@ static bool select_like_stmt_test_with_open(Prepared_statement *stmt, TABLE_LIST *tables, int (*specific_prepare)(THD *thd), - ulong setup_tables_done_option) + ulonglong setup_tables_done_option) { uint table_count= 0; DBUG_ENTER("select_like_stmt_test_with_open"); diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 381ac26f3a37a..6f4eff4880c0c 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -147,8 +147,7 @@ #define OPTION_RELAXED_UNIQUE_CHECKS (1ULL << 27) // THD, user, binlog #define OPTION_IF_EXISTS (1ULL << 28) // binlog #define OPTION_SCHEMA_TABLE (1ULL << 29) // SELECT, intern -/** Flag set if setup_tables already done */ -#define OPTION_SETUP_TABLES_DONE (1ULL << 30) // intern +#define OPTION_INSERT_HISTORY (1ULL << 30) /** If not set then the thread will ignore all warnings with level notes. */ #define OPTION_SQL_NOTES (1ULL << 31) // THD, user /** @@ -187,6 +186,8 @@ #define OPTION_BIN_COMMIT_OFF (1ULL << 43) /* The following is used to detect a conflict with DISTINCT */ #define SELECT_ALL (1ULL << 44) // SELECT, user, parser +/** Flag set if setup_tables already done */ +#define OPTION_SETUP_TABLES_DONE (1ULL << 45) // intern #define OPTION_LEX_FOUND_COMMENT (1ULL << 0) // intern, parser diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 45fed46e37590..f1ff1ca2d1d90 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -560,7 +560,7 @@ static void trace_table_dependencies(THD *thd, */ bool handle_select(THD *thd, LEX *lex, select_result *result, - ulong setup_tables_done_option) + ulonglong setup_tables_done_option) { bool res; SELECT_LEX *select_lex= lex->first_select_lex(); diff --git a/sql/sql_select.h b/sql/sql_select.h index 9174d5f7d9381..48452ce34a9c1 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2086,7 +2086,7 @@ int join_read_key2(THD *thd, struct st_join_table *tab, TABLE *table, struct st_table_ref *table_ref); bool handle_select(THD *thd, LEX *lex, select_result *result, - ulong setup_tables_done_option); + ulonglong setup_tables_done_option); bool mysql_select(THD *thd, TABLE_LIST *tables, List &list, COND *conds, uint og_num, ORDER *order, ORDER *group, Item *having, ORDER *proc_param, ulonglong select_type, diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 758edbdcbaa09..0a92422676a04 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -33,7 +33,7 @@ #include "item_windowfunc.h" bool mysql_union(THD *thd, LEX *lex, select_result *result, - SELECT_LEX_UNIT *unit, ulong setup_tables_done_option) + SELECT_LEX_UNIT *unit, ulonglong setup_tables_done_option) { DBUG_ENTER("mysql_union"); bool res; diff --git a/sql/sql_union.h b/sql/sql_union.h index 3776831bdd7b2..2cda0cbba3602 100644 --- a/sql/sql_union.h +++ b/sql/sql_union.h @@ -23,7 +23,7 @@ struct LEX; typedef class st_select_lex_unit SELECT_LEX_UNIT; bool mysql_union(THD *thd, LEX *lex, select_result *result, - SELECT_LEX_UNIT *unit, ulong setup_tables_done_option); + SELECT_LEX_UNIT *unit, ulonglong setup_tables_done_option); #endif /* SQL_UNION_INCLUDED */ diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index de7390f9500a6..e324e860d13d8 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -6954,3 +6954,10 @@ static Sys_var_ulonglong Sys_max_rowid_filter_size( SESSION_VAR(max_rowid_filter_size), CMD_LINE(REQUIRED_ARG), VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(128*1024), BLOCK_SIZE(1)); + +static Sys_var_bit Sys_system_versioning_insert_history( + "system_versioning_insert_history", + "Allows direct inserts into ROW_START and ROW_END columns", + SESSION_VAR(option_bits), CMD_LINE(OPT_ARG), + OPTION_INSERT_HISTORY, DEFAULT(FALSE), + NO_MUTEX_GUARD, IN_BINLOG); From 8d2ec37a40117996897c97904ac91b674a448cb8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 6 Sep 2022 19:28:42 +0200 Subject: [PATCH 056/113] MDEV-16546 post-review fixes * clarify the help text for --system-versioning-insert-history * move the vers_write=false check from Item_field::fix_fields() next to other vers field checks in find_field_in_table() * move row_start validation from handler::write_row() next to vers_update_fields() * make secure_timestamp check to happen in one place only, extract it into a function is_set_timestamp_vorbidden(). * overwriting vers fields is an error, just like setting @@timestamp * don't run vers_insert_history() for every row --- mysql-test/main/mysqld--help.result | 1 + .../sys_vars/r/sysvars_server_embedded.result | 2 +- .../r/sysvars_server_notembedded.result | 2 +- mysql-test/suite/versioning/r/insert.result | 19 +++--- .../suite/versioning/r/partition.result | 21 ++++++ mysql-test/suite/versioning/r/rpl.result | 19 ++++++ mysql-test/suite/versioning/t/insert.test | 21 +++--- mysql-test/suite/versioning/t/partition.test | 19 +++++- mysql-test/suite/versioning/t/rpl.test | 13 ++++ sql/handler.cc | 24 ------- sql/item.cc | 7 -- sql/mysqld.h | 1 + sql/sql_base.cc | 68 ++++++++++++++----- sql/sql_class.h | 19 +----- sql/sys_vars.cc | 11 ++- sql/table.cc | 3 - 16 files changed, 162 insertions(+), 88 deletions(-) diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 5a91d06a7686b..9523377d2ed64 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -1386,6 +1386,7 @@ The following specify which files/extra groups are read (specified before remain to ALTER --system-versioning-insert-history Allows direct inserts into ROW_START and ROW_END columns + if secure_timestamp allows changing @@timestamp --table-cache=# Deprecated; use --table-open-cache instead. --table-definition-cache=# The number of cached table definitions 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 b0174607ce221..74f6534f83376 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -3555,7 +3555,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME SYSTEM_VERSIONING_INSERT_HISTORY VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Allows direct inserts into ROW_START and ROW_END columns +VARIABLE_COMMENT Allows direct inserts into ROW_START and ROW_END columns if secure_timestamp allows changing @@timestamp NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE 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 831db50d52e42..946ae3f8b007b 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -4275,7 +4275,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME SYSTEM_VERSIONING_INSERT_HISTORY VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Allows direct inserts into ROW_START and ROW_END columns +VARIABLE_COMMENT Allows direct inserts into ROW_START and ROW_END columns if secure_timestamp allows changing @@timestamp NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/mysql-test/suite/versioning/r/insert.result b/mysql-test/suite/versioning/r/insert.result index c2ca4392a9f94..a9d3c734aef62 100644 --- a/mysql-test/suite/versioning/r/insert.result +++ b/mysql-test/suite/versioning/r/insert.result @@ -141,6 +141,8 @@ t1 CREATE TABLE `t1` ( insert into t1(x, row_start, row_end) values (3, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); insert into t2(y, row_start, row_end) values (4, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); insert into t3 values (5, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into t3 values (5, '1980-01-02 00:00:00', '1980-01-01 00:00:01'); +ERROR HY000: Incorrect row_start value: '1980-01-02 00:00:00.000000' select x, row_start, row_end from t1 for system_time all; x row_start row_end 3 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 @@ -286,18 +288,19 @@ row_start = '1980-01-01 00:00:00' row_end = '1980-01-01 00:00:01' # restart: --secure-timestamp=YES set @@system_versioning_insert_history= 1; insert into t1(x, row_start, row_end) values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); -ERROR 42S22: Unknown column 'row_start' in 'field list' +ERROR HY000: The MariaDB server is running with the --secure-timestamp=YES option so it cannot execute this statement # restart: --secure-timestamp=REPLICATION +create user nobody; +grant all privileges on test.* to nobody; set @@system_versioning_insert_history= 1; -insert into t1(x, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); -ERROR 42S22: Unknown column 'row_start' in 'field list' +insert into test.t1(x, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42000: Access denied; you need (at least one of) the BINLOG REPLAY privilege(s) for this operation # restart: --secure-timestamp=SUPER set @@system_versioning_insert_history= 1; -insert into t1(x, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); -create user nobody; -use test; -insert into t1(x, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); -ERROR 42S22: Unknown column 'row_start' in 'field list' +insert into test.t1(x, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +set @@system_versioning_insert_history= 1; +insert into test.t1(x, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG REPLAY privilege(s) for this operation use test; # restart: --secure-timestamp=NO drop tables t1, t2, t3; diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index 8ec2e1e8177ef..fa5085ec13c67 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -3257,6 +3257,7 @@ delete from t partition (px); ERROR HY000: Unknown partition 'px' in table 't' unlock tables; drop table t; +set timestamp= default; # # MDEV-28978 Assertion failure in THD::binlog_query or unexpected # ER_ERROR_ON_WRITE with auto-partitioning @@ -3266,4 +3267,24 @@ insert into t () values (),(),(),(),(),(); update t set a = 1; update t set a = 2 limit 0; drop table t; +# +# MDEV-16546 System versioning setting to allow history modification +# +create table t1 (a varchar(100)) with system versioning +partition by system_time interval 1 day +starts '2021-09-30 00:00:00' partitions 3; +set system_versioning_insert_history=1; +insert into t1 (a,row_start,row_end) values +('p0', '2021-09-30', '2021-09-30 10:00:00'), +('p1', '2021-09-30', '2021-10-01 10:00:00'), +('overflows, so also p1','2021-09-30', '2021-10-10 10:00:00'), +('pn, current', '2021-09-30', '2038-01-19 03:14:07.999999'); +select table_name,partition_name,partition_ordinal_position,partition_method,partition_description,table_rows +from information_schema.partitions where table_schema='test'; +table_name partition_name partition_ordinal_position partition_method partition_description table_rows +t1 p0 1 SYSTEM_TIME 2021-10-01 00:00:00 1 +t1 p1 2 SYSTEM_TIME 2021-10-02 00:00:00 2 +t1 pn 3 SYSTEM_TIME CURRENT 1 +drop table t1; +set system_versioning_insert_history=0; set global innodb_stats_persistent= @save_persistent; diff --git a/mysql-test/suite/versioning/r/rpl.result b/mysql-test/suite/versioning/r/rpl.result index f342cd725a2e0..a6ac9aad3ca1f 100644 --- a/mysql-test/suite/versioning/r/rpl.result +++ b/mysql-test/suite/versioning/r/rpl.result @@ -434,6 +434,25 @@ x check_row_ts(row_start, row_end) select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t3 for system_time all where x = 3; row_start = '1980-01-01 00:00:00' row_end = '1980-01-01 00:00:01' 1 1 +# why a slave cannot have system_versioning_insert_history always on +connection master; +set @@system_versioning_insert_history= 0; +set sql_mode=''; +create or replace table t1 (a int, +rs timestamp(6) as row start, re timestamp(6) as row end, +period for system_time (rs,re)) with system versioning; +insert t1 values (1, '2000-01-01 02:03:04', '2001-01-01 02:03.04'); +Warnings: +Warning 1906 The value specified for generated column 'rs' in table 't1' has been ignored +Warning 1906 The value specified for generated column 're' in table 't1' has been ignored +select a,check_row_ts(rs,re) from t1 for system_time all; +a check_row_ts(rs,re) +1 CURRENT ROW +connection slave; +select a,check_row_ts(rs,re) from t1 for system_time all; +a check_row_ts(rs,re) +1 CURRENT ROW +set sql_mode=default; connection master; drop tables t1, t2, t3; include/rpl_end.inc diff --git a/mysql-test/suite/versioning/t/insert.test b/mysql-test/suite/versioning/t/insert.test index 37307b3bf9708..e7a736d613365 100644 --- a/mysql-test/suite/versioning/t/insert.test +++ b/mysql-test/suite/versioning/t/insert.test @@ -108,6 +108,8 @@ show create table t1; insert into t1(x, row_start, row_end) values (3, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); insert into t2(y, row_start, row_end) values (4, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); insert into t3 values (5, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--error ER_WRONG_VALUE +insert into t3 values (5, '1980-01-02 00:00:00', '1980-01-01 00:00:01'); select x, row_start, row_end from t1 for system_time all; select y, row_start, row_end from t2 for system_time all; @@ -215,22 +217,25 @@ select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t --let $restart_parameters= --secure-timestamp=YES --source include/restart_mysqld.inc set @@system_versioning_insert_history= 1; ---error ER_BAD_FIELD_ERROR +--error ER_OPTION_PREVENTS_STATEMENT insert into t1(x, row_start, row_end) values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); --let $restart_parameters= --secure-timestamp=REPLICATION --source include/restart_mysqld.inc +create user nobody; +grant all privileges on test.* to nobody; +change_user nobody; set @@system_versioning_insert_history= 1; ---error ER_BAD_FIELD_ERROR -insert into t1(x, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +insert into test.t1(x, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +change_user root; --let $restart_parameters= --secure-timestamp=SUPER --source include/restart_mysqld.inc set @@system_versioning_insert_history= 1; -insert into t1(x, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); -create user nobody; +insert into test.t1(x, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); change_user nobody; -use test; ---error ER_BAD_FIELD_ERROR -insert into t1(x, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +set @@system_versioning_insert_history= 1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +insert into test.t1(x, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); change_user root; use test; --let $restart_parameters= --secure-timestamp=NO diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index 74e806f7d5fc8..2190239b2be16 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -2494,8 +2494,8 @@ lock tables t write; --error ER_UNKNOWN_PARTITION delete from t partition (px); unlock tables; -# cleanup drop table t; +set timestamp= default; --echo # --echo # MDEV-28978 Assertion failure in THD::binlog_query or unexpected @@ -2508,6 +2508,23 @@ update t set a = 2 limit 0; # cleanup drop table t; +--echo # +--echo # MDEV-16546 System versioning setting to allow history modification +--echo # +create table t1 (a varchar(100)) with system versioning +partition by system_time interval 1 day +starts '2021-09-30 00:00:00' partitions 3; +set system_versioning_insert_history=1; +insert into t1 (a,row_start,row_end) values +('p0', '2021-09-30', '2021-09-30 10:00:00'), +('p1', '2021-09-30', '2021-10-01 10:00:00'), +('overflows, so also p1','2021-09-30', '2021-10-10 10:00:00'), +('pn, current', '2021-09-30', '2038-01-19 03:14:07.999999'); +select table_name,partition_name,partition_ordinal_position,partition_method,partition_description,table_rows +from information_schema.partitions where table_schema='test'; +drop table t1; +set system_versioning_insert_history=0; + --disable_prepare_warnings set global innodb_stats_persistent= @save_persistent; --source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/rpl.test b/mysql-test/suite/versioning/t/rpl.test index 3096bd60cd447..16e6af75dbadd 100644 --- a/mysql-test/suite/versioning/t/rpl.test +++ b/mysql-test/suite/versioning/t/rpl.test @@ -336,6 +336,19 @@ select x, check_row_ts(row_start, row_end) from t3 for system_time all order by select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t3 for system_time all where x = 3; --remove_file $DATAFILE +--echo # why a slave cannot have system_versioning_insert_history always on +connection master; +set @@system_versioning_insert_history= 0; +set sql_mode=''; +create or replace table t1 (a int, + rs timestamp(6) as row start, re timestamp(6) as row end, + period for system_time (rs,re)) with system versioning; +insert t1 values (1, '2000-01-01 02:03:04', '2001-01-01 02:03.04'); +select a,check_row_ts(rs,re) from t1 for system_time all; +sync_slave_with_master; +select a,check_row_ts(rs,re) from t1 for system_time all; +set sql_mode=default; + connection master; drop tables t1, t2, t3; diff --git a/sql/handler.cc b/sql/handler.cc index 99bfc8c5c7280..4a8b58951d394 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7573,30 +7573,6 @@ int handler::ha_write_row(const uchar *buf) DBUG_RETURN(error); } - if (table->versioned() && !table->vers_write) - { - Field *row_start= table->vers_start_field(); - Field *row_end= table->vers_end_field(); - MYSQL_TIME ltime; - - bitmap_set_bit(table->read_set, row_start->field_index); - bitmap_set_bit(table->read_set, row_end->field_index); - - /* - Inserting the history row directly, check ROW_START <= ROW_END and - ROW_START is non-zero. - */ - if ((row_start->cmp(row_start->ptr, row_end->ptr) >= 0) || - row_start->get_date(<ime, Datetime::Options( - TIME_NO_ZERO_DATE, time_round_mode_t(time_round_mode_t::FRAC_NONE)))) - { - String val; - row_start->val_str(&val); - my_error(ER_WRONG_VALUE, MYF(0), row_start->field_name.str, val.ptr()); - DBUG_RETURN(HA_ERR_GENERIC); - } - } - MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str); mark_trx_read_write(); increment_statistics(&SSV::ha_write_count); diff --git a/sql/item.cc b/sql/item.cc index 0021acfa8f559..8bba7b65f2ef6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6127,13 +6127,6 @@ bool Item_field::fix_fields(THD *thd, Item **reference) else if (!from_field) goto error; - if (thd->column_usage == MARK_COLUMNS_WRITE && - from_field != view_ref_found && - thd->vers_insert_history(from_field)) - { - DBUG_ASSERT(from_field->table->versioned()); - from_field->table->vers_write= false; - } table_list= (cached_table ? cached_table : from_field != view_ref_found ? from_field->table->pos_in_table_list : 0); diff --git a/sql/mysqld.h b/sql/mysqld.h index d36e7c0a01425..90306ccb290c4 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -309,6 +309,7 @@ extern uint default_password_lifetime; extern my_bool disconnect_on_expired_password; enum secure_timestamp { SECTIME_NO, SECTIME_SUPER, SECTIME_REPL, SECTIME_YES }; +bool is_set_timestamp_forbidden(THD *thd); #ifdef HAVE_MMAP extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4638674ba5249..10a9513a909b7 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6309,11 +6309,17 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length, !DBUG_IF("test_completely_invisible")) DBUG_RETURN((Field*)0); - if (field->invisible == INVISIBLE_SYSTEM && - thd->column_usage != MARK_COLUMNS_READ && - thd->column_usage != COLUMNS_READ && - !thd->vers_insert_history(field)) - DBUG_RETURN((Field*)0); + if (thd->column_usage != MARK_COLUMNS_READ && + thd->column_usage != COLUMNS_READ) + { + if (thd->vers_insert_history(field)) + { + DBUG_ASSERT(table->versioned()); + table->vers_write= false; + } + else if (field->invisible == INVISIBLE_SYSTEM) + DBUG_RETURN((Field*)0); + } } else { @@ -8832,6 +8838,37 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List &leaves, } +static bool vers_update_or_validate_fields(TABLE *table) +{ + if (!table->versioned()) + return 0; + + if (table->vers_write) + { + table->vers_update_fields(); + return 0; + } + + Field *row_start= table->vers_start_field(); + Field *row_end= table->vers_end_field(); + MYSQL_TIME ltime; + + /* + Inserting the history row directly, check ROW_START < ROW_END and + ROW_START is non-zero. + */ + if ((row_start->cmp(row_start->ptr, row_end->ptr) < 0) && + !row_start->get_date(<ime, Datetime::Options( + TIME_NO_ZERO_DATE, time_round_mode_t(time_round_mode_t::FRAC_NONE)))) + return 0; + + StringBuffer val; + row_start->val_str(&val); + my_error(ER_WRONG_VALUE, MYF(0), row_start->field_name.str, val.c_ptr()); + return 1; +} + + /****************************************************************************** ** Fill a record with data (for INSERT or UPDATE) ** Returns : 1 if some field has wrong type @@ -8897,7 +8934,7 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, rfield->field_index == table->next_number_field->field_index) table->auto_increment_field_not_null= TRUE; const bool skip_sys_field= rfield->vers_sys_field() && - (update || !thd->vers_insert_history(rfield)); + (update || table->vers_write); if ((rfield->vcol_info || skip_sys_field) && !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) @@ -8953,8 +8990,9 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, table_arg->update_default_fields(ignore_errors)) goto err; - if (table_arg->versioned() && !only_unvers_fields) - table_arg->vers_update_fields(); + if (!only_unvers_fields && vers_update_or_validate_fields(table_arg)) + goto err; + /* Update virtual fields */ if (table_arg->vfield && table_arg->update_virtual_fields(table_arg->file, VCOL_UPDATE_FOR_WRITE)) @@ -9178,14 +9216,12 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List &values, /* Ensure the end of the list of values is not reached */ DBUG_ASSERT(value); - bool vers_sys_field= table->versioned() && field->vers_sys_field(); + const bool skip_sys_field= field->vers_sys_field() && + table->vers_write; if (field->field_index == autoinc_index) table->auto_increment_field_not_null= TRUE; - if ((unlikely(field->vcol_info) || - (vers_sys_field && - !ignore_errors && - !thd->vers_insert_history(field))) && + if ((unlikely(field->vcol_info) || (skip_sys_field && !ignore_errors)) && !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) { @@ -9193,7 +9229,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List &values, ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN, ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN), field->field_name.str, table->s->table_name.str); - if (vers_sys_field) + if (skip_sys_field) continue; } @@ -9210,8 +9246,8 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List &values, thd->abort_on_warning= FALSE; if (table->default_field && table->update_default_fields(ignore_errors)) goto err; - if (table->versioned()) - table->vers_update_fields(); + if (vers_update_or_validate_fields(table)) + goto err; if (table->vfield && table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_WRITE)) goto err; diff --git a/sql/sql_class.h b/sql/sql_class.h index f048ef22f9bc7..5910ac4cbf3f2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5575,7 +5575,7 @@ class THD: public THD_count, /* this must be first */ lex= backup_lex; } - bool vers_insert_history(const Field *field) const + bool vers_insert_history(const Field *field) { if (!field->vers_sys_field()) return false; @@ -5590,22 +5590,7 @@ class THD: public THD_count, /* this must be first */ lex->sql_command != SQLCOM_REPLACE_SELECT && lex->sql_command != SQLCOM_LOAD) return false; - switch (opt_secure_timestamp) - { - case SECTIME_NO: - return true; - case SECTIME_SUPER: - if (security_ctx->master_access & SUPER_ACL) - return true; - return false; - case SECTIME_REPL: - if (slave_thread) - return true; - return false; - case SECTIME_YES: - return false; - } - return false; + return !is_set_timestamp_forbidden(this); } }; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index e324e860d13d8..6e56e401b0267 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4780,7 +4780,8 @@ static Sys_var_harows Sys_select_limit( VALID_RANGE(0, HA_POS_ERROR), DEFAULT(HA_POS_ERROR), BLOCK_SIZE(1)); static const char *secure_timestamp_levels[]= {"NO", "SUPER", "REPLICATION", "YES", 0}; -bool Sys_var_timestamp::on_check_access_session(THD *thd) const + +bool is_set_timestamp_forbidden(THD *thd) { switch (opt_secure_timestamp) { case SECTIME_NO: @@ -4798,6 +4799,11 @@ bool Sys_var_timestamp::on_check_access_session(THD *thd) const my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), buf); return true; } + +bool Sys_var_timestamp::on_check_access_session(THD *thd) const +{ + return is_set_timestamp_forbidden(thd); +} static Sys_var_timestamp Sys_timestamp( "timestamp", "Set the time for this client", sys_var::ONLY_SESSION, NO_CMD_LINE, @@ -6957,7 +6963,8 @@ static Sys_var_ulonglong Sys_max_rowid_filter_size( static Sys_var_bit Sys_system_versioning_insert_history( "system_versioning_insert_history", - "Allows direct inserts into ROW_START and ROW_END columns", + "Allows direct inserts into ROW_START and ROW_END columns if " + "secure_timestamp allows changing @@timestamp", SESSION_VAR(option_bits), CMD_LINE(OPT_ARG), OPTION_INSERT_HISTORY, DEFAULT(FALSE), NO_MUTEX_GUARD, IN_BINLOG); diff --git a/sql/table.cc b/sql/table.cc index e94c8eabed0f0..202ff6b708f78 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -9155,9 +9155,6 @@ bool TABLE::check_period_overlaps(const KEY &key, void TABLE::vers_update_fields() { - if (!vers_write) - return; - if (versioned(VERS_TIMESTAMP)) { if (vers_start_field()->store_timestamp(in_use->query_start(), From d94ed0bb2a3305d8c1588360c0ac6a384e580981 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 10 Oct 2022 10:30:51 +0200 Subject: [PATCH 057/113] MDEV-29721 Inconsistency upon inserting history with visible period columns don't set vers_write=false if one vers column was used explicitly, instead do vers_update_fields() for columns that do not have explicit value. So, if row_start has the value and row_end not, row_end will get max by default. --- mysql-test/suite/versioning/r/insert.result | 50 +++++++++++++-------- mysql-test/suite/versioning/t/insert.test | 39 ++++++++-------- sql/sql_base.cc | 34 +++++++------- sql/sql_insert.cc | 10 ++--- sql/sql_load.cc | 1 + sql/table.cc | 15 +++++-- sql/table.h | 2 +- 7 files changed, 88 insertions(+), 63 deletions(-) diff --git a/mysql-test/suite/versioning/r/insert.result b/mysql-test/suite/versioning/r/insert.result index a9d3c734aef62..b2042df05f976 100644 --- a/mysql-test/suite/versioning/r/insert.result +++ b/mysql-test/suite/versioning/r/insert.result @@ -170,11 +170,9 @@ ERROR HY000: Incorrect row_start value: '1980-01-01 00:00:01.000000' insert into t1(x, row_start, row_end) values (7, '1980-01-01 00:00:11', '1980-01-01 00:00:11'); ERROR HY000: Incorrect row_start value: '1980-01-01 00:00:11.000000' insert into t1(x, row_start) values (8, '1980-01-01 00:00:22'); -ERROR HY000: Incorrect row_start value: '1980-01-01 00:00:22.000000' insert into t1(x, row_end) values (9, '1980-01-01 00:00:33'); -ERROR HY000: Incorrect row_start value: '0000-00-00 00:00:00.000000' +ERROR HY000: Incorrect row_start value: 'now' insert into t1(x, row_end) values (10, TIMESTAMP'2038-01-19 03:14:07.999999'); -ERROR HY000: Incorrect row_start value: '0000-00-00 00:00:00.000000' select x, check_row_ts(row_start, row_end) from t1 for system_time all order by x; x check_row_ts(row_start, row_end) 1 HISTORICAL ROW @@ -182,6 +180,8 @@ x check_row_ts(row_start, row_end) 3 HISTORICAL ROW 4 CURRENT ROW 5 HISTORICAL ROW +8 CURRENT ROW +10 CURRENT ROW select x, row_start, row_end from t1 for system_time all where x > 1 and row_end < TIMESTAMP'2038-01-19 03:14:07.999999' order by x, row_start, row_end; x row_start row_end @@ -207,6 +207,8 @@ x check_row_ts(row_start, row_end) 3 HISTORICAL ROW 4 CURRENT ROW 5 HISTORICAL ROW +8 CURRENT ROW +10 CURRENT ROW select x, row_start, row_end from t2 for system_time all where x > 1 and row_end < TIMESTAMP'2038-01-19 03:14:07.999999' order by x, row_start, row_end; x row_start row_end @@ -229,10 +231,8 @@ ERROR 42S22: Unknown column 'row_start' in 'field list' replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1; ERROR 42S22: Unknown column 'row_start' in 'field list' set @@system_versioning_insert_history= 1; -replace into t2 (a, row_start) values (1, '1980-01-01 00:00:00'); -ERROR HY000: Incorrect row_start value: '1980-01-01 00:00:00.000000' replace into t2 (a, row_end) values (0, '1980-01-01 00:00:00'); -ERROR HY000: Incorrect row_start value: '0000-00-00 00:00:00.000000' +ERROR HY000: Incorrect row_start value: 'now' replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; a row_start row_end @@ -243,63 +243,75 @@ select a, row_start, row_end from t2 for system_time all order by a, row_start, a row_start row_end 1 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 1 1980-01-01 00:00:00.000000 1990-01-01 00:00:01.000000 -# But changing row_start via REPLACE is possible: +# REPLACE is DELETE + INSERT +set timestamp=unix_timestamp('2020-10-10 10:10:10'); replace into t2 (a, row_start, row_end) values (1, '1971-01-01 00:00:00', '1980-01-01 00:00:01'); +set timestamp=default; select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; a row_start row_end 1 1971-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 1 1980-01-01 00:00:00.000000 1990-01-01 00:00:01.000000 +1 1980-01-01 00:00:00.000000 2020-10-10 10:10:10.000000 replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1 for system_time all where x > 1 and row_end < TIMESTAMP'2038-01-19 03:14:07.999999'; select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; a row_start row_end 1 1971-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 1 1980-01-01 00:00:00.000000 1990-01-01 00:00:01.000000 +1 1980-01-01 00:00:00.000000 2020-10-10 10:10:10.000000 3 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 5 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 # LOAD DATA select x, row_start, row_end into outfile 'DATAFILE' from t1 for system_time all; -create or replace table t3 like t1; -show create table t3; +create or replace table t2 like t1; +show create table t2; Table Create Table -t3 CREATE TABLE `t3` ( +t2 CREATE TABLE `t2` ( `x` int(11) NOT NULL, PRIMARY KEY (`x`) ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING set @@system_versioning_insert_history= 1; -show create table t3; +show create table t2; Table Create Table -t3 CREATE TABLE `t3` ( +t2 CREATE TABLE `t2` ( `x` int(11) NOT NULL, PRIMARY KEY (`x`) ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING -load data infile 'DATAFILE' into table t3 (x, row_start, row_end); -select x, check_row_ts(row_start, row_end) from t3 for system_time all order by x; +load data infile 'DATAFILE' into table t2 (x, row_start, row_end); +select x, check_row_ts(row_start, row_end) from t2 for system_time all order by x; x check_row_ts(row_start, row_end) 1 HISTORICAL ROW 2 CURRENT ROW 3 HISTORICAL ROW 4 CURRENT ROW 5 HISTORICAL ROW -select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t3 for system_time all where x = 3; +8 CURRENT ROW +10 CURRENT ROW +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t2 for system_time all where x = 3; row_start = '1980-01-01 00:00:00' row_end = '1980-01-01 00:00:01' 1 1 # Honor secure_timestamp option # restart: --secure-timestamp=YES set @@system_versioning_insert_history= 1; -insert into t1(x, row_start, row_end) values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into t3(z, row_start, row_end) values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR HY000: The MariaDB server is running with the --secure-timestamp=YES option so it cannot execute this statement +insert into t3 values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); ERROR HY000: The MariaDB server is running with the --secure-timestamp=YES option so it cannot execute this statement # restart: --secure-timestamp=REPLICATION create user nobody; grant all privileges on test.* to nobody; set @@system_versioning_insert_history= 1; -insert into test.t1(x, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into test.t3(z, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42000: Access denied; you need (at least one of) the BINLOG REPLAY privilege(s) for this operation +insert into test.t3 values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); ERROR 42000: Access denied; you need (at least one of) the BINLOG REPLAY privilege(s) for this operation # restart: --secure-timestamp=SUPER set @@system_versioning_insert_history= 1; -insert into test.t1(x, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into test.t3(z, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); set @@system_versioning_insert_history= 1; -insert into test.t1(x, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into test.t3(z, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG REPLAY privilege(s) for this operation +insert into test.t3 values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG REPLAY privilege(s) for this operation use test; # restart: --secure-timestamp=NO diff --git a/mysql-test/suite/versioning/t/insert.test b/mysql-test/suite/versioning/t/insert.test index e7a736d613365..8328d4d6f6b5a 100644 --- a/mysql-test/suite/versioning/t/insert.test +++ b/mysql-test/suite/versioning/t/insert.test @@ -134,13 +134,10 @@ insert into t1 set x= 5, row_start= '1980-01-01 00:00:00', row_end= '1980-01-01 insert into t1(x, row_start, row_end) values (6, '1980-01-01 00:00:01', '1980-01-01 00:00:00'); --error ER_WRONG_VALUE insert into t1(x, row_start, row_end) values (7, '1980-01-01 00:00:11', '1980-01-01 00:00:11'); ---error ER_WRONG_VALUE insert into t1(x, row_start) values (8, '1980-01-01 00:00:22'); -# NOTE: having row_start=0 might be useful and can mean -# "there is no information on when history was started" (an opposite to row_end=MAX_TIMESTAMP) +--replace_regex /'202\d-\d\d-\d\d .*'/'now'/ --error ER_WRONG_VALUE insert into t1(x, row_end) values (9, '1980-01-01 00:00:33'); ---error ER_WRONG_VALUE eval insert into t1(x, row_end) values (10, $MAX_TIMESTAMP); select x, check_row_ts(row_start, row_end) from t1 for system_time all order by x; eval select x, row_start, row_end from t1 for system_time all @@ -180,18 +177,18 @@ replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980- --error ER_BAD_FIELD_ERROR replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1; set @@system_versioning_insert_history= 1; ---error ER_WRONG_VALUE -replace into t2 (a, row_start) values (1, '1980-01-01 00:00:00'); +--replace_regex /'202\d-\d\d-\d\d .*'/'now'/ --error ER_WRONG_VALUE replace into t2 (a, row_end) values (0, '1980-01-01 00:00:00'); replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; --echo # Changing row_end via REPLACE is NOT possible, we just insert new row: -# NOTE: because multiple versions of history row with a=1 may exist, so what REPLACE should change? replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1990-01-01 00:00:01'); select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; ---echo # But changing row_start via REPLACE is possible: +--echo # REPLACE is DELETE + INSERT +set timestamp=unix_timestamp('2020-10-10 10:10:10'); replace into t2 (a, row_start, row_end) values (1, '1971-01-01 00:00:00', '1980-01-01 00:00:01'); +set timestamp=default; select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; eval replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1 for system_time all where x > 1 and row_end < $MAX_TIMESTAMP; @@ -201,16 +198,16 @@ select a, row_start, row_end from t2 for system_time all order by a, row_start, --let DATAFILE= $MYSQLTEST_VARDIR/tmp/test_versioning_t3.data --replace_result $DATAFILE DATAFILE eval select x, row_start, row_end into outfile '$DATAFILE' from t1 for system_time all; -create or replace table t3 like t1; +create or replace table t2 like t1; --replace_result $default_engine DEFAULT_ENGINE -show create table t3; +show create table t2; set @@system_versioning_insert_history= 1; --replace_result $default_engine DEFAULT_ENGINE -show create table t3; +show create table t2; --replace_result $DATAFILE DATAFILE -eval load data infile '$DATAFILE' into table t3 (x, row_start, row_end); -select x, check_row_ts(row_start, row_end) from t3 for system_time all order by x; -select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t3 for system_time all where x = 3; +eval load data infile '$DATAFILE' into table t2 (x, row_start, row_end); +select x, check_row_ts(row_start, row_end) from t2 for system_time all order by x; +select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t2 for system_time all where x = 3; --remove_file $DATAFILE --echo # Honor secure_timestamp option @@ -218,7 +215,9 @@ select row_start = '1980-01-01 00:00:00', row_end = '1980-01-01 00:00:01' from t --source include/restart_mysqld.inc set @@system_versioning_insert_history= 1; --error ER_OPTION_PREVENTS_STATEMENT -insert into t1(x, row_start, row_end) values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into t3(z, row_start, row_end) values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--error ER_OPTION_PREVENTS_STATEMENT +insert into t3 values (8, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); --let $restart_parameters= --secure-timestamp=REPLICATION --source include/restart_mysqld.inc create user nobody; @@ -226,16 +225,20 @@ grant all privileges on test.* to nobody; change_user nobody; set @@system_versioning_insert_history= 1; --error ER_SPECIFIC_ACCESS_DENIED_ERROR -insert into test.t1(x, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into test.t3(z, row_start, row_end) values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +insert into test.t3 values (9, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); change_user root; --let $restart_parameters= --secure-timestamp=SUPER --source include/restart_mysqld.inc set @@system_versioning_insert_history= 1; -insert into test.t1(x, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into test.t3(z, row_start, row_end) values (10, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); change_user nobody; set @@system_versioning_insert_history= 1; --error ER_SPECIFIC_ACCESS_DENIED_ERROR -insert into test.t1(x, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +insert into test.t3(z, row_start, row_end) values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +insert into test.t3 values (7, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); change_user root; use test; --let $restart_parameters= --secure-timestamp=NO diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 10a9513a909b7..d37f461c0b9af 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6313,10 +6313,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length, thd->column_usage != COLUMNS_READ) { if (thd->vers_insert_history(field)) - { DBUG_ASSERT(table->versioned()); - table->vers_write= false; - } else if (field->invisible == INVISIBLE_SYSTEM) DBUG_RETURN((Field*)0); } @@ -8842,12 +8839,10 @@ static bool vers_update_or_validate_fields(TABLE *table) { if (!table->versioned()) return 0; + DBUG_ASSERT(table->vers_write); - if (table->vers_write) - { - table->vers_update_fields(); + if (table->vers_update_fields()) return 0; - } Field *row_start= table->vers_start_field(); Field *row_end= table->vers_end_field(); @@ -8933,8 +8928,11 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, if (table->next_number_field && rfield->field_index == table->next_number_field->field_index) table->auto_increment_field_not_null= TRUE; + const bool skip_sys_field= rfield->vers_sys_field() && - (update || table->vers_write); + (update || table->versioned(VERS_TRX_ID) || + !(thd->variables.option_bits & OPTION_INSERT_HISTORY)); + if ((rfield->vcol_info || skip_sys_field) && !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) @@ -8949,11 +8947,14 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, if (rfield->stored_in_db()) { - if (!skip_sys_field && - unlikely(value->save_in_field(rfield, 0) < 0) && !ignore_errors) + if (!skip_sys_field) { - my_message(ER_UNKNOWN_ERROR, ER_THD(thd, ER_UNKNOWN_ERROR), MYF(0)); - goto err; + if (value->save_in_field(rfield, 0) < 0 && !ignore_errors) + { + my_message(ER_UNKNOWN_ERROR, ER_THD(thd, ER_UNKNOWN_ERROR), MYF(0)); + goto err; + } + rfield->set_has_explicit_value(); } /* In sql MODE_SIMULTANEOUS_ASSIGNMENT, @@ -8964,7 +8965,6 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, rfield->move_field_offset((my_ptrdiff_t) (table->record[1] - table->record[0])); } - rfield->set_has_explicit_value(); } if (update && thd->variables.sql_mode & MODE_SIMULTANEOUS_ASSIGNMENT) @@ -9217,7 +9217,8 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List &values, DBUG_ASSERT(value); const bool skip_sys_field= field->vers_sys_field() && - table->vers_write; + (table->versioned(VERS_TRX_ID) || + !(thd->variables.option_bits & OPTION_INSERT_HISTORY)); if (field->field_index == autoinc_index) table->auto_increment_field_not_null= TRUE; @@ -9229,10 +9230,11 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List &values, ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN, ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN), field->field_name.str, table->s->table_name.str); - if (skip_sys_field) - continue; } + if (skip_sys_field) + continue; + if (use_value) value->save_val(field); else diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 930001714f395..cb2b3a3a4e008 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1749,11 +1749,10 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, if (duplic == DUP_REPLACE && table_list->set_insert_values(thd->mem_root)) DBUG_RETURN(1); - Field *row_start= table->vers_start_field(); - Field *row_end= table->vers_end_field(); - if (!fields.elements && !(row_start->invisible && row_end->invisible) && - thd->vers_insert_history(row_start)) - table->vers_write= false; + Field *row_start= table->vers_start_field(); + Field *row_end= table->vers_end_field(); + if (!fields.elements && !(row_start->invisible && row_end->invisible)) + thd->vers_insert_history(row_start); // check privileges } if (!select_insert) @@ -4194,6 +4193,7 @@ int select_insert::send_data(List &values) bool error=0; thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields + table->reset_default_fields(); store_values(values); if (table->default_field && unlikely(table->update_default_fields(info.ignore))) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index fe574db528fad..489835c0a5f4c 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1106,6 +1106,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, } } restore_record(table, s->default_values); + table->reset_default_fields(); while ((item= it++)) { diff --git a/sql/table.cc b/sql/table.cc index 202ff6b708f78..828bccf0927d1 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -9153,9 +9153,11 @@ bool TABLE::check_period_overlaps(const KEY &key, return true; } -void TABLE::vers_update_fields() +/* returns true if vers_end_field was updated */ +bool TABLE::vers_update_fields() { - if (versioned(VERS_TIMESTAMP)) + bool res= false; + if (versioned(VERS_TIMESTAMP) && !vers_start_field()->has_explicit_value()) { if (vers_start_field()->store_timestamp(in_use->query_start(), in_use->query_start_sec_part())) @@ -9165,11 +9167,16 @@ void TABLE::vers_update_fields() vers_start_field()->set_has_explicit_value(); } - vers_end_field()->set_max(); - vers_end_field()->set_has_explicit_value(); + if (!versioned(VERS_TIMESTAMP) || !vers_end_field()->has_explicit_value()) + { + vers_end_field()->set_max(); + vers_end_field()->set_has_explicit_value(); + res= true; + } if (vfield) update_virtual_fields(file, VCOL_UPDATE_FOR_READ); + return res; } diff --git a/sql/table.h b/sql/table.h index f9ac2428d251e..482503828b132 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1842,7 +1842,7 @@ struct TABLE static bool check_period_overlaps(const KEY &key, const uchar *lhs, const uchar *rhs); int delete_row(); /* Used in majority of DML (called from fill_record()) */ - void vers_update_fields(); + bool vers_update_fields(); /* Used in DELETE, DUP REPLACE and insert history row */ void vers_update_end(); void find_constraint_correlated_indexes(); From a858ff17312405732d54e74049b958f0937d9e94 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 10 Oct 2022 17:35:23 +0200 Subject: [PATCH 058/113] different fix for MDEV-26778 --- sql/sql_insert.cc | 1 - sql/sql_load.cc | 1 - sql/sql_update.cc | 2 +- sql/table.cc | 3 --- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index cb2b3a3a4e008..73535c2cd9279 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4193,7 +4193,6 @@ int select_insert::send_data(List &values) bool error=0; thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields - table->reset_default_fields(); store_values(values); if (table->default_field && unlikely(table->update_default_fields(info.ignore))) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 489835c0a5f4c..fe574db528fad 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1106,7 +1106,6 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, } } restore_record(table, s->default_values); - table->reset_default_fields(); while ((item= it++)) { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 033f98fd7195b..f56ec5c83c941 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -51,7 +51,7 @@ compare_record(TABLE*). */ bool records_are_comparable(const TABLE *table) { - return !table->versioned(VERS_TRX_ID) && + return !table->versioned() && (((table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ) == 0) || bitmap_is_subset(table->write_set, table->read_set)); } diff --git a/sql/table.cc b/sql/table.cc index 828bccf0927d1..c85cfa203a23c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -9164,13 +9164,11 @@ bool TABLE::vers_update_fields() { DBUG_ASSERT(0); } - vers_start_field()->set_has_explicit_value(); } if (!versioned(VERS_TIMESTAMP) || !vers_end_field()->has_explicit_value()) { vers_end_field()->set_max(); - vers_end_field()->set_has_explicit_value(); res= true; } @@ -9185,7 +9183,6 @@ void TABLE::vers_update_end() if (vers_end_field()->store_timestamp(in_use->query_start(), in_use->query_start_sec_part())) DBUG_ASSERT(0); - vers_end_field()->set_has_explicit_value(); } /** From 4d1e3671d32e34f520c0b44dbd924bc918336130 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 10 Oct 2022 20:24:39 +0200 Subject: [PATCH 059/113] MDEV-29741 SHOW BINLOG EVENTS shows garbage with system_versioning_insert_history=on --- mysql-test/suite/versioning/r/binlog.result | 18 ++++++++++++++++++ mysql-test/suite/versioning/t/binlog.test | 13 +++++++++++++ sql/log_event_server.cc | 2 ++ 3 files changed, 33 insertions(+) create mode 100644 mysql-test/suite/versioning/r/binlog.result create mode 100644 mysql-test/suite/versioning/t/binlog.test diff --git a/mysql-test/suite/versioning/r/binlog.result b/mysql-test/suite/versioning/r/binlog.result new file mode 100644 index 0000000000000..88c68100f679f --- /dev/null +++ b/mysql-test/suite/versioning/r/binlog.result @@ -0,0 +1,18 @@ +# +# MDEV-29741 SHOW BINLOG EVENTS shows garbage with system_versioning_insert_history=on +# +reset master; +create table t (a int) with system versioning; +set system_versioning_insert_history= on; +insert into t (a) values (1); +set system_versioning_insert_history= off; +drop table t; +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 t (a int) with system versioning +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; set @@system_versioning_insert_history=1; insert into t (a) values (1) +master-bin.000001 # Query # # set @@system_versioning_insert_history=1; COMMIT +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ diff --git a/mysql-test/suite/versioning/t/binlog.test b/mysql-test/suite/versioning/t/binlog.test new file mode 100644 index 0000000000000..1cad112e4192e --- /dev/null +++ b/mysql-test/suite/versioning/t/binlog.test @@ -0,0 +1,13 @@ +--source include/have_log_bin.inc + +--echo # +--echo # MDEV-29741 SHOW BINLOG EVENTS shows garbage with system_versioning_insert_history=on +--echo # + +reset master; +create table t (a int) with system versioning; +set system_versioning_insert_history= on; +insert into t (a) values (1); +set system_versioning_insert_history= off; +drop table t; +source include/show_binlog_events.inc; diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 7036c5bf1d059..535a2cf93de40 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -1056,6 +1056,8 @@ void Query_log_event::pack_info(Protocol *protocol) buf.append(STRING_WITH_LEN("check_constraint_checks=1, ")); if (flags2 & OPTION_IF_EXISTS) buf.append(STRING_WITH_LEN("@@sql_if_exists=1, ")); + if (flags2 & OPTION_INSERT_HISTORY) + buf.append(STRING_WITH_LEN("@@system_versioning_insert_history=1, ")); buf[buf.length()-2]=';'; } if (query && q_len) From e536cb8845d57d5c803b51d9e4b6837d3753e00f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 10 Oct 2022 20:27:26 +0200 Subject: [PATCH 060/113] MDEV-29732 mysqlbinlog produces syntactically incorrect output with system_versioning_insert_history --- mysql-test/main/mysqlbinlog-innodb.result | 4 +- mysql-test/main/mysqlbinlog.result | 22 +++--- .../main/mysqlbinlog_row_compressed.result | 2 +- .../main/mysqlbinlog_row_minimal.result | 4 +- .../main/mysqlbinlog_stmt_compressed.result | 2 +- mysql-test/main/user_var-binlog.result | 2 +- .../suite/binlog/r/binlog_mysqlbinlog2.result | 70 +++++++++---------- .../binlog/r/binlog_mysqlbinlog_row.result | 4 +- .../r/binlog_mysqlbinlog_row_innodb.result | 8 +-- .../r/binlog_mysqlbinlog_row_myisam.result | 8 +-- .../r/binlog_mysqlbinlog_row_trans.result | 2 +- .../suite/binlog/r/binlog_row_annotate.result | 12 ++-- .../binlog/r/binlog_row_ctype_ucs.result | 4 +- .../r/binlog_row_mysqlbinlog_options.result | 4 +- .../binlog/r/binlog_stm_ctype_ucs.result | 4 +- mysql-test/suite/binlog/r/flashback.result | 4 +- .../binlog_row_annotate.result | 6 +- .../suite/engines/funcs/r/rpl_sp.result | 2 +- .../suite/galera/r/galera_gra_log.result | 2 +- .../rpl/r/rpl_blackhole_row_annotate.result | 2 +- mysql-test/suite/rpl/r/rpl_hrtime.result | 2 +- mysql-test/suite/rpl/r/rpl_mdev382.result | 6 +- .../suite/rpl/r/rpl_row_mysqlbinlog.result | 8 +-- mysql-test/suite/rpl/r/rpl_sp.result | 2 +- mysql-test/suite/rpl/r/rpl_timestamp.result | 2 +- mysql-test/suite/versioning/r/binlog.result | 39 +++++++++++ mysql-test/suite/versioning/t/binlog.test | 7 +- sql/log_event_client.cc | 3 + 28 files changed, 143 insertions(+), 94 deletions(-) diff --git a/mysql-test/main/mysqlbinlog-innodb.result b/mysql-test/main/mysqlbinlog-innodb.result index 522bbd6227687..4587ac572b09f 100644 --- a/mysql-test/main/mysqlbinlog-innodb.result +++ b/mysql-test/main/mysqlbinlog-innodb.result @@ -29,7 +29,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -60,7 +60,7 @@ START TRANSACTION use `foo`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/mysqlbinlog.result b/mysql-test/main/mysqlbinlog.result index 034d48791aa99..6574615852c30 100644 --- a/mysql-test/main/mysqlbinlog.result +++ b/mysql-test/main/mysqlbinlog.result @@ -22,7 +22,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -102,7 +102,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -138,7 +138,7 @@ START TRANSACTION /*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -189,7 +189,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -216,7 +216,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -296,7 +296,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -332,7 +332,7 @@ START TRANSACTION /*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -383,7 +383,7 @@ START TRANSACTION use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -492,7 +492,7 @@ DELIMITER /*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -544,7 +544,7 @@ DELIMITER /*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -626,6 +626,8 @@ FLUSH LOGS; INSERT INTO t1 VALUES ('0123456789'); FLUSH LOGS; DROP TABLE t1; +Warnings: +Warning 1262 Row 98 was truncated; it contained more data than there were input columns We expect this value to be 2 (one for the INSERT, one for COMMIT). The bug being tested was that 'Query' lines were not preceded by '#' If the line is in the table, it had to have been preceded by a '#' diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result index fe82520490d02..a360ba3f1e768 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.result +++ b/mysql-test/main/mysqlbinlog_row_compressed.result @@ -33,7 +33,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result index eb9def13ca751..d7bbb3d45fe42 100644 --- a/mysql-test/main/mysqlbinlog_row_minimal.result +++ b/mysql-test/main/mysqlbinlog_row_minimal.result @@ -31,7 +31,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -397,7 +397,7 @@ START TRANSACTION # server id 1 end_log_pos END_LOG_POS CRC32 XXX Query thread_id=TID exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=TID/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.result b/mysql-test/main/mysqlbinlog_stmt_compressed.result index d2968cd795c18..b2790e5a0792d 100644 --- a/mysql-test/main/mysqlbinlog_stmt_compressed.result +++ b/mysql-test/main/mysqlbinlog_stmt_compressed.result @@ -33,7 +33,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/main/user_var-binlog.result b/mysql-test/main/user_var-binlog.result index cfe5192155430..024f0482e6fd9 100644 --- a/mysql-test/main/user_var-binlog.result +++ b/mysql-test/main/user_var-binlog.result @@ -29,7 +29,7 @@ SET @`a b`:=_latin1 X'68656C6C6F' COLLATE `latin1_swedish_ci`/*!*/; use `test`/*!*/; SET TIMESTAMP=10000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result index a78db4386a917..96b3ca97da561 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result @@ -25,7 +25,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -97,7 +97,7 @@ SET INSERT_ID=1/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -163,7 +163,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -208,7 +208,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -253,7 +253,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -280,7 +280,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -325,7 +325,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -368,7 +368,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -430,7 +430,7 @@ SET INSERT_ID=6/*!*/; use `test`/*!*/; SET TIMESTAMP=1773143/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -460,7 +460,7 @@ SET INSERT_ID=1/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -516,7 +516,7 @@ SET INSERT_ID=6/*!*/; use `test`/*!*/; SET TIMESTAMP=1773143/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -546,7 +546,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -584,7 +584,7 @@ SET INSERT_ID=6/*!*/; use `test`/*!*/; SET TIMESTAMP=1773143/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -611,7 +611,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -687,7 +687,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -725,7 +725,7 @@ SET INSERT_ID=6/*!*/; use `test`/*!*/; SET TIMESTAMP=1773143/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -752,7 +752,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -794,7 +794,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -866,7 +866,7 @@ SET INSERT_ID=1/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -931,7 +931,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -976,7 +976,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1020,7 +1020,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1047,7 +1047,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1092,7 +1092,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1134,7 +1134,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1196,7 +1196,7 @@ SET INSERT_ID=6/*!*/; use `test`/*!*/; SET TIMESTAMP=1773143/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1226,7 +1226,7 @@ SET INSERT_ID=1/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1282,7 +1282,7 @@ SET INSERT_ID=6/*!*/; use `test`/*!*/; SET TIMESTAMP=1773143/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1311,7 +1311,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1349,7 +1349,7 @@ SET INSERT_ID=6/*!*/; use `test`/*!*/; SET TIMESTAMP=1773143/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1376,7 +1376,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1450,7 +1450,7 @@ SET INSERT_ID=3/*!*/; use `test`/*!*/; SET TIMESTAMP=1773144/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1488,7 +1488,7 @@ SET INSERT_ID=6/*!*/; use `test`/*!*/; SET TIMESTAMP=1773143/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1515,7 +1515,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1557,7 +1557,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1773142/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result index ebbb23ed17128..b793887af0a70 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result @@ -376,7 +376,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -5386,7 +5386,7 @@ DELIMITER /*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result index b5e817dbaab7a..1340337c0bdae 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result @@ -2270,7 +2270,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; @@ -5279,7 +5279,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; @@ -5679,7 +5679,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; @@ -6317,7 +6317,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result index d99764a1365a3..ec145fa4059e1 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result @@ -2268,7 +2268,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; @@ -5300,7 +5300,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; @@ -5706,7 +5706,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; @@ -6354,7 +6354,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result index 1bb9d5efbdd21..5735b9b804d1d 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result @@ -146,7 +146,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_row_annotate.result b/mysql-test/suite/binlog/r/binlog_row_annotate.result index bf19e999d51a4..bb4d318bdd4c2 100644 --- a/mysql-test/suite/binlog/r/binlog_row_annotate.result +++ b/mysql-test/suite/binlog/r/binlog_row_annotate.result @@ -116,7 +116,7 @@ ROLLBACK/*!*/; #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -354,7 +354,7 @@ ROLLBACK/*!*/; #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -513,7 +513,7 @@ ROLLBACK/*!*/; #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -739,7 +739,7 @@ ROLLBACK/*!*/; #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -977,7 +977,7 @@ ROLLBACK/*!*/; #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1136,7 +1136,7 @@ ROLLBACK/*!*/; #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result index 0e153116b15b6..c02912b85d97c 100644 --- a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result +++ b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result @@ -22,7 +22,7 @@ START TRANSACTION #Q> insert into t2 values (@v) SET TIMESTAMP=10000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -92,7 +92,7 @@ DELIMITER /*!*/; use `test`/*!*/; SET TIMESTAMP=XXX/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result index 6161ae4044154..a0cf5b2dcdb59 100644 --- a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result +++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result @@ -50,7 +50,7 @@ use `new_test1`/*!*/; #010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -291,7 +291,7 @@ use `new_test1`/*!*/; #010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result index dc525b2869ca6..f9dc5d647535f 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result @@ -21,7 +21,7 @@ SET @`v`:=_ucs2 X'006100620063' COLLATE `ucs2_general_ci`/*!*/; use `test`/*!*/; SET TIMESTAMP=10000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -94,7 +94,7 @@ DELIMITER /*!*/; use `test`/*!*/; SET TIMESTAMP=XXX/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; diff --git a/mysql-test/suite/binlog/r/flashback.result b/mysql-test/suite/binlog/r/flashback.result index 7b3fc0d58d3fa..2eac49397a92c 100644 --- a/mysql-test/suite/binlog/r/flashback.result +++ b/mysql-test/suite/binlog/r/flashback.result @@ -60,7 +60,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -422,7 +422,7 @@ COMMIT use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog_encryption/binlog_row_annotate.result b/mysql-test/suite/binlog_encryption/binlog_row_annotate.result index 8d2c279c35f1f..583d9a30a5aa8 100644 --- a/mysql-test/suite/binlog_encryption/binlog_row_annotate.result +++ b/mysql-test/suite/binlog_encryption/binlog_row_annotate.result @@ -120,7 +120,7 @@ ROLLBACK/*!*/; #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -361,7 +361,7 @@ ROLLBACK/*!*/; #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -523,7 +523,7 @@ ROLLBACK/*!*/; #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0 xid= SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/engines/funcs/r/rpl_sp.result b/mysql-test/suite/engines/funcs/r/rpl_sp.result index 8ae7c1ccb4535..945db68d8dd31 100644 --- a/mysql-test/suite/engines/funcs/r/rpl_sp.result +++ b/mysql-test/suite/engines/funcs/r/rpl_sp.result @@ -771,7 +771,7 @@ DELIMITER /*!*/; ROLLBACK/*!*/; SET TIMESTAMP=t/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/galera/r/galera_gra_log.result b/mysql-test/suite/galera/r/galera_gra_log.result index 66190c1ca236a..8f85a838c5d6e 100644 --- a/mysql-test/suite/galera/r/galera_gra_log.result +++ b/mysql-test/suite/galera/r/galera_gra_log.result @@ -18,7 +18,7 @@ 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, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result b/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result index 25804b60da508..37d86920f93dc 100644 --- a/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result +++ b/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result @@ -200,7 +200,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=#/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_hrtime.result b/mysql-test/suite/rpl/r/rpl_hrtime.result index 5e7a306c7c656..feae41219655c 100644 --- a/mysql-test/suite/rpl/r/rpl_hrtime.result +++ b/mysql-test/suite/rpl/r/rpl_hrtime.result @@ -37,7 +37,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1293832861/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_mdev382.result b/mysql-test/suite/rpl/r/rpl_mdev382.result index c71ea1d79a0c9..f44ce43ac0b9d 100644 --- a/mysql-test/suite/rpl/r/rpl_mdev382.result +++ b/mysql-test/suite/rpl/r/rpl_mdev382.result @@ -179,7 +179,7 @@ ROLLBACK/*!*/; use `db1``; select 'oops!'`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -279,7 +279,7 @@ ROLLBACK/*!*/; use `db1``; select 'oops!'`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -388,7 +388,7 @@ START TRANSACTION use `ts``et`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result index 9ac5f6e888e33..4dea26a5aeb17 100644 --- a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result +++ b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result @@ -168,7 +168,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -191,7 +191,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -306,7 +306,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -335,7 +335,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result index 0cb67bf47676d..645c86b317d1a 100644 --- a/mysql-test/suite/rpl/r/rpl_sp.result +++ b/mysql-test/suite/rpl/r/rpl_sp.result @@ -784,7 +784,7 @@ DELIMITER /*!*/; ROLLBACK/*!*/; SET TIMESTAMP=t/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_timestamp.result b/mysql-test/suite/rpl/r/rpl_timestamp.result index 7a2b3efcdf660..31ffd1ed37164 100644 --- a/mysql-test/suite/rpl/r/rpl_timestamp.result +++ b/mysql-test/suite/rpl/r/rpl_timestamp.result @@ -28,7 +28,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1656940000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=0/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=0, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/versioning/r/binlog.result b/mysql-test/suite/versioning/r/binlog.result index 88c68100f679f..fffd76298875e 100644 --- a/mysql-test/suite/versioning/r/binlog.result +++ b/mysql-test/suite/versioning/r/binlog.result @@ -1,7 +1,9 @@ # # MDEV-29741 SHOW BINLOG EVENTS shows garbage with system_versioning_insert_history=on +# MDEV-29732 mysqlbinlog produces syntactically incorrect output with system_versioning_insert_history # reset master; +set timestamp=1000000000; create table t (a int) with system versioning; set system_versioning_insert_history= on; insert into t (a) values (1); @@ -16,3 +18,40 @@ master-bin.000001 # Query # # use `test`; set @@system_versioning_insert_history master-bin.000001 # Query # # set @@system_versioning_insert_history=1; COMMIT master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ +flush binary logs; +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; +/*!40019 SET @@session.max_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +DELIMITER /*!*/; +ROLLBACK/*!*/; +use `test`/*!*/; +SET TIMESTAMP=1000000000/*!*/; +SET @@session.pseudo_thread_id=999999999/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; +SET @@session.sql_mode=1411383296/*!*/; +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/*!*/; +SET @@session.lc_time_names=0/*!*/; +SET @@session.collation_database=DEFAULT/*!*/; +create table t (a int) with system versioning +/*!*/; +START TRANSACTION +/*!*/; +SET TIMESTAMP=1000000000/*!*/; +SET @@session.system_versioning_insert_history=1/*!*/; +insert into t (a) values (1) +/*!*/; +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +SET TIMESTAMP=1000000000/*!*/; +SET @@session.system_versioning_insert_history=0/*!*/; +DROP TABLE `t` /* generated by server */ +/*!*/; +DELIMITER ; +# End of log file +ROLLBACK /* added by mysqlbinlog */; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; +set timestamp=default; diff --git a/mysql-test/suite/versioning/t/binlog.test b/mysql-test/suite/versioning/t/binlog.test index 1cad112e4192e..8b6de96d1b406 100644 --- a/mysql-test/suite/versioning/t/binlog.test +++ b/mysql-test/suite/versioning/t/binlog.test @@ -2,12 +2,17 @@ --echo # --echo # MDEV-29741 SHOW BINLOG EVENTS shows garbage with system_versioning_insert_history=on +--echo # MDEV-29732 mysqlbinlog produces syntactically incorrect output with system_versioning_insert_history --echo # - reset master; +set timestamp=1000000000; create table t (a int) with system versioning; set system_versioning_insert_history= on; insert into t (a) values (1); set system_versioning_insert_history= off; drop table t; source include/show_binlog_events.inc; +flush binary logs; +--let $datadir=`select @@datadir` +--exec $MYSQL_BINLOG -s $datadir/master-bin.000001 +set timestamp=default; diff --git a/sql/log_event_client.cc b/sql/log_event_client.cc index 6d308ac6cd660..3c7c3da7e6d3f 100644 --- a/sql/log_event_client.cc +++ b/sql/log_event_client.cc @@ -1904,6 +1904,9 @@ bool Query_log_event::print_query_header(IO_CACHE* file, print_set_option(file, tmp, mask & OPTION_EXPLICIT_DEF_TIMESTAMP, flags2, "@@session.explicit_defaults_for_timestamp", &need_comma) || + print_set_option(file, tmp, mask & OPTION_INSERT_HISTORY, flags2, + "@@session.system_versioning_insert_history", + &need_comma) || my_b_printf(file,"%s\n", print_event_info->delimiter)) goto err; print_event_info->flags2= flags2; From b6a608700dc7345e53800edd4ff1041252498a71 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 18 Oct 2022 18:24:27 +0200 Subject: [PATCH 061/113] MDEV-29805 Attempt to insert into system versioning columns on old server may make slave data diverge --- mysql-test/main/mysqlbinlog.result | 16 ++++++++-------- .../suite/binlog/r/binlog_base64_flag.result | 2 +- .../suite/rpl/r/rpl_old_master_29078.result | 2 +- mysql-test/suite/rpl/r/rpl_parallel_29322.result | 4 ++-- sql/log_event.cc | 6 ++---- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/mysql-test/main/mysqlbinlog.result b/mysql-test/main/mysqlbinlog.result index 6574615852c30..8cfbe20220824 100644 --- a/mysql-test/main/mysqlbinlog.result +++ b/mysql-test/main/mysqlbinlog.result @@ -726,7 +726,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1253783037/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -780,7 +780,7 @@ DELIMITER /*!*/; ROLLBACK/*!*/; SET TIMESTAMP=1253783037/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -815,7 +815,7 @@ ROLLBACK /* added by mysqlbinlog */; DELIMITER /*!*/; SET TIMESTAMP=1266652094/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -857,7 +857,7 @@ ROLLBACK /* added by mysqlbinlog */; DELIMITER /*!*/; SET TIMESTAMP=1266652094/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -975,7 +975,7 @@ AAAAAAAAAAAAAAAAAAAgrgJSFzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=0 error_code=0 xid=0 SET TIMESTAMP=1375907364/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1058,7 +1058,7 @@ AAAAAAAAAAAAAAAAAAA/rQJSGzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=1 error_code=0 xid=0 SET TIMESTAMP=1375907141/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1141,7 +1141,7 @@ AAAAAAAAAAAAAAAAAAAnrAJSHzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=0 error_code=0 xid=0 SET TIMESTAMP=1375906879/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; @@ -1224,7 +1224,7 @@ AAAAAAAAAAAAAAAAAABbsAJSEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC # Event: Query thread_id=1 exec_time=0 error_code=0 xid=0 SET TIMESTAMP=1375907933/*!*/; SET @@session.pseudo_thread_id=1/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_base64_flag.result b/mysql-test/suite/binlog/r/binlog_base64_flag.result index 8b6f767be6d52..e325feb508bf7 100644 --- a/mysql-test/suite/binlog/r/binlog_base64_flag.result +++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result @@ -59,7 +59,7 @@ ROLLBACK/*!*/; <#> use `test`/*!*/; SET TIMESTAMP=1196959712/*!*/; -<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_old_master_29078.result b/mysql-test/suite/rpl/r/rpl_old_master_29078.result index 434727e12920b..bc7f188a48e3b 100644 --- a/mysql-test/suite/rpl/r/rpl_old_master_29078.result +++ b/mysql-test/suite/rpl/r/rpl_old_master_29078.result @@ -16,7 +16,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1658586280/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; diff --git a/mysql-test/suite/rpl/r/rpl_parallel_29322.result b/mysql-test/suite/rpl/r/rpl_parallel_29322.result index 8ef68e2958713..752fb32122588 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_29322.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_29322.result @@ -42,7 +42,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1658586280/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; @@ -137,7 +137,7 @@ ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=1658586280/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/; SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8mb3 *//*!*/; diff --git a/sql/log_event.cc b/sql/log_event.cc index eb51e89748016..b7a23d0d17fb8 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2343,7 +2343,8 @@ void Format_description_log_event::calc_server_version_split() void Format_description_log_event::deduct_options_written_to_bin_log() { options_written_to_bin_log= OPTION_AUTO_IS_NULL | OPTION_NOT_AUTOCOMMIT | - OPTION_NO_FOREIGN_KEY_CHECKS | OPTION_RELAXED_UNIQUE_CHECKS; + OPTION_NO_FOREIGN_KEY_CHECKS | OPTION_RELAXED_UNIQUE_CHECKS | + OPTION_INSERT_HISTORY; if (!server_version_split.version_is_valid() || server_version_split.kind == master_version_split::KIND_MYSQL || server_version_split < Version(10,5,2)) @@ -2357,9 +2358,6 @@ void Format_description_log_event::deduct_options_written_to_bin_log() return; } options_written_to_bin_log|= OPTION_EXPLICIT_DEF_TIMESTAMP; - if (server_version_split < Version(10, 11, 0)) - return; - options_written_to_bin_log|= OPTION_INSERT_HISTORY; DBUG_ASSERT(options_written_to_bin_log == OPTIONS_WRITTEN_TO_BIN_LOG); } From fe44d46a0356128a5c97440cfab93a93f904a5e6 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 17 Oct 2022 19:09:47 +0200 Subject: [PATCH 062/113] MDEV-29721 Inconsistency upon inserting history with visible system versioning columns --- mysql-test/suite/versioning/r/misc.result | 25 +++++++++++++++++++++++ mysql-test/suite/versioning/t/misc.test | 21 +++++++++++++++++++ sql/field.cc | 6 ++++++ sql/table.cc | 5 +---- 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 mysql-test/suite/versioning/r/misc.result create mode 100644 mysql-test/suite/versioning/t/misc.test diff --git a/mysql-test/suite/versioning/r/misc.result b/mysql-test/suite/versioning/r/misc.result new file mode 100644 index 0000000000000..d74bb8607ed5c --- /dev/null +++ b/mysql-test/suite/versioning/r/misc.result @@ -0,0 +1,25 @@ +set time_zone='+00:00'; +# +# MDEV-29721 Inconsistency upon inserting history with visible system versioning columns +# +create table t1 (a int, s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning; +set system_versioning_insert_history=on; +set timestamp=unix_timestamp('2010-10-10 10:10:10'); +insert t1 (a,s,e) values (1,'2020-01-01',default), (2,'2020-02-02',ignore),(3,default,'2020-03-03'), (4,ignore,'2020-04-04'); +set timestamp=unix_timestamp('2010-11-11 11:11:11'); +insert t1 values (5,'2020-01-01',default), (6,'2020-02-02',ignore),(7,default,'2020-03-03'), (8,ignore,'2020-04-04'); +set timestamp=default; +select * from t1 for system_time all; +a s e +1 2020-01-01 00:00:00.000000 2038-01-19 03:14:07.999999 +2 2020-02-02 00:00:00.000000 2038-01-19 03:14:07.999999 +3 2010-10-10 10:10:10.000000 2020-03-03 00:00:00.000000 +4 2010-10-10 10:10:10.000000 2020-04-04 00:00:00.000000 +5 2020-01-01 00:00:00.000000 2038-01-19 03:14:07.999999 +6 2020-02-02 00:00:00.000000 2038-01-19 03:14:07.999999 +7 2010-11-11 11:11:11.000000 2020-03-03 00:00:00.000000 +8 2010-11-11 11:11:11.000000 2020-04-04 00:00:00.000000 +drop table t1; +# +# End of 10.11 tests +# diff --git a/mysql-test/suite/versioning/t/misc.test b/mysql-test/suite/versioning/t/misc.test new file mode 100644 index 0000000000000..fd7808687bcd2 --- /dev/null +++ b/mysql-test/suite/versioning/t/misc.test @@ -0,0 +1,21 @@ +# +# simple tests that don't need to be run in multiple various combinations +# +set time_zone='+00:00'; + +--echo # +--echo # MDEV-29721 Inconsistency upon inserting history with visible system versioning columns +--echo # +create table t1 (a int, s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning; +set system_versioning_insert_history=on; +set timestamp=unix_timestamp('2010-10-10 10:10:10'); +insert t1 (a,s,e) values (1,'2020-01-01',default), (2,'2020-02-02',ignore),(3,default,'2020-03-03'), (4,ignore,'2020-04-04'); +set timestamp=unix_timestamp('2010-11-11 11:11:11'); +insert t1 values (5,'2020-01-01',default), (6,'2020-02-02',ignore),(7,default,'2020-03-03'), (8,ignore,'2020-04-04'); +set timestamp=default; +select * from t1 for system_time all; +drop table t1; + +--echo # +--echo # End of 10.11 tests +--echo # diff --git a/sql/field.cc b/sql/field.cc index c7f63282f0fec..4a81ff09a29b0 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -11307,7 +11307,13 @@ bool Field::save_in_field_default_value(bool view_error_processing) This condition will go away as well as other conditions with vers_sys_field(). */ if (vers_sys_field()) + { + if (flags & VERS_ROW_START) + set_time(); + else + set_max(); return false; + } if (unlikely(flags & NO_DEFAULT_VALUE_FLAG && real_type() != MYSQL_TYPE_ENUM)) diff --git a/sql/table.cc b/sql/table.cc index c85cfa203a23c..cf1c6e6b3b61a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -9159,11 +9159,8 @@ bool TABLE::vers_update_fields() bool res= false; if (versioned(VERS_TIMESTAMP) && !vers_start_field()->has_explicit_value()) { - if (vers_start_field()->store_timestamp(in_use->query_start(), - in_use->query_start_sec_part())) - { + if (vers_start_field()->set_time()) DBUG_ASSERT(0); - } } if (!versioned(VERS_TIMESTAMP) || !vers_end_field()->has_explicit_value()) From 13901dafe1379492b4a26dcb47bb5356603873fb Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 18 Oct 2022 13:45:10 +0200 Subject: [PATCH 063/113] cleanup --- sql/sql_base.cc | 6 ++---- sql/sql_class.h | 12 ++++++++---- sql/sql_insert.cc | 6 ++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d37f461c0b9af..59d1c18bb35a4 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8930,8 +8930,7 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, table->auto_increment_field_not_null= TRUE; const bool skip_sys_field= rfield->vers_sys_field() && - (update || table->versioned(VERS_TRX_ID) || - !(thd->variables.option_bits & OPTION_INSERT_HISTORY)); + (update || !thd->vers_insert_history_fast(table)); if ((rfield->vcol_info || skip_sys_field) && !value->vcol_assignment_allowed_value() && @@ -9217,8 +9216,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List &values, DBUG_ASSERT(value); const bool skip_sys_field= field->vers_sys_field() && - (table->versioned(VERS_TRX_ID) || - !(thd->variables.option_bits & OPTION_INSERT_HISTORY)); + !thd->vers_insert_history_fast(table); if (field->field_index == autoinc_index) table->auto_increment_field_not_null= TRUE; diff --git a/sql/sql_class.h b/sql/sql_class.h index 5910ac4cbf3f2..10b24205245e3 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5575,14 +5575,18 @@ class THD: public THD_count, /* this must be first */ lex= backup_lex; } + bool vers_insert_history_fast(const TABLE *table) + { + DBUG_ASSERT(table->versioned()); + return table->versioned(VERS_TIMESTAMP) && + (variables.option_bits & OPTION_INSERT_HISTORY); + } + bool vers_insert_history(const Field *field) { if (!field->vers_sys_field()) return false; - DBUG_ASSERT(field->table->versioned()); - if (field->table->versioned(VERS_TRX_ID)) - return false; - if (!(variables.option_bits & OPTION_INSERT_HISTORY)) + if (!vers_insert_history_fast(field->table)) return false; if (lex->sql_command != SQLCOM_INSERT && lex->sql_command != SQLCOM_INSERT_SELECT && diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 73535c2cd9279..ba03fe991c244 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -898,10 +898,8 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, For single line insert, generate an error if try to set a NOT NULL field to NULL. */ - thd->count_cuted_fields= ((values_list.elements == 1 && - !ignore) ? - CHECK_FIELD_ERROR_FOR_NULL : - CHECK_FIELD_WARN); + thd->count_cuted_fields= (values_list.elements == 1 && !ignore) + ? CHECK_FIELD_ERROR_FOR_NULL : CHECK_FIELD_WARN; thd->cuted_fields = 0L; table->next_number_field=table->found_next_number_field; From 3b6742a106b4136bcfa0f1293c88b25645f04bf9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 18 Oct 2022 15:56:28 +0200 Subject: [PATCH 064/113] don't support REPLACE and INSERT ODKU with system_versioning_insert_history they'll ignore the value of system_versioning_insert_history, just as DELETE and UPDATE do --- mysql-test/suite/versioning/r/insert.result | 37 +++++---------------- mysql-test/suite/versioning/t/insert.test | 23 +++++-------- sql/sql_class.h | 5 ++- 3 files changed, 18 insertions(+), 47 deletions(-) diff --git a/mysql-test/suite/versioning/r/insert.result b/mysql-test/suite/versioning/r/insert.result index b2042df05f976..b429dc69ad21f 100644 --- a/mysql-test/suite/versioning/r/insert.result +++ b/mysql-test/suite/versioning/r/insert.result @@ -163,6 +163,8 @@ insert t1 (x) values (2) on duplicate key update x= 3, row_end= '1970-01-01 00:0 ERROR 42S22: Unknown column 'row_end' in 'field list' insert t2 (y) values (1) on duplicate key update y= 3, row_end= '1970-01-01 00:00:00'; ERROR HY000: The value specified for generated column 'row_end' in table 't2' has been ignored +insert t2 (y,row_end) values (1, '1970-01-01 00:00:00') on duplicate key update y= 3; +ERROR HY000: The value specified for generated column 'row_end' in table 't2' has been ignored insert into t1 values (4); insert into t1 set x= 5, row_start= '1980-01-01 00:00:00', row_end= '1980-01-01 00:00:01'; insert into t1(x, row_start, row_end) values (6, '1980-01-01 00:00:01', '1980-01-01 00:00:00'); @@ -231,36 +233,13 @@ ERROR 42S22: Unknown column 'row_start' in 'field list' replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1; ERROR 42S22: Unknown column 'row_start' in 'field list' set @@system_versioning_insert_history= 1; +# REPLACE ignores system_versioning_insert_history replace into t2 (a, row_end) values (0, '1980-01-01 00:00:00'); -ERROR HY000: Incorrect row_start value: 'now' -replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); -select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; -a row_start row_end -1 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 -# Changing row_end via REPLACE is NOT possible, we just insert new row: -replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1990-01-01 00:00:01'); -select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; -a row_start row_end -1 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 -1 1980-01-01 00:00:00.000000 1990-01-01 00:00:01.000000 -# REPLACE is DELETE + INSERT -set timestamp=unix_timestamp('2020-10-10 10:10:10'); -replace into t2 (a, row_start, row_end) values (1, '1971-01-01 00:00:00', '1980-01-01 00:00:01'); -set timestamp=default; -select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; -a row_start row_end -1 1971-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 -1 1980-01-01 00:00:00.000000 1990-01-01 00:00:01.000000 -1 1980-01-01 00:00:00.000000 2020-10-10 10:10:10.000000 -replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1 for system_time all -where x > 1 and row_end < TIMESTAMP'2038-01-19 03:14:07.999999'; -select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; -a row_start row_end -1 1971-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 -1 1980-01-01 00:00:00.000000 1990-01-01 00:00:01.000000 -1 1980-01-01 00:00:00.000000 2020-10-10 10:10:10.000000 -3 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 -5 1980-01-01 00:00:00.000000 1980-01-01 00:00:01.000000 +ERROR 42S22: Unknown column 'row_end' in 'field list' +replace into t3 (z, row_start) values (0, '1980-01-01 00:00:00'); +ERROR HY000: The value specified for generated column 'row_start' in table 't3' has been ignored +replace into t3 values (0, '1980-01-01 00:00:00', '1981-01-01 00:00:00'); +ERROR HY000: The value specified for generated column 'row_start' in table 't3' has been ignored # LOAD DATA select x, row_start, row_end into outfile 'DATAFILE' from t1 for system_time all; create or replace table t2 like t1; diff --git a/mysql-test/suite/versioning/t/insert.test b/mysql-test/suite/versioning/t/insert.test index 8328d4d6f6b5a..fcbf017cba1bc 100644 --- a/mysql-test/suite/versioning/t/insert.test +++ b/mysql-test/suite/versioning/t/insert.test @@ -127,6 +127,8 @@ update t2 set row_start= '1971-01-01 00:00:00'; insert t1 (x) values (2) on duplicate key update x= 3, row_end= '1970-01-01 00:00:00'; --error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN insert t2 (y) values (1) on duplicate key update y= 3, row_end= '1970-01-01 00:00:00'; +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN +insert t2 (y,row_end) values (1, '1970-01-01 00:00:00') on duplicate key update y= 3; # this should work, row_start/row_end must be mentioned explicitly: insert into t1 values (4); insert into t1 set x= 5, row_start= '1980-01-01 00:00:00', row_end= '1980-01-01 00:00:01'; @@ -177,22 +179,13 @@ replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980- --error ER_BAD_FIELD_ERROR replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1; set @@system_versioning_insert_history= 1; ---replace_regex /'202\d-\d\d-\d\d .*'/'now'/ ---error ER_WRONG_VALUE +--echo # REPLACE ignores system_versioning_insert_history +--error ER_BAD_FIELD_ERROR replace into t2 (a, row_end) values (0, '1980-01-01 00:00:00'); -replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1980-01-01 00:00:01'); -select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; ---echo # Changing row_end via REPLACE is NOT possible, we just insert new row: -replace into t2 (a, row_start, row_end) values (1, '1980-01-01 00:00:00', '1990-01-01 00:00:01'); -select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; ---echo # REPLACE is DELETE + INSERT -set timestamp=unix_timestamp('2020-10-10 10:10:10'); -replace into t2 (a, row_start, row_end) values (1, '1971-01-01 00:00:00', '1980-01-01 00:00:01'); -set timestamp=default; -select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; -eval replace into t2 (a, row_start, row_end) select x, row_start, row_end from t1 for system_time all -where x > 1 and row_end < $MAX_TIMESTAMP; -select a, row_start, row_end from t2 for system_time all order by a, row_start, row_end; +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN +replace into t3 (z, row_start) values (0, '1980-01-01 00:00:00'); +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN +replace into t3 values (0, '1980-01-01 00:00:00', '1981-01-01 00:00:00'); --echo # LOAD DATA --let DATAFILE= $MYSQLTEST_VARDIR/tmp/test_versioning_t3.data diff --git a/sql/sql_class.h b/sql/sql_class.h index 10b24205245e3..5085db8f837f3 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5579,7 +5579,8 @@ class THD: public THD_count, /* this must be first */ { DBUG_ASSERT(table->versioned()); return table->versioned(VERS_TIMESTAMP) && - (variables.option_bits & OPTION_INSERT_HISTORY); + (variables.option_bits & OPTION_INSERT_HISTORY) && + lex->duplicates == DUP_ERROR; } bool vers_insert_history(const Field *field) @@ -5590,8 +5591,6 @@ class THD: public THD_count, /* this must be first */ return false; if (lex->sql_command != SQLCOM_INSERT && lex->sql_command != SQLCOM_INSERT_SELECT && - lex->sql_command != SQLCOM_REPLACE && - lex->sql_command != SQLCOM_REPLACE_SELECT && lex->sql_command != SQLCOM_LOAD) return false; return !is_set_timestamp_forbidden(this); From ab503215081779f3e9ebb6cd21a65cb6efb86f26 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 18 Oct 2022 20:18:07 +0200 Subject: [PATCH 065/113] MDEV-29813 REPLACE/IGNORE does not work with historical records in InnoDB note that replace no longer supports system_versioning_insert_history, the test case is only for ignore --- mysql-test/suite/versioning/r/insert.result | 24 +++++++++++++++++++++ mysql-test/suite/versioning/t/insert.test | 23 ++++++++++++++++++++ sql/sql_delete.cc | 4 ++-- storage/innobase/row/row0ins.cc | 2 +- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/versioning/r/insert.result b/mysql-test/suite/versioning/r/insert.result index b429dc69ad21f..442d71c6a9167 100644 --- a/mysql-test/suite/versioning/r/insert.result +++ b/mysql-test/suite/versioning/r/insert.result @@ -295,3 +295,27 @@ ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG REPLAY use test; # restart: --secure-timestamp=NO drop tables t1, t2, t3; +# +# MDEV-29813 REPLACE/IGNORE does not work with historical records in InnoDB +# +set sql_mode='STRICT_ALL_TABLES'; +create or replace table t1 (a int) with system versioning; +set system_versioning_insert_history= on; +insert into t1 (a,row_start,row_end) values (1,'2022-01-01','2023-01-01'),(1,'2022-01-01','2023-01-01'); +select a,row_start,row_end into outfile 'mdev29813.txt' from t1 for system_time all; +create or replace table t1 (a int primary key) with system versioning; +load data infile 'mdev29813.txt' ignore into table t1 (a,row_start,row_end); +Warnings: +Warning 1062 Duplicate entry '1' for key 'PRIMARY' +select a,row_start,row_end from t1 for system_time all; +a row_start row_end +1 2022-01-01 00:00:00.000000 2023-01-01 00:00:00.000000 +create or replace table t1 (a int primary key) with system versioning; +insert ignore into t1 (a,row_start,row_end) values (1,'2022-01-01','2023-01-01'),(1,'2022-01-01','2023-01-01'); +Warnings: +Warning 1062 Duplicate entry '1' for key 'PRIMARY' +select a,row_start,row_end from t1 for system_time all; +a row_start row_end +1 2022-01-01 00:00:00.000000 2023-01-01 00:00:00.000000 +drop table t1; +set sql_mode=default; diff --git a/mysql-test/suite/versioning/t/insert.test b/mysql-test/suite/versioning/t/insert.test index fcbf017cba1bc..e6dcd1aeac6b0 100644 --- a/mysql-test/suite/versioning/t/insert.test +++ b/mysql-test/suite/versioning/t/insert.test @@ -239,4 +239,27 @@ use test; drop tables t1, t2, t3; +--echo # +--echo # MDEV-29813 REPLACE/IGNORE does not work with historical records in InnoDB +--echo # +set sql_mode='STRICT_ALL_TABLES'; + +create or replace table t1 (a int) with system versioning; +set system_versioning_insert_history= on; +insert into t1 (a,row_start,row_end) values (1,'2022-01-01','2023-01-01'),(1,'2022-01-01','2023-01-01'); +select a,row_start,row_end into outfile 'mdev29813.txt' from t1 for system_time all; + +create or replace table t1 (a int primary key) with system versioning; +load data infile 'mdev29813.txt' ignore into table t1 (a,row_start,row_end); +select a,row_start,row_end from t1 for system_time all; + +create or replace table t1 (a int primary key) with system versioning; +insert ignore into t1 (a,row_start,row_end) values (1,'2022-01-01','2023-01-01'),(1,'2022-01-01','2023-01-01'); +select a,row_start,row_end from t1 for system_time all; + +--let $datadir= `select @@datadir` +--remove_file $datadir/test/mdev29813.txt +drop table t1; +set sql_mode=default; + -- source suite/versioning/common_finish.inc diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 1f0945b1a2d9d..c74a5f0b92ed8 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -284,11 +284,11 @@ int TABLE::delete_row() vers_update_end(); int err= file->ha_update_row(record[1], record[0]); /* - MDEV-23644: we get HA_ERR_FOREIGN_DUPLICATE_KEY iff we already got history + MDEV-23644: we get HA_ERR_FOUND_DUPP_KEY iff we already got history row with same trx_id which is the result of foreign key action, so we don't need one more history row. */ - if (err == HA_ERR_FOREIGN_DUPLICATE_KEY) + if (err == HA_ERR_FOUND_DUPP_KEY) return file->ha_delete_row(record[0]); return err; } diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 7f9fbe896eeac..a3fe0bd6db776 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2348,7 +2348,7 @@ row_ins_duplicate_error_in_clust( &trx_id_len); ut_ad(trx_id_len == DATA_TRX_ID_LEN); if (trx->id == trx_read_trx_id(trx_id)) { - err = DB_FOREIGN_DUPLICATE_KEY; + err = DB_DUPLICATE_KEY; } } goto func_exit; From a3dbd5de4445d96d14c0a02817c1a192ef9e8982 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 17 Sep 2022 22:15:22 +0200 Subject: [PATCH 066/113] cleanup: mysqldump remove extra loop over result set, don't check for INVISIBLE columns, when not needed (xml ignores complete_insert and old servers cannot have INVISIBLE) --- client/mysqldump.c | 67 +++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 43 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 20c20a964b02c..12258322900e0 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1356,9 +1356,9 @@ static int get_options(int *argc, char ***argv) my_progname_short, opt_asof_timestamp); return(EX_USAGE); } + if (strcmp(default_charset, MYSQL_AUTODETECT_CHARSET_NAME) && - !(charset_info= get_charset_by_csname(default_charset, - MY_CS_PRIMARY, + !(charset_info= get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_UTF8_IS_UTF8MB3 | MY_WME)))) exit(1); if (opt_order_by_size && (*argc > 1 && !opt_databases)) @@ -3086,15 +3086,6 @@ static uint get_table_structure(const char *table, const char *db, char *table_t char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3]; char table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH]; char temp_buff[NAME_LEN*2 + 3], temp_buff2[NAME_LEN*2 + 3]; - const char *show_fields_stmt= "SELECT `COLUMN_NAME` AS `Field`, " - "`COLUMN_TYPE` AS `Type`, " - "`IS_NULLABLE` AS `Null`, " - "`COLUMN_KEY` AS `Key`, " - "`COLUMN_DEFAULT` AS `Default`, " - "`EXTRA` AS `Extra`, " - "`COLUMN_COMMENT` AS `Comment` " - "FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE " - "TABLE_SCHEMA = %s AND TABLE_NAME = %s"; FILE *sql_file= md_result_file; size_t len; my_bool is_log_table; @@ -3171,8 +3162,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t } len= my_snprintf(query_buff, sizeof(query_buff), - "SET SQL_QUOTE_SHOW_CREATE=%d", - (opt_quoted || opt_keywords)); + "SET SQL_QUOTE_SHOW_CREATE=%d", opt_quoted || opt_keywords); if (!create_options) strmov(query_buff+len, "/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') */"); @@ -3408,7 +3398,6 @@ static uint get_table_structure(const char *table, const char *db, char *table_t dynstr_append_checked(&select_field_names_for_header, quote_for_equal(row[SHOW_FIELDNAME], name_buff)); } - init=0; /* If write_data is true, then we build up insert statements for the table's data. Note: in subsequent lines of code, this test @@ -3444,6 +3433,16 @@ static uint get_table_structure(const char *table, const char *db, char *table_t } else { + const char *show_fields_stmt= "SELECT `COLUMN_NAME` AS `Field`, " + "`COLUMN_TYPE` AS `Type`, " + "`IS_NULLABLE` AS `Null`, " + "`COLUMN_KEY` AS `Key`, " + "`COLUMN_DEFAULT` AS `Default`, " + "`EXTRA` AS `Extra`, " + "`COLUMN_COMMENT` AS `Comment` " + "FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE " + "TABLE_SCHEMA = %s AND TABLE_NAME = %s"; + verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n", my_progname_short, mysql_error(mysql)); @@ -3498,14 +3497,17 @@ static uint get_table_structure(const char *table, const char *db, char *table_t while ((row= mysql_fetch_row(result))) { - if (strlen(row[SHOW_EXTRA]) && strstr(row[SHOW_EXTRA],"INVISIBLE")) - complete_insert= 1; + ulong *lengths= mysql_fetch_lengths(result); if (init) { + if (!opt_xml && !opt_no_create_info) + { + fputs(",\n",sql_file); + check_io(sql_file); + } dynstr_append_checked(&select_field_names, ", "); if (opt_header) dynstr_append_checked(&select_field_names_for_header, ", "); - } dynstr_append_checked(&select_field_names, quote_name(row[SHOW_FIELDNAME], name_buff, 0)); @@ -3513,27 +3515,6 @@ static uint get_table_structure(const char *table, const char *db, char *table_t dynstr_append_checked(&select_field_names_for_header, quote_for_equal(row[SHOW_FIELDNAME], name_buff)); init=1; - } - init=0; - mysql_data_seek(result, 0); - - while ((row= mysql_fetch_row(result))) - { - ulong *lengths= mysql_fetch_lengths(result); - if (init) - { - if (!opt_xml && !opt_no_create_info) - { - fputs(",\n",sql_file); - check_io(sql_file); - } - if (complete_insert) - dynstr_append_checked(&insert_pat, ", "); - } - init=1; - if (complete_insert) - dynstr_append_checked(&insert_pat, - quote_name(row[SHOW_FIELDNAME], name_buff, 0)); if (!opt_no_create_info) { if (opt_xml) @@ -3544,12 +3525,10 @@ static uint get_table_structure(const char *table, const char *db, char *table_t if (opt_keywords) fprintf(sql_file, " %s.%s %s", result_table, - quote_name(row[SHOW_FIELDNAME],name_buff, 0), - row[SHOW_TYPE]); + quote_name(row[SHOW_FIELDNAME],name_buff, 0), row[SHOW_TYPE]); else - fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME], - name_buff, 0), - row[SHOW_TYPE]); + fprintf(sql_file, " %s %s", + quote_name(row[SHOW_FIELDNAME], name_buff, 0), row[SHOW_TYPE]); if (row[SHOW_DEFAULT]) { fputs(" DEFAULT ", sql_file); @@ -3562,6 +3541,8 @@ static uint get_table_structure(const char *table, const char *db, char *table_t check_io(sql_file); } } + if (complete_insert) + dynstr_append_checked(&insert_pat, select_field_names.str); num_fields= mysql_num_rows(result); mysql_free_result(result); if (!opt_no_create_info) From a39b4848e46fdb519af43c77ad47be64b3427429 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 17 Sep 2022 23:35:05 +0200 Subject: [PATCH 067/113] MDEV-16733 mysqldump --tab and --xml options are conflicting --- client/mysqldump.c | 5 +++++ mysql-test/main/mysqldump.result | 1 + mysql-test/main/mysqldump.test | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/client/mysqldump.c b/client/mysqldump.c index 12258322900e0..1d23eebd64292 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1350,6 +1350,11 @@ static int get_options(int *argc, char ***argv) my_progname_short); return(EX_USAGE); } + if (opt_xml && path) + { + fprintf(stderr, "%s: --xml can't be used with --tab.\n", my_progname_short); + return(EX_USAGE); + } if (opt_asof_timestamp && strchr(opt_asof_timestamp, '\'')) { fprintf(stderr, "%s: Incorrect DATETIME value: '%s'\n", diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index c3e51542aa245..0191238ce7140 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -6584,3 +6584,4 @@ SET GLOBAL LOG_OUTPUT=DEFAULT, GLOBAL GENERAL_LOG=@save_general_log; TRUNCATE TABLE mysql.general_log; DROP DATABASE test1; # End of 10.3 tests +mysqldump: --xml can't be used with --tab. diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test index c093c5e7cd89a..c03ae71b539d4 100644 --- a/mysql-test/main/mysqldump.test +++ b/mysql-test/main/mysqldump.test @@ -2980,3 +2980,10 @@ DROP DATABASE test1; --remove_file $MYSQLTEST_VARDIR/tmp/dumptest1.sql --echo # End of 10.3 tests + +# +# MDEV-16733 mysqldump --tab and --xml options are conflicting +# +--replace_result mysqldump.exe mysqldump +--error 1 +--exec $MYSQL_DUMP --xml --tab=$MYSQLTEST_VARDIR/tmp 2>&1 From d249761ae5a33de0011f7b56ae3934016cc16aac Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 17 Sep 2022 23:36:29 +0200 Subject: [PATCH 068/113] MDEV-16029 mysqldump: dump and restore historical data --- client/mysqldump.c | 71 +++++++++--- mysql-test/suite/versioning/r/data.result | 126 ++++++++++++++++++++++ mysql-test/suite/versioning/t/data.test | 118 ++++++++++++++++++++ 3 files changed, 303 insertions(+), 12 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 1d23eebd64292..05d13859026c3 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -130,7 +130,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_no_data_m opt_events= 0, opt_comments_used= 0, opt_alltspcs=0, opt_notspcs= 0, opt_logging, opt_header=0, - opt_drop_trigger= 0; + opt_drop_trigger= 0, opt_dump_history= 0; #define OPT_SYSTEM_ALL 1 #define OPT_SYSTEM_USERS 2 #define OPT_SYSTEM_PLUGINS 4 @@ -353,6 +353,8 @@ static struct my_option my_long_options[] = "'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER " "TABLE tb_name ENABLE KEYS */; will be put in the output.", &opt_disable_keys, &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"dump-history", 'H', "Dump tables with history", &opt_dump_history, + &opt_dump_history, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"dump-slave", OPT_MYSQLDUMP_SLAVE_DATA, "This causes the binary log position and filename of the master to be " "appended to the dumped data output. Setting the value to 1, will print" @@ -1355,6 +1357,24 @@ static int get_options(int *argc, char ***argv) fprintf(stderr, "%s: --xml can't be used with --tab.\n", my_progname_short); return(EX_USAGE); } + if (opt_xml && opt_dump_history) + { + fprintf(stderr, "%s: --xml can't be used with --dump-history.\n", + my_progname_short); + return(EX_USAGE); + } + if (opt_replace_into && opt_dump_history) + { + fprintf(stderr, "%s: --dump-history can't be used with --replace.\n", + my_progname_short); + return(EX_USAGE); + } + if (opt_asof_timestamp && opt_dump_history) + { + fprintf(stderr, "%s: --dump-history can't be used with --as-of.\n", + my_progname_short); + return(EX_USAGE); + } if (opt_asof_timestamp && strchr(opt_asof_timestamp, '\'')) { fprintf(stderr, "%s: Incorrect DATETIME value: '%s'\n", @@ -3148,7 +3168,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t if (versioned) { - if (!opt_asof_timestamp) + if (!opt_asof_timestamp && !opt_dump_history) versioned= NULL; else { @@ -3180,6 +3200,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t if (!opt_xml && !mysql_query_with_error_report(mysql, 0, query_buff)) { + int vers_hidden= opt_dump_history && versioned && *versioned; /* using SHOW CREATE statement */ if (!opt_no_create_info) { @@ -3377,8 +3398,10 @@ static uint get_table_structure(const char *table, const char *db, char *table_t dynstr_free(&create_table_str); mysql_free_result(result); } - my_snprintf(query_buff, sizeof(query_buff), "show fields from %s", - result_table); + my_snprintf(query_buff, sizeof(query_buff), + "select column_name, extra, generation_expression " + "from information_schema.columns where table_schema=database() " + "and table_name=%s", quote_for_equal(table, temp_buff)); if (mysql_query_with_error_report(mysql, &result, query_buff)) { if (path) @@ -3388,8 +3411,10 @@ static uint get_table_structure(const char *table, const char *db, char *table_t while ((row= mysql_fetch_row(result))) { - if (strlen(row[SHOW_EXTRA]) && strstr(row[SHOW_EXTRA],"INVISIBLE")) + if (strstr(row[1],"INVISIBLE")) complete_insert= 1; + if (vers_hidden && row[2]) + vers_hidden= strcmp(row[2], "ROW START"); if (init) { dynstr_append_checked(&select_field_names, ", "); @@ -3398,11 +3423,18 @@ static uint get_table_structure(const char *table, const char *db, char *table_t } init=1; dynstr_append_checked(&select_field_names, - quote_name(row[SHOW_FIELDNAME], name_buff, 0)); + quote_name(row[0], name_buff, 0)); if (opt_header) dynstr_append_checked(&select_field_names_for_header, - quote_for_equal(row[SHOW_FIELDNAME], name_buff)); + quote_for_equal(row[0], name_buff)); } + + if (vers_hidden) + { + complete_insert= 1; + dynstr_append_checked(&select_field_names, ", row_start, row_end"); + } + /* If write_data is true, then we build up insert statements for the table's data. Note: in subsequent lines of code, this test @@ -3433,7 +3465,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t if (complete_insert) dynstr_append_checked(&insert_pat, select_field_names.str); - num_fields= mysql_num_rows(result); + num_fields= mysql_num_rows(result) + (vers_hidden ? 2 : 0); mysql_free_result(result); } else @@ -4033,10 +4065,15 @@ static char *alloc_query_str(size_t size) static void vers_append_system_time(DYNAMIC_STRING* query_string) { - DBUG_ASSERT(opt_asof_timestamp); - dynstr_append_checked(query_string, " FOR SYSTEM_TIME AS OF TIMESTAMP '"); - dynstr_append_checked(query_string, opt_asof_timestamp); - dynstr_append_checked(query_string, "'"); + if (opt_dump_history) + dynstr_append_checked(query_string, " FOR SYSTEM_TIME ALL"); + else + { + DBUG_ASSERT(opt_asof_timestamp); + dynstr_append_checked(query_string, " FOR SYSTEM_TIME AS OF TIMESTAMP '"); + dynstr_append_checked(query_string, opt_asof_timestamp); + dynstr_append_checked(query_string, "'"); + } } @@ -4282,6 +4319,11 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, goto err; } + if (versioned && !opt_xml && opt_dump_history) + { + fprintf(md_result_file,"/*!101100 SET system_versioning_insert_history=1 */;\n"); + check_io(md_result_file); + } if (opt_lock) { fprintf(md_result_file,"LOCK TABLES %s WRITE;\n", opt_quoted_table); @@ -4579,6 +4621,11 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, fprintf(md_result_file, "commit;\n"); check_io(md_result_file); } + if (versioned && !opt_xml && opt_dump_history) + { + fprintf(md_result_file,"/*!101100 SET system_versioning_insert_history=1 */;\n"); + check_io(md_result_file); + } mysql_free_result(res); } dynstr_free(&query_string); diff --git a/mysql-test/suite/versioning/r/data.result b/mysql-test/suite/versioning/r/data.result index 88ba4156afe9c..320bd88a4245a 100644 --- a/mysql-test/suite/versioning/r/data.result +++ b/mysql-test/suite/versioning/r/data.result @@ -57,3 +57,129 @@ INSERT INTO `t1` VALUES #MYSQL_DUMP --compact --as-of="1990-08-04 00:00' where 'abc" test 2>&1 mysqldump: Incorrect DATETIME value: '1990-08-04 00:00' where 'abc' drop tables t1; +# +# MDEV-16029 mysqldump: dump and restore historical data +# +create or replace table t1 (x int) with system versioning; +set timestamp=unix_timestamp('2010-10-10 10:10:10.101010'); +insert into t1 values (1), (2); +set timestamp=unix_timestamp('2011-11-11 11:11:11.111111'); +delete from t1 where x = 1; +set timestamp=default; +select row_start, row_end into @s1, @e1 from t1 for system_time all where x = 1; +select row_start, row_end into @s2, @e2 from t1 for system_time all where x = 2; +create or replace table t2 ( +x int, +row_start timestamp(6) as row start invisible, +row_end timestamp(6) as row end invisible, +period for system_time (row_start, row_end)) +with system versioning; +create or replace function check_fields(x int, row_start timestamp(6), row_end timestamp(6)) +returns char(50) deterministic +return if (x = 1, +if (row_start = @s1 and row_end = @e1, '[CORRECT]', '[WRONG]'), +if (x = 2 and row_start = @s2 and row_end = @e2, '[CORRECT]', '[WRONG]')); +set @@system_versioning_insert_history= 1; +insert into t2 (x, row_start, row_end) select x, row_start, row_end from t1 for system_time all; +set @@system_versioning_insert_history= 0; +# t2 has the same data as t1 +select x, check_fields(x, row_start, row_end) from t2 for system_time all order by x; +x check_fields(x, row_start, row_end) +1 [CORRECT] +2 [CORRECT] +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t1` ( + `x` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!101100 SET system_versioning_insert_history=1 */; +INSERT INTO `t1` (`x`, row_start, row_end) VALUES (1,'2010-10-10 10:10:10.101010','2011-11-11 11:11:11.111111'), +(2,'2010-10-10 10:10:10.101010','2038-01-19 03:14:07.999999'); +/*!101100 SET system_versioning_insert_history=1 */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t2` ( + `x` int(11) DEFAULT NULL, + `row_start` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE, + `row_end` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE, + PERIOD FOR SYSTEM_TIME (`row_start`, `row_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!101100 SET system_versioning_insert_history=1 */; +INSERT INTO `t2` (`x`, `row_start`, `row_end`) VALUES (1,'2010-10-10 10:10:10.101010','2011-11-11 11:11:11.111111'), +(2,'2010-10-10 10:10:10.101010','2038-01-19 03:14:07.999999'); +/*!101100 SET system_versioning_insert_history=1 */; +mysqldump: --dump-history can't be used with --as-of. +mysqldump: --dump-history can't be used with --replace. +mysqldump: --xml can't be used with --dump-history. +# SQL dump with/without history +## With history +drop tables t1, t2; +select x, check_fields(x, row_start, row_end) from t1 for system_time all order by x; +x check_fields(x, row_start, row_end) +1 [CORRECT] +2 [CORRECT] +select x, check_fields(x, row_start, row_end) from t2 for system_time all order by x; +x check_fields(x, row_start, row_end) +1 [CORRECT] +2 [CORRECT] +## Without history +drop tables t1, t2; +select x, check_row_ts(row_start, row_end) from t1 for system_time all order by x; +x check_row_ts(row_start, row_end) +2 CURRENT ROW +select x, check_row_ts(row_start, row_end) from t2 for system_time all order by x; +x check_row_ts(row_start, row_end) +2 CURRENT ROW +## History and --no-create-info --skip-comments +create or replace table t1 (x int) with system versioning; +delete from t2; +delete history from t2; +select x, check_fields(x, row_start, row_end) from t1 for system_time all order by x; +x check_fields(x, row_start, row_end) +1 [CORRECT] +2 [CORRECT] +select x, check_fields(x, row_start, row_end) from t2 for system_time all order by x; +x check_fields(x, row_start, row_end) +1 [CORRECT] +2 [CORRECT] +## compact +select x, check_fields(x, row_start, row_end) from t1 for system_time all order by x; +x check_fields(x, row_start, row_end) +1 [CORRECT] +2 [CORRECT] +select x, check_fields(x, row_start, row_end) from t2 for system_time all order by x; +x check_fields(x, row_start, row_end) +1 [CORRECT] +2 [CORRECT] +create or replace table t1 (x int) with system versioning; +# --tab with history +drop tables t1, t2; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `x` int(11) DEFAULT NULL, + `row_start` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE, + `row_end` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE, + PERIOD FOR SYSTEM_TIME (`row_start`, `row_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +set @@system_versioning_insert_history= 1; +load data infile 'tmp/t1.txt' into table t1 (x, row_start, row_end); +load data infile 'tmp/t2.txt' into table t2 (x, row_start, row_end); +set @@system_versioning_insert_history= 0; +select *, check_row_ts(row_start, row_end) from t1 for system_time all; +x check_row_ts(row_start, row_end) +1 HISTORICAL ROW +2 CURRENT ROW +select *, check_row_ts(row_start, row_end) from t2 for system_time all; +x check_row_ts(row_start, row_end) +1 HISTORICAL ROW +2 CURRENT ROW +drop tables t1, t2; +drop function check_fields; diff --git a/mysql-test/suite/versioning/t/data.test b/mysql-test/suite/versioning/t/data.test index 4046ec609dd23..155130d6cd6be 100644 --- a/mysql-test/suite/versioning/t/data.test +++ b/mysql-test/suite/versioning/t/data.test @@ -29,4 +29,122 @@ set timestamp=default; drop tables t1; +--echo # +--echo # MDEV-16029 mysqldump: dump and restore historical data +--echo # +create or replace table t1 (x int) with system versioning; +set timestamp=unix_timestamp('2010-10-10 10:10:10.101010'); +insert into t1 values (1), (2); +set timestamp=unix_timestamp('2011-11-11 11:11:11.111111'); +delete from t1 where x = 1; +set timestamp=default; +select row_start, row_end into @s1, @e1 from t1 for system_time all where x = 1; +select row_start, row_end into @s2, @e2 from t1 for system_time all where x = 2; + +create or replace table t2 ( + x int, + row_start timestamp(6) as row start invisible, + row_end timestamp(6) as row end invisible, + period for system_time (row_start, row_end)) +with system versioning; + +eval +create or replace function check_fields(x int, row_start timestamp(6), row_end timestamp(6)) + returns char(50) deterministic + return if (x = 1, + if (row_start = @s1 and row_end = @e1, '[CORRECT]', '[WRONG]'), + if (x = 2 and row_start = @s2 and row_end = @e2, '[CORRECT]', '[WRONG]')); + +set @@system_versioning_insert_history= 1; +insert into t2 (x, row_start, row_end) select x, row_start, row_end from t1 for system_time all; +set @@system_versioning_insert_history= 0; +--echo # t2 has the same data as t1 +select x, check_fields(x, row_start, row_end) from t2 for system_time all order by x; + +--let TMP= $MYSQLTEST_VARDIR/tmp + +--exec $MYSQL_DUMP --dump-history --databases test > $TMP/dump_history.sql +--exec $MYSQL_DUMP --databases test > $TMP/dump_no_history.sql +--exec $MYSQL_DUMP --dump-history --no-create-info --skip-comments --databases test > $TMP/dump_only_data.sql +--exec $MYSQL_DUMP --dump-history --compact test 2>&1 > $TMP/dump_history_compact.sql +--cat_file $TMP/dump_history_compact.sql +--replace_result mysqldump.exe mysqldump +--error 1 +--exec $MYSQL_DUMP --dump-history --as-of="1990-01-02 00:00" test 2>&1 +--replace_result mysqldump.exe mysqldump +--error 1 +--exec $MYSQL_DUMP --dump-history --replace test 2>&1 +--replace_result mysqldump.exe mysqldump +--error 1 +--exec $MYSQL_DUMP --dump-history --xml test 2>&1 + +--exec $MYSQL_DUMP --dump-history --tab=$TMP test + +--echo # SQL dump with/without history +--echo ## With history +drop tables t1, t2; +--exec $MYSQL test < $TMP/dump_history.sql +select x, check_fields(x, row_start, row_end) from t1 for system_time all order by x; +select x, check_fields(x, row_start, row_end) from t2 for system_time all order by x; +--echo ## Without history +drop tables t1, t2; +--exec $MYSQL test < $TMP/dump_no_history.sql +select x, check_row_ts(row_start, row_end) from t1 for system_time all order by x; +select x, check_row_ts(row_start, row_end) from t2 for system_time all order by x; + +--echo ## History and --no-create-info --skip-comments +create or replace table t1 (x int) with system versioning; +delete from t2; delete history from t2; +--exec $MYSQL test < $TMP/dump_only_data.sql +select x, check_fields(x, row_start, row_end) from t1 for system_time all order by x; +select x, check_fields(x, row_start, row_end) from t2 for system_time all order by x; + +--echo ## compact +--exec $MYSQL test < $TMP/dump_history.sql +select x, check_fields(x, row_start, row_end) from t1 for system_time all order by x; +select x, check_fields(x, row_start, row_end) from t2 for system_time all order by x; + +create or replace table t1 (x int) with system versioning; + +# TODO: MDEV-16766 mysqldump: dump history in XML +if (0) +{ +--echo # XML with history +drop table t1; +create or replace table t1 (x int) with system versioning; +delete from t2; +delete history from t2; +set @@system_versioning_insert_history= 1; +--replace_result $TMP TMP +eval load xml infile '$TMP/dump_history.xml' into table t1; +--exec cp $TMP/dump_history.xml /tmp +set @@system_versioning_insert_history= 0; +--echo ## History is now loaded as current data (TODO) +select *, check_row_ts(row_start, row_end) from t1 for system_time all; +# TODO: check mysqlimport +# --exec $MYSQL_IMPORT test $TMP/dump_history.xml +} + +--echo # --tab with history +drop tables t1, t2; +--exec $MYSQL test < $TMP/t1.sql +--exec $MYSQL test < $TMP/t2.sql +show create table t1; +show create table t2; +set @@system_versioning_insert_history= 1; +--replace_result $TMP tmp +eval load data infile '$TMP/t1.txt' into table t1 (x, row_start, row_end); +--replace_result $TMP tmp +eval load data infile '$TMP/t2.txt' into table t2 (x, row_start, row_end); +set @@system_versioning_insert_history= 0; +select *, check_row_ts(row_start, row_end) from t1 for system_time all; +select *, check_row_ts(row_start, row_end) from t2 for system_time all; + +# Cleanup +--remove_files_wildcard $TMP *.sql +--remove_files_wildcard $TMP *.txt +--remove_files_wildcard $TMP *.xml +drop tables t1, t2; +drop function check_fields; + --source suite/versioning/common_finish.inc From 73b2a326d290040e8abd68bc02ffb2182f79d1d1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 10 Oct 2022 19:45:10 +0200 Subject: [PATCH 069/113] MDEV-29730 mysqldump --dump-history creates broken dump if there are precision-versioned tables --- client/mysqldump.c | 14 +++++++++++--- mysql-test/suite/versioning/r/data.result | 23 +++++++++++++++++++++++ mysql-test/suite/versioning/t/data.test | 19 +++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 05d13859026c3..dcc8c6ed69bae 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3399,7 +3399,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t mysql_free_result(result); } my_snprintf(query_buff, sizeof(query_buff), - "select column_name, extra, generation_expression " + "select column_name, extra, generation_expression, data_type " "from information_schema.columns where table_schema=database() " "and table_name=%s", quote_for_equal(table, temp_buff)); if (mysql_query_with_error_report(mysql, &result, query_buff)) @@ -3413,8 +3413,16 @@ static uint get_table_structure(const char *table, const char *db, char *table_t { if (strstr(row[1],"INVISIBLE")) complete_insert= 1; - if (vers_hidden && row[2]) - vers_hidden= strcmp(row[2], "ROW START"); + if (vers_hidden && row[2] && strcmp(row[2], "ROW START") == 0) + { + vers_hidden= 0; + if (row[3] && strcmp(row[3], "bigint") == 0) + { + maybe_die(EX_ILLEGAL_TABLE, "Cannot use --dump-history for table %s with transaction-precise history", + result_table); + *versioned= 0; + } + } if (init) { dynstr_append_checked(&select_field_names, ", "); diff --git a/mysql-test/suite/versioning/r/data.result b/mysql-test/suite/versioning/r/data.result index 320bd88a4245a..e12520864ca31 100644 --- a/mysql-test/suite/versioning/r/data.result +++ b/mysql-test/suite/versioning/r/data.result @@ -183,3 +183,26 @@ x check_row_ts(row_start, row_end) 2 CURRENT ROW drop tables t1, t2; drop function check_fields; +# +# MDEV-29730 mysqldump --dump-history creates broken dump if there are precision-versioned tables +# +create table t1 (x int, +rs BIGINT unsigned as row start, re BiGiNt unsigned as row end, +period for system_time (rs,re)) with system versioning engine=innodb; +insert t1 (x) values (1); +insert t1 (x) values (2); +delete from t1 where x=1; +mysqldump: Cannot use --dump-history for table `t1` with transaction-precise history +mysqldump: Cannot use --dump-history for table `t1` with transaction-precise history +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t1` ( + `x` int(11) DEFAULT NULL, + `rs` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `re` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`rs`, `re`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING; +/*!40101 SET character_set_client = @saved_cs_client */; +INSERT INTO `t1` VALUES +(2,XXX,18446744073709551615); +drop table t1; diff --git a/mysql-test/suite/versioning/t/data.test b/mysql-test/suite/versioning/t/data.test index 155130d6cd6be..501cbfc54e6fe 100644 --- a/mysql-test/suite/versioning/t/data.test +++ b/mysql-test/suite/versioning/t/data.test @@ -147,4 +147,23 @@ select *, check_row_ts(row_start, row_end) from t2 for system_time all; drop tables t1, t2; drop function check_fields; +--echo # +--echo # MDEV-29730 mysqldump --dump-history creates broken dump if there are precision-versioned tables +--echo # +create table t1 (x int, + rs BIGINT unsigned as row start, re BiGiNt unsigned as row end, + period for system_time (rs,re)) with system versioning engine=innodb; +insert t1 (x) values (1); +insert t1 (x) values (2); +delete from t1 where x=1; + +--replace_result mysqldump.exe mysqldump +--error 6 +--exec $MYSQL_DUMP --dump-history test 2>&1 >/dev/null +--replace_regex /2,\d+,/2,XXX,/ /mysqldump\.exe/mysqldump/ +--error 6 +--exec $MYSQL_DUMP --force --dump-history --compact test 2>&1 + +drop table t1; + --source suite/versioning/common_finish.inc From a6f9694650743f7ae33e505429595c1860da70d2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 11 Oct 2022 11:02:27 +0200 Subject: [PATCH 070/113] MDEV-29736 mysqldump sets system_versioning_insert_history=1 twice and doesn't restore previous value --- client/mysqldump.c | 4 ++-- mysql-test/suite/versioning/r/data.result | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index dcc8c6ed69bae..de6c4ac35bedb 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -4329,7 +4329,7 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, if (versioned && !opt_xml && opt_dump_history) { - fprintf(md_result_file,"/*!101100 SET system_versioning_insert_history=1 */;\n"); + fprintf(md_result_file,"/*!101100 SET @old_system_versioning_insert_history=@@session.system_versioning_insert_history, @@session.system_versioning_insert_history=1 */;\n"); check_io(md_result_file); } if (opt_lock) @@ -4631,7 +4631,7 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, } if (versioned && !opt_xml && opt_dump_history) { - fprintf(md_result_file,"/*!101100 SET system_versioning_insert_history=1 */;\n"); + fprintf(md_result_file,"/*!101100 SET system_versioning_insert_history=@old_system_versioning_insert_history */;\n"); check_io(md_result_file); } mysql_free_result(res); diff --git a/mysql-test/suite/versioning/r/data.result b/mysql-test/suite/versioning/r/data.result index e12520864ca31..045d61b599427 100644 --- a/mysql-test/suite/versioning/r/data.result +++ b/mysql-test/suite/versioning/r/data.result @@ -93,10 +93,10 @@ CREATE TABLE `t1` ( `x` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING; /*!40101 SET character_set_client = @saved_cs_client */; -/*!101100 SET system_versioning_insert_history=1 */; +/*!101100 SET @old_system_versioning_insert_history=@@session.system_versioning_insert_history, @@session.system_versioning_insert_history=1 */; INSERT INTO `t1` (`x`, row_start, row_end) VALUES (1,'2010-10-10 10:10:10.101010','2011-11-11 11:11:11.111111'), (2,'2010-10-10 10:10:10.101010','2038-01-19 03:14:07.999999'); -/*!101100 SET system_versioning_insert_history=1 */; +/*!101100 SET system_versioning_insert_history=@old_system_versioning_insert_history */; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t2` ( @@ -106,10 +106,10 @@ CREATE TABLE `t2` ( PERIOD FOR SYSTEM_TIME (`row_start`, `row_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING; /*!40101 SET character_set_client = @saved_cs_client */; -/*!101100 SET system_versioning_insert_history=1 */; +/*!101100 SET @old_system_versioning_insert_history=@@session.system_versioning_insert_history, @@session.system_versioning_insert_history=1 */; INSERT INTO `t2` (`x`, `row_start`, `row_end`) VALUES (1,'2010-10-10 10:10:10.101010','2011-11-11 11:11:11.111111'), (2,'2010-10-10 10:10:10.101010','2038-01-19 03:14:07.999999'); -/*!101100 SET system_versioning_insert_history=1 */; +/*!101100 SET system_versioning_insert_history=@old_system_versioning_insert_history */; mysqldump: --dump-history can't be used with --as-of. mysqldump: --dump-history can't be used with --replace. mysqldump: --xml can't be used with --dump-history. From 7bdc024fb0a1869ca793748a226b701295bc6542 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 20 Oct 2022 14:09:53 +0200 Subject: [PATCH 071/113] MDEV-29830 Assertion `table->versioned()' in THD::vers_insert_history_fast remove assert temporarily, the proper fix comes after MDEV-29833 --- mysql-test/suite/versioning/r/misc.result | 10 ++++++++++ mysql-test/suite/versioning/t/misc.test | 10 ++++++++++ sql/sql_class.h | 1 - 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/versioning/r/misc.result b/mysql-test/suite/versioning/r/misc.result index d74bb8607ed5c..22a83b2427167 100644 --- a/mysql-test/suite/versioning/r/misc.result +++ b/mysql-test/suite/versioning/r/misc.result @@ -21,5 +21,15 @@ a s e 8 2010-11-11 11:11:11.000000 2020-04-04 00:00:00.000000 drop table t1; # +# MDEV-29830 Assertion `table->versioned()' in THD::vers_insert_history_fast +# +create table t1 (a int) with system versioning; +insert into t1 values (1),(2); +create table t2 (a timestamp); +insert into t2 (a) values (now()),(now()); +select * from t2 where a in (select row_start from t1); +a +drop table t1, t2; +# # End of 10.11 tests # diff --git a/mysql-test/suite/versioning/t/misc.test b/mysql-test/suite/versioning/t/misc.test index fd7808687bcd2..84d290f608ba5 100644 --- a/mysql-test/suite/versioning/t/misc.test +++ b/mysql-test/suite/versioning/t/misc.test @@ -16,6 +16,16 @@ set timestamp=default; select * from t1 for system_time all; drop table t1; +--echo # +--echo # MDEV-29830 Assertion `table->versioned()' in THD::vers_insert_history_fast +--echo # +create table t1 (a int) with system versioning; +insert into t1 values (1),(2); +create table t2 (a timestamp); +insert into t2 (a) values (now()),(now()); +select * from t2 where a in (select row_start from t1); +drop table t1, t2; + --echo # --echo # End of 10.11 tests --echo # diff --git a/sql/sql_class.h b/sql/sql_class.h index 5085db8f837f3..b7acea5ed3ecb 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5577,7 +5577,6 @@ class THD: public THD_count, /* this must be first */ bool vers_insert_history_fast(const TABLE *table) { - DBUG_ASSERT(table->versioned()); return table->versioned(VERS_TIMESTAMP) && (variables.option_bits & OPTION_INSERT_HISTORY) && lex->duplicates == DUP_ERROR; From c0fe0cce4359b9bb46ecea37477c0e00280cf632 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 20 Oct 2022 14:10:04 +0200 Subject: [PATCH 072/113] MDEV-29830 Assertion `table->versioned()' in THD::vers_insert_history_fast don't set VERS_ROW_START or VERS_ROW_END flags on fields of a temporary table (as not versioned tables should not have ROW START/ROW END fields) --- sql/field.cc | 4 +--- sql/sql_class.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 4a81ff09a29b0..862c40b847d7d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2569,9 +2569,7 @@ Field *Field::make_new_field(MEM_ROOT *root, TABLE *new_table, */ tmp->unireg_check= Field::NONE; tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG | - ZEROFILL_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG | - VERS_ROW_START | VERS_ROW_END | - VERS_UPDATE_UNVERSIONED_FLAG); + ZEROFILL_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG); tmp->reset_fields(); tmp->invisible= VISIBLE; return tmp; diff --git a/sql/sql_class.h b/sql/sql_class.h index b7acea5ed3ecb..5085db8f837f3 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5577,6 +5577,7 @@ class THD: public THD_count, /* this must be first */ bool vers_insert_history_fast(const TABLE *table) { + DBUG_ASSERT(table->versioned()); return table->versioned(VERS_TIMESTAMP) && (variables.option_bits & OPTION_INSERT_HISTORY) && lex->duplicates == DUP_ERROR; From dc3be2426856a3adbdc7649f53cb080b755ef328 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 21 Oct 2022 21:40:48 +0200 Subject: [PATCH 073/113] MDEV-29828 Indicate that --dump-history only applies to timestamp-based versioning --- client/mysqldump.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index de6c4ac35bedb..3de507b3d0f06 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -353,7 +353,11 @@ static struct my_option my_long_options[] = "'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER " "TABLE tb_name ENABLE KEYS */; will be put in the output.", &opt_disable_keys, &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"dump-history", 'H', "Dump tables with history", &opt_dump_history, + {"dump-date", OPT_DUMP_DATE, "Put a dump date to the end of the output.", + &opt_dump_date, &opt_dump_date, 0, + GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"dump-history", 'H', "Dump system-versioned tables with history (only for " + "timestamp based versioning)", &opt_dump_history, &opt_dump_history, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"dump-slave", OPT_MYSQLDUMP_SLAVE_DATA, "This causes the binary log position and filename of the master to be " @@ -571,9 +575,6 @@ static struct my_option my_long_options[] = "isolated from them. Option automatically turns off --lock-tables.", &opt_single_transaction, &opt_single_transaction, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"dump-date", OPT_DUMP_DATE, "Put a dump date to the end of the output.", - &opt_dump_date, &opt_dump_date, 0, - GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-opt", OPT_SKIP_OPTIMIZATION, "Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, From fd0dcad676e7b8665f5363d97849a20cbb712933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Wed, 4 May 2022 21:42:38 -0700 Subject: [PATCH 074/113] MDEV-22659: Create one single unified and optimal logrotate config Replace mysql-log-rotate.sh and debian/...mysql-server.logrotate with one new unified and well documented version. Name is mariadb.logrotate.in as in 10.11 branch onward we use now the 'mariadb' name, and use 'logrotate' to match the actual name of the utility. Also automatically disable deprecated /etc/logrotate.d/mysql-server file on deb upgrades. Reviewer: Daniel Black Reviewer edits made: * Added 'su mysql mysql' to the logrotate this is more RPM friendly. This is commented on Debian * /var/log/mysql is the path on SuSe based distributions --- .gitignore | 2 +- debian/mariadb-server.install | 1 + debian/mariadb-server.mysql-server.logrotate | 20 ------- debian/mariadb-server.postinst | 7 +++ debian/not-installed | 1 - debian/rules | 3 - support-files/CMakeLists.txt | 20 ++++++- support-files/mariadb.logrotate.sh | 59 ++++++++++++++++++++ support-files/mysql-log-rotate.sh | 38 ------------- 9 files changed, 85 insertions(+), 66 deletions(-) delete mode 100644 debian/mariadb-server.mysql-server.logrotate create mode 100644 support-files/mariadb.logrotate.sh delete mode 100644 support-files/mysql-log-rotate.sh diff --git a/.gitignore b/.gitignore index 93a132b3d83dd..2fb3857120c1f 100644 --- a/.gitignore +++ b/.gitignore @@ -261,7 +261,7 @@ support-files/my-innodb-heavy-4G.cnf support-files/my-large.cnf support-files/my-medium.cnf support-files/my-small.cnf -support-files/mysql-log-rotate +support-files/mariadb.logrotate support-files/mysql.10.0.11.spec support-files/mysql.server support-files/mysql.service diff --git a/debian/mariadb-server.install b/debian/mariadb-server.install index 254e9cc8945af..2350196e9d38e 100644 --- a/debian/mariadb-server.install +++ b/debian/mariadb-server.install @@ -5,6 +5,7 @@ debian/additions/mariadb.conf.d/50-mysqld_safe.cnf etc/mysql/mariadb.conf.d debian/additions/mariadb.conf.d/50-server.cnf etc/mysql/mariadb.conf.d debian/additions/source_mariadb.py usr/share/apport/package-hooks etc/apparmor.d/usr.sbin.mariadbd +etc/logrotate.d/mariadb etc/security/user_map.conf lib/*/security/pam_user_map.so lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf diff --git a/debian/mariadb-server.mysql-server.logrotate b/debian/mariadb-server.mysql-server.logrotate deleted file mode 100644 index 11e4480c42715..0000000000000 --- a/debian/mariadb-server.mysql-server.logrotate +++ /dev/null @@ -1,20 +0,0 @@ -# - I put everything in one block and added sharedscripts, so that mysql gets -# flush-logs'd only once. -# Else the binary logs would automatically increase by n times every day. -# - The error log is obsolete, messages go to syslog now. -/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/mariadb-slow.log /var/log/mysql/error.log { - daily - rotate 7 - missingok - create 640 mysql adm - compress - sharedscripts - postrotate - test -x /usr/bin/mysqladmin || exit 0 - # check if server is running - if mysqladmin ping > /dev/null 2>&1; then - mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log \ - flush-engine-log flush-general-log flush-slow-log - fi - endscript -} diff --git a/debian/mariadb-server.postinst b/debian/mariadb-server.postinst index 9cf0821eb1087..2e89e983d9545 100644 --- a/debian/mariadb-server.postinst +++ b/debian/mariadb-server.postinst @@ -220,6 +220,13 @@ EOF fi fi + # The introduction of /etc/logrotate.d/mariadb has made the old config + # obsolete and it needs to be disabled to prevent logrotate running twice. + if [ -f /etc/logrotate.d/mysql-server ] + then + mv -vf /etc/logrotate.d/mysql-server /etc/logrotate.d/mysql-server.dpkg-bak + fi + # @TODO: Remove once buildbot.askmonty.org has been updated not to expect this file mkdir -p /etc/systemd/system/mariadb.service.d/ # Note that file cannot be empty, otherwise systemd version in Ubuntu Bionic diff --git a/debian/not-installed b/debian/not-installed index b94bfaf3c6e2a..c2cd8b43482af 100644 --- a/debian/not-installed +++ b/debian/not-installed @@ -52,7 +52,6 @@ usr/share/mysql/Mongo3.jar usr/share/mysql/binary-configure usr/share/mysql/magic usr/share/mysql/maria_add_gis_sp.sql # mariadb-server-core.install has *_bootstrap.sql -usr/share/mysql/mysql-log-rotate # Debian packaging uses mariadb-server.mysql-server.logrotate usr/share/mysql/mysql-test/asan.supp usr/share/mysql/mysql-test/lsan.supp usr/share/mysql/mysql-test/unstable-tests diff --git a/debian/rules b/debian/rules index 660797f3c2b57..cd4865d9f386d 100755 --- a/debian/rules +++ b/debian/rules @@ -190,9 +190,6 @@ endif # Move test plugins that are only needed by the client to the libmariadb path mv -v $(TMP)/usr/lib/mysql/plugin/qa_auth_client.so $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadb3/plugin/ -override_dh_installlogrotate-arch: - dh_installlogrotate --name mysql-server - override_dh_systemd_enable: dh_systemd_enable --name=mariadb dh_systemd_enable --no-enable --name=mariadb mariadb.socket diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 9623440f1103e..26091e472a366 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -32,6 +32,19 @@ ELSE() SET(MYSQLD_GROUP "mysql") SET(ini_file_extension "cnf") SET(HOSTNAME "uname -n") + + # Define directly here, as cmake/install_layout.cmake has no LOGDIR to be inherited + SET(su_user "su mysql mysql") + IF(RPM MATCHES "(suse|sles)") + SET(logdir "/var/log/mysql") + ELSEIF(RPM) + SET(logdir "/var/log/mariadb") + ELSE() + SET(logdir "/var/log/mysql") + ENDIF() + IF(DEB) + SET(su_user "#su mysql mysql") + ENDIF() ENDIF() # XXX: shouldn't we just have variables for all this stuff and centralise @@ -51,7 +64,7 @@ ENDIF() IF(UNIX AND NOT WITHOUT_SERVER) SET(prefix ${CMAKE_INSTALL_PREFIX}) - FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure wsrep_notify mini-benchmark) + FOREACH(script mysqld_multi.server mariadb.logrotate binary-configure wsrep_notify mini-benchmark) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${script}.sh ${CMAKE_CURRENT_BINARY_DIR}/${script} @ONLY ) INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script} @@ -199,8 +212,9 @@ IF(UNIX AND NOT WITHOUT_SERVER) ENDIF() IF (INSTALL_SYSCONFDIR) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d - RENAME mysql COMPONENT SupportFiles) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.logrotate + DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d + RENAME mariadb COMPONENT SupportFiles) IF(NOT HAVE_SYSTEMD) INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mysql.server DESTINATION ${INSTALL_SYSCONFDIR}/init.d diff --git a/support-files/mariadb.logrotate.sh b/support-files/mariadb.logrotate.sh new file mode 100644 index 0000000000000..811b274778f50 --- /dev/null +++ b/support-files/mariadb.logrotate.sh @@ -0,0 +1,59 @@ +# This is the MariaDB configuration for the logrotate utility +# +# Note that on most Linux systems logs are written to journald, which has its +# own rotation scheme. +# +# Read https://mariadb.com/kb/en/error-log/ to learn more about logging and +# https://mariadb.com/kb/en/rotating-logs-on-unix-and-linux/ about rotating logs. + +@localstatedir@/mysqld.log @localstatedir@/mariadb.log @logdir@/*.log { + + # Depends on a mysql@localhost unix_socket authenticated user with RELOAD privilege + @su_user@ + + # If any of the files listed above is missing, skip them silently without + # emitting any errors + missingok + + # If file exists but is empty, don't rotate it + notifempty + + # Run monthly + monthly + + # Keep 6 months of logs + rotate 6 + + # If file is growing too big, rotate immediately + maxsize 500M + + # If file size is too small, don't rotate at all + minsize 50M + + # Compress logs, as they are text and compression will save a lot of disk space + compress + + # Don't compress the log immediately to avoid errors about "file size changed while zipping" + delaycompress + + # Don't run the postrotate script for each file configured in this file, but + # run it only once if one or more files were rotated + sharedscripts + + # After each rotation, run this custom script to flush the logs. Note that + # this assumes that the mariadb-admin command has database access, which it + # has thanks to the default use of Unix socket authentication for the 'mysql' + # (or root on Debian) account used everywhere since MariaDB 10.4. + postrotate + if test -r /etc/mysql/debian.cnf + then + EXTRAPARAM='--defaults-file=/etc/mysql/debian.cnf' + fi + + if test -x @bindir@/mariadb-admin + then + @bindir@/mariadb-admin $EXTRAPARAM --local flush-error-log \ + flush-engine-log flush-general-log flush-slow-log + fi + endscript +} diff --git a/support-files/mysql-log-rotate.sh b/support-files/mysql-log-rotate.sh deleted file mode 100644 index c89aa6e0b99e1..0000000000000 --- a/support-files/mysql-log-rotate.sh +++ /dev/null @@ -1,38 +0,0 @@ -# This logname can be set in /etc/my.cnf -# by setting the variable "log-error" -# in the [mysqld] section as follows: -# -# [mysqld] -# log-error=@localstatedir@/mysqld.log -# -# If the root user has a password you have to create a -# /root/.my.cnf configuration file with the following -# content: -# -# [mysqladmin] -# password = -# user= root -# -# where "" is the password. -# -# ATTENTION: This /root/.my.cnf should be readable ONLY -# for root ! - -@localstatedir@/mysqld.log { - # create 600 mysql mysql - su mysql mysql - notifempty - daily - rotate 3 - missingok - compress - postrotate - # just if mariadbd is really running - if test -x @bindir@/mysqladmin && \ - @bindir@/mysqladmin ping &>/dev/null - then - @bindir@/mysqladmin --local flush-error-log \ - flush-engine-log flush-general-log flush-slow-log - fi - endscript -} From ba16202e785e4117d250bdc9a30339405e9b362e Mon Sep 17 00:00:00 2001 From: Paragoumba <22895992+Paragoumba@users.noreply.github.com> Date: Thu, 27 Oct 2022 11:42:30 +0200 Subject: [PATCH 075/113] MDEV-24377: Accept comma separated addresses as --bind-address value (#2009) * MDEV-24377: Accept comma separated addresses as --bind-address value When bind address form the basis of wsrep based variables, the first address in the comma separated list is used. The test uses the IP address 192.168.0.1 as we need to include multiple address. This will include failures without the following commit. The tests for bind_multiple_address_resolution could return addresses that we cannot bind too. Windows and FreeBSD, and probably other OSs will terminate the service if addresses are unavailable. We use the WSAEADDRNOTAVAIL / POSIX EADDRNOTAVAIL codes to continue to bind to other interfaces. If at the end of the bind list, if no binds are successful, the we terminate but still leaving the error messages in the log. Co-authored-by: Daniel Black --- .../bind_multiple_addresses_resolution.opt | 1 + .../bind_multiple_addresses_resolution.result | 12 +++ .../bind_multiple_addresses_resolution.test | 23 ++++++ mysql-test/main/mysqld--help.result | 3 +- .../sys_vars/r/sysvars_server_embedded.result | 2 +- .../r/sysvars_server_notembedded.result | 2 +- sql/mysqld.cc | 82 ++++++++++++++++--- sql/sys_vars.cc | 3 +- sql/wsrep_utils.cc | 8 +- 9 files changed, 121 insertions(+), 15 deletions(-) create mode 100644 mysql-test/main/bind_multiple_addresses_resolution.opt create mode 100644 mysql-test/main/bind_multiple_addresses_resolution.result create mode 100644 mysql-test/main/bind_multiple_addresses_resolution.test diff --git a/mysql-test/main/bind_multiple_addresses_resolution.opt b/mysql-test/main/bind_multiple_addresses_resolution.opt new file mode 100644 index 0000000000000..ab5aaff94547a --- /dev/null +++ b/mysql-test/main/bind_multiple_addresses_resolution.opt @@ -0,0 +1 @@ +--bind-address=localhost,192.168.0.1 diff --git a/mysql-test/main/bind_multiple_addresses_resolution.result b/mysql-test/main/bind_multiple_addresses_resolution.result new file mode 100644 index 0000000000000..d0e1441312413 --- /dev/null +++ b/mysql-test/main/bind_multiple_addresses_resolution.result @@ -0,0 +1,12 @@ +call mtr.add_suppression("Can't start server: Bind on TCP/IP port."); +CREATE TABLE t (a TEXT); +connect con1,localhost,root,,test; +SELECT * FROM t; +a +connect con2,127.0.0.1,root,,test; +SELECT * FROM t; +a +connection default; +DROP TABLE t; +disconnect con1; +disconnect con2; diff --git a/mysql-test/main/bind_multiple_addresses_resolution.test b/mysql-test/main/bind_multiple_addresses_resolution.test new file mode 100644 index 0000000000000..752c8d1a37a10 --- /dev/null +++ b/mysql-test/main/bind_multiple_addresses_resolution.test @@ -0,0 +1,23 @@ +--source include/check_ipv6.inc +--source include/not_embedded.inc + +call mtr.add_suppression("Can't start server: Bind on TCP/IP port."); +# The server is started with --bind-address=localhost,192.168.0.1, and should +# listen on all addresses 'localhost' resolves to and 192.168.0.1. With at least +# 127.0.0.1 and ::1 amongst them. + +CREATE TABLE t (a TEXT); +--connect(con1,localhost,root,,test) +SELECT * FROM t; +--connect(con2,127.0.0.1,root,,test) +SELECT * FROM t; +# Temporary disable. +# Some cloud-init services don't resolve localhost->::1 +# bb - kvm-asan, kvm-deb-focal-amd64, kvm-deb-groovy-amd64 +#--connect(con3,::1,root,,test) +#SELECT * FROM t; +--connection default +DROP TABLE t; +--disconnect con1 +--disconnect con2 +#--disconnect con3 diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 9523377d2ed64..5720988df2ff9 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -42,7 +42,8 @@ The following specify which files/extra groups are read (specified before remain by saving all temporary sets to disk, avoiding 'table full' errors. No longer needed, as the server now handles this automatically. - --bind-address=name IP address to bind to. + --bind-address=name IP address to bind to. Several addresses may be + specified, separated by a comma (,). --binlog-alter-two-phase When set, split ALTER at binary logging into 2 statements: START ALTER and COMMIT/ROLLBACK ALTER 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 74f6534f83376..f896421559c43 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -325,7 +325,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME BIND_ADDRESS VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR -VARIABLE_COMMENT IP address to bind to. +VARIABLE_COMMENT IP address to bind to. Several addresses may be specified, separated by a comma (,). NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE 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 946ae3f8b007b..23942418b07db 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -325,7 +325,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME BIND_ADDRESS VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR -VARIABLE_COMMENT IP address to bind to. +VARIABLE_COMMENT IP address to bind to. Several addresses may be specified, separated by a comma (,). NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8e40149ee72a2..a49dec5008d5a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -135,7 +135,6 @@ #define mysqld_charset &my_charset_latin1 - extern "C" { // Because of SCO 3.2V4.2 #include #ifndef __GNU_LIBRARY__ @@ -2291,7 +2290,7 @@ static void activate_tcp_port(uint port, Dynamic_array *sockets, bool is_extra_port= false) { - struct addrinfo *ai, *a; + struct addrinfo *ai, *a = NULL, *head = NULL; struct addrinfo hints; int error; int arg; @@ -2312,16 +2311,52 @@ static void activate_tcp_port(uint port, real_bind_addr_str= my_bind_addr_str; my_snprintf(port_buf, NI_MAXSERV, "%d", port); - error= getaddrinfo(real_bind_addr_str, port_buf, &hints, &ai); - if (unlikely(error != 0)) + + if (real_bind_addr_str && *real_bind_addr_str) { - DBUG_PRINT("error",("Got error: %d from getaddrinfo()", error)); - sql_print_error("%s: %s", ER_DEFAULT(ER_IPSOCK_ERROR), gai_strerror(error)); - unireg_abort(1); /* purecov: tested */ + char *end; + char address[FN_REFLEN]; + + do + { + end= strcend(real_bind_addr_str, ','); + strmake(address, real_bind_addr_str, (uint) (end - real_bind_addr_str)); + + error= getaddrinfo(address, port_buf, &hints, &ai); + if (unlikely(error != 0)) + { + DBUG_PRINT("error", ("Got error: %d from getaddrinfo()", error)); + + sql_print_error("%s: %s", ER_DEFAULT(ER_IPSOCK_ERROR), + gai_strerror(error)); + unireg_abort(1); /* purecov: tested */ + } + + if (!head) + { + head= ai; + } + if (a) + { + a->ai_next= ai; + } + a= ai; + while (a->ai_next) + { + a= a->ai_next; + } + + real_bind_addr_str= end + 1; + } while (*end); + } + else + { + error= getaddrinfo(real_bind_addr_str, port_buf, &hints, &ai); + head= ai; } - for (a= ai; a != NULL; a= a->ai_next) + for (a= head; a != NULL; a= a->ai_next) { ip_sock= mysql_socket_socket(key_socket_tcpip, a->ai_family, a->ai_socktype, a->ai_protocol); @@ -2410,9 +2445,31 @@ static void activate_tcp_port(uint port, if (ret < 0) { char buff[100]; + int s_errno= socket_errno; sprintf(buff, "Can't start server: Bind on TCP/IP port. Got error: %d", - (int) socket_errno); + (int) s_errno); sql_perror(buff); + /* + Linux will quite happily bind to addresses not present. The + mtr test main.bind_multiple_addresses_resolution relies on this. + For Windows, this is fatal and generates the error: + WSAEADDRNOTAVAIL: The requested address is not valid in its context + In this case, where multiple addresses where specified, maybe + we can live with an error in the log and hope the other addresses + are successful. We catch if no successful bindings occur at the + end of this function. + + FreeBSD returns EADDRNOTAVAIL, and EADDRNOTAVAIL is even in Linux + manual pages. So may was well apply uniform behaviour. + */ +#ifdef _WIN32 + if (s_errno == WSAEADDRNOTAVAIL) + continue; +#endif +#ifdef EADDRNOTAVAIL + if (s_errno == EADDRNOTAVAIL) + continue; +#endif sql_print_error("Do you already have another server running on " "port: %u ?", port); unireg_abort(1); @@ -2433,7 +2490,12 @@ static void activate_tcp_port(uint port, } } - freeaddrinfo(ai); + freeaddrinfo(head); + if (head && sockets->size() == 0) + { + sql_print_error("No TCP address could be bound to"); + unireg_abort(1); + } DBUG_VOID_RETURN; } diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 6e56e401b0267..d3dc2d4bf60f0 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -511,7 +511,8 @@ static Sys_var_charptr_fscs Sys_basedir( DEFAULT(0)); static Sys_var_charptr_fscs Sys_my_bind_addr( - "bind_address", "IP address to bind to.", + "bind_address", "IP address to bind to. Several addresses may be " + "specified, separated by a comma (,).", READ_ONLY GLOBAL_VAR(my_bind_addr_str), CMD_LINE(REQUIRED_ARG), DEFAULT(0)); diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc index a679304c40aff..854c11c1eea71 100644 --- a/sql/wsrep_utils.cc +++ b/sql/wsrep_utils.cc @@ -457,7 +457,13 @@ unsigned int wsrep_check_ip (const char* const addr, bool *is_ipv6) *is_ipv6= false; - int gai_ret= getaddrinfo(addr, NULL, &hints, &res); + char *end; + char address[INET6_ADDRSTRLEN]; + + end= strcend(addr, ','); + strmake(address, addr, (uint) (end - addr)); + + int gai_ret= getaddrinfo(address, NULL, &hints, &res); if (0 == gai_ret) { if (AF_INET == res->ai_family) /* IPv4 */ From d15260990d94258bca9eb2bae94159f65164500a Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 27 Oct 2022 19:41:19 +1100 Subject: [PATCH 076/113] MDEV-22659: Create one logrotate config - Deb/Rpm fix --- cmake/cpack_rpm.cmake | 2 +- debian/not-installed | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index dc2ca544d28d2..339363b216943 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -162,7 +162,7 @@ SET(ignored SET(CPACK_RPM_server_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*" - "%config(noreplace) ${INSTALL_SYSCONFDIR}/logrotate.d/mysql" + "%config(noreplace) ${INSTALL_SYSCONFDIR}/logrotate.d/mariadb" ) SET(CPACK_RPM_common_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONFDIR}/my.cnf") SET(CPACK_RPM_shared_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*") diff --git a/debian/not-installed b/debian/not-installed index c2cd8b43482af..a75ac911de813 100644 --- a/debian/not-installed +++ b/debian/not-installed @@ -1,5 +1,4 @@ etc/columnstore/storagemanager.cnf.example # Copy of etc/columnstore/storagemanager.cnf that is installed -etc/logrotate.d/mysql # Debian packaging uses mariadb-server.mysql-server.logrotate etc/my.cnf # Debian packaging has /etc/mysql/my.cnf, which is a symlink to mariadb.cnf etc/mysql/mariadb.conf.d/client.cnf # Debian packaging uses files from debian/additions/mariadb.cnf.d/ etc/mysql/mariadb.conf.d/enable_encryption.preset # Debian packaging uses files from debian/additions/mariadb.cnf.d/ @@ -51,6 +50,7 @@ usr/share/mysql/Mongo2.jar usr/share/mysql/Mongo3.jar usr/share/mysql/binary-configure usr/share/mysql/magic +usr/share/mysql/mariadb.logrotate usr/share/mysql/maria_add_gis_sp.sql # mariadb-server-core.install has *_bootstrap.sql usr/share/mysql/mysql-test/asan.supp usr/share/mysql/mysql-test/lsan.supp From 2bd41fc5bf765bb9b1b2caa872070b271fc7c039 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 27 Oct 2022 22:18:51 +0200 Subject: [PATCH 077/113] Revert MDEV-25292 Atomic CREATE OR REPLACE TABLE Specifically: Revert "MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection" This reverts commit ba875e939619baefb08936863a889830f595e426. Revert "MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock" This reverts commit aa08a7442a5141750de96353132c7799e10c9302. Revert "MDEV-29628 Memory leak after CREATE OR REPLACE with foreign key" This reverts commit c579d66ba689c8a20a951de5e6be2e1bc255ba7f. Revert "MDEV-29609 create_not_windows test fails with different result" This reverts commit cb583b2f1bf1c910e82c7caee4a53e0f3ff954ba. Revert "MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables" This reverts commit dcd66c3814991e686615eac2e65d01a7fa80cb66. Revert "MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name" This reverts commit cf6c5176328c8fbfadac80f337ef285732cc8d06. Revert "MDEV-28933 Moved RENAME_CONSTRAINT_IDS to include/sql_funcs.h" This reverts commit f1e1c1335b506905244502ee8584736a17a6ecd0. Revert "MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES" This reverts commit a228ec80e30cae59c2057b786fd3559171ce794f. Revert "MDEV-25292 gcol.gcol_bugfixes --ps fix" This reverts commit 24fff8267d0722b20ca780cf144ce27560df1394. Revert "MDEV-25292 Disable atomic replace for slave-generated or-replace" This reverts commit 2af15914cb3ae204d3b413995a96c7722ad60d93. Revert "MDEV-25292 backup_log improved" This reverts commit 34398a20b5829f0508c78bc8f765f7bef6e0ad48. Revert "MDEV-25292 Atomic CREATE OR REPLACE TABLE" This reverts commit 93c8252f02faa8ad8dc5f005e52f1990c29d4a0d. Revert "MDEV-25292 Table_name class for (db, table_name, alias)" This reverts commit d145dda9c7b6db394edf7150cc255343a4a7b116. Revert "MDEV-25292 ha_table_exists() cleanup and improvement" This reverts commit 409b8a86de45efc96377c618a99cff1301523150. Revert "MDEV-25292 Cleanups" This reverts commit 595dad83ad3c23879c59deec1173ea16b47871ed. Revert "MDEV-25292 Refactoring: moved select_field_count into Alter_info." This reverts commit f02af1d2295f108d96671b5a4f731ec998002dd5. --- .../include/binlog_formats.combinations | 8 - mysql-test/include/binlog_formats.inc | 4 - mysql-test/main/backup_log.inc | 26 +- mysql-test/main/backup_log.result | 195 ++-- mysql-test/main/backup_log.test | 3 - mysql-test/main/backup_log_print.inc | 7 - mysql-test/main/create_not_windows.result | 36 - mysql-test/main/create_not_windows.test | 63 -- mysql-test/main/create_or_replace.result | 383 +------- mysql-test/main/create_or_replace.test | 230 +---- mysql-test/main/create_or_replace2.result | 27 + mysql-test/main/create_or_replace2.test | 35 + mysql-test/main/create_replace_debug.result | 103 --- mysql-test/main/create_replace_debug.test | 99 --- mysql-test/main/default.result | 14 +- mysql-test/main/default.test | 15 +- mysql-test/main/long_unique_bugs.result | 3 +- mysql-test/main/long_unique_bugs.test | 1 + .../create_replace,aria_notrans,row.result | 710 --------------- .../atomic/create_replace,aria_notrans.result | 696 --------------- ...create_replace,expensive_rename,row.result | 584 ------------ .../create_replace,expensive_rename.result | 561 ------------ .../suite/atomic/create_replace,ib,row.result | 661 -------------- .../suite/atomic/create_replace,ib.result | 648 -------------- .../atomic/create_replace,myisam,row.result | 710 --------------- .../suite/atomic/create_replace,row.result | 710 --------------- .../suite/atomic/create_replace.combinations | 6 - mysql-test/suite/atomic/create_replace.result | 696 --------------- mysql-test/suite/atomic/create_replace.test | 211 ----- mysql-test/suite/atomic/create_table.result | 215 ++++- mysql-test/suite/atomic/create_table.test | 9 +- mysql-test/suite/binlog/include/binlog.test | 1 - .../suite/binlog/r/binlog_row_binlog.result | 6 +- .../suite/binlog/r/binlog_stm_binlog.result | 5 +- .../suite/binlog/r/binlog_write_error.result | 2 - .../suite/binlog/t/binlog_write_error.test | 3 - .../binlog_write_error.result | 2 - .../innodb/r/foreign_key_not_windows.result | 43 - .../innodb/t/foreign_key_not_windows.test | 47 +- mysql-test/suite/parts/r/backup_log.result | 215 ++--- .../suite/rpl/r/create_or_replace2,stmt.rdiff | 17 - .../suite/rpl/r/create_or_replace2.result | 11 - .../suite/rpl/r/create_or_replace_mix.result | 29 +- .../suite/rpl/r/create_or_replace_row.result | 35 +- .../rpl/r/create_or_replace_statement.result | 29 +- mysql-test/suite/rpl/r/rpl_gtid_strict.result | 5 +- mysql-test/suite/rpl/t/create_or_replace.inc | 11 +- .../suite/rpl/t/create_or_replace2.test | 2 - mysql-test/suite/rpl/t/rpl_gtid_strict.test | 7 +- mysql-test/suite/versioning/r/foreign.result | 17 - mysql-test/suite/versioning/t/foreign.test | 6 - sql/ddl_log.cc | 230 ++--- sql/ddl_log.h | 19 +- sql/handler.cc | 33 +- sql/handler.h | 107 +-- sql/log.cc | 15 +- sql/log_event.h | 4 +- sql/sql_acl.cc | 3 +- sql/sql_alter.cc | 3 +- sql/sql_alter.h | 8 - sql/sql_base.cc | 13 +- sql/sql_class.cc | 2 +- sql/sql_class.h | 24 +- sql/sql_db.cc | 3 +- sql/sql_insert.cc | 430 +++------ sql/sql_parse.cc | 4 +- sql/sql_partition.cc | 12 +- sql/sql_partition_admin.cc | 2 +- sql/sql_rename.cc | 114 ++- sql/sql_select.cc | 2 - sql/sql_show.cc | 7 +- sql/sql_table.cc | 837 ++++-------------- sql/sql_table.h | 70 +- sql/sql_trigger.cc | 58 +- sql/sql_trigger.h | 15 +- sql/sql_truncate.cc | 45 +- sql/sql_view.cc | 3 +- sql/structs.h | 12 +- sql/table.cc | 21 - sql/table.h | 17 +- storage/innobase/CMakeLists.txt | 1 - storage/innobase/dict/dict0dict.cc | 92 +- storage/innobase/dict/dict0load.cc | 4 +- storage/innobase/fts/fts0fts.cc | 4 +- storage/innobase/handler/ha_innodb.cc | 228 ++--- storage/innobase/handler/handler0alter.cc | 56 +- storage/innobase/include/dict0dict.h | 12 +- storage/innobase/include/row0mysql.h | 15 +- storage/innobase/include/sql_funcs.h | 111 --- storage/innobase/row/row0mysql.cc | 89 +- storage/maria/ha_s3.cc | 5 +- storage/maria/ma_check.c | 2 +- 92 files changed, 1385 insertions(+), 9509 deletions(-) delete mode 100644 mysql-test/include/binlog_formats.combinations delete mode 100644 mysql-test/include/binlog_formats.inc delete mode 100644 mysql-test/main/backup_log_print.inc create mode 100644 mysql-test/main/create_or_replace2.result create mode 100644 mysql-test/main/create_or_replace2.test delete mode 100644 mysql-test/main/create_replace_debug.result delete mode 100644 mysql-test/main/create_replace_debug.test delete mode 100644 mysql-test/suite/atomic/create_replace,aria_notrans,row.result delete mode 100644 mysql-test/suite/atomic/create_replace,aria_notrans.result delete mode 100644 mysql-test/suite/atomic/create_replace,expensive_rename,row.result delete mode 100644 mysql-test/suite/atomic/create_replace,expensive_rename.result delete mode 100644 mysql-test/suite/atomic/create_replace,ib,row.result delete mode 100644 mysql-test/suite/atomic/create_replace,ib.result delete mode 100644 mysql-test/suite/atomic/create_replace,myisam,row.result delete mode 100644 mysql-test/suite/atomic/create_replace,row.result delete mode 100644 mysql-test/suite/atomic/create_replace.combinations delete mode 100644 mysql-test/suite/atomic/create_replace.result delete mode 100644 mysql-test/suite/atomic/create_replace.test delete mode 100644 mysql-test/suite/rpl/r/create_or_replace2,stmt.rdiff delete mode 100644 storage/innobase/include/sql_funcs.h diff --git a/mysql-test/include/binlog_formats.combinations b/mysql-test/include/binlog_formats.combinations deleted file mode 100644 index 07042c2cbecd2..0000000000000 --- a/mysql-test/include/binlog_formats.combinations +++ /dev/null @@ -1,8 +0,0 @@ -[row] -binlog-format=row - -[stmt] -binlog-format=statement - -[mix] -binlog-format=mixed diff --git a/mysql-test/include/binlog_formats.inc b/mysql-test/include/binlog_formats.inc deleted file mode 100644 index 44d64293102ca..0000000000000 --- a/mysql-test/include/binlog_formats.inc +++ /dev/null @@ -1,4 +0,0 @@ -# This file adds combinations for all binlog formats: row, stmt, mix -# Under each combination a corresponding binlog-format option is set. - ---source include/have_log_bin.inc diff --git a/mysql-test/main/backup_log.inc b/mysql-test/main/backup_log.inc index 4ad6b9122cd23..f553a3b952743 100644 --- a/mysql-test/main/backup_log.inc +++ b/mysql-test/main/backup_log.inc @@ -7,7 +7,7 @@ # non-partitioned testing --echo # ---echo # Testing normal tables +--echo # Testing with normal tables --echo # eval create table t1 (a int) engine=myisam $part_int; @@ -20,8 +20,6 @@ repair table t1; optimize table t1; drop table t1; ---source backup_log_print.inc - eval create table t1_innodb (a int) engine=innodb $part_int; insert into t1_innodb values (1),(2); alter table t1_innodb add column b int; @@ -32,8 +30,6 @@ repair table t1_innodb; optimize table t1_innodb; drop table t1_innodb; ---source backup_log_print.inc - --echo # --echo # Testing with temporary tables (should not be logged) --echo # @@ -45,8 +41,6 @@ rename table tmp_t11 to tmp_t10; truncate table tmp_t10; drop table tmp_t10; ---source backup_log_print.inc - --echo # --echo # Testing with mix of normal and temporary tables --echo # @@ -60,8 +54,6 @@ eval create table t21 (a int) $part_int; drop temporary table if exists tmp_t21,t21; drop table if exists tmp_t21,t21; ---source backup_log_print.inc - --echo # --echo # Testing create select --echo # @@ -76,8 +68,6 @@ eval create or replace table t31 (a int primary key) $part_int select * from t30 eval create table t32 (a int) $part_int; drop table if exists t30,t31,t32,tmp_t30; ---source backup_log_print.inc - --echo # --echo # Testing create LIKE --echo # @@ -91,8 +81,6 @@ create or replace table t42 like t41; show create table t42; drop table t40, t41, t42; ---source backup_log_print.inc - --echo # --echo # Testing rename --echo # @@ -103,8 +91,6 @@ rename table t50 to t52, t51 to t53; rename table t52 to tmp, t53 to t52, tmp to t53; drop table t52,t53; ---source backup_log_print.inc - --echo # --echo # Testing enable/disable keys --echo # @@ -121,8 +107,6 @@ INSERT INTO t61 VALUES(1),(2),(3); ALTER TABLE t61 DISABLE KEYS; DROP TABLE t61; ---source backup_log_print.inc - --echo # --echo # Testing load data --echo # @@ -144,8 +128,6 @@ insert into t71 select * from t70; unlock tables; drop table t70,t71; ---source backup_log_print.inc - --echo # --echo # Testing strange table names --echo # @@ -153,8 +135,6 @@ drop table t70,t71; eval create table `t 1` (a int) $part_int; drop table `t 1`; ---source backup_log_print.inc - --echo # --echo # Testing views and triggers --echo # @@ -166,8 +146,6 @@ drop trigger trg; drop view v1; drop table t80; ---source backup_log_print.inc - --echo # --echo # Testing alter to a new storage engine --echo # @@ -175,5 +153,3 @@ drop table t80; eval create table t85 (a int primary key, b int) engine=myisam $part_int; alter table t85 engine=innodb; drop table t85; - ---source backup_log_print.inc diff --git a/mysql-test/main/backup_log.result b/mysql-test/main/backup_log.result index 9b86c19ae407d..cc8d098825d25 100644 --- a/mysql-test/main/backup_log.result +++ b/mysql-test/main/backup_log.result @@ -4,7 +4,7 @@ connect con1,localhost,root,,; BACKUP STAGE START; connection default; # -# Testing normal tables +# Testing with normal tables # create table t1 (a int) engine=myisam ; insert into t1 values (1),(2); @@ -19,16 +19,6 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK drop table t1; -# -# Reading backup ddl log file -# -CREATE,MyISAM,0,test,t1,id: 1,,0,,, -ALTER,MyISAM,0,test,t1,id: 1,MyISAM,0,test,t1,id: 2 -RENAME,MyISAM,0,test,t1,id: 2,MyISAM,0,test,t2,id: 2 -RENAME,MyISAM,0,test,t2,id: 2,MyISAM,0,test,t1,id: 2 -repair,MyISAM,0,test,t1,id: 2,,0,,, -optimize,MyISAM,0,test,t1,id: 2,,0,,, -DROP,MyISAM,0,test,t1,id: 2,,0,,, create table t1_innodb (a int) engine=innodb ; insert into t1_innodb values (1),(2); alter table t1_innodb add column b int; @@ -44,17 +34,6 @@ test.t1_innodb optimize note Table does not support optimize, doing recreate + a test.t1_innodb optimize status OK drop table t1_innodb; # -# Reading backup ddl log file -# -CREATE,InnoDB,0,test,t1_innodb,id: 1,,0,,, -ALTER,InnoDB,0,test,t1_innodb,id: 1,InnoDB,0,test,t1_innodb,id: 2 -RENAME,InnoDB,0,test,t1_innodb,id: 2,InnoDB,0,test,t2_innodb,id: 2 -RENAME,InnoDB,0,test,t2_innodb,id: 2,InnoDB,0,test,t1_innodb,id: 2 -TRUNCATE,InnoDB,0,test,t1_innodb,id: 2,,0,,, -repair,InnoDB,0,test,t1_innodb,id: 2,,0,,, -ALTER,InnoDB,0,test,t1_innodb,id: 2,InnoDB,0,test,t1_innodb,id: 3 -DROP,InnoDB,0,test,t1_innodb,id: 3,,0,,, -# # Testing with temporary tables (should not be logged) # create temporary table tmp_t10 (a int) engine=myisam; @@ -64,9 +43,6 @@ rename table tmp_t11 to tmp_t10; truncate table tmp_t10; drop table tmp_t10; # -# Reading backup ddl log file -# -# # Testing with mix of normal and temporary tables # create temporary table tmp_t20 (a int); @@ -81,13 +57,6 @@ drop table if exists tmp_t21,t21; Warnings: Note 1051 Unknown table 'test.tmp_t21' # -# Reading backup ddl log file -# -CREATE,MyISAM,0,test,t20,id: 1,,0,,, -DROP,MyISAM,0,test,t20,id: 1,,0,,, -CREATE,MyISAM,0,test,t21,id: 2,,0,,, -DROP,MyISAM,0,test,t21,id: 2,,0,,, -# # Testing create select # create table t30 (a int) ; @@ -100,18 +69,7 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' create table t32 (a int) ; drop table if exists t30,t31,t32,tmp_t30; Warnings: -Note 1051 Unknown table 'test.tmp_t30' -# -# Reading backup ddl log file -# -CREATE,MyISAM,0,test,t30,id: 1,,0,,, -CREATE,MyISAM,0,test,t31,id: 2,,0,,, -DROP,MyISAM,0,test,t31,id: 2,,0,,, -CREATE,MyISAM,0,test,t31,id: 3,,0,,, -CREATE,MyISAM,0,test,t32,id: 4,,0,,, -DROP,MyISAM,0,test,t30,id: 1,,0,,, -DROP,MyISAM,0,test,t31,id: 3,,0,,, -DROP,MyISAM,0,test,t32,id: 4,,0,,, +Note 1051 Unknown table 'test.t31,test.tmp_t30' # # Testing create LIKE # @@ -128,17 +86,6 @@ t42 CREATE TABLE `t42` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t40, t41, t42; # -# Reading backup ddl log file -# -CREATE,MyISAM,0,test,t40,id: 1,,0,,, -CREATE,InnoDB,0,test,t41,id: 2,,0,,, -CREATE,MyISAM,0,test,t42,id: 3,,0,,, -DROP,MyISAM,0,test,t42,id: 3,,0,,, -CREATE,InnoDB,0,test,t42,id: 4,,0,,, -DROP,MyISAM,0,test,t40,id: 1,,0,,, -DROP,InnoDB,0,test,t41,id: 2,,0,,, -DROP,InnoDB,0,test,t42,id: 4,,0,,, -# # Testing rename # create table t50 (a int) ; @@ -147,18 +94,6 @@ rename table t50 to t52, t51 to t53; rename table t52 to tmp, t53 to t52, tmp to t53; drop table t52,t53; # -# Reading backup ddl log file -# -CREATE,MyISAM,0,test,t50,id: 1,,0,,, -CREATE,MyISAM,0,test,t51,id: 2,,0,,, -RENAME,MyISAM,0,test,t50,id: 1,MyISAM,0,test,t52,id: 1 -RENAME,MyISAM,0,test,t51,id: 2,MyISAM,0,test,t53,id: 2 -RENAME,MyISAM,0,test,t52,id: 1,MyISAM,0,test,tmp,id: 1 -RENAME,MyISAM,0,test,t53,id: 2,MyISAM,0,test,t52,id: 2 -RENAME,MyISAM,0,test,tmp,id: 1,MyISAM,0,test,t53,id: 1 -DROP,MyISAM,0,test,t52,id: 2,,0,,, -DROP,MyISAM,0,test,t53,id: 1,,0,,, -# # Testing enable/disable keys # CREATE TABLE t60 (a int(10), index(a) ) ENGINE=Aria ; @@ -172,13 +107,6 @@ INSERT INTO t61 VALUES(1),(2),(3); ALTER TABLE t61 DISABLE KEYS; DROP TABLE t61; # -# Reading backup ddl log file -# -CREATE,Aria,0,test,t60,id: 1,,0,,, -CHANGE_INDEX,Aria,0,test,t60,id: 1,,0,,, -CHANGE_INDEX,Aria,0,test,t60,id: 1,,0,,, -DROP,Aria,0,test,t60,id: 1,,0,,, -# # Testing load data # create table t70 (a date, b date, c date not null, d date) engine=aria ; @@ -195,26 +123,11 @@ insert into t71 select * from t70; unlock tables; drop table t70,t71; # -# Reading backup ddl log file -# -CREATE,Aria,0,test,t70,id: 1,,0,,, -BULK_INSERT,Aria,0,test,t70,id: 1,,0,,, -BULK_INSERT,Aria,0,test,t70,id: 1,,0,,, -CREATE,Aria,0,test,t71,id: 2,,0,,, -BULK_INSERT,Aria,0,test,t71,id: 2,,0,,, -DROP,Aria,0,test,t70,id: 1,,0,,, -DROP,Aria,0,test,t71,id: 2,,0,,, -# # Testing strange table names # create table `t 1` (a int) ; drop table `t 1`; # -# Reading backup ddl log file -# -CREATE,MyISAM,0,test,t@00201,id: 1,,0,,, -DROP,MyISAM,0,test,t@00201,id: 1,,0,,, -# # Testing views and triggers # create table t80 (a int, b int) engine=myisam ; @@ -224,27 +137,12 @@ drop trigger trg; drop view v1; drop table t80; # -# Reading backup ddl log file -# -CREATE,MyISAM,0,test,t80,id: 1,,0,,, -CREATE,VIEW,0,test,v1,,,0,,, -CREATE,TRIGGER,0,test,trg,,,0,,, -DROP,TRIGGER,0,test,trg,,,0,,, -DROP,VIEW,0,test,v1,,,0,,, -DROP,MyISAM,0,test,t80,id: 1,,0,,, -# # Testing alter to a new storage engine # create table t85 (a int primary key, b int) engine=myisam ; alter table t85 engine=innodb; drop table t85; # -# Reading backup ddl log file -# -CREATE,MyISAM,0,test,t85,id: 1,,0,,, -ALTER,MyISAM,0,test,t85,id: 1,InnoDB,0,test,t85,id: 2 -DROP,InnoDB,0,test,t85,id: 2,,0,,, -# # Testing create/drop/alter database # create database mysqltest; @@ -253,16 +151,6 @@ create table mysqltest.t91 (a int primary key, b int) engine=innodb; alter database mysqltest character set utf8; drop database mysqltest; # -# Reading backup ddl log file -# -CREATE,DATABASE,0,mysqltest,,,,0,,, -CREATE,MyISAM,0,mysqltest,t90,id: 1,,0,,, -CREATE,InnoDB,0,mysqltest,t91,id: 2,,0,,, -ALTER,DATABASE,0,mysqltest,,,,0,,, -DROP,MyISAM,0,mysqltest,t90,id: 1,,0,,, -DROP,InnoDB,0,mysqltest,t91,id: 2,,0,,, -DROP,DATABASE,0,mysqltest,,,,0,,, -# # MENT-222 bug testing # CREATE TABLE IF NOT EXISTS t_exists LIKE t_exists_template; @@ -271,14 +159,83 @@ Note 1050 Table 't_exists' already exists # # Reading backup ddl log file # +CREATE,MyISAM,0,test,t1,id: 1,,0,,, +ALTER,MyISAM,0,test,t1,id: 1,MyISAM,0,test,t1,id: 2 +RENAME,MyISAM,0,test,t1,id: 2,MyISAM,0,test,t2,id: 2 +RENAME,MyISAM,0,test,t2,id: 2,MyISAM,0,test,t1,id: 2 +repair,MyISAM,0,test,t1,id: 2,,0,,, +optimize,MyISAM,0,test,t1,id: 2,,0,,, +DROP,MyISAM,0,test,t1,id: 2,,0,,, +CREATE,InnoDB,0,test,t1_innodb,id: 3,,0,,, +ALTER,InnoDB,0,test,t1_innodb,id: 3,InnoDB,0,test,t1_innodb,id: 4 +RENAME,InnoDB,0,test,t1_innodb,id: 4,InnoDB,0,test,t2_innodb,id: 4 +RENAME,InnoDB,0,test,t2_innodb,id: 4,InnoDB,0,test,t1_innodb,id: 4 +TRUNCATE,InnoDB,0,test,t1_innodb,id: 4,,0,,, +repair,InnoDB,0,test,t1_innodb,id: 4,,0,,, +ALTER,InnoDB,0,test,t1_innodb,id: 4,InnoDB,0,test,t1_innodb,id: 5 +DROP,InnoDB,0,test,t1_innodb,id: 5,,0,,, +CREATE,MyISAM,0,test,t20,id: 6,,0,,, +DROP,MyISAM,0,test,t20,id: 6,,0,,, +CREATE,MyISAM,0,test,t21,id: 7,,0,,, +DROP,MyISAM,0,test,t21,id: 7,,0,,, +CREATE,MyISAM,0,test,t30,id: 8,,0,,, +CREATE,MyISAM,0,test,t31,id: 9,,0,,, +DROP,MyISAM,0,test,t31,id: 9,,0,,, +CREATE,MyISAM,0,test,t31,id: 10,,0,,, +DROP,MyISAM,0,test,t31,id: 10,,0,,, +DROP_AFTER_CREATE,MyISAM,0,test,t31,id: 11,,0,,, +CREATE,MyISAM,0,test,t32,id: 12,,0,,, +DROP,MyISAM,0,test,t30,id: 8,,0,,, +DROP,MyISAM,0,test,t32,id: 12,,0,,, +CREATE,MyISAM,0,test,t40,id: 13,,0,,, +CREATE,InnoDB,0,test,t41,id: 14,,0,,, +CREATE,MyISAM,0,test,t42,id: 15,,0,,, +DROP,MyISAM,0,test,t42,id: 15,,0,,, +CREATE,InnoDB,0,test,t42,id: 16,,0,,, +DROP,MyISAM,0,test,t40,id: 13,,0,,, +DROP,InnoDB,0,test,t41,id: 14,,0,,, +DROP,InnoDB,0,test,t42,id: 16,,0,,, +CREATE,MyISAM,0,test,t50,id: 17,,0,,, +CREATE,MyISAM,0,test,t51,id: 18,,0,,, +RENAME,MyISAM,0,test,t50,id: 17,MyISAM,0,test,t52,id: 17 +RENAME,MyISAM,0,test,t51,id: 18,MyISAM,0,test,t53,id: 18 +RENAME,MyISAM,0,test,t52,id: 17,MyISAM,0,test,tmp,id: 17 +RENAME,MyISAM,0,test,t53,id: 18,MyISAM,0,test,t52,id: 18 +RENAME,MyISAM,0,test,tmp,id: 17,MyISAM,0,test,t53,id: 17 +DROP,MyISAM,0,test,t52,id: 18,,0,,, +DROP,MyISAM,0,test,t53,id: 17,,0,,, +CREATE,Aria,0,test,t60,id: 19,,0,,, +CHANGE_INDEX,Aria,0,test,t60,id: 19,,0,,, +CHANGE_INDEX,Aria,0,test,t60,id: 19,,0,,, +DROP,Aria,0,test,t60,id: 19,,0,,, +CREATE,Aria,0,test,t70,id: 20,,0,,, +BULK_INSERT,Aria,0,test,t70,id: 20,,0,,, +BULK_INSERT,Aria,0,test,t70,id: 20,,0,,, +CREATE,Aria,0,test,t71,id: 21,,0,,, +BULK_INSERT,Aria,0,test,t71,id: 21,,0,,, +DROP,Aria,0,test,t70,id: 20,,0,,, +DROP,Aria,0,test,t71,id: 21,,0,,, +CREATE,MyISAM,0,test,t@00201,id: 22,,0,,, +DROP,MyISAM,0,test,t@00201,id: 22,,0,,, +CREATE,MyISAM,0,test,t80,id: 23,,0,,, +CREATE,VIEW,0,test,v1,,,0,,, +CREATE,TRIGGER,0,test,trg,,,0,,, +DROP,TRIGGER,0,test,trg,,,0,,, +DROP,VIEW,0,test,v1,,,0,,, +DROP,MyISAM,0,test,t80,id: 23,,0,,, +CREATE,MyISAM,0,test,t85,id: 24,,0,,, +ALTER,MyISAM,0,test,t85,id: 24,InnoDB,0,test,t85,id: 25 +DROP,InnoDB,0,test,t85,id: 25,,0,,, +CREATE,DATABASE,0,mysqltest,,,,0,,, +CREATE,MyISAM,0,mysqltest,t90,id: 26,,0,,, +CREATE,InnoDB,0,mysqltest,t91,id: 27,,0,,, +ALTER,DATABASE,0,mysqltest,,,,0,,, +DROP,MyISAM,0,mysqltest,t90,id: 26,,0,,, +DROP,InnoDB,0,mysqltest,t91,id: 27,,0,,, +DROP,DATABASE,0,mysqltest,,,,0,,, # # Cleanup # DROP TABLE t_exists; DROP TABLE t_exists_template; -# -# Reading backup ddl log file -# -DROP,MyISAM,0,test,t_exists,id: 1,,0,,, -DROP,MyISAM,0,test,t_exists_template,id: 2,,0,,, disconnect con1; diff --git a/mysql-test/main/backup_log.test b/mysql-test/main/backup_log.test index d2f5d4616bd75..ee34484e92bf9 100644 --- a/mysql-test/main/backup_log.test +++ b/mysql-test/main/backup_log.test @@ -24,8 +24,6 @@ create table mysqltest.t91 (a int primary key, b int) engine=innodb; alter database mysqltest character set utf8; drop database mysqltest; ---source backup_log_print.inc - --echo # --echo # MENT-222 bug testing --echo # @@ -38,5 +36,4 @@ CREATE TABLE IF NOT EXISTS t_exists LIKE t_exists_template; --echo # DROP TABLE t_exists; DROP TABLE t_exists_template; ---source backup_log_print.inc disconnect con1; diff --git a/mysql-test/main/backup_log_print.inc b/mysql-test/main/backup_log_print.inc deleted file mode 100644 index ad46dde49f938..0000000000000 --- a/mysql-test/main/backup_log_print.inc +++ /dev/null @@ -1,7 +0,0 @@ ---disable_query_log ---source include/print_ddl_log.inc ---connection con1 -backup stage end; -backup stage start; ---connection default ---enable_query_log diff --git a/mysql-test/main/create_not_windows.result b/mysql-test/main/create_not_windows.result index 43860c2fdca85..8dacf2894eb57 100644 --- a/mysql-test/main/create_not_windows.result +++ b/mysql-test/main/create_not_windows.result @@ -29,39 +29,3 @@ select count(a) from t1; count(a) 0 drop table t1; -# -# MDEV-25292 Atomic CREATE OR REPLACE TABLE -# -# Test multi-byte characters in table name -set names utf8; -# Filename is too long because it is converted to @274e@274e@274e@274e... -# so each '❎' is 5 bytes in filesystem, 51 x 5 = 255 bytes -create table ❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (x int); -ERROR HY000: Can't create table `test`.`❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` (errno: 36 "File name too long") -# Let's find out max length for '❎'... -# Acceptable name length: 50; Filename length: 254 -# OK with 64-characters table name, filesystem name is 40 x 5 + 24 = 224 bytes -create table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (x int); -# Not OK with 65-characters table name -create table ttttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (x int); -ERROR 42000: Incorrect table name 'ttttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎' -show tables; -Tables_in_test -tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ -create or replace table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (y int); -show create table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎; -Table Create Table -tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ CREATE TABLE `tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` ( - `y` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -set @@debug_dbug="+d,ddl_log_create_after_save_backup", @debug_crash_counter=1; -create or replace table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (z int); -ERROR HY000: Lost connection to server during query -#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD -#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI -#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm -#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD -#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI -#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm -drop table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎; -set @@debug_dbug=""; diff --git a/mysql-test/main/create_not_windows.test b/mysql-test/main/create_not_windows.test index d6dfc0d3fa1db..b612e31e3aa49 100644 --- a/mysql-test/main/create_not_windows.test +++ b/mysql-test/main/create_not_windows.test @@ -1,8 +1,6 @@ # Non-windows specific create tests. --source include/not_windows.inc ---source include/have_debug.inc ---source include/not_embedded.inc # # Bug#19479:mysqldump creates invalid dump @@ -43,64 +41,3 @@ create table t1(a int, b int, c int); --echo "Try to select from the table. This should not crash the server" select count(a) from t1; drop table t1; - ---echo # ---echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE ---echo # - -# This does not work on Windows because of max path limit 255 -# (actually it does not work for path 254 already) -# Note: on Windows use ER_BAD_DB_ERROR instead of ER_CANT_CREATE_TABLE -# unless MDEV-28746 is fixed. - ---echo # Test multi-byte characters in table name -set names utf8; -let $save_debug=`select @@debug_dbug`; -let $MYSQLD_DATADIR= `SELECT @@datadir`; ---echo # Filename is too long because it is converted to @274e@274e@274e@274e... ---echo # so each '❎' is 5 bytes in filesystem, 51 x 5 = 255 bytes -let $t= `select repeat('❎', 51)`; ---error ER_CANT_CREATE_TABLE -eval create table $t (x int); -# The below case is useful for experimenting on Windows ---echo # Let's find out max length for '❎'... ---disable_query_log -let $i= 50; -while ($i) -{ - let $t= `select repeat('❎', $i)`; - --error 0,ER_CANT_CREATE_TABLE - eval create table $t (x int); - let $good_len= $i; - dec $i; - if (!$mysql_errno) - { - let $i= 0; - } -} -let $fn_len= `select $good_len * 5 + 4`; # 4 is extension length -eval drop table $t; ---enable_query_log ---echo # Acceptable name length: $good_len; Filename length: $fn_len ---echo # OK with 64-characters table name, filesystem name is 40 x 5 + 24 = 224 bytes -let $t= `select concat(repeat('t', 24), repeat('❎', 40))`; -eval create table $t (x int); ---echo # Not OK with 65-characters table name -let $t2= `select concat(repeat('t', 25), repeat('❎', 40))`; ---error ER_WRONG_TABLE_NAME -eval create table $t2 (x int); -show tables; -# Let's try atomic replace with such long name and see what happens -eval create or replace table $t (y int); -eval show create table $t; -set @@debug_dbug="+d,ddl_log_create_after_save_backup", @debug_crash_counter=1; ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---disable_reconnect ---error 2013 -eval create or replace table $t (z int); ---replace_regex /-\w+-\w+-ttt/-PID-TID-ttt/ ---list_files $MYSQLD_DATADIR/test *sql* ---enable_reconnect ---source include/wait_until_connected_again.inc -eval drop table $t; -eval set @@debug_dbug="$save_debug"; diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index be863986f78ea..4e96af9732649 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -1,3 +1,5 @@ +SET @save_persistent=@@GLOBAL.innodb_stats_persistent; +SET GLOBAL innodb_stats_persistent=OFF; CREATE TABLE t2 (a int); INSERT INTO t2 VALUES(1),(2),(3); # @@ -258,8 +260,7 @@ Note 1051 Unknown table 'test.t1,mysqltest2.t2' create table test.t1 (i int) engine=myisam; create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -271,37 +272,24 @@ create or replace table test.t1; ERROR 42000: A table must have at least 1 column show tables; Tables_in_test -t1 t2 -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 -# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 create or replace table mysqltest2.t2; ERROR 42000: A table must have at least 1 column -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_BACKUP_DDL NULL Backup lock -# MDL_BACKUP_DML NULL Backup lock -# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 -# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test -# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 -# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 -drop table mysqltest2.t2; -drop table t1; create table t1 (i int); drop table t1; create table test.t1 (i int); create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -313,37 +301,24 @@ create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a'; ERROR 42S21: Duplicate column name 'a' show tables; Tables_in_test -t1 t2 -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 -# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; ERROR 42S21: Duplicate column name 'a' -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_BACKUP_DDL NULL Backup lock -# MDL_BACKUP_DML NULL Backup lock -# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 -# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test -# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 -# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 -drop table mysqltest2.t2; -drop table t1; create table t1 (i int); drop table t1; create table test.t1 (i int) engine=innodb; create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 @@ -355,8 +330,7 @@ drop table test.t1,mysqltest2.t2; create table test.t1 (i int) engine=aria transactional=1 checksum=1; create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 @@ -373,8 +347,7 @@ drop table test.t1; # create table t1 (i int); lock table t1 write; -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -382,12 +355,10 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a; ERROR 22001: Data too long for column 'a' at row 1 -drop table t1; show tables; Tables_in_test t2 -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME create table t1 (i int); drop table t1; @@ -475,8 +446,7 @@ drop view t1; # create table t1 (a int); lock table t1 write, t2 read; -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -484,8 +454,7 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 # MDL_SHARED_READ NULL Table metadata lock test t2 create or replace table t1 (i int); -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -493,8 +462,7 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 # MDL_SHARED_READ NULL Table metadata lock test t2 create or replace table t1 like t2; -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -502,8 +470,7 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 # MDL_SHARED_READ NULL Table metadata lock test t2 create or replace table t1 select 1 as f1; -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -612,320 +579,4 @@ DROP TABLE IF EXISTS tm, t; # # End of 10.3 tests # -# End of 10.4 tests -# -# MDEV-25292 Atomic CREATE OR REPLACE TABLE -# -create table t1 (a int); -insert t1 values (1), (1); -create table t2 (c int); -create or replace table t2 (a int, b int, key k (a), key k (b)); -ERROR 42000: Duplicate key name 'k' -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `c` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -create or replace table t2 (a int, b int, key k (a), key k (b)) as select a, a as b from t1; -ERROR 42000: Duplicate key name 'k' -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `c` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -create or replace table t2 (a int primary key) as select * from t1; -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `c` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -set @old_mode= @@sql_mode; -set @@sql_mode='ALLOW_INVALID_DATES'; -create table t3 (dt datetime default '2008-02-31 00:00:00'); -set @@sql_mode= @old_mode; -create or replace table t2 like t3; -ERROR 42000: Invalid default value for 'dt' -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `c` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -# LOCK TABLES -lock tables t2 write, t1 write; -flush tables; -show open tables like 't2'; -Database Table In_use Name_locked -test t2 1 0 -create or replace table t2 (y int); -flush tables; -show open tables like 't2'; -Database Table In_use Name_locked -test t2 1 0 -create or replace table t2 like t1; -flush tables; -show open tables like 't2'; -Database Table In_use Name_locked -test t2 1 0 -create or replace table t2 (y int) as select * from t1; -flush tables; -show open tables like 't2'; -Database Table In_use Name_locked -test t2 1 0 -unlock tables; -# SP -create or replace procedure sp(n int) -begin -select concat('sp call ', n, ':') as ''; -show open tables like 't2'; -create or replace table t2 (y int); -select 'create or replace table t2 (y int);' as ''; -show open tables like 't2'; -insert into t2 values (2); -select 'insert into t2 values (2);' as ''; -show open tables like 't2'; -create or replace table t2 like t1; -select 'create or replace table t2 like t1;' as ''; -show open tables like 't2'; -create or replace table t2 (y int) as select * from t1; -select 'create or replace table t2 (y int) as select * from t1;' as ''; -show open tables like 't2'; -select 'select * from t2;' as ''; -select * from t2; -show open tables like 't2'; -end $ -flush tables; -call sp(1); - -sp call 1: -Database Table In_use Name_locked - -create or replace table t2 (y int); -Database Table In_use Name_locked - -insert into t2 values (2); -Database Table In_use Name_locked -test t2 0 0 - -create or replace table t2 like t1; -Database Table In_use Name_locked - -create or replace table t2 (y int) as select * from t1; -Database Table In_use Name_locked - -select * from t2; -y a -NULL 1 -NULL 1 -Database Table In_use Name_locked -test t2 0 0 -call sp(2); - -sp call 2: -Database Table In_use Name_locked -test t2 0 0 - -create or replace table t2 (y int); -Database Table In_use Name_locked - -insert into t2 values (2); -Database Table In_use Name_locked -test t2 0 0 - -create or replace table t2 like t1; -Database Table In_use Name_locked - -create or replace table t2 (y int) as select * from t1; -Database Table In_use Name_locked - -select * from t2; -y a -NULL 1 -NULL 1 -Database Table In_use Name_locked -test t2 0 0 -# SP under LOCK TABLES -lock tables t2 write, t1 write; -call sp(3); - -sp call 3: -Database Table In_use Name_locked -test t2 1 0 - -create or replace table t2 (y int); -Database Table In_use Name_locked -test t2 1 0 - -insert into t2 values (2); -Database Table In_use Name_locked -test t2 1 0 - -create or replace table t2 like t1; -Database Table In_use Name_locked -test t2 1 0 - -create or replace table t2 (y int) as select * from t1; -Database Table In_use Name_locked -test t2 1 0 - -select * from t2; -y a -NULL 1 -NULL 1 -Database Table In_use Name_locked -test t2 1 0 -call sp(4); - -sp call 4: -Database Table In_use Name_locked -test t2 1 0 - -create or replace table t2 (y int); -Database Table In_use Name_locked -test t2 1 0 - -insert into t2 values (2); -Database Table In_use Name_locked -test t2 1 0 - -create or replace table t2 like t1; -Database Table In_use Name_locked -test t2 1 0 - -create or replace table t2 (y int) as select * from t1; -Database Table In_use Name_locked -test t2 1 0 - -select * from t2; -y a -NULL 1 -NULL 1 -Database Table In_use Name_locked -test t2 1 0 -unlock tables; -drop procedure sp; -drop tables t1, t2, t3; -# Trigger -create table t1 (a int); -create trigger a before insert on t1 for each row set @s= 1; -create or replace table t1 (old int); -show create trigger a; -ERROR HY000: Trigger does not exist -drop table t1; -# PS: check thd->change_list sanity -create table t1 (a int not null, b char(10) as (concat('', dayname('2020-02-02')))) collate utf8_bin; -prepare stmt from 'insert into t1 (b) values (2)'; -create or replace table t1 (x int); -drop table t1; -drop prepare stmt; -# Foreign keys -create table t1 (x int primary key, y int) engine innodb; -create table t2 (x int references t1(x)) engine innodb; -create or replace table t1 (x int primary key); -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) -create or replace table t1 (x int primary key); -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) -create table t3 (x int); -create or replace table t1 like t3; -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) -create or replace table t1 like t3; -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) -create or replace table t1 select * from t3; -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) -create or replace table t1 select * from t3; -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (t2) -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `x` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`x`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -drop tables t3, t2, t1; -# UNIQUE -create table t1 (pk int auto_increment primary key, a varchar(2300), unique (a)) engine aria; -insert into t1 (a) values ('a'), ('b'), ('c'); -create table t2 (x int); -create or replace table t2 engine aria select * from t1; -select * from t2; -pk a -1 a -2 b -3 c -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `pk` int(11) NOT NULL DEFAULT 0, - `a` varchar(2300) DEFAULT NULL -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -drop tables t2, t1; -# -# MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES -# -# Atomic CREATE OR REPLACE part: -# -create table t1 (pk int primary key) engine=innodb; -create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; -lock tables t1 write, t2 write; -create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -select * from t1; -pk -select * from t2; -a -unlock tables; -drop tables t2, t1; -# -# MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name -# -use test; -create table t (a int primary key) engine=innodb; -create or replace table u ( -a int primary key, -constraint c foreign key d (a) references t (a)) engine=innodb; -select * from information_schema.innodb_sys_foreign; -ID FOR_NAME REF_NAME N_COLS TYPE -test/c test/u test/t 1 0 -select * from information_schema.innodb_sys_foreign_cols; -ID FOR_COL_NAME REF_COL_NAME POS -test/c a a 0 -create or replace table u ( -a int primary key, -constraint c foreign key d (a) references t (a)) engine=innodb; -select * from information_schema.innodb_sys_foreign; -ID FOR_NAME REF_NAME N_COLS TYPE -test/c test/u test/t 1 0 -select * from information_schema.innodb_sys_foreign_cols; -ID FOR_COL_NAME REF_COL_NAME POS -test/c a a 0 -drop tables u, t; -select * from information_schema.innodb_sys_foreign; -ID FOR_NAME REF_NAME N_COLS TYPE -select * from information_schema.innodb_sys_foreign_cols; -ID FOR_COL_NAME REF_COL_NAME POS -# -# MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables -# -call mtr.add_suppression("mysql.innodb_index_stats"); -set sql_mode= ''; -create table t (x int) engine innodb; -insert into t values (77); -alter table mysql.innodb_index_stats modify stat_description char(10); -Warnings: -Warning 1265 Data truncated for column 'stat_description' at row 2 -Warning 1265 Data truncated for column 'stat_description' at row 3 -lock table t write; -create or replace table t (y int); -ERROR HY000: Error on rename of './test/t' to './test/#sql-backup-t' (errno: 168 "Unknown (generic) error from engine") -unlock tables; -alter table mysql.innodb_index_stats modify stat_description varchar(1024) not null; -select * from t; -x -77 -drop table t; -set sql_mode= default; -# -# MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock -# -create or replace table t1 (i serial) as select * from (values(1), (2)) dt; -drop table t1; +SET GLOBAL innodb_stats_persistent=@save_persistent; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 3622d8342f498..05c5d25ba1523 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -5,7 +5,8 @@ --source include/have_innodb.inc --source include/have_metadata_lock_info.inc -let $MYSQLD_DATADIR= `SELECT @@datadir`; +SET @save_persistent=@@GLOBAL.innodb_stats_persistent; +SET GLOBAL innodb_stats_persistent=OFF; # # Create help table @@ -217,23 +218,18 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; --error ER_TABLE_MUST_HAVE_COLUMNS create or replace table test.t1; show tables; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; --error ER_TABLE_MUST_HAVE_COLUMNS create or replace table mysqltest2.t2; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; -drop table mysqltest2.t2; -drop table t1; +select * from information_schema.metadata_lock_info; create table t1 (i int); drop table t1; @@ -242,23 +238,18 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; --error ER_DUP_FIELDNAME create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a'; show tables; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; --error ER_DUP_FIELDNAME create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; -drop table mysqltest2.t2; -drop table t1; +select * from information_schema.metadata_lock_info; create table t1 (i int); drop table t1; @@ -267,8 +258,7 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; unlock tables; drop table test.t1,mysqltest2.t2; @@ -277,8 +267,7 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; unlock tables; drop table t1; @@ -294,16 +283,13 @@ create table t1 (i int); lock table t1 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; --error ER_DATA_TOO_LONG create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a; -drop table t1; show tables; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; create table t1 (i int); drop table t1; --enable_view_protocol @@ -381,24 +367,20 @@ create table t1 (a int); lock table t1 write, t2 read; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; create or replace table t1 (i int); --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; create or replace table t1 like t2; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; create or replace table t1 select 1 as f1; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info -where table_schema!='mysql' or table_name not like 'innodb_%_stats'; +select * from information_schema.metadata_lock_info; drop table t1; unlock tables; @@ -546,182 +528,4 @@ DROP TABLE IF EXISTS tm, t; --echo # End of 10.3 tests --echo # ---echo # End of 10.4 tests - ---echo # ---echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE ---echo # -create table t1 (a int); -insert t1 values (1), (1); -create table t2 (c int); ---error ER_DUP_KEYNAME -create or replace table t2 (a int, b int, key k (a), key k (b)); -show create table t2; ---error ER_DUP_KEYNAME -create or replace table t2 (a int, b int, key k (a), key k (b)) as select a, a as b from t1; -show create table t2; ---error ER_DUP_ENTRY -create or replace table t2 (a int primary key) as select * from t1; -show create table t2; -set @old_mode= @@sql_mode; -set @@sql_mode='ALLOW_INVALID_DATES'; -create table t3 (dt datetime default '2008-02-31 00:00:00'); -set @@sql_mode= @old_mode; ---error ER_INVALID_DEFAULT -create or replace table t2 like t3; -show create table t2; ---echo # LOCK TABLES -lock tables t2 write, t1 write; -flush tables; -show open tables like 't2'; -create or replace table t2 (y int); -flush tables; -show open tables like 't2'; -create or replace table t2 like t1; -flush tables; -show open tables like 't2'; -create or replace table t2 (y int) as select * from t1; -flush tables; -show open tables like 't2'; -unlock tables; ---echo # SP ---delimiter $ -create or replace procedure sp(n int) -begin - select concat('sp call ', n, ':') as ''; - show open tables like 't2'; - create or replace table t2 (y int); - select 'create or replace table t2 (y int);' as ''; - show open tables like 't2'; - insert into t2 values (2); - select 'insert into t2 values (2);' as ''; - show open tables like 't2'; - create or replace table t2 like t1; - select 'create or replace table t2 like t1;' as ''; - show open tables like 't2'; - create or replace table t2 (y int) as select * from t1; - select 'create or replace table t2 (y int) as select * from t1;' as ''; - show open tables like 't2'; - select 'select * from t2;' as ''; - select * from t2; - show open tables like 't2'; -end $ ---delimiter ; -flush tables; -call sp(1); call sp(2); ---echo # SP under LOCK TABLES -lock tables t2 write, t1 write; -call sp(3); call sp(4); -unlock tables; -drop procedure sp; -drop tables t1, t2, t3; ---echo # Trigger -create table t1 (a int); -create trigger a before insert on t1 for each row set @s= 1; -create or replace table t1 (old int); ---error ER_TRG_DOES_NOT_EXIST -show create trigger a; -drop table t1; ---echo # PS: check thd->change_list sanity -create table t1 (a int not null, b char(10) as (concat('', dayname('2020-02-02')))) collate utf8_bin; -prepare stmt from 'insert into t1 (b) values (2)'; -create or replace table t1 (x int); -drop table t1; -drop prepare stmt; ---echo # Foreign keys ---list_files $MYSQLD_DATADIR/test *sql* -create table t1 (x int primary key, y int) engine innodb; -create table t2 (x int references t1(x)) engine innodb; ---error ER_ROW_IS_REFERENCED_2 -create or replace table t1 (x int primary key); ---list_files $MYSQLD_DATADIR/test *sql* ---error ER_ROW_IS_REFERENCED_2 -create or replace table t1 (x int primary key); -create table t3 (x int); ---error ER_ROW_IS_REFERENCED_2 -create or replace table t1 like t3; ---list_files $MYSQLD_DATADIR/test *sql* ---error ER_ROW_IS_REFERENCED_2 -create or replace table t1 like t3; ---error ER_ROW_IS_REFERENCED_2 -create or replace table t1 select * from t3; ---error ER_ROW_IS_REFERENCED_2 -create or replace table t1 select * from t3; ---list_files $MYSQLD_DATADIR/test *sql* -show create table t1; -drop tables t3, t2, t1; ---echo # UNIQUE -create table t1 (pk int auto_increment primary key, a varchar(2300), unique (a)) engine aria; -insert into t1 (a) values ('a'), ('b'), ('c'); -create table t2 (x int); -create or replace table t2 engine aria select * from t1; -select * from t2; -show create table t2; -drop tables t2, t1; - ---echo # ---echo # MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES ---echo # ---echo # Atomic CREATE OR REPLACE part: ---echo # ---disable_service_connection -create table t1 (pk int primary key) engine=innodb; -create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; - -lock tables t1 write, t2 write; ---error ER_DUP_FIELDNAME -create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; -select * from t1; -select * from t2; -unlock tables; - -drop tables t2, t1; ---enable_service_connection - ---echo # ---echo # MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name ---echo # -use test; -create table t (a int primary key) engine=innodb; -create or replace table u ( - a int primary key, - constraint c foreign key d (a) references t (a)) engine=innodb; - -select * from information_schema.innodb_sys_foreign; -select * from information_schema.innodb_sys_foreign_cols; - -create or replace table u ( - a int primary key, - constraint c foreign key d (a) references t (a)) engine=innodb; - -select * from information_schema.innodb_sys_foreign; -select * from information_schema.innodb_sys_foreign_cols; -drop tables u, t; -select * from information_schema.innodb_sys_foreign; -select * from information_schema.innodb_sys_foreign_cols; - ---echo # ---echo # MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables ---echo # -call mtr.add_suppression("mysql.innodb_index_stats"); -set sql_mode= ''; -create table t (x int) engine innodb; -insert into t values (77); -alter table mysql.innodb_index_stats modify stat_description char(10); -lock table t write; ---replace_regex /#sql-backup-.+-.+-/#sql-backup-/ ---replace_result $MYSQLD_DATADIR ./ ---error ER_ERROR_ON_RENAME -create or replace table t (y int); -# cleanup -unlock tables; -alter table mysql.innodb_index_stats modify stat_description varchar(1024) not null; -select * from t; -drop table t; -set sql_mode= default; - ---echo # ---echo # MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock ---echo # -create or replace table t1 (i serial) as select * from (values(1), (2)) dt; -drop table t1; +SET GLOBAL innodb_stats_persistent=@save_persistent; diff --git a/mysql-test/main/create_or_replace2.result b/mysql-test/main/create_or_replace2.result new file mode 100644 index 0000000000000..c84d54004caa2 --- /dev/null +++ b/mysql-test/main/create_or_replace2.result @@ -0,0 +1,27 @@ +include/master-slave.inc +[connection master] +drop table if exists t1; +SET @old_debug= @@session.debug; +CREATE TABLE t1 (i INT, KEY(i)) ENGINE=InnoDB; +CREATE OR REPLACE TEMPORARY TABLE tmp (a int, b int, key(a)) engine=myisam; +SET debug_dbug='+d,send_kill_after_delete'; +CREATE OR REPLACE TABLE t1 LIKE tmp; +SET debug_dbug=@old_debug; +SHOW TABLES; +Tables_in_test +t1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection slave; +SHOW TABLES; +Tables_in_test +t1 +connection master; +drop temporary table if exists tmp; +drop table t1; +include/rpl_end.inc diff --git a/mysql-test/main/create_or_replace2.test b/mysql-test/main/create_or_replace2.test new file mode 100644 index 0000000000000..80c8b635d8d5d --- /dev/null +++ b/mysql-test/main/create_or_replace2.test @@ -0,0 +1,35 @@ +# +# Check CREATE OR REPLACE TABLE for test that requires DEBUG +# + +--source include/have_debug.inc +--source include/have_binlog_format_row.inc +--source include/have_innodb.inc +--source include/master-slave.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings +SET @old_debug= @@session.debug; + +# +# MDEV-5854 +# Interrupted CREATE OR REPLACE is written into binlog, and in a wrong format +# + +CREATE TABLE t1 (i INT, KEY(i)) ENGINE=InnoDB; +CREATE OR REPLACE TEMPORARY TABLE tmp (a int, b int, key(a)) engine=myisam; +SET debug_dbug='+d,send_kill_after_delete'; +CREATE OR REPLACE TABLE t1 LIKE tmp; +SET debug_dbug=@old_debug; +SHOW TABLES; +show create table t1; +--sync_slave_with_master +SHOW TABLES; +--connection master + +--disable_warnings +drop temporary table if exists tmp; +--enable_warnings +drop table t1; +--source include/rpl_end.inc diff --git a/mysql-test/main/create_replace_debug.result b/mysql-test/main/create_replace_debug.result deleted file mode 100644 index 3a3ef21bdecea..0000000000000 --- a/mysql-test/main/create_replace_debug.result +++ /dev/null @@ -1,103 +0,0 @@ -include/master-slave.inc -[connection master] -drop table if exists t1; -SET @old_debug= @@session.debug; -CREATE TABLE t1 (i INT, KEY(i)) ENGINE=InnoDB; -CREATE OR REPLACE TEMPORARY TABLE tmp (a int, b int, key(a)) engine=myisam; -SET debug_dbug='+d,send_kill_after_delete'; -CREATE OR REPLACE TABLE t1 LIKE tmp; -SET debug_dbug=@old_debug; -SHOW TABLES; -Tables_in_test -t1 -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -connection slave; -SHOW TABLES; -Tables_in_test -t1 -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -connection master; -drop temporary table if exists tmp; -drop table t1; -include/rpl_end.inc -# -# MDEV-25292 Atomic CREATE OR REPLACE TABLE -# -set @saved_debug_dbug= @@session.debug_dbug; -create table t1 (a int primary key) engine innodb; -insert t1 values (1), (2); -create table t2 (c int, a int constraint t1_a references t1 (a)) engine innodb; -insert into t2 values (2, 2); -lock tables t2 write, t1 write; -set session debug_dbug= '+d,atomic_replace_external_lock_fail'; -create or replace table t2 (y int) as select * from t1; -ERROR HY000: The total number of locks exceeds the lock table size -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL, - PRIMARY KEY (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `c` int(11) DEFAULT NULL, - `a` int(11) DEFAULT NULL, - KEY `t1_a` (`a`), - CONSTRAINT `t1_a` FOREIGN KEY (`a`) REFERENCES `t1` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -select * from t2; -c a -2 2 -unlock tables; -drop tables t2, t1; -set session debug_dbug= @saved_debug_dbug; -# Test entry_pos in higher position, so drop chain executes before create chain -# (see commit message: On linking two chains together) -create table t1 (c int); -create or replace table t1 (a int, b int, key k (a), key k (b)); -ERROR 42000: Duplicate key name 'k' -create or replace table t1 (a int, b int, key k (a), key k (b)); -ERROR 42000: Duplicate key name 'k' -drop table t1; -# -# MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES -# -# Non-atomic CREATE OR REPLACE part: -# -set @saved_debug_dbug= @@session.debug_dbug; -set @@debug_dbug="+d,ddl_log_expensive_rename"; -create table t1 (pk int primary key) engine=innodb; -create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; -lock tables t1 write, t2 write; -create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -select * from t1; -pk -select * from t2; -ERROR HY000: Table 't2' was not locked with LOCK TABLES -unlock tables; -drop tables t1; -set @@debug_dbug= @saved_debug_dbug; -# -# MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection -# -create table t1 (x int); -set @old_dbug= @@debug_dbug; -set @@debug_dbug= '+d,ha_end_bulk_insert_fail'; -create or replace table t2 (y int) engine innodb select * from t1; -ERROR HY000: Out of memory. -set @@debug_dbug= @old_dbug; -drop table t1; diff --git a/mysql-test/main/create_replace_debug.test b/mysql-test/main/create_replace_debug.test deleted file mode 100644 index 86e68c4774318..0000000000000 --- a/mysql-test/main/create_replace_debug.test +++ /dev/null @@ -1,99 +0,0 @@ -# -# Check CREATE OR REPLACE TABLE for test that requires DEBUG -# - ---source include/have_debug.inc ---source include/have_binlog_format_row.inc ---source include/have_innodb.inc ---source include/master-slave.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings -SET @old_debug= @@session.debug; - -# -# MDEV-5854 -# Interrupted CREATE OR REPLACE is written into binlog, and in a wrong format -# - -CREATE TABLE t1 (i INT, KEY(i)) ENGINE=InnoDB; -CREATE OR REPLACE TEMPORARY TABLE tmp (a int, b int, key(a)) engine=myisam; -SET debug_dbug='+d,send_kill_after_delete'; -CREATE OR REPLACE TABLE t1 LIKE tmp; -SET debug_dbug=@old_debug; -SHOW TABLES; -show create table t1; ---sync_slave_with_master -SHOW TABLES; -show create table t1; ---connection master - ---disable_warnings -drop temporary table if exists tmp; ---enable_warnings -drop table t1; ---source include/rpl_end.inc - - ---echo # ---echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE ---echo # -set @saved_debug_dbug= @@session.debug_dbug; -create table t1 (a int primary key) engine innodb; -insert t1 values (1), (2); -create table t2 (c int, a int constraint t1_a references t1 (a)) engine innodb; -insert into t2 values (2, 2); -lock tables t2 write, t1 write; -set session debug_dbug= '+d,atomic_replace_external_lock_fail'; ---error ER_LOCK_TABLE_FULL -create or replace table t2 (y int) as select * from t1; -let $MYSQLD_DATADIR= `SELECT @@datadir`; ---list_files $MYSQLD_DATADIR/test *sql* -show create table t1; -show create table t2; -select * from t2; -unlock tables; -drop tables t2, t1; -set session debug_dbug= @saved_debug_dbug; - ---echo # Test entry_pos in higher position, so drop chain executes before create chain ---echo # (see commit message: On linking two chains together) -create table t1 (c int); ---error ER_DUP_KEYNAME -create or replace table t1 (a int, b int, key k (a), key k (b)); ---error ER_DUP_KEYNAME -create or replace table t1 (a int, b int, key k (a), key k (b)); -drop table t1; - ---echo # ---echo # MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES ---echo # ---echo # Non-atomic CREATE OR REPLACE part: ---echo # -set @saved_debug_dbug= @@session.debug_dbug; -set @@debug_dbug="+d,ddl_log_expensive_rename"; -create table t1 (pk int primary key) engine=innodb; -create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; - -lock tables t1 write, t2 write; ---error ER_DUP_FIELDNAME -create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; -select * from t1; ---error ER_TABLE_NOT_LOCKED -select * from t2; -unlock tables; - -drop tables t1; -set @@debug_dbug= @saved_debug_dbug; - ---echo # ---echo # MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection ---echo # -create table t1 (x int); -set @old_dbug= @@debug_dbug; -set @@debug_dbug= '+d,ha_end_bulk_insert_fail'; ---error ER_OUT_OF_RESOURCES -create or replace table t2 (y int) engine innodb select * from t1; -set @@debug_dbug= @old_dbug; -drop table t1; diff --git a/mysql-test/main/default.result b/mysql-test/main/default.result index 874f3af25e0a8..abcf3b27c9c5b 100644 --- a/mysql-test/main/default.result +++ b/mysql-test/main/default.result @@ -428,6 +428,14 @@ a b c e 2 -1 1 1 drop table t1; # +# Create or replace can delete a table on error +# +create table t1 (a int); +create or replace table t1 (a int default b, b int default a); +ERROR 01000: Expression for field `a` is referring to uninitialized field `b` +show create table t1; +ERROR 42S02: Table 'test.t1' doesn't exist +# # Refering to other columns # create or replace table t1 (a int default 1, b int default a); @@ -445,11 +453,11 @@ ERROR 01000: Expression for field `a` is referring to uninitialized field `a` create or replace table t1 (a int default b, b int default (1+1)); create or replace table t1 (a int default 1, b int as (c), c int as (a+1)); ERROR 01000: Expression for field `b` is referring to uninitialized field `c` -CREATE OR REPLACE TABLE t1 (a INT DEFAULT (DEFAULT(a))); +CREATE TABLE t1 (a INT DEFAULT (DEFAULT(a))); ERROR 01000: Expression for field `a` is referring to uninitialized field `a` -CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); +CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); ERROR 01000: Expression for field `a` is referring to uninitialized field `b` -CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); +CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); ERROR 01000: Expression for field `a` is referring to uninitialized field `b` # # Allow defaults to refer to not default fields diff --git a/mysql-test/main/default.test b/mysql-test/main/default.test index 36a616551d734..26fc218653313 100644 --- a/mysql-test/main/default.test +++ b/mysql-test/main/default.test @@ -307,6 +307,15 @@ insert into t1 values(); select * from t1; drop table t1; +--echo # +--echo # Create or replace can delete a table on error +--echo # +create table t1 (a int); +--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD +create or replace table t1 (a int default b, b int default a); +--error ER_NO_SUCH_TABLE +show create table t1; + --echo # --echo # Refering to other columns --echo # @@ -329,11 +338,11 @@ create or replace table t1 (a int default b, b int default (1+1)); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD create or replace table t1 (a int default 1, b int as (c), c int as (a+1)); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -CREATE OR REPLACE TABLE t1 (a INT DEFAULT (DEFAULT(a))); +CREATE TABLE t1 (a INT DEFAULT (DEFAULT(a))); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); +CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); +CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); --echo # --echo # Allow defaults to refer to not default fields diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index b0d64c1f2842d..31fa5f8c8d5c8 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -397,8 +397,7 @@ c d create or replace table t2 (a int, b blob, unique(b)) as select * from t1; ERROR 23000: Duplicate entry 'bar' for key 'b' select * from t2; -c d -3 bar +ERROR 42S02: Table 'test.t2' doesn't exist create or replace table t2 (a int, b blob, unique(b)) ignore as select * from t1; Warnings: Warning 1062 Duplicate entry 'bar' for key 'b' diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index e522f5140bae9..18e430858b05a 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -480,6 +480,7 @@ delete from t2 using t1, t2 where t1.a=t2.c and t1.b='foo'; # CREATE...SELECT --error ER_DUP_ENTRY create or replace table t2 (a int, b blob, unique(b)) as select * from t1; +--error ER_NO_SUCH_TABLE select * from t2; create or replace table t2 (a int, b blob, unique(b)) ignore as select * from t1; select * from t2; diff --git a/mysql-test/suite/atomic/create_replace,aria_notrans,row.result b/mysql-test/suite/atomic/create_replace,aria_notrans,row.result deleted file mode 100644 index c8df035b23a2d..0000000000000 --- a/mysql-test/suite/atomic/create_replace,aria_notrans,row.result +++ /dev/null @@ -1,710 +0,0 @@ -# Crash recovery -Table Create Table -const_table CREATE TABLE `const_table` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into const_table values (1, 1), (2, 2); -flush tables; -# QUERY: CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -Warnings: -Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,aria_notrans.result b/mysql-test/suite/atomic/create_replace,aria_notrans.result deleted file mode 100644 index 7a3e47f1312ad..0000000000000 --- a/mysql-test/suite/atomic/create_replace,aria_notrans.result +++ /dev/null @@ -1,696 +0,0 @@ -# Crash recovery -Table Create Table -const_table CREATE TABLE `const_table` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into const_table values (1, 1), (2, 2); -flush tables; -# QUERY: CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -Warnings: -Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,expensive_rename,row.result b/mysql-test/suite/atomic/create_replace,expensive_rename,row.result deleted file mode 100644 index 5095b1fea0375..0000000000000 --- a/mysql-test/suite/atomic/create_replace,expensive_rename,row.result +++ /dev/null @@ -1,584 +0,0 @@ -# Crash recovery -Table Create Table -const_table CREATE TABLE `const_table` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into const_table values (1, 1), (2, 2); -flush tables; -# QUERY: CREATE OR REPLACE TABLE t1 (new int) -# CRASH POINT: ddl_log_create_before_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_drop_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_rename_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table -# CRASH POINT: ddl_log_create_before_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_drop_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_rename_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table -# CRASH POINT: ddl_log_create_before_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_drop_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_rename_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_prepare_eof -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -Warnings: -Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,expensive_rename.result b/mysql-test/suite/atomic/create_replace,expensive_rename.result deleted file mode 100644 index 41405a2c217c9..0000000000000 --- a/mysql-test/suite/atomic/create_replace,expensive_rename.result +++ /dev/null @@ -1,561 +0,0 @@ -# Crash recovery -Table Create Table -const_table CREATE TABLE `const_table` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into const_table values (1, 1), (2, 2); -flush tables; -# QUERY: CREATE OR REPLACE TABLE t1 (new int) -# CRASH POINT: ddl_log_create_before_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_drop_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_rename_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table -# CRASH POINT: ddl_log_create_before_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_drop_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_rename_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table -# CRASH POINT: ddl_log_create_before_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_drop_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_log_rename_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_install_new -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_prepare_eof -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by ddl recovery */ -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -Warnings: -Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,ib,row.result b/mysql-test/suite/atomic/create_replace,ib,row.result deleted file mode 100644 index a98ff0acbac85..0000000000000 --- a/mysql-test/suite/atomic/create_replace,ib,row.result +++ /dev/null @@ -1,661 +0,0 @@ -# Crash recovery -Table Create Table -const_table CREATE TABLE `const_table` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into const_table values (1, 1), (2, 2); -flush tables; -# QUERY: CREATE OR REPLACE TABLE t1 (new int) -# CRASH POINT: ddl_log_create_before_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_save_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_binlog -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.TRG -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete2 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -Warnings: -Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,ib.result b/mysql-test/suite/atomic/create_replace,ib.result deleted file mode 100644 index 82041ed7aeb45..0000000000000 --- a/mysql-test/suite/atomic/create_replace,ib.result +++ /dev/null @@ -1,648 +0,0 @@ -# Crash recovery -Table Create Table -const_table CREATE TABLE `const_table` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into const_table values (1, 1), (2, 2); -flush tables; -# QUERY: CREATE OR REPLACE TABLE t1 (new int) -# CRASH POINT: ddl_log_create_before_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_save_backup -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -t1.TRG -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_binlog -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.frm -t1.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -Warnings: -Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,myisam,row.result b/mysql-test/suite/atomic/create_replace,myisam,row.result deleted file mode 100644 index 507969c557ad2..0000000000000 --- a/mysql-test/suite/atomic/create_replace,myisam,row.result +++ /dev/null @@ -1,710 +0,0 @@ -# Crash recovery -Table Create Table -const_table CREATE TABLE `const_table` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into const_table values (1, 1), (2, 2); -flush tables; -# QUERY: CREATE OR REPLACE TABLE t1 (new int) -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -Warnings: -Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace,row.result b/mysql-test/suite/atomic/create_replace,row.result deleted file mode 100644 index d081b92953f0e..0000000000000 --- a/mysql-test/suite/atomic/create_replace,row.result +++ /dev/null @@ -1,710 +0,0 @@ -# Crash recovery -Table Create Table -const_table CREATE TABLE `const_table` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into const_table values (1, 1), (2, 2); -flush tables; -# QUERY: CREATE OR REPLACE TABLE t1 (new int) -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) PAGE_CHECKSUM=1 -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) PAGE_CHECKSUM=1 -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) PAGE_CHECKSUM=1 -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) PAGE_CHECKSUM=1 -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -Warnings: -Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace.combinations b/mysql-test/suite/atomic/create_replace.combinations deleted file mode 100644 index 09eb352b1cdf3..0000000000000 --- a/mysql-test/suite/atomic/create_replace.combinations +++ /dev/null @@ -1,6 +0,0 @@ -[ib] -[myisam] -[aria] -[aria_notrans] -[expensive_rename] -[lock_tables] diff --git a/mysql-test/suite/atomic/create_replace.result b/mysql-test/suite/atomic/create_replace.result deleted file mode 100644 index 2c82dbce03e4c..0000000000000 --- a/mysql-test/suite/atomic/create_replace.result +++ /dev/null @@ -1,696 +0,0 @@ -# Crash recovery -Table Create Table -const_table CREATE TABLE `const_table` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into const_table values (1, 1), (2, 2); -flush tables; -# QUERY: CREATE OR REPLACE TABLE t1 (new int) -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table -# CRASH POINT: ddl_log_create_before_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_drop_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_log_rename_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_frm -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_create_table -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_drop -# No crash! -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_after_send_data -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_save_backup -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_install_new -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_before_binlog -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_prepare_eof -t1.DATA1 -t1.DATA2 -t1.TRG -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_after_binlog -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_fk_fail -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail2 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_fk_fail3 -t1.TRG -t1.frm -t1.ibd -t2.frm -t2.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `old` int(11) NOT NULL, - `y` int(11) DEFAULT NULL, - PRIMARY KEY (`old`) -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -old y -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -a INSERT t1 set @s= 1 BEFORE -# CRASH POINT: ddl_log_create_log_complete -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete2 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -# CRASH POINT: ddl_log_create_log_complete3 -t1.DATA1 -t1.DATA2 -t1.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table -Table Create Table -t1 CREATE TABLE `t1` ( - `new` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -new b -1 1 -2 2 -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -Warnings: -Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace.test b/mysql-test/suite/atomic/create_replace.test deleted file mode 100644 index 7cb6d3494445a..0000000000000 --- a/mysql-test/suite/atomic/create_replace.test +++ /dev/null @@ -1,211 +0,0 @@ ---source include/have_debug.inc ---source include/have_sequence.inc ---source include/have_innodb.inc ---source include/binlog_formats.inc ---source include/not_valgrind.inc - ---disable_query_log -let $default_engine=InnoDB; -let $extra_option= ''; -let $save_debug=`select @@debug_dbug`; -let $show_error=0; -let $drop_error=0; - -if ($MTR_COMBINATION_MYISAM) -{ - let $default_engine=MyISAM; -} -if ($MTR_COMBINATION_ARIA) -{ - let $default_engine=Aria; - call mtr.add_suppression("Checking table"); - call mtr.add_suppression("marked as crashed"); -} -if ($MTR_COMBINATION_ARIA_NOTRANS) -{ - let $default_engine=Aria; - let $extra_option=' engine=aria,transactional=0'; - call mtr.add_suppression("Checking table"); - call mtr.add_suppression("marked as crashed"); -} -if ($MTR_COMBINATION_EXPENSIVE_RENAME) -{ - # Disable atomic CREATE OR REPLACE (emulates HTON_EXPENSIVE_RENAME flag) - let $default_engine=MyISAM; - let $show_error=0, ER_NO_SUCH_TABLE; - let $drop_error=0, ER_BAD_TABLE_ERROR; - set @@debug_dbug="+d,ddl_log_expensive_rename"; -} -if ($MTR_COMBINATION_LOCK_TABLES) -{ - let $default_engine=Aria; - call mtr.add_suppression("Checking table"); - call mtr.add_suppression("marked as crashed"); -} - -if ($MTR_COMBINATION_STMT) -{ - let $binlog_format=include/set_binlog_format_statement.sql; -} -if ($MTR_COMBINATION_ROW) -{ - let $binlog_format=include/set_binlog_format_row.sql; -} -if ($MTR_COMBINATION_MIX) -{ - --skip same as stmt -} - ---eval set @@default_storage_engine=$default_engine ---enable_query_log - ---echo # Crash recovery - -let $MYSQLD_DATADIR= `SELECT @@datadir`; - -let $crash_count=19; -let $crash_points='ddl_log_create_before_install_new', - 'ddl_log_create_after_log_drop_backup', - 'ddl_log_create_after_log_rename_backup', - 'ddl_log_create_before_create_frm', - 'ddl_log_create_before_create_table', - 'ddl_log_create_after_create_table', - 'ddl_log_create_after_drop', - 'ddl_log_create_after_send_data', - 'ddl_log_create_after_save_backup', - 'ddl_log_create_after_install_new', - 'ddl_log_create_before_binlog', - 'ddl_log_create_after_prepare_eof', - 'ddl_log_create_after_binlog', - 'ddl_log_create_fk_fail', - 'ddl_log_create_fk_fail2', - 'ddl_log_create_fk_fail3', - 'ddl_log_create_log_complete', - 'ddl_log_create_log_complete2', - 'ddl_log_create_log_complete3'; - -#let $crash_count=1; -#let $crash_points='ddl_log_create_fk_fail'; -# 'ddl_log_create_before_binlog3', -# 'ddl_log_create_before_binlog4'; - -let $statement_count=3; -let $statements='CREATE OR REPLACE TABLE t1 (new int) EXTRA_OPTION', - 'CREATE OR REPLACE TABLE t1 LIKE const_table', - 'CREATE OR REPLACE TABLE t1 EXTRA_OPTION SELECT * from const_table'; - -#let $statement_count=1; -#let $statements='CREATE OR REPLACE TABLE t1 EXTRA_OPTION SELECT * from const_table'; - ---disable_query_log -let create_const=`select REPLACE('create table const_table (new int, b int) EXTRA_OPTION', ' EXTRA_OPTION', $extra_option)`; -eval $create_const; ---replace_result $default_engine ENGINE ' PAGE_CHECKSUM=1' '' ' TRANSACTIONAL=0' '' -show create table const_table; ---enable_query_log -insert into const_table values (1, 1), (2, 2); -flush tables; - -let $old_debug=`select @@debug_dbug`; - -let $keep_include_silent=1; -let $grep_script=CREATE|DROP; ---disable_query_log - -let $r=0; -while ($r < $statement_count) -{ - inc $r; - let $STATEMENT=`select REPLACE(ELT($r, $statements), ' EXTRA_OPTION', $extra_option)`; - --echo # QUERY: $STATEMENT - - let $c=0; - while ($c < $crash_count) - { - inc $c; - let $crash= `select ELT($c, $crash_points)`; - let $fk_error= `select '$crash' like 'ddl_log_create_fk_fail%'`; - - --eval set @@default_storage_engine=$default_engine - create or replace table t1 (old int); - if ($fk_error) - { - create or replace table t1 (old int primary key, y int) engine innodb; - create table t2 (x int references t1(old)) engine innodb; - } - create trigger a before insert on t1 for each row set @s= 1; - flush tables; - if ($MTR_COMBINATION_LOCK_TABLES) - { - lock tables t1 write, const_table read; - } - - --source $binlog_format - - RESET MASTER; - --echo # CRASH POINT: $crash - --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect - --disable_reconnect - --eval set @@debug_dbug="+d,$crash",@debug_crash_counter=1 - let $errno=0; - --error 0,2013 - eval $STATEMENT; - let $error=$errno; - --enable_reconnect - --source include/wait_until_connected_again.inc - --disable_query_log - --eval set @@debug_dbug="$old_debug" - - if ($error == 0) - { - --echo # No crash! - if ($MTR_COMBINATION_LOCK_TABLES) - { - unlock tables; - } - } - # Check which tables still exists - --replace_result .MAD .DATA1 .MYD .DATA1 .MAI .DATA2 .MYI .DATA2 - --list_files $MYSQLD_DATADIR/test t* - --list_files $MYSQLD_DATADIR/test *sql* - - --let $binlog_file=master-bin.000001 - --source include/show_binlog_events.inc - if ($error) - { - --let $binlog_file=master-bin.000002 - --source include/show_binlog_events.inc - } - - if ($default_engine == Aria) - { - # Again we suppress 'marked as crashed', it works differently in --ps - --disable_warnings - } - --replace_result $default_engine ENGINE InnoDB ENGINE ' PAGE_CHECKSUM=1' '' ' TRANSACTIONAL=0' '' - --error $show_error - show create table t1; - --enable_warnings - if (`select locate('SELECT', '$STATEMENT')`) - { - --error $show_error - select * from t1; - } - --enable_warnings - --replace_column 6 '' 7 '' 8 '' 9 '' 10 '' 11 '' - show triggers; - # Drop the tables. The warnings will show what was dropped - if ($fk_error) - { - drop table t2; - } - --disable_warnings - --error $drop_error - drop table t1; - --enable_warnings - } -} -drop table if exists t1,const_table; ---eval set @@debug_dbug="$save_debug" - ---enable_query_log diff --git a/mysql-test/suite/atomic/create_table.result b/mysql-test/suite/atomic/create_table.result index aa22e3cb0ed55..acc78c76d254c 100644 --- a/mysql-test/suite/atomic/create_table.result +++ b/mysql-test/suite/atomic/create_table.result @@ -55,6 +55,7 @@ t2.MYI t2.frm master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) crash point: ddl_log_create_log_complete +"No crash!" t1.MYD t1.MYI t1.frm @@ -62,6 +63,40 @@ t2.MYD t2.MYI t2.frm master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) +query: CREATE OR REPLACE TABLE t2 (a int) +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) +crash point: ddl_log_create_log_complete +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) query: CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_before_create_frm t2.MYD @@ -115,6 +150,7 @@ t2.MYI t2.frm master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_log_complete +"No crash!" t1.MYD t1.MYI t1.frm @@ -122,6 +158,40 @@ t2.MYD t2.MYI t2.frm master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table +query: CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_log_complete +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table query: CREATE TABLE t1 SELECT * from t2 crash point: ddl_log_create_before_create_frm t2.MYD @@ -168,9 +238,16 @@ t2.MYD t2.MYI t2.frm crash point: ddl_log_create_after_binlog +t1.MYD +t1.MYI +t1.frm t2.MYD t2.MYI t2.frm +master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` ( + `seq` bigint(20) unsigned NOT NULL +) +master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT * from t2 crash point: ddl_log_create_log_complete t1.MYD t1.MYI @@ -182,6 +259,47 @@ master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` ( `seq` bigint(20) unsigned NOT NULL ) master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT * from t2 +query: CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_log_complete +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table engine: innodb query: CREATE TABLE t1 (a int) crash point: ddl_log_create_before_create_frm @@ -224,11 +342,42 @@ t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) crash point: ddl_log_create_log_complete +"No crash!" t1.frm t1.ibd t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) +query: CREATE OR REPLACE TABLE t2 (a int) +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) +crash point: ddl_log_create_after_binlog +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) +crash point: ddl_log_create_log_complete +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) query: CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_before_create_frm t2.frm @@ -274,12 +423,47 @@ t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_log_complete +"No crash!" t1.MYD t1.MYI t1.frm t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table +query: CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_log_complete +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table query: CREATE TABLE t1 SELECT * from t2 crash point: ddl_log_create_before_create_frm t2.frm @@ -310,17 +494,44 @@ t2.ibd crash point: ddl_log_create_after_prepare_eof t2.frm t2.ibd +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 +master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t1` /* generated by ddl recovery */ crash point: ddl_log_create_after_binlog -t1.frm -t1.ibd t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 +master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t1` /* generated by ddl recovery */ crash point: ddl_log_create_log_complete t1.frm t1.ibd t2.frm t2.ibd master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 +query: CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_binlog +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t2` /* generated by ddl recovery */ +crash point: ddl_log_create_log_complete +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table Warnings: Note 1051 Unknown table 'test.t1,test.t2' diff --git a/mysql-test/suite/atomic/create_table.test b/mysql-test/suite/atomic/create_table.test index d2b63de877d1c..ff53a12ebabc0 100644 --- a/mysql-test/suite/atomic/create_table.test +++ b/mysql-test/suite/atomic/create_table.test @@ -30,10 +30,13 @@ if ($engine_count == "") let $crash_count=9; let $crash_points='ddl_log_create_before_create_frm', 'storage_engine_middle_of_create', 'ddl_log_create_before_create_table', 'ddl_log_create_after_create_table', 'ddl_log_create_after_drop', 'ddl_log_create_before_binlog', 'ddl_log_create_after_prepare_eof', 'ddl_log_create_after_binlog', 'ddl_log_create_log_complete'; -let $statement_count=3; +let $statement_count=6; let $statements='CREATE TABLE t1 (a int)', + 'CREATE OR REPLACE TABLE t2 (a int)', 'CREATE TABLE t1 LIKE const_table', - 'CREATE TABLE t1 SELECT * from t2'; + 'CREATE OR REPLACE TABLE t2 LIKE const_table', + 'CREATE TABLE t1 SELECT * from t2', + 'CREATE OR REPLACE TABLE t2 SELECT * from const_table'; create table const_table (a int, b int) engine=myisam; insert into const_table values (1,1),(2,2); @@ -51,8 +54,6 @@ while ($e < $engine_count) inc $e; let $engine=`select ELT($e, $engines)`; let $default_engine=$engine; - # Note: $extra_option is not used. This dead code here is for conformity with - # other tests. let $extra_option=; if ($engine == "aria") diff --git a/mysql-test/suite/binlog/include/binlog.test b/mysql-test/suite/binlog/include/binlog.test index 1061cf5101822..9f3288b52f07a 100644 --- a/mysql-test/suite/binlog/include/binlog.test +++ b/mysql-test/suite/binlog/include/binlog.test @@ -419,7 +419,6 @@ create table t (old_table_field int); create or replace table t as select 1 as b, 2 as b; --error ER_DUP_FIELDNAME create or replace temporary table t as select 1 as b, 2 as b; -drop table t; create table t (new_table_field int); --source include/show_binlog_events.inc diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result index c0e4e6f46be3d..fa111106cd663 100644 --- a/mysql-test/suite/binlog/r/binlog_row_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result @@ -1085,14 +1085,14 @@ create or replace table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' create or replace temporary table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' -drop table t; create table t (new_table_field int); 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 t (old_table_field int) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t (new_table_field int) drop table t; diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result index dc0b3c2b4a104..f48b624ec2152 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result @@ -682,16 +682,15 @@ create or replace table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' create or replace temporary table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' -drop table t; create table t (new_table_field int); 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 t (old_table_field int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ +master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t (new_table_field int) drop table t; diff --git a/mysql-test/suite/binlog/r/binlog_write_error.result b/mysql-test/suite/binlog/r/binlog_write_error.result index eb83a1805e61e..46a233718d982 100644 --- a/mysql-test/suite/binlog/r/binlog_write_error.result +++ b/mysql-test/suite/binlog/r/binlog_write_error.result @@ -9,8 +9,6 @@ CREATE TABLE t1 (a INT); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; INSERT INTO t1 VALUES (1),(2),(3); -ERROR 42S02: Table 'test.t1' doesn't exist -CREATE TABLE t1 (a INT); set @saved_dbug = @@global.debug_dbug; SET GLOBAL debug_dbug='d,injecting_fault_writing'; INSERT INTO t1 VALUES (4),(5),(6); diff --git a/mysql-test/suite/binlog/t/binlog_write_error.test b/mysql-test/suite/binlog/t/binlog_write_error.test index f62d1f1fd494a..bd1cb5301b3d4 100644 --- a/mysql-test/suite/binlog/t/binlog_write_error.test +++ b/mysql-test/suite/binlog/t/binlog_write_error.test @@ -30,11 +30,8 @@ call mtr.add_suppression("Write to binary log failed: Error writing file*"); let $query= CREATE TABLE t1 (a INT); source include/binlog_inject_error.inc; ---error ER_NO_SUCH_TABLE INSERT INTO t1 VALUES (1),(2),(3); -CREATE TABLE t1 (a INT); - let $query= INSERT INTO t1 VALUES (4),(5),(6); source include/binlog_inject_error.inc; diff --git a/mysql-test/suite/binlog_encryption/binlog_write_error.result b/mysql-test/suite/binlog_encryption/binlog_write_error.result index eb83a1805e61e..46a233718d982 100644 --- a/mysql-test/suite/binlog_encryption/binlog_write_error.result +++ b/mysql-test/suite/binlog_encryption/binlog_write_error.result @@ -9,8 +9,6 @@ CREATE TABLE t1 (a INT); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; INSERT INTO t1 VALUES (1),(2),(3); -ERROR 42S02: Table 'test.t1' doesn't exist -CREATE TABLE t1 (a INT); set @saved_dbug = @@global.debug_dbug; SET GLOBAL debug_dbug='d,injecting_fault_writing'; INSERT INTO t1 VALUES (4),(5),(6); diff --git a/mysql-test/suite/innodb/r/foreign_key_not_windows.result b/mysql-test/suite/innodb/r/foreign_key_not_windows.result index 02b2e3c29af9d..aaff06f8d6866 100644 --- a/mysql-test/suite/innodb/r/foreign_key_not_windows.result +++ b/mysql-test/suite/innodb/r/foreign_key_not_windows.result @@ -6,20 +6,11 @@ CREATE DATABASE `d255`; CREATE TABLE `d255`.`d255` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; ERROR HY000: Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023/@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@ -CREATE OR REPLACE TABLE `d255`.`d255` -(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; -ERROR HY000: Long database name and identifier for object resulted in path length exceeding 511 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023/@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@ CREATE TABLE `d255`.`_##################################################` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; ERROR HY000: Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023/_@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023 -CREATE OR REPLACE TABLE `d255`.`_##################################################` -(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; -ERROR HY000: Long database name and identifier for object resulted in path length exceeding 511 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023/_@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023 CREATE TABLE `d255`.`##################################################` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; -CREATE OR REPLACE TABLE `d255`.`d245` -(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; -DROP TABLE `d255`.`d245`; # # MDEV-29258 Failing assertion for name length on RENAME TABLE # @@ -38,37 +29,3 @@ RENAME TABLE `d255`.u TO u; DROP TABLE u; DROP DATABASE `d255`; # End of 10.3 tests -# -# MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name -# -set names utf8; -create database `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎`; -use `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎`; -create table t (a int primary key) engine=innodb; -create table u ( -a int primary key, -constraint `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` foreign key d (a) references t (a)) engine=innodb; -select * from information_schema.innodb_sys_foreign; -ID FOR_NAME REF_NAME N_COLS TYPE -@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 @274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 @274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 1 0 -select * from information_schema.innodb_sys_foreign_cols; -ID FOR_COL_NAME REF_COL_NAME POS -@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 a a 0 -create or replace table u ( -a int primary key, -constraint `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` foreign key d (a) references t (a)) engine=innodb; -select * from information_schema.innodb_sys_foreign; -ID FOR_NAME REF_NAME N_COLS TYPE -@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 @274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 @274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 1 0 -select * from information_schema.innodb_sys_foreign_cols; -ID FOR_COL_NAME REF_COL_NAME POS -@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@27 a a 0 -show create table u; -Table Create Table -u CREATE TABLE `u` ( - `a` int(11) NOT NULL, - PRIMARY KEY (`a`), - CONSTRAINT `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` FOREIGN KEY (`a`) REFERENCES `t` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -use test; -drop database `❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎`; diff --git a/mysql-test/suite/innodb/t/foreign_key_not_windows.test b/mysql-test/suite/innodb/t/foreign_key_not_windows.test index 67e8935c66001..e5f42a0ddab03 100644 --- a/mysql-test/suite/innodb/t/foreign_key_not_windows.test +++ b/mysql-test/suite/innodb/t/foreign_key_not_windows.test @@ -25,43 +25,20 @@ CREATE TABLE t (a INT PRIMARY KEY) ENGINE=InnoDB; # corresponding to the 51 characters below: 5*51=255. let $d255=###################################################; let $d250=##################################################; -let $d245=#####################; -# FIXME: MDEV-29258 -# let $d245=#################################################; --replace_result $d255 d255 eval CREATE DATABASE `$d255`; - --replace_result $d255 d255 --error ER_IDENT_CAUSES_TOO_LONG_PATH eval CREATE TABLE `$d255`.`$d255` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; - ---replace_result $d255 d255 ---error ER_IDENT_CAUSES_TOO_LONG_PATH -eval CREATE OR REPLACE TABLE `$d255`.`$d255` -(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; - --replace_result $d255 d255 --error ER_IDENT_CAUSES_TOO_LONG_PATH eval CREATE TABLE `$d255`.`_$d250` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; - ---replace_result $d255 d255 ---error ER_IDENT_CAUSES_TOO_LONG_PATH -eval CREATE OR REPLACE TABLE `$d255`.`_$d250` -(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; - --replace_result $d255 d255 eval CREATE TABLE `$d255`.`$d250` (a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; ---replace_result $d255 d255 $d245 d245 -eval CREATE OR REPLACE TABLE `$d255`.`$d245` -(a INT PRIMARY KEY, FOREIGN KEY(a) REFERENCES test.t(a)) ENGINE=InnoDB; - ---replace_result $d255 d255 $d245 d245 -eval DROP TABLE `$d255`.`$d245`; - --echo # --echo # MDEV-29258 Failing assertion for name length on RENAME TABLE --echo # @@ -76,6 +53,7 @@ eval DROP TABLE `$d255`.`$d250`; eval RENAME TABLE `$d255`.`$d245` TO `$d255`.`$d250`; --replace_result $d250 d250 $d255 d255 eval RENAME TABLE `$d255`.`$d250` TO a; +--replace_result $d255 d255 DROP TABLE a,t; --echo # @@ -97,26 +75,3 @@ DROP TABLE u; eval DROP DATABASE `$d255`; --echo # End of 10.3 tests - ---echo # ---echo # MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name ---echo # -set names utf8; -let $d= `select repeat('❎', 45)`; -let $t= `select repeat('❎', 64)`; -eval create database `$d`; -eval use `$d`; -create table t (a int primary key) engine=innodb; -eval create table u ( - a int primary key, - constraint `$t` foreign key d (a) references t (a)) engine=innodb; -select * from information_schema.innodb_sys_foreign; -select * from information_schema.innodb_sys_foreign_cols; -eval create or replace table u ( - a int primary key, - constraint `$t` foreign key d (a) references t (a)) engine=innodb; -select * from information_schema.innodb_sys_foreign; -select * from information_schema.innodb_sys_foreign_cols; -show create table u; -use test; -eval drop database `$d`; diff --git a/mysql-test/suite/parts/r/backup_log.result b/mysql-test/suite/parts/r/backup_log.result index df1dd0e4cdbba..be4109965bcf4 100644 --- a/mysql-test/suite/parts/r/backup_log.result +++ b/mysql-test/suite/parts/r/backup_log.result @@ -2,7 +2,7 @@ connect con1,localhost,root,,; BACKUP STAGE START; connection default; # -# Testing normal tables +# Testing with normal tables # create table t1 (a int) engine=myisam PARTITION BY HASH(a) PARTITIONS 2; insert into t1 values (1),(2); @@ -17,17 +17,6 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK drop table t1; -# -# Reading backup ddl log file -# -CREATE,MyISAM,1,test,t1,id: 1,,0,,, -ALTER,MyISAM,1,test,t1,id: 1,MyISAM,1,test,t1,id: 2 -RENAME,MyISAM,1,test,t1,id: 2,MyISAM,1,test,t2,id: 2 -RENAME,MyISAM,1,test,t2,id: 2,MyISAM,1,test,t1,id: 2 -TRUNCATE,MyISAM,1,test,t1,id: 2,,0,,, -repair,MyISAM,1,test,t1,id: 2,,0,,, -optimize,MyISAM,1,test,t1,id: 2,,0,,, -DROP,MyISAM,1,test,t1,id: 2,,0,,, create table t1_innodb (a int) engine=innodb PARTITION BY HASH(a) PARTITIONS 2; insert into t1_innodb values (1),(2); alter table t1_innodb add column b int; @@ -43,17 +32,6 @@ test.t1_innodb optimize note Table does not support optimize, doing recreate + a test.t1_innodb optimize status OK drop table t1_innodb; # -# Reading backup ddl log file -# -CREATE,InnoDB,1,test,t1_innodb,id: 1,,0,,, -ALTER,InnoDB,1,test,t1_innodb,id: 1,InnoDB,1,test,t1_innodb,id: 2 -RENAME,InnoDB,1,test,t1_innodb,id: 2,InnoDB,1,test,t2_innodb,id: 2 -RENAME,InnoDB,1,test,t2_innodb,id: 2,InnoDB,1,test,t1_innodb,id: 2 -TRUNCATE,InnoDB,1,test,t1_innodb,id: 2,,0,,, -repair,InnoDB,1,test,t1_innodb,id: 2,,0,,, -ALTER,InnoDB,1,test,t1_innodb,id: 2,InnoDB,1,test,t1_innodb,id: 3 -DROP,InnoDB,1,test,t1_innodb,id: 3,,0,,, -# # Testing with temporary tables (should not be logged) # create temporary table tmp_t10 (a int) engine=myisam; @@ -63,9 +41,6 @@ rename table tmp_t11 to tmp_t10; truncate table tmp_t10; drop table tmp_t10; # -# Reading backup ddl log file -# -# # Testing with mix of normal and temporary tables # create temporary table tmp_t20 (a int); @@ -80,13 +55,6 @@ drop table if exists tmp_t21,t21; Warnings: Note 1051 Unknown table 'test.tmp_t21' # -# Reading backup ddl log file -# -CREATE,MyISAM,1,test,t20,id: 1,,0,,, -DROP,MyISAM,1,test,t20,id: 1,,0,,, -CREATE,MyISAM,1,test,t21,id: 2,,0,,, -DROP,MyISAM,1,test,t21,id: 2,,0,,, -# # Testing create select # create table t30 (a int) PARTITION BY HASH(a) PARTITIONS 2; @@ -99,18 +67,7 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' create table t32 (a int) PARTITION BY HASH(a) PARTITIONS 2; drop table if exists t30,t31,t32,tmp_t30; Warnings: -Note 1051 Unknown table 'test.tmp_t30' -# -# Reading backup ddl log file -# -CREATE,MyISAM,1,test,t30,id: 1,,0,,, -CREATE,MyISAM,1,test,t31,id: 2,,0,,, -DROP,MyISAM,1,test,t31,id: 2,,0,,, -CREATE,MyISAM,0,test,t31,id: 3,,0,,, -CREATE,MyISAM,1,test,t32,id: 4,,0,,, -DROP,MyISAM,1,test,t30,id: 1,,0,,, -DROP,MyISAM,0,test,t31,id: 3,,0,,, -DROP,MyISAM,1,test,t32,id: 4,,0,,, +Note 1051 Unknown table 'test.t31,test.tmp_t30' # # Testing create LIKE # @@ -128,17 +85,6 @@ t42 CREATE TABLE `t42` ( PARTITIONS 2 drop table t40, t41, t42; # -# Reading backup ddl log file -# -CREATE,MyISAM,1,test,t40,id: 1,,0,,, -CREATE,InnoDB,1,test,t41,id: 2,,0,,, -CREATE,partition,0,test,t42,id: 3,,0,,, -DROP,MyISAM,1,test,t42,id: 3,,0,,, -CREATE,partition,0,test,t42,id: 4,,0,,, -DROP,MyISAM,1,test,t40,id: 1,,0,,, -DROP,InnoDB,1,test,t41,id: 2,,0,,, -DROP,InnoDB,1,test,t42,id: 4,,0,,, -# # Testing rename # create table t50 (a int) PARTITION BY HASH(a) PARTITIONS 2; @@ -147,18 +93,6 @@ rename table t50 to t52, t51 to t53; rename table t52 to tmp, t53 to t52, tmp to t53; drop table t52,t53; # -# Reading backup ddl log file -# -CREATE,MyISAM,1,test,t50,id: 1,,0,,, -CREATE,MyISAM,1,test,t51,id: 2,,0,,, -RENAME,MyISAM,1,test,t50,id: 1,MyISAM,1,test,t52,id: 1 -RENAME,MyISAM,1,test,t51,id: 2,MyISAM,1,test,t53,id: 2 -RENAME,MyISAM,1,test,t52,id: 1,MyISAM,1,test,tmp,id: 1 -RENAME,MyISAM,1,test,t53,id: 2,MyISAM,1,test,t52,id: 2 -RENAME,MyISAM,1,test,tmp,id: 1,MyISAM,1,test,t53,id: 1 -DROP,MyISAM,1,test,t52,id: 2,,0,,, -DROP,MyISAM,1,test,t53,id: 1,,0,,, -# # Testing enable/disable keys # CREATE TABLE t60 (a int(10), index(a) ) ENGINE=Aria PARTITION BY HASH(a) PARTITIONS 2; @@ -172,13 +106,6 @@ INSERT INTO t61 VALUES(1),(2),(3); ALTER TABLE t61 DISABLE KEYS; DROP TABLE t61; # -# Reading backup ddl log file -# -CREATE,Aria,1,test,t60,id: 1,,0,,, -CHANGE_INDEX,Aria,1,test,t60,id: 1,,0,,, -CHANGE_INDEX,Aria,1,test,t60,id: 1,,0,,, -DROP,Aria,1,test,t60,id: 1,,0,,, -# # Testing load data # create table t70 (a date, b date, c date not null, d date) engine=aria PARTITION BY HASH(YEAR(a)) PARTITIONS 2; @@ -195,30 +122,11 @@ insert into t71 select * from t70; unlock tables; drop table t70,t71; # -# Reading backup ddl log file -# -CREATE,Aria,1,test,t70,id: 1,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, -TRUNCATE,Aria,1,test,t70,id: 1,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, -CREATE,Aria,1,test,t71,id: 2,,0,,, -BULK_INSERT,Aria,1,test,t71,id: 2,,0,,, -BULK_INSERT,Aria,1,test,t71,id: 2,,0,,, -DROP,Aria,1,test,t70,id: 1,,0,,, -DROP,Aria,1,test,t71,id: 2,,0,,, -# # Testing strange table names # create table `t 1` (a int) PARTITION BY HASH(a) PARTITIONS 2; drop table `t 1`; # -# Reading backup ddl log file -# -CREATE,MyISAM,1,test,t@00201,id: 1,,0,,, -DROP,MyISAM,1,test,t@00201,id: 1,,0,,, -# # Testing views and triggers # create table t80 (a int, b int) engine=myisam PARTITION BY HASH(a) PARTITIONS 2; @@ -228,27 +136,12 @@ drop trigger trg; drop view v1; drop table t80; # -# Reading backup ddl log file -# -CREATE,MyISAM,1,test,t80,id: 1,,0,,, -CREATE,VIEW,0,test,v1,,,0,,, -CREATE,TRIGGER,0,test,trg,,,0,,, -DROP,TRIGGER,0,test,trg,,,0,,, -DROP,VIEW,0,test,v1,,,0,,, -DROP,MyISAM,1,test,t80,id: 1,,0,,, -# # Testing alter to a new storage engine # create table t85 (a int primary key, b int) engine=myisam PARTITION BY HASH(a) PARTITIONS 2; alter table t85 engine=innodb; drop table t85; # -# Reading backup ddl log file -# -CREATE,MyISAM,1,test,t85,id: 1,,0,,, -ALTER,MyISAM,1,test,t85,id: 1,InnoDB,1,test,t85,id: 2 -DROP,InnoDB,1,test,t85,id: 2,,0,,, -# # Testing backup ddl log for partitioned tables # CREATE TABLE t200(a INT, b INT) ENGINE ARIA TRANSACTIONAL = 1 PAGE_CHECKSUM = 1; @@ -291,22 +184,94 @@ DROP TABLE t220; # # Reading backup ddl log file # -CREATE,Aria,0,test,t200,id: 1,,0,,, -ALTER,Aria,0,test,t200,id: 1,Aria,1,test,t200,id: 2 -CREATE,Aria,0,test,t210,id: 3,,0,,, -EXCHANGE_PARTITION,Aria,1,test,t200,id: 2,Aria,0,test,t210,id: 3 -ALTER,Aria,1,test,t200,id: 2,Aria,1,test,t200,id: 4 -ALTER,Aria,1,test,t200,id: 4,Aria,1,test,t200,id: 5 -ALTER,Aria,1,test,t200,id: 5,Aria,1,test,t200,id: 6 -ALTER,Aria,1,test,t200,id: 6,Aria,1,test,t200,id: 7 -ALTER,Aria,1,test,t200,id: 7,Aria,1,test,t200,id: 8 -ALTER,Aria,1,test,t200,id: 8,Aria,1,test,t200,id: 9 -ALTER,Aria,1,test,t200,id: 9,Aria,1,test,t200,id: 10 -ALTER,Aria,1,test,t200,id: 10,Aria,0,test,t200,id: 11 -DROP,Aria,0,test,t200,id: 11,,0,,, -DROP,Aria,0,test,t210,id: 3,,0,,, -CREATE,Aria,1,test,t220,id: 12,,0,,, -DROP,Aria,1,test,t220,id: 12,,0,,, +CREATE,MyISAM,1,test,t1,id: 1,,0,,, +ALTER,MyISAM,1,test,t1,id: 1,MyISAM,1,test,t1,id: 2 +RENAME,MyISAM,1,test,t1,id: 2,MyISAM,1,test,t2,id: 2 +RENAME,MyISAM,1,test,t2,id: 2,MyISAM,1,test,t1,id: 2 +TRUNCATE,MyISAM,1,test,t1,id: 2,,0,,, +repair,MyISAM,1,test,t1,id: 2,,0,,, +optimize,MyISAM,1,test,t1,id: 2,,0,,, +DROP,MyISAM,1,test,t1,id: 2,,0,,, +CREATE,InnoDB,1,test,t1_innodb,id: 3,,0,,, +ALTER,InnoDB,1,test,t1_innodb,id: 3,InnoDB,1,test,t1_innodb,id: 4 +RENAME,InnoDB,1,test,t1_innodb,id: 4,InnoDB,1,test,t2_innodb,id: 4 +RENAME,InnoDB,1,test,t2_innodb,id: 4,InnoDB,1,test,t1_innodb,id: 4 +TRUNCATE,InnoDB,1,test,t1_innodb,id: 4,,0,,, +repair,InnoDB,1,test,t1_innodb,id: 4,,0,,, +ALTER,InnoDB,1,test,t1_innodb,id: 4,InnoDB,1,test,t1_innodb,id: 5 +DROP,InnoDB,1,test,t1_innodb,id: 5,,0,,, +CREATE,MyISAM,1,test,t20,id: 6,,0,,, +DROP,MyISAM,1,test,t20,id: 6,,0,,, +CREATE,MyISAM,1,test,t21,id: 7,,0,,, +DROP,MyISAM,1,test,t21,id: 7,,0,,, +CREATE,MyISAM,1,test,t30,id: 8,,0,,, +CREATE,MyISAM,1,test,t31,id: 9,,0,,, +DROP,MyISAM,1,test,t31,id: 9,,0,,, +CREATE,MyISAM,0,test,t31,id: 10,,0,,, +DROP,MyISAM,0,test,t31,id: 10,,0,,, +DROP_AFTER_CREATE,MyISAM,1,test,t31,id: 11,,0,,, +CREATE,MyISAM,1,test,t32,id: 12,,0,,, +DROP,MyISAM,1,test,t30,id: 8,,0,,, +DROP,MyISAM,1,test,t32,id: 12,,0,,, +CREATE,MyISAM,1,test,t40,id: 13,,0,,, +CREATE,InnoDB,1,test,t41,id: 14,,0,,, +CREATE,partition,0,test,t42,id: 15,,0,,, +DROP,MyISAM,1,test,t42,id: 15,,0,,, +CREATE,partition,0,test,t42,id: 16,,0,,, +DROP,MyISAM,1,test,t40,id: 13,,0,,, +DROP,InnoDB,1,test,t41,id: 14,,0,,, +DROP,InnoDB,1,test,t42,id: 16,,0,,, +CREATE,MyISAM,1,test,t50,id: 17,,0,,, +CREATE,MyISAM,1,test,t51,id: 18,,0,,, +RENAME,MyISAM,1,test,t50,id: 17,MyISAM,1,test,t52,id: 17 +RENAME,MyISAM,1,test,t51,id: 18,MyISAM,1,test,t53,id: 18 +RENAME,MyISAM,1,test,t52,id: 17,MyISAM,1,test,tmp,id: 17 +RENAME,MyISAM,1,test,t53,id: 18,MyISAM,1,test,t52,id: 18 +RENAME,MyISAM,1,test,tmp,id: 17,MyISAM,1,test,t53,id: 17 +DROP,MyISAM,1,test,t52,id: 18,,0,,, +DROP,MyISAM,1,test,t53,id: 17,,0,,, +CREATE,Aria,1,test,t60,id: 19,,0,,, +CHANGE_INDEX,Aria,1,test,t60,id: 19,,0,,, +CHANGE_INDEX,Aria,1,test,t60,id: 19,,0,,, +DROP,Aria,1,test,t60,id: 19,,0,,, +CREATE,Aria,1,test,t70,id: 20,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, +TRUNCATE,Aria,1,test,t70,id: 20,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, +CREATE,Aria,1,test,t71,id: 21,,0,,, +BULK_INSERT,Aria,1,test,t71,id: 21,,0,,, +BULK_INSERT,Aria,1,test,t71,id: 21,,0,,, +DROP,Aria,1,test,t70,id: 20,,0,,, +DROP,Aria,1,test,t71,id: 21,,0,,, +CREATE,MyISAM,1,test,t@00201,id: 22,,0,,, +DROP,MyISAM,1,test,t@00201,id: 22,,0,,, +CREATE,MyISAM,1,test,t80,id: 23,,0,,, +CREATE,VIEW,0,test,v1,,,0,,, +CREATE,TRIGGER,0,test,trg,,,0,,, +DROP,TRIGGER,0,test,trg,,,0,,, +DROP,VIEW,0,test,v1,,,0,,, +DROP,MyISAM,1,test,t80,id: 23,,0,,, +CREATE,MyISAM,1,test,t85,id: 24,,0,,, +ALTER,MyISAM,1,test,t85,id: 24,InnoDB,1,test,t85,id: 25 +DROP,InnoDB,1,test,t85,id: 25,,0,,, +CREATE,Aria,0,test,t200,id: 26,,0,,, +ALTER,Aria,0,test,t200,id: 26,Aria,1,test,t200,id: 27 +CREATE,Aria,0,test,t210,id: 28,,0,,, +EXCHANGE_PARTITION,Aria,1,test,t200,id: 27,Aria,0,test,t210,id: 28 +ALTER,Aria,1,test,t200,id: 27,Aria,1,test,t200,id: 29 +ALTER,Aria,1,test,t200,id: 29,Aria,1,test,t200,id: 30 +ALTER,Aria,1,test,t200,id: 30,Aria,1,test,t200,id: 31 +ALTER,Aria,1,test,t200,id: 31,Aria,1,test,t200,id: 32 +ALTER,Aria,1,test,t200,id: 32,Aria,1,test,t200,id: 33 +ALTER,Aria,1,test,t200,id: 33,Aria,1,test,t200,id: 34 +ALTER,Aria,1,test,t200,id: 34,Aria,1,test,t200,id: 35 +ALTER,Aria,1,test,t200,id: 35,Aria,0,test,t200,id: 36 +DROP,Aria,0,test,t200,id: 36,,0,,, +DROP,Aria,0,test,t210,id: 28,,0,,, +CREATE,Aria,1,test,t220,id: 37,,0,,, +DROP,Aria,1,test,t220,id: 37,,0,,, # # Cleanup # diff --git a/mysql-test/suite/rpl/r/create_or_replace2,stmt.rdiff b/mysql-test/suite/rpl/r/create_or_replace2,stmt.rdiff deleted file mode 100644 index 52dd3828b3848..0000000000000 --- a/mysql-test/suite/rpl/r/create_or_replace2,stmt.rdiff +++ /dev/null @@ -1,17 +0,0 @@ ---- create_or_replace2.result -+++ create_or_replace2,stmt.reject -@@ -34,9 +34,11 @@ - master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) - RETURN ( SELECT MAX(a) FROM t1 ) - master-bin.000001 # Gtid # # GTID #-#-# --master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( -- `b` int(11) DEFAULT NULL --) ENGINE=InnoDB -+master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp (b INT) ENGINE=InnoDB -+master-bin.000001 # Gtid # # GTID #-#-# -+master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE tmp -+master-bin.000001 # Gtid # # GTID #-#-# -+master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `tmp` - drop function f1; - drop table t1; - include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/create_or_replace2.result b/mysql-test/suite/rpl/r/create_or_replace2.result index 149fe54577807..adcceaf97dd34 100644 --- a/mysql-test/suite/rpl/r/create_or_replace2.result +++ b/mysql-test/suite/rpl/r/create_or_replace2.result @@ -26,17 +26,6 @@ unlock tables; connection default; ERROR 42S22: Unknown column 'a' in 'field list' disconnect con1; -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 t1 (a INT) ENGINE=InnoDB -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) -RETURN ( SELECT MAX(a) FROM t1 ) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( - `b` int(11) DEFAULT NULL -) ENGINE=InnoDB drop function f1; drop table t1; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/create_or_replace_mix.result b/mysql-test/suite/rpl/r/create_or_replace_mix.result index fbcdc0ecc4427..3917b5b7c0544 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_mix.result +++ b/mysql-test/suite/rpl/r/create_or_replace_mix.result @@ -64,12 +64,13 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -create or replace table t1 (b int primary key) select a as b from t2; +Warnings: +Note 1051 Unknown table 'test.t1' +create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -create table t1 (c int); -create or replace table t1 (d int primary key) select a as d from t2; +create table t1 (a int); +create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -drop table t1; create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' @@ -79,26 +80,34 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create or replace table t1 +master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create table t1 (c int) +master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create temporary table t9 (a int) +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t9`/* Generated to handle failed CREATE OR REPLACE */ connection server_2; show tables; Tables_in_test t2 connection server_1; -create table t1 (e int); +create table t1 (a int); create or replace table t1 (a int, a int) select * from t2; ERROR 42S21: Duplicate column name 'a' 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 t1 (e int) +master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' @@ -208,7 +217,7 @@ drop table t1; # connection server_2; connection server_1; -create table t1 (f int); +create table t1 (a int); insert into t1 values (0),(1),(2); create table t2 engine=myisam select * from t1; create or replace table t2 engine=innodb select * from t1; @@ -217,7 +226,7 @@ binlog from server 2 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Gtid # # GTID #-#-# -slave-bin.000001 # Query # # use `test`; create table t1 (f int) +slave-bin.000001 # Query # # use `test`; create table t1 (a int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; insert into t1 values (0),(1),(2) slave-bin.000001 # Query # # COMMIT diff --git a/mysql-test/suite/rpl/r/create_or_replace_row.result b/mysql-test/suite/rpl/r/create_or_replace_row.result index 18c077bd549e3..3bb998397511b 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_row.result +++ b/mysql-test/suite/rpl/r/create_or_replace_row.result @@ -92,12 +92,13 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -create or replace table t1 (b int primary key) select a as b from t2; +Warnings: +Note 1051 Unknown table 'test.t1' +create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -create table t1 (c int); -create or replace table t1 (d int primary key) select a as d from t2; +create table t1 (a int); +create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -drop table t1; create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' @@ -107,24 +108,32 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ +master-bin.000001 # Query # # use `test`; create or replace table t1 master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create table t1 (c int) +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK connection server_2; show tables; Tables_in_test t2 connection server_1; -create table t1 (e int); +create table t1 (a int); create or replace table t1 (a int, a int) select * from t2; ERROR 42S21: Duplicate column name 'a' 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 t1 (e int) +master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' @@ -234,7 +243,7 @@ drop table t1; # connection server_2; connection server_1; -create table t1 (f int); +create table t1 (a int); insert into t1 values (0),(1),(2); create table t2 engine=myisam select * from t1; create or replace table t2 engine=innodb select * from t1; @@ -243,7 +252,7 @@ binlog from server 2 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Gtid # # GTID #-#-# -slave-bin.000001 # Query # # use `test`; create table t1 (f int) +slave-bin.000001 # Query # # use `test`; create table t1 (a int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Annotate_rows # # insert into t1 values (0),(1),(2) slave-bin.000001 # Table_map # # table_id: # (test.t1) @@ -251,7 +260,7 @@ slave-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F slave-bin.000001 # Query # # COMMIT slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE TABLE `t2` ( - `f` int(11) DEFAULT NULL + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM slave-bin.000001 # Annotate_rows # # create table t2 engine=myisam select * from t1 slave-bin.000001 # Table_map # # table_id: # (test.t2) @@ -259,7 +268,7 @@ slave-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F slave-bin.000001 # Query # # COMMIT slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( - `f` int(11) DEFAULT NULL + `a` int(11) DEFAULT NULL ) ENGINE=InnoDB slave-bin.000001 # Annotate_rows # # create or replace table t2 engine=innodb select * from t1 slave-bin.000001 # Table_map # # table_id: # (test.t2) diff --git a/mysql-test/suite/rpl/r/create_or_replace_statement.result b/mysql-test/suite/rpl/r/create_or_replace_statement.result index fbcdc0ecc4427..3917b5b7c0544 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_statement.result +++ b/mysql-test/suite/rpl/r/create_or_replace_statement.result @@ -64,12 +64,13 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -create or replace table t1 (b int primary key) select a as b from t2; +Warnings: +Note 1051 Unknown table 'test.t1' +create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -create table t1 (c int); -create or replace table t1 (d int primary key) select a as d from t2; +create table t1 (a int); +create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -drop table t1; create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' @@ -79,26 +80,34 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create or replace table t1 +master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create table t1 (c int) +master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create temporary table t9 (a int) +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t9`/* Generated to handle failed CREATE OR REPLACE */ connection server_2; show tables; Tables_in_test t2 connection server_1; -create table t1 (e int); +create table t1 (a int); create or replace table t1 (a int, a int) select * from t2; ERROR 42S21: Duplicate column name 'a' 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 t1 (e int) +master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' @@ -208,7 +217,7 @@ drop table t1; # connection server_2; connection server_1; -create table t1 (f int); +create table t1 (a int); insert into t1 values (0),(1),(2); create table t2 engine=myisam select * from t1; create or replace table t2 engine=innodb select * from t1; @@ -217,7 +226,7 @@ binlog from server 2 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Gtid # # GTID #-#-# -slave-bin.000001 # Query # # use `test`; create table t1 (f int) +slave-bin.000001 # Query # # use `test`; create table t1 (a int) slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; insert into t1 values (0),(1),(2) slave-bin.000001 # Query # # COMMIT diff --git a/mysql-test/suite/rpl/r/rpl_gtid_strict.result b/mysql-test/suite/rpl/r/rpl_gtid_strict.result index d246bb31713b3..7a1e18c4dfd4e 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_strict.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_strict.result @@ -59,7 +59,7 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4) master-bin.000001 # Xid # # COMMIT /* XID */ -*** Test non-transactional GTID error. *** +*** Test non-transactional GTID error (cannot be rolled back). *** SET server_id= 3; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled @@ -68,6 +68,9 @@ SET gtid_seq_no= 1; SET SESSION debug_dbug=@old_dbug; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled +SET sql_log_bin= 0; +DROP TABLE t2; +SET sql_log_bin= 1; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-3-5, and gtid strict mode is enabled diff --git a/mysql-test/suite/rpl/t/create_or_replace.inc b/mysql-test/suite/rpl/t/create_or_replace.inc index bdde953f7dce7..df46cc36e9788 100644 --- a/mysql-test/suite/rpl/t/create_or_replace.inc +++ b/mysql-test/suite/rpl/t/create_or_replace.inc @@ -47,13 +47,12 @@ create or replace table t1; drop table if exists t1; # The following is not logged as t1 does not exists; --error ER_DUP_ENTRY -create or replace table t1 (b int primary key) select a as b from t2; +create or replace table t1 (a int primary key) select a from t2; -create table t1 (c int); +create table t1 (a int); # This should as a delete as we will delete t1 --error ER_DUP_ENTRY -create or replace table t1 (d int primary key) select a as d from t2; -drop table t1; +create or replace table t1 (a int primary key) select a from t2; # Same with temporary table create temporary table t9 (a int); @@ -70,7 +69,7 @@ show tables; connection server_1; --let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1) -create table t1 (e int); +create table t1 (a int); --error ER_DUP_FIELDNAME create or replace table t1 (a int, a int) select * from t2; --source include/show_binlog_events.inc @@ -170,7 +169,7 @@ sync_with_master; --let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1) connection server_1; -create table t1 (f int); +create table t1 (a int); insert into t1 values (0),(1),(2); create table t2 engine=myisam select * from t1; create or replace table t2 engine=innodb select * from t1; diff --git a/mysql-test/suite/rpl/t/create_or_replace2.test b/mysql-test/suite/rpl/t/create_or_replace2.test index 0208be577a7f4..f0091db7fb909 100644 --- a/mysql-test/suite/rpl/t/create_or_replace2.test +++ b/mysql-test/suite/rpl/t/create_or_replace2.test @@ -36,8 +36,6 @@ unlock tables; --reap --disconnect con1 ---source include/show_binlog_events.inc - # Cleanup drop function f1; drop table t1; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_strict.test b/mysql-test/suite/rpl/t/rpl_gtid_strict.test index 7cbd6304c1045..56ebba824c481 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_strict.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_strict.test @@ -49,7 +49,7 @@ INSERT INTO t1 VALUES (4); SELECT * FROM t1 ORDER BY 1; --source include/show_binlog_events.inc ---echo *** Test non-transactional GTID error. *** +--echo *** Test non-transactional GTID error (cannot be rolled back). *** SET server_id= 3; --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 1; @@ -58,6 +58,11 @@ SET gtid_seq_no= 1; SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; +# The table is still created, DDL cannot be rolled back. +# Fix it up for replication. +SET sql_log_bin= 0; +DROP TABLE t2; +SET sql_log_bin= 1; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; --error ER_GTID_STRICT_OUT_OF_ORDER diff --git a/mysql-test/suite/versioning/r/foreign.result b/mysql-test/suite/versioning/r/foreign.result index 8df5a042275b4..3c8508507fd5a 100644 --- a/mysql-test/suite/versioning/r/foreign.result +++ b/mysql-test/suite/versioning/r/foreign.result @@ -263,13 +263,6 @@ constraint `fk_child_parent` on delete cascade on update cascade ) engine = innodb with system versioning; -select * from information_schema.innodb_sys_foreign; -ID FOR_NAME REF_NAME N_COLS TYPE -test/fk_child_parent test/child test/parent 2 5 -select * from information_schema.innodb_sys_foreign_cols; -ID FOR_COL_NAME REF_COL_NAME POS -test/fk_child_parent parent_id id 0 -test/fk_child_parent parent_value value 1 create or replace table subchild ( id int not null auto_increment primary key, parent_id smallint unsigned not null, @@ -279,16 +272,6 @@ constraint `fk_subchild_child_parent` on delete cascade on update cascade ) engine=innodb; -select * from information_schema.innodb_sys_foreign; -ID FOR_NAME REF_NAME N_COLS TYPE -test/fk_child_parent test/child test/parent 2 5 -test/fk_subchild_child_parent test/subchild test/child 2 5 -select * from information_schema.innodb_sys_foreign_cols; -ID FOR_COL_NAME REF_COL_NAME POS -test/fk_child_parent parent_id id 0 -test/fk_child_parent parent_value value 1 -test/fk_subchild_child_parent parent_id parent_id 0 -test/fk_subchild_child_parent parent_value parent_value 1 insert into parent (value) values (23); select id, value from parent into @id, @value; Warnings: diff --git a/mysql-test/suite/versioning/t/foreign.test b/mysql-test/suite/versioning/t/foreign.test index acd6dde2e4b59..934053f83ba70 100644 --- a/mysql-test/suite/versioning/t/foreign.test +++ b/mysql-test/suite/versioning/t/foreign.test @@ -303,9 +303,6 @@ eval create or replace table child ( on update cascade ) engine = innodb with system versioning; -select * from information_schema.innodb_sys_foreign; -select * from information_schema.innodb_sys_foreign_cols; - create or replace table subchild ( id int not null auto_increment primary key, parent_id smallint unsigned not null, @@ -316,9 +313,6 @@ create or replace table subchild ( on update cascade ) engine=innodb; -select * from information_schema.innodb_sys_foreign; -select * from information_schema.innodb_sys_foreign_cols; - insert into parent (value) values (23); --enable_prepare_warnings select id, value from parent into @id, @value; diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index afcf2e6497eff..67c8a8bca4f72 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2022, MariaDB + Copyright (c) 2010, 2021, 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 @@ -135,13 +135,6 @@ class st_ddl_recovery { char current_db[NAME_LEN]; uint execute_entry_pos; ulonglong xid; - void free() - { - drop_table.free(); - drop_view.free(); - query.free(); - db.free(); - } }; static st_global_ddl_log global_ddl_log; @@ -462,7 +455,7 @@ bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry) static bool is_execute_entry_active(uint entry_pos) { uchar buff[1]; - DBUG_ENTER("is_execute_entry_active"); + DBUG_ENTER("disable_execute_entry"); if (mysql_file_pread(global_ddl_log.file_id, buff, sizeof(buff), global_ddl_log.io_size * entry_pos + @@ -970,12 +963,11 @@ static bool build_filename_and_delete_tmp_file(char *path, size_t path_length, const LEX_CSTRING *db, const LEX_CSTRING *name, const char *ext, - PSI_file_key psi_key, - uint flags) + PSI_file_key psi_key) { bool deleted; uint length= build_table_filename(path, path_length-1, - db->str, name->str, ext, flags); + db->str, name->str, ext, 0); path[length]= '~'; path[length+1]= 0; deleted= mysql_file_delete(psi_key, path, MYF(0)) != 0; @@ -1089,15 +1081,15 @@ static handler *create_handler(THD *thd, MEM_ROOT *mem_root, like connect, needs the .frm file to exists to be able to do an rename. */ -static int execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, - const LEX_CSTRING *from_db, - const LEX_CSTRING *from_table, - const LEX_CSTRING *to_db, - const LEX_CSTRING *to_table, uint flags, - char *from_path, char *to_path) +static void execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, + const LEX_CSTRING *from_db, + const LEX_CSTRING *from_table, + const LEX_CSTRING *to_db, + const LEX_CSTRING *to_table, + uint flags, + char *from_path, char *to_path) { uint to_length=0, fr_length=0; - int error; DBUG_ENTER("execute_rename_table"); if (file->needs_lower_case_filenames()) @@ -1112,12 +1104,12 @@ static int execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, { fr_length= build_table_filename(from_path, FN_REFLEN, from_db->str, from_table->str, "", - flags & FN_FROM_IS_TMP); + flags & FN_TO_IS_TMP); to_length= build_table_filename(to_path, FN_REFLEN, to_db->str, to_table->str, "", flags & FN_TO_IS_TMP); } - error= file->ha_rename_table(from_path, to_path); + file->ha_rename_table(from_path, to_path); if (file->needs_lower_case_filenames()) { /* @@ -1138,7 +1130,7 @@ static int execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, } if (!access(from_path, F_OK)) (void) mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)); - DBUG_RETURN(error); + DBUG_VOID_RETURN; } @@ -1152,7 +1144,7 @@ static int execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, */ static void rename_triggers(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, - bool swap_tables, uint flags) + bool swap_tables) { LEX_CSTRING to_table, from_table, to_db, from_db, from_converted_name; char to_path[FN_REFLEN+1], from_path[FN_REFLEN+1], conv_path[FN_REFLEN+1]; @@ -1174,10 +1166,10 @@ static void rename_triggers(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, build_filename_and_delete_tmp_file(from_path, sizeof(from_path), &from_db, &from_table, - TRG_EXT, key_file_trg, flags & FN_FROM_IS_TMP); + TRG_EXT, key_file_trg); build_filename_and_delete_tmp_file(to_path, sizeof(to_path), &to_db, &to_table, - TRG_EXT, key_file_trg, flags & FN_TO_IS_TMP); + TRG_EXT, key_file_trg); if (lower_case_table_names) { uint errors; @@ -1303,15 +1295,15 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, handlerton *hton= 0; ddl_log_error_handler no_such_table_handler; uint entry_pos= ddl_log_entry->entry_pos; - int error= 0; - uint fn_flags= 0; + int error; bool frm_action= FALSE; DBUG_ENTER("ddl_log_execute_action"); mysql_mutex_assert_owner(&LOCK_gdl); DBUG_PRINT("ddl_log", - ("pos: %u->%u type: %u action: %u (%s) phase: %u " + ("pos: %u=>%u->%u type: %u action: %u (%s) phase: %u " "handler: '%s' name: '%s' from_name: '%s' tmp_name: '%s'", + recovery_state.execute_entry_pos, ddl_log_entry->entry_pos, ddl_log_entry->next_entry, (uint) ddl_log_entry->entry_type, @@ -1339,11 +1331,6 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, hton= file->ht; } - if (ddl_log_entry->flags & DDL_LOG_FLAG_FROM_IS_TMP) - fn_flags|= FN_FROM_IS_TMP; - if (ddl_log_entry->flags & DDL_LOG_FLAG_TO_IS_TMP) - fn_flags|= FN_TO_IS_TMP; - switch (ddl_log_entry->action_type) { case DDL_LOG_REPLACE_ACTION: case DDL_LOG_DELETE_ACTION: @@ -1387,28 +1374,24 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, /* fall through */ case DDL_LOG_RENAME_ACTION: { + error= TRUE; if (frm_action) { strxmov(to_path, ddl_log_entry->name.str, reg_ext, NullS); strxmov(from_path, ddl_log_entry->from_name.str, reg_ext, NullS); - error= mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)); + (void) mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)); #ifdef WITH_PARTITION_STORAGE_ENGINE strxmov(to_path, ddl_log_entry->name.str, PAR_EXT, NullS); strxmov(from_path, ddl_log_entry->from_name.str, PAR_EXT, NullS); - int err2= mysql_file_rename(key_file_partition_ddl_log, from_path, - to_path, MYF(MY_WME)); - if (!error) - error= err2; + (void) mysql_file_rename(key_file_partition_ddl_log, from_path, to_path, + MYF(MY_WME)); #endif } else - error= file->ha_rename_table(ddl_log_entry->from_name.str, + (void) file->ha_rename_table(ddl_log_entry->from_name.str, ddl_log_entry->name.str); if (increment_phase(entry_pos)) - { - error= -1; break; - } break; } case DDL_LOG_EXCHANGE_ACTION: @@ -1462,40 +1445,25 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, */ switch (ddl_log_entry->phase) { case DDL_RENAME_PHASE_TRIGGER: - rename_triggers(thd, ddl_log_entry, 0, fn_flags); + rename_triggers(thd, ddl_log_entry, 0); if (increment_phase(entry_pos)) break; /* fall through */ case DDL_RENAME_PHASE_STAT: - if (fn_flags & FN_TO_IS_TMP) - { - /* - Only executed in case of CREATE OR REPLACE table when renaming - the orignal table to a temporary name. - - If new code is added here please finish this block like this: - - if (increment_phase(entry_pos)) - break; - */ - } - else - { - /* - Stat tables must be updated last so that we can handle a rename of - a stat table. For now we just remember that we have to update it. - */ - update_flags(ddl_log_entry->entry_pos, DDL_LOG_FLAG_UPDATE_STAT); - ddl_log_entry->flags|= DDL_LOG_FLAG_UPDATE_STAT; - } + /* + Stat tables must be updated last so that we can handle a rename of + a stat table. For now we just rememeber that we have to update it + */ + update_flags(ddl_log_entry->entry_pos, DDL_LOG_FLAG_UPDATE_STAT); + ddl_log_entry->flags|= DDL_LOG_FLAG_UPDATE_STAT; /* fall through */ case DDL_RENAME_PHASE_TABLE: /* Restore frm and table to original names */ - error= execute_rename_table(ddl_log_entry, file, - &ddl_log_entry->db, &ddl_log_entry->name, - &ddl_log_entry->from_db, - &ddl_log_entry->from_name, - fn_flags, from_path, to_path); + execute_rename_table(ddl_log_entry, file, + &ddl_log_entry->db, &ddl_log_entry->name, + &ddl_log_entry->from_db, &ddl_log_entry->from_name, + 0, + from_path, to_path); if (ddl_log_entry->flags & DDL_LOG_FLAG_UPDATE_STAT) { @@ -1523,11 +1491,11 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, &ddl_log_entry->db, &ddl_log_entry->name, reg_ext, - key_file_fileparser, 0); + key_file_fileparser); build_filename_and_delete_tmp_file(from_path, sizeof(from_path) - 1, &ddl_log_entry->from_db, &ddl_log_entry->from_name, - reg_ext, key_file_fileparser, 0); + reg_ext, key_file_fileparser); /* Rename view back if the original rename did succeed */ if (!access(to_path, F_OK)) @@ -1602,39 +1570,25 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, /* Fall through */ case DDL_DROP_PHASE_TRIGGER: Table_triggers_list::drop_all_triggers(thd, &db, &table, - fn_flags, MYF(MY_WME | MY_IGNORE_ENOENT)); if (increment_phase(entry_pos)) break; /* Fall through */ case DDL_DROP_PHASE_BINLOG: - if (fn_flags & FN_IS_TMP) + if (strcmp(recovery_state.current_db, db.str)) { - /* - If new code is added here please finish this block like this: - - if (increment_phase(entry_pos)) - break; - */ + append_identifier(thd, &recovery_state.drop_table, &db); + recovery_state.drop_table.append('.'); } - else + append_identifier(thd, &recovery_state.drop_table, &table); + recovery_state.drop_table.append(','); + /* We don't increment phase as we want to retry this in case of crash */ + + if (ddl_log_drop_to_binary_log(thd, ddl_log_entry, + &recovery_state.drop_table)) { - if (strcmp(recovery_state.current_db, db.str)) - { - append_identifier(thd, &recovery_state.drop_table, &db); - recovery_state.drop_table.append('.'); - } - append_identifier(thd, &recovery_state.drop_table, &table); - recovery_state.drop_table.append(','); - /* - We don't increment phase as we want to retry this in case of crash. - */ - if (ddl_log_drop_to_binary_log(thd, ddl_log_entry, - &recovery_state.drop_table)) - { - if (increment_phase(entry_pos)) - break; - } + if (increment_phase(entry_pos)) + break; } break; case DDL_DROP_PHASE_RESET: @@ -1690,7 +1644,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, &ddl_log_entry->db, &ddl_log_entry->name, TRG_EXT, - key_file_fileparser, 0)) + key_file_fileparser)) { /* Temporary file existed and was deleted, nothing left to do */ (void) update_phase(entry_pos, DDL_LOG_FINAL_PHASE); @@ -1915,11 +1869,11 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, (void) build_filename_and_delete_tmp_file(to_path, sizeof(to_path) - 1, &db, &table, TRG_EXT, - key_file_fileparser, 0); + key_file_fileparser); (void) build_filename_and_delete_tmp_file(to_path, sizeof(to_path) - 1, &db, &trigger, TRN_EXT, - key_file_fileparser, 0); + key_file_fileparser); switch (ddl_log_entry->phase) { case DDL_CREATE_TRIGGER_PHASE_DELETE_COPY: { @@ -2228,7 +2182,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, if (is_renamed) { // rename_triggers will rename from: from_db.from_name -> db.extra_name - rename_triggers(thd, ddl_log_entry, 1, 0); + rename_triggers(thd, ddl_log_entry, 1); (void) update_phase(entry_pos, DDL_ALTER_TABLE_PHASE_UPDATE_STATS); } } @@ -2807,7 +2761,7 @@ int ddl_log_execute_recovery() if (ddl_log_entry.entry_type == DDL_LOG_EXECUTE_CODE) { /* - Remember information about executive ddl log entry, + Remeber information about executive ddl log entry, used for binary logging during recovery */ recovery_state.execute_entry_pos= i; @@ -2904,7 +2858,6 @@ void ddl_log_release() } my_free(global_ddl_log.file_entry_buf); global_ddl_log.file_entry_buf= 0; - recovery_state.free(); close_ddl_log(); create_ddl_log_file_name(file_name, 0); @@ -3088,8 +3041,7 @@ static bool ddl_log_write(DDL_LOG_STATE *ddl_state, mysql_mutex_lock(&LOCK_gdl); error= ((ddl_log_write_entry(ddl_log_entry, &log_entry)) || - ddl_log_write_execute_entry(log_entry->entry_pos, - ddl_state->master_chain_pos, + ddl_log_write_execute_entry(log_entry->entry_pos, 0, &ddl_state->execute_entry)); mysql_mutex_unlock(&LOCK_gdl); if (error) @@ -3105,10 +3057,7 @@ static bool ddl_log_write(DDL_LOG_STATE *ddl_state, /** - Logging of rename - - @param phase Starting phase (usually DDL_RENAME_PHASE_TABLE) - @param flags Rename flags (FN_FROM_IS_TMP, FN_TO_IS_TMP) + Logging of rename table */ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, @@ -3116,9 +3065,7 @@ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, const LEX_CSTRING *new_db, - const LEX_CSTRING *new_alias, - enum_ddl_log_rename_table_phase phase, - uint16 flags) + const LEX_CSTRING *new_alias) { DDL_LOG_ENTRY ddl_log_entry; DBUG_ENTER("ddl_log_rename_file"); @@ -3133,8 +3080,7 @@ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, ddl_log_entry.name= *const_cast(new_alias); ddl_log_entry.from_db= *const_cast(org_db); ddl_log_entry.from_name= *const_cast(org_alias); - ddl_log_entry.phase= (uchar) phase; - ddl_log_entry.flags= flags; + ddl_log_entry.phase= DDL_RENAME_PHASE_TABLE; DBUG_RETURN(ddl_log_write(ddl_state, &ddl_log_entry)); } @@ -3180,7 +3126,7 @@ static bool ddl_log_drop_init(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *comment) { DDL_LOG_ENTRY ddl_log_entry; - DBUG_ENTER("ddl_log_drop_init"); + DBUG_ENTER("ddl_log_drop_file"); bzero(&ddl_log_entry, sizeof(ddl_log_entry)); @@ -3215,15 +3161,6 @@ bool ddl_log_drop_view_init(DDL_LOG_STATE *ddl_state, be stored in call order instead of reverse order, which is the normal case for all other events. See also comment before ddl_log_drop_init(). - - @param ddl_state DDL log chain - @param action_code DDL_LOG_DROP_TABLE_ACTION or DDL_LOG_DROP_VIEW_ACTION - @param phase Starting phase (for table DDL_DROP_PHASE_TABLE) - @param hton Handlerton - @param path Table filepath without extension - @param db DB name - @param table Table name - @param flags DDL_LOG_FLAG_FROM_IS_TMP or DDL_LOG_FLAG_TO_IS_TMP */ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, @@ -3232,16 +3169,13 @@ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, - const LEX_CSTRING *table, - uint16 flags) + const LEX_CSTRING *table) { DDL_LOG_ENTRY ddl_log_entry; DDL_LOG_MEMORY_ENTRY *log_entry; DBUG_ENTER("ddl_log_drop"); DBUG_ASSERT(ddl_state->list); - DBUG_ASSERT(action_code == DDL_LOG_DROP_TABLE_ACTION || - action_code == DDL_LOG_DROP_VIEW_ACTION); bzero(&ddl_log_entry, sizeof(ddl_log_entry)); ddl_log_entry.action_type= action_code; @@ -3252,7 +3186,6 @@ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, ddl_log_entry.name= *const_cast(table); ddl_log_entry.tmp_name= *const_cast(path); ddl_log_entry.phase= (uchar) phase; - ddl_log_entry.flags= flags; mysql_mutex_lock(&LOCK_gdl); if (ddl_log_write_entry(&ddl_log_entry, &log_entry)) @@ -3276,36 +3209,19 @@ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, } -/** - @param ddl_state DDL log chain - @param hton Handlerton - @param path Table filepath without extension - @param db DB name - @param table Table name - @param flags DDL_LOG_FLAG_FROM_IS_TMP or DDL_LOG_FLAG_TO_IS_TMP -*/ - bool ddl_log_drop_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, - const LEX_CSTRING *table, - uint16 flags) + const LEX_CSTRING *table) { DBUG_ENTER("ddl_log_drop_table"); DBUG_RETURN(ddl_log_drop(ddl_state, DDL_LOG_DROP_TABLE_ACTION, DDL_DROP_PHASE_TABLE, - hton, path, db, table, flags)); + hton, path, db, table)); } -/** - @param ddl_state DDL log chain - @param path Table filepath without extension - @param db DB name - @param table Table name -*/ - bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, const LEX_CSTRING *db, @@ -3314,7 +3230,7 @@ bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, DBUG_ENTER("ddl_log_drop_view"); DBUG_RETURN(ddl_log_drop(ddl_state, DDL_LOG_DROP_VIEW_ACTION, 0, - (handlerton*) 0, path, db, table, 0)); + (handlerton*) 0, path, db, table)); } @@ -3408,8 +3324,6 @@ bool ddl_log_create_table(DDL_LOG_STATE *ddl_state, ddl_log_entry.name= *const_cast(table); ddl_log_entry.tmp_name= *const_cast(path); ddl_log_entry.flags= only_frm ? DDL_LOG_FLAG_ONLY_FRM : 0; - /* Needed for finalize_atomic_replace() which logs 2 events. */ - ddl_log_entry.next_entry= ddl_state->list ? ddl_state->list->entry_pos : 0; DBUG_RETURN(ddl_log_write(ddl_state, &ddl_log_entry)); } @@ -3617,7 +3531,7 @@ bool ddl_log_store_query(THD *thd, DDL_LOG_STATE *ddl_state, ddl_log_entry.extra_name.length= 0; max_query_length= ddl_log_free_space_in_entry(&ddl_log_entry); } - if (ddl_log_write_execute_entry(first_entry->entry_pos, 0, + if (ddl_log_write_execute_entry(first_entry->entry_pos, &ddl_state->execute_entry)) goto err; @@ -3662,17 +3576,3 @@ bool ddl_log_delete_frm(DDL_LOG_STATE *ddl_state, const char *to_path) ddl_log_add_entry(ddl_state, log_entry); DBUG_RETURN(0); } - -/* - Link the ddl_log_state to another (master) chain. If the master - chain is active during DDL recovery, this event will not be executed. - - This is used for DROP TABLE of the original table when - CREATE OR REPLACE ... is used. -*/ - -void ddl_log_link_chains(DDL_LOG_STATE *state, DDL_LOG_STATE *master_state) -{ - DBUG_ASSERT(master_state->execute_entry); - state->master_chain_pos= master_state->execute_entry->entry_pos; -} diff --git a/sql/ddl_log.h b/sql/ddl_log.h index 809b51a0e10ac..88f6695fc72d7 100644 --- a/sql/ddl_log.h +++ b/sql/ddl_log.h @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2022, MariaDB + Copyright (c) 2010, 2021, 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 @@ -173,8 +173,6 @@ enum enum_ddl_log_alter_table_phase { engine is not changed */ #define DDL_LOG_FLAG_ALTER_PARTITION (1 << 4) -#define DDL_LOG_FLAG_FROM_IS_TMP (1 << 5) -#define DDL_LOG_FLAG_TO_IS_TMP (1 << 6) /* Setting ddl_log_entry.phase to this has the same effect as setting @@ -250,7 +248,6 @@ typedef struct st_ddl_log_state */ DDL_LOG_MEMORY_ENTRY *main_entry; uint16 flags; /* Cache for flags */ - uint master_chain_pos; bool is_active() { return list != 0; } } DDL_LOG_STATE; @@ -267,6 +264,12 @@ bool ddl_log_write_entry(DDL_LOG_ENTRY *ddl_log_entry, bool ddl_log_write_execute_entry(uint first_entry, uint cond_entry, DDL_LOG_MEMORY_ENTRY** active_entry); +inline +bool ddl_log_write_execute_entry(uint first_entry, + DDL_LOG_MEMORY_ENTRY **active_entry) +{ + return ddl_log_write_execute_entry(first_entry, 0, active_entry); +} bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry); void ddl_log_complete(DDL_LOG_STATE *ddl_log_state); @@ -289,9 +292,7 @@ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, const LEX_CSTRING *new_db, - const LEX_CSTRING *new_alias, - enum_ddl_log_rename_table_phase phase, - uint16 flags); + const LEX_CSTRING *new_alias); bool ddl_log_rename_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, @@ -306,8 +307,7 @@ bool ddl_log_drop_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, - const LEX_CSTRING *table, - uint16 flags); + const LEX_CSTRING *table); bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, const LEX_CSTRING *db, @@ -354,6 +354,5 @@ bool ddl_log_alter_table(DDL_LOG_STATE *ddl_state, bool ddl_log_store_query(THD *thd, DDL_LOG_STATE *ddl_log_state, const char *query, size_t length); bool ddl_log_delete_frm(DDL_LOG_STATE *ddl_state, const char *to_path); -void ddl_log_link_chains(DDL_LOG_STATE *state, DDL_LOG_STATE *master_state); extern mysql_mutex_t LOCK_gdl; #endif /* DDL_LOG_INCLUDED */ diff --git a/sql/handler.cc b/sql/handler.cc index 4a8b58951d394..21d9b434a72ac 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4992,7 +4992,7 @@ void handler::mark_trx_read_write_internal() table_share can be NULL, for example, in ha_delete_table() or ha_rename_table(). */ - if (table_share == NULL || table_share->tmp_table <= NO_TMP_TABLE) + if (table_share == NULL || table_share->tmp_table == NO_TMP_TABLE) ha_info->set_trx_read_write(); } } @@ -5029,11 +5029,6 @@ int handler::ha_end_bulk_insert() DBUG_ENTER("handler::ha_end_bulk_insert"); DBUG_EXECUTE_IF("crash_end_bulk_insert", { extra(HA_EXTRA_FLUSH) ; DBUG_SUICIDE();}); - if (DBUG_IF("ha_end_bulk_insert_fail")) - { - my_error(ER_OUT_OF_RESOURCES, MYF(0)); - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } estimation_rows_to_insert= 0; DBUG_RETURN(end_bulk_insert()); } @@ -6205,7 +6200,7 @@ static my_bool discover_existence(THD *thd, plugin_ref plugin, bool ha_table_exists(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, LEX_CUSTRING *table_id, LEX_CSTRING *partition_engine_name, - handlerton **hton, bool *is_sequence, uint flags) + handlerton **hton, bool *is_sequence) { handlerton *dummy; bool dummy2; @@ -6260,7 +6255,7 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db, #endif char path[FN_REFLEN + 1]; size_t path_len = build_table_filename(path, sizeof(path) - 1, - db->str, table_name->str, "", flags); + db->str, table_name->str, "", 0); st_discover_existence_args args= {path, path_len, db->str, table_name->str, 0, true}; if (file_ext_exists(path, path_len, reg_ext)) @@ -7041,7 +7036,8 @@ int handler::binlog_log_row(TABLE *table, THD *thd= table->in_use; DBUG_ENTER("binlog_log_row"); - if (!thd->binlog_table_maps && thd->binlog_write_table_maps(table)) + if (!thd->binlog_table_maps && + thd->binlog_write_table_maps()) DBUG_RETURN(HA_ERR_RBR_LOGGING_FAILED); error= (*log_func)(thd, table, row_logging_has_trans, @@ -7590,7 +7586,7 @@ int handler::ha_write_row(const uchar *buf) error= binlog_log_row(table, 0, buf, log_func); } #ifdef WITH_WSREP - if (WSREP_NNULL(ha_thd()) && table_share->tmp_table <= NO_TMP_TABLE && + if (WSREP_NNULL(ha_thd()) && table_share->tmp_table == NO_TMP_TABLE && ht->flags & HTON_WSREP_REPLICATION && !error && (error= wsrep_after_row(ha_thd()))) { @@ -7664,7 +7660,7 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data) " can not mark as PA unsafe"); } - if (!error && table_share->tmp_table <= NO_TMP_TABLE && + if (!error && table_share->tmp_table == NO_TMP_TABLE && ht->flags & HTON_WSREP_REPLICATION) error= wsrep_after_row(thd); } @@ -7742,7 +7738,7 @@ int handler::ha_delete_row(const uchar *buf) " can not mark as PA unsafe"); } - if (!error && table_share->tmp_table <= NO_TMP_TABLE && + if (!error && table_share->tmp_table == NO_TMP_TABLE && ht->flags & HTON_WSREP_REPLICATION) error= wsrep_after_row(thd); } @@ -8190,7 +8186,7 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields( bool Table_scope_and_contents_source_st::vers_check_system_fields( THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, - const Lex_table_name &db) + const Lex_table_name &db, int select_count) { if (!(options & HA_VERSIONED_TABLE)) return false; @@ -8211,7 +8207,7 @@ bool Table_scope_and_contents_source_st::vers_check_system_fields( SELECT go last there. */ bool is_dup= false; - if (fieldnr >= alter_info->field_count()) + if (fieldnr >= alter_info->create_list.elements - select_count) { List_iterator dup_it(alter_info->create_list); for (Create_field *dup= dup_it++; !is_dup && dup != f; dup= dup_it++) @@ -8618,11 +8614,12 @@ bool Table_period_info::check_field(const Create_field* f, } bool Table_scope_and_contents_source_st::check_fields( - THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, - const Lex_table_name &db) + THD *thd, Alter_info *alter_info, + const Lex_table_name &table_name, const Lex_table_name &db, int select_count) { - return (vers_check_system_fields(thd, alter_info, table_name, db) || - check_period_fields(thd, alter_info)); + return vers_check_system_fields(thd, alter_info, + table_name, db, select_count) || + check_period_fields(thd, alter_info); } bool Table_scope_and_contents_source_st::check_period_fields( diff --git a/sql/handler.h b/sql/handler.h index d4ea7687f150b..049f7a7b69955 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -35,7 +35,6 @@ #include "sql_array.h" /* Dynamic_array<> */ #include "mdl.h" #include "vers_string.h" -#include "backup.h" #include "sql_analyze_stmt.h" // for Exec_time_tracker @@ -1781,12 +1780,6 @@ handlerton *ha_default_tmp_handlerton(THD *thd); */ #define HTON_REQUIRES_NOTIFY_TABLEDEF_CHANGED_AFTER_COMMIT (1 << 20) -/* - Indicates that rename table is expensive operation. - When set atomic CREATE OR REPLACE TABLE is not used. -*/ -#define HTON_EXPENSIVE_RENAME (1 << 21) - class Ha_trx_info; struct THD_TRANS @@ -2232,11 +2225,6 @@ struct Table_scope_and_contents_source_pod_st // For trivial members { bzero(this, sizeof(*this)); } - /* - NOTE: share->tmp_table (tmp_table_type) is superset of this - HA_LEX_CREATE_TMP_TABLE which means TEMPORARY keyword in - CREATE TEMPORARY TABLE statement. - */ bool tmp_table() const { return options & HA_LEX_CREATE_TMP_TABLE; } void use_default_db_type(THD *thd) { @@ -2269,7 +2257,8 @@ struct Table_scope_and_contents_source_st: bool fix_period_fields(THD *thd, Alter_info *alter_info); bool check_fields(THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, - const Lex_table_name &db); + const Lex_table_name &db, + int select_count= 0); bool check_period_fields(THD *thd, Alter_info *alter_info); bool vers_fix_system_fields(THD *thd, Alter_info *alter_info, @@ -2277,82 +2266,19 @@ struct Table_scope_and_contents_source_st: bool vers_check_system_fields(THD *thd, Alter_info *alter_info, const Lex_table_name &table_name, - const Lex_table_name &db); -}; - -typedef struct st_ddl_log_state DDL_LOG_STATE; - -struct Atomic_info -{ - Table_name tmp_name; - Table_name backup_name; - DDL_LOG_STATE *ddl_log_state_create; - DDL_LOG_STATE *ddl_log_state_rm; - handlerton *old_hton; - backup_log_info drop_entry; - - Atomic_info() - { - bzero(this, sizeof(*this)); - } + const Lex_table_name &db, + int select_count= 0); - Atomic_info(DDL_LOG_STATE *ddl_log_state_rm) - { - bzero(this, sizeof(*this)); - Atomic_info::ddl_log_state_rm= ddl_log_state_rm; - } - - bool is_atomic_replace() const - { - return tmp_name.table_name.str != NULL; - } }; -/* - mysql_create_table_no_lock can be called in one of the following - mutually exclusive situations: - - - Just a normal ordinary CREATE TABLE statement that explicitly - defines the table structure. - - - CREATE TABLE ... SELECT. It is special, because only in this case, - the list of fields is allowed to have duplicates, as long as one of the - duplicates comes from the select list, and the other doesn't. For - example in - - CREATE TABLE t1 (a int(5) NOT NUL) SELECT b+10 as a FROM t2; - - the list in alter_info->create_list will have two fields `a`. - - - ALTER TABLE, that creates a temporary table #sql-xxx, which will be later - renamed to replace the original table. - - - ALTER TABLE as above, but which only modifies the frm file, it only - creates an frm file for the #sql-xxx, the table in the engine is not - created. - - - Assisted discovery, CREATE TABLE statement without the table structure. - - These situations are distinguished by the following "create table mode" - values, except CREATE ... SELECT which is denoted by non-zero - Alter_info::select_field_count. -*/ - -#define C_ORDINARY_CREATE 0 -#define C_ALTER_TABLE 1 -#define C_ALTER_TABLE_FRM_ONLY 2 -#define C_ASSISTED_DISCOVERY 4 - - /** This struct is passed to handler table routines, e.g. ha_create(). It does not include the "OR REPLACE" and "IF NOT EXISTS" parts, as these parts are handled on the SQL level and are not needed on the handler level. */ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, - public Schema_specification_st, - public Atomic_info + public Schema_specification_st { /* TODO: remove after MDEV-20865 */ Alter_info *alter_info; @@ -2374,17 +2300,6 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, const Lex_table_charset_collation_attrs_st &default_cscl, const Lex_table_charset_collation_attrs_st &convert_cscl, const Charset_collation_context &ctx); - bool is_atomic_replace_usable() const - { - return !tmp_table() && !sequence && - !(db_type->flags & HTON_EXPENSIVE_RENAME) && - !DBUG_IF("ddl_log_expensive_rename"); - } - bool finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table); - void finalize_ddl(THD *thd, bool roll_back); - bool finalize_locked_tables(THD *thd, bool operation_failed); - bool make_tmp_table_list(THD *thd, TABLE_LIST **create_table, - int *create_table_mode); }; @@ -2464,11 +2379,6 @@ struct Table_specification_st: public HA_CREATE_INFO, convert_charset_collation, ctx); } - bool is_atomic_replace() const - { - return or_replace() && !or_replace_slave_generated() && - is_atomic_replace_usable(); - } }; @@ -5331,10 +5241,9 @@ int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp, Discovered_table_list *result, bool reusable); bool ha_table_exists(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, - LEX_CUSTRING *table_version, - LEX_CSTRING *partition_engine_name, - handlerton **hton, bool *is_sequence, - uint flags); + LEX_CUSTRING *table_version= 0, + LEX_CSTRING *partition_engine_name= 0, + handlerton **hton= 0, bool *is_sequence= 0); bool ha_check_if_updates_are_ignored(THD *thd, handlerton *hton, const char *op); #endif /* MYSQL_SERVER */ diff --git a/sql/log.cc b/sql/log.cc index f5664c1fe7488..ddcbecf511b66 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -6103,12 +6103,9 @@ bool THD::binlog_write_annotated_row(Log_event_writer *writer) Also write annotate events and start transactions. This is using the "tables_with_row_logging" list prepared by THD::binlog_prepare_for_row_logging - - Atomic CREATE OR REPLACE .. SELECT logs row events via temporary table, - so it is missed in locks. We write table map for that specially via cur_table. */ -bool THD::binlog_write_table_maps(TABLE *cur_table) +bool THD::binlog_write_table_maps() { bool with_annotate; MYSQL_LOCK *locks[2], **locks_end= locks; @@ -6161,16 +6158,6 @@ bool THD::binlog_write_table_maps(TABLE *cur_table) } } } - if (cur_table->s->tmp_table && cur_table->file->row_logging) - { - /* - This is a temporary table created with CREATE OR REPLACE ... SELECT. - As these types of tables are not locked, we have to write the bitmap - separately. - */ - if (binlog_write_table_map(cur_table, with_annotate)) - DBUG_RETURN(1); - } binlog_table_maps= 1; // Table maps written DBUG_RETURN(0); } diff --git a/sql/log_event.h b/sql/log_event.h index 5267227b37344..4976fcaaa175f 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -681,11 +681,9 @@ enum Log_event_type /* New MySQL/Sun events are to be added right above this comment */ MYSQL_EVENTS_END, + MARIA_EVENTS_BEGIN= 160, /* New Maria event numbers start from here */ ANNOTATE_ROWS_EVENT= 160, - /* Keep that here for GDB to display ANNOTATE_ROWS_EVENT */ - MARIA_EVENTS_BEGIN= 160, - /* Binlog checkpoint event. Used for XA crash recovery on the master, not used in replication. diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index e49089ce678f5..20293c613f200 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -7125,8 +7125,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, { if (!(rights & CREATE_ACL)) { - if (!ha_table_exists(thd, &table_list->db, &table_list->table_name, - NULL, NULL, NULL, NULL, 0)) + if (!ha_table_exists(thd, &table_list->db, &table_list->table_name)) { my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db.str, table_list->alias.str); diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index 9546d011a3704..ffcc7679273e6 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2016, 2022, MariaDB Corporation + Copyright (c) 2016, 2020, 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 @@ -30,7 +30,6 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root) key_list(rhs.key_list, mem_root), alter_rename_key_list(rhs.alter_rename_key_list, mem_root), create_list(rhs.create_list, mem_root), - select_field_count(rhs.select_field_count), alter_index_ignorability_list(rhs.alter_index_ignorability_list, mem_root), check_constraint_list(rhs.check_constraint_list, mem_root), flags(rhs.flags), partition_flags(rhs.partition_flags), diff --git a/sql/sql_alter.h b/sql/sql_alter.h index 142b71c725a54..bf1edd4c964b2 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -96,7 +96,6 @@ class Alter_info List alter_rename_key_list; // List of columns, used by both CREATE and ALTER TABLE. List create_list; - uint select_field_count; // Indexes whose ignorability needs to be changed. List alter_index_ignorability_list; List check_constraint_list; @@ -119,7 +118,6 @@ class Alter_info Alter_info() : - select_field_count(0), flags(0), partition_flags(0), keys_onoff(LEAVE_AS_IS), num_parts(0), @@ -136,7 +134,6 @@ class Alter_info create_list.empty(); alter_index_ignorability_list.empty(); check_constraint_list.empty(); - select_field_count= 0; flags= 0; partition_flags= 0; keys_onoff= LEAVE_AS_IS; @@ -237,11 +234,6 @@ class Alter_info */ enum_alter_table_algorithm algorithm(const THD *thd) const; - uint field_count() const - { - return create_list.elements - select_field_count; - } - private: Alter_info &operator=(const Alter_info &rhs); // not implemented Alter_info(const Alter_info &rhs); // not implemented diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 59d1c18bb35a4..a2b79f1899a8d 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1950,9 +1950,8 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) DBUG_PRINT("info",("Using locked table")); #ifdef WITH_PARTITION_STORAGE_ENGINE part_names_error= set_partitions_as_used(table_list, table); - if (!part_names_error && - table_list->lock_type >= TL_WRITE_ALLOW_WRITE && - table->vers_switch_partition(thd, table_list, ot_ctx)) + if (!part_names_error + && table->vers_switch_partition(thd, table_list, ot_ctx)) DBUG_RETURN(true); #endif goto reset; @@ -2009,8 +2008,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) if (table_list->open_strategy == TABLE_LIST::OPEN_IF_EXISTS) { - if (!ha_table_exists(thd, &table_list->db, &table_list->table_name, - NULL, NULL, NULL, NULL, 0)) + if (!ha_table_exists(thd, &table_list->db, &table_list->table_name)) DBUG_RETURN(FALSE); } else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB) @@ -2214,7 +2212,6 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) #ifdef WITH_PARTITION_STORAGE_ENGINE if (!part_names_error && - table_list->lock_type >= TL_WRITE_ALLOW_WRITE && table->vers_switch_partition(thd, table_list, ot_ctx)) { MYSQL_UNBIND_TABLE(table->file); @@ -3156,7 +3153,7 @@ bool tdc_open_view(THD *thd, TABLE_LIST *table_list, uint flags) static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry) { if (Table_triggers_list::check_n_load(thd, &share->db, - &share->table_name, entry, false, 0)) + &share->table_name, entry, 0)) return TRUE; /* @@ -4228,7 +4225,7 @@ static bool upgrade_lock_if_not_exists(THD *thd, DEBUG_SYNC(thd,"create_table_before_check_if_exists"); if (!create_info.or_replace() && ha_table_exists(thd, &create_table->db, &create_table->table_name, - NULL, NULL, &create_table->db_type, NULL, 0)) + NULL, NULL, &create_table->db_type)) { if (create_info.if_not_exists()) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7c1064c5c54b4..68dfa249449c1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2915,7 +2915,7 @@ struct Item_change_record: public ilink /* - Register an item tree transformation, performed by the query + Register an item tree tree transformation, performed by the query optimizer. We need a pointer to runtime_memroot because it may be != thd->mem_root (due to possible set_n_backup_active_arena called for thd). */ diff --git a/sql/sql_class.h b/sql/sql_class.h index 5085db8f837f3..1f44bf792c95e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2931,7 +2931,7 @@ class THD: public THD_count, /* this must be first */ bool prepare_handlers_for_update(uint flag); bool binlog_write_annotated_row(Log_event_writer *writer); void binlog_prepare_for_row_logging(); - bool binlog_write_table_maps(TABLE *cur_table); + bool binlog_write_table_maps(); bool binlog_write_table_map(TABLE *table, bool with_annotate); static void binlog_prepare_row_images(TABLE* table); @@ -6140,11 +6140,6 @@ class select_insert :public select_result_interceptor { ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not COPY_INFO info; bool insert_into_view; - bool binary_logged; // true if query was binlogged - bool atomic_replace; // true for atomic create or replace - bool tmp_table; - Table_specification_st *create_info; - select_insert(THD *thd_arg, TABLE_LIST *table_list_par, TABLE *table_par, List *fields_par, List *update_fields, List *update_values, enum_duplicates duplic, @@ -6156,7 +6151,6 @@ class select_insert :public select_result_interceptor { virtual void store_values(List &values); virtual bool can_rollback_data() { return 0; } bool prepare_eof(); - bool binlog_query(); bool send_ok_packet(); bool send_eof(); virtual void abort_result_set(); @@ -6166,7 +6160,7 @@ class select_insert :public select_result_interceptor { class select_create: public select_insert { - TABLE_LIST *orig_table; + Table_specification_st *create_info; TABLE_LIST *select_tables; Alter_info *alter_info; Field **field; @@ -6183,7 +6177,19 @@ class select_create: public select_insert { Table_specification_st *create_info_par, Alter_info *alter_info_arg, List &select_fields,enum_duplicates duplic, bool ignore, - TABLE_LIST *select_tables_arg); + TABLE_LIST *select_tables_arg): + select_insert(thd_arg, table_arg, NULL, &select_fields, 0, 0, duplic, + ignore, NULL), + create_info(create_info_par), + select_tables(select_tables_arg), + alter_info(alter_info_arg), + m_plock(NULL), exit_done(0), + saved_tmp_table_share(0) + { + DBUG_ASSERT(create_info->default_table_charset); + bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); + bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); + } int prepare(List &list, SELECT_LEX_UNIT *u); void store_values(List &values); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 765509056b5b1..7be4ba00b8618 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1236,8 +1236,7 @@ mysql_rm_db_internal(THD *thd, const LEX_CSTRING *db, bool if_exists, char quoted_name[FN_REFLEN+3]; // Only write drop table to the binlog for tables that no longer exist. - if (ha_table_exists(thd, &tbl->db, &tbl->table_name, - NULL, NULL, NULL, NULL, 0)) + if (ha_table_exists(thd, &tbl->db, &tbl->table_name)) continue; tbl_name_len= my_snprintf(quoted_name, sizeof(quoted_name), "%`s", diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index ba03fe991c244..73ffa9dd2197e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3887,8 +3887,7 @@ select_insert::select_insert(THD *thd_arg, TABLE_LIST *table_list_par, sel_result(result), table_list(table_list_par), table(table_par), fields(fields_par), autoinc_value_of_last_inserted_row(0), - insert_into_view(table_list_par && table_list_par->view != 0), - binary_logged(false), atomic_replace(false), create_info(NULL) + insert_into_view(table_list_par && table_list_par->view != 0) { bzero((char*) &info,sizeof(info)); info.handle_duplicates= duplic; @@ -3897,37 +3896,6 @@ select_insert::select_insert(THD *thd_arg, TABLE_LIST *table_list_par, info.update_values= update_values; info.view= (table_list_par->view ? table_list_par : 0); info.table_list= table_list_par; - tmp_table= table ? table->s->tmp_table != NO_TMP_TABLE : false; -} - - -select_create::select_create(THD *thd, TABLE_LIST *table_arg, - Table_specification_st *create_info_par, - Alter_info *alter_info_arg, - List &select_fields, - enum_duplicates duplic, bool ignore, - TABLE_LIST *select_tables_arg): - select_insert(thd, table_arg, NULL, &select_fields, 0, 0, duplic, - ignore, NULL), - orig_table(table_arg), - select_tables(select_tables_arg), - alter_info(alter_info_arg), - m_plock(NULL), exit_done(0), - saved_tmp_table_share(0) -{ - DBUG_ASSERT(create_info_par->default_table_charset); - bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); - bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); - create_info= create_info_par; - if (!thd->is_current_stmt_binlog_format_row() || - !ha_check_storage_engine_flag(create_info->db_type, - HTON_NO_BINLOG_ROW_OPT)) - atomic_replace= create_info->is_atomic_replace(); - else - DBUG_ASSERT(!atomic_replace); - create_info->ddl_log_state_create= &ddl_log_state_create; - create_info->ddl_log_state_rm= &ddl_log_state_rm; - tmp_table= create_info->tmp_table(); } @@ -4266,10 +4234,10 @@ void select_insert::store_values(List &values) bool select_insert::prepare_eof() { int error; -#ifndef DBUG_OFF bool const trans_table= table->file->has_transactions_and_rollback(); -#endif bool changed; + bool binary_logged= 0; + killed_state killed_status= thd->killed; DBUG_ENTER("select_insert::prepare_eof"); DBUG_PRINT("enter", ("trans_table: %d, table_type: '%s'", @@ -4287,33 +4255,12 @@ bool select_insert::prepare_eof() error= thd->get_stmt_da()->sql_errno(); if (info.ignore || info.handle_duplicates != DUP_ERROR) - if (table->file->ha_table_flags() & HA_DUPLICATE_POS) - table->file->ha_rnd_end(); + if (table->file->ha_table_flags() & HA_DUPLICATE_POS) + table->file->ha_rnd_end(); table->file->extra(HA_EXTRA_END_ALTER_COPY); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); - if (atomic_replace && !error) - { - DBUG_ASSERT(table->s->tmp_table); - - table->file->ha_release_auto_increment(); - - /* - Note: InnoDB does autocommit on external unlock. - We cannot do commit twice and we must commit after binlog - (flush row events is done at commit), so we cannot do it here. - Test: rpl.create_or_replace_row - */ - ulonglong save_options_bits= thd->variables.option_bits; - thd->variables.option_bits|= OPTION_NOT_AUTOCOMMIT; - int lock_error= table->file->ha_external_lock(thd, F_UNLCK); - thd->variables.option_bits= save_options_bits; - - if (lock_error) - DBUG_RETURN(true); /* purecov: inspected */ - } - if (likely((changed= (info.copied || info.deleted || info.updated)))) { /* @@ -4331,54 +4278,19 @@ bool select_insert::prepare_eof() DBUG_ASSERT(trans_table || !changed || thd->transaction->stmt.modified_non_trans_table); - if (unlikely(error)) - { - if ((thd->transaction->stmt.modified_non_trans_table || - thd->log_current_statement()) && !atomic_replace) - { - if (binlog_query()) - table->file->print_error(error,MYF(0)); - } - else - table->file->ha_release_auto_increment(); - DBUG_RETURN(true); - } - - DBUG_RETURN(false); -} - -bool select_insert::binlog_query() -{ - /* For atomic_replace table was already closed in send_eof(). */ - DBUG_ASSERT(table || atomic_replace); - const bool trans_table= table ? table->file->has_transactions_and_rollback() : - false; - killed_state killed_status= thd->killed; - DBUG_ENTER("select_insert::binlog_query"); - /* Write to binlog before commiting transaction. No statement will be written by the binlog_query() below in RBR mode. All the events are in the transaction cache and will be written when ha_autocommit_or_rollback() is issued below. */ - if ((WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open())) + if ((WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) && + (likely(!error) || thd->transaction->stmt.modified_non_trans_table || + thd->log_current_statement())) { - - debug_crash_here("ddl_log_create_before_binlog"); - - if (create_info && !create_info->tmp_table()) - { - thd->binlog_xid= thd->query_id; - /* Remember xid's for the case of row based logging */ - ddl_log_update_xid(create_info->ddl_log_state_create, thd->binlog_xid); - if (create_info->ddl_log_state_rm->is_active() && !atomic_replace) - ddl_log_update_xid(create_info->ddl_log_state_rm, thd->binlog_xid); - } - int errcode= 0; int res; - if (thd->is_error()) + if (likely(!error)) thd->clear_error(); else errcode= query_error_code(thd, killed_status == NOT_KILLED); @@ -4387,24 +4299,20 @@ bool select_insert::binlog_query() res= thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), trans_table, FALSE, FALSE, errcode); - /* - NOTE: binlog_xid must be cleared after commit because pending row events - are written at commit phase. - */ if (res > 0) { - thd->binlog_xid= 0; - if (table) - table->file->ha_release_auto_increment(); + table->file->ha_release_auto_increment(); DBUG_RETURN(true); } - binary_logged= res == 0 || !tmp_table; + binary_logged= res == 0 || !table->s->tmp_table; } - if (table) + table->s->table_creation_was_logged|= binary_logged; + table->file->ha_release_auto_increment(); + + if (unlikely(error)) { - /* NOTE: used in binlog_drop_table(), not needed for atomic_replace */ - table->s->table_creation_was_logged|= binary_logged; - table->file->ha_release_auto_increment(); + table->file->print_error(error,MYF(0)); + DBUG_RETURN(true); } DBUG_RETURN(false); @@ -4451,8 +4359,7 @@ bool select_insert::send_eof() { bool res; DBUG_ENTER("select_insert::send_eof"); - res= (prepare_eof() || binlog_query() || - (!suppress_my_ok && send_ok_packet())); + res= (prepare_eof() || (!suppress_my_ok && send_ok_packet())); DBUG_RETURN(res); } @@ -4517,11 +4424,7 @@ void select_insert::abort_result_set() res= thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), transactional_table, FALSE, FALSE, errcode); - - /* TODO: Update binary_logged in do_postlock() for RBR? */ - const bool tmp_table= create_info ? create_info->tmp_table() : - (bool) table->s->tmp_table; - binary_logged= res == 0 || !tmp_table; + binary_logged= res == 0 || !table->s->tmp_table; } if (changed) query_cache_invalidate3(thd, table, 1); @@ -4594,13 +4497,11 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, TABLE tmp_table; // Used during 'Create_field()' TABLE_SHARE share; TABLE *table= 0; - alter_info->select_field_count= items->elements; + uint select_field_count= items->elements; /* Add selected items to field list */ List_iterator_fast it(*items); Item *item; bool save_table_creation_was_logged; - int create_table_mode= C_ORDINARY_CREATE; - LEX_CUSTRING frm= {0, 0}; DBUG_ENTER("select_create::create_table_from_items"); tmp_table.s= &share; @@ -4656,7 +4557,8 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, if (create_info->check_fields(thd, alter_info, table_list->table_name, - table_list->db)) + table_list->db, + select_field_count)) DBUG_RETURN(NULL); DEBUG_SYNC(thd,"create_table_select_before_create"); @@ -4671,13 +4573,6 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, create_info->mdl_ticket= table_list->table->mdl_ticket; } - if (atomic_replace) - { - if (create_info->make_tmp_table_list(thd, &table_list, - &create_table_mode)) - DBUG_RETURN(NULL); - } - /* Create and lock table. @@ -4695,14 +4590,11 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, open_table(). */ - if (!mysql_create_table_no_lock(thd, - &orig_table->db, - &orig_table->table_name, + if (!mysql_create_table_no_lock(thd, &ddl_log_state_create, &ddl_log_state_rm, &table_list->db, &table_list->table_name, create_info, alter_info, NULL, - create_table_mode, table_list, - atomic_replace ? &frm : NULL)) + select_field_count, table_list)) { DEBUG_SYNC(thd,"create_table_select_before_open"); @@ -4712,58 +4604,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, */ table_list->table= 0; - if (atomic_replace) - { - char tmp_path[FN_REFLEN + 1]; - build_table_filename(tmp_path, sizeof(tmp_path) - 1, table_list->db.str, - table_list->table_name.str, "", FN_IS_TMP); - - table_list->table= - thd->create_and_open_tmp_table(&frm, tmp_path, orig_table->db.str, - orig_table->table_name.str, false); - /* - NOTE: if create_and_open_tmp_table() fails the table is dropped by - ddl_log_state_create - */ - if (table_list->table) - { - table_list->table->s->tmp_table= TMP_TABLE_ATOMIC_REPLACE; - /* - NOTE: Aria tables require table locking to work in transactional - mode. Since we don't lock our temporary table we get problems with - unproperly initialized transactional mode: seg-fault while accessing - uninitialized trn member (reproduced by - atomic.create_replace,aria,stmt). - - This hack disables logging for Aria table (that is not needed anyway - for a temporary table). - */ - TABLE *table= table_list->table; - int error; - - /* Disable logging of inserted rows */ - mysql_trans_prepare_alter_copy_data(thd); - - if ((DBUG_IF("atomic_replace_external_lock_fail") && - (error= HA_ERR_LOCK_TABLE_FULL)) || - (error= table->file->ha_external_lock(thd, F_WRLCK))) - { - table->file->print_error(error, MYF(0)); - /* - Enable transaction logging. We cannot call ha_enable_transaction() - as this would write the transaction to the binary log - */ - thd->transaction->on= true; - table->file->ha_reset(); - thd->drop_temporary_table(table, NULL, false); - table_list->table= 0; - goto err; - } - - table_list->table->s->can_do_row_logging= 1; - } - } - else if (!create_info->tmp_table()) + if (!create_info->tmp_table()) { Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); TABLE_LIST::enum_open_strategy save_open_strategy; @@ -4804,18 +4645,13 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, } else table_list->table= 0; // Create failed - -err: - DBUG_ASSERT(!table_list->table || frm.str || !atomic_replace); - my_free(const_cast(frm.str)); - + if (unlikely(!(table= table_list->table))) { - const bool error= thd->is_error(); - /* CREATE ... IF NOT EXISTS succeed, but did nothing */ - if (likely(!error)) - my_ok(thd); - create_info->finalize_ddl(thd, error); + if (likely(!thd->is_error())) // CREATE ... IF NOT EXISTS + my_ok(thd); // succeed, but did nothing + ddl_log_complete(&ddl_log_state_rm); + ddl_log_complete(&ddl_log_state_create); DBUG_RETURN(NULL); } @@ -4834,13 +4670,9 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, mysql_lock_tables() below should never fail with request to reopen table since it won't wait for the table lock (we have exclusive metadata lock on the table) and thus can't get aborted. - - In case of atomic_replace we have already called ha_external_lock() above - on the newly created temporary table. */ - if ((!atomic_replace && - unlikely(!((*lock)= mysql_lock_tables(thd, &table, 1, 0)))) || - postlock(thd, &table)) + if (unlikely(!((*lock)= mysql_lock_tables(thd, &table, 1, 0)) || + postlock(thd, &table))) { /* purecov: begin tested */ /* @@ -4857,24 +4689,13 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, *lock= 0; } drop_open_table(thd, table, &table_list->db, &table_list->table_name); - if (atomic_replace) - create_info->finalize_ddl(thd, 1); - else - { - debug_crash_here("ddl_log_create_log_complete"); - ddl_log_complete(&ddl_log_state_create); - debug_crash_here("ddl_log_create_log_complete2"); - } - thd->transaction->on= true; + ddl_log_complete(&ddl_log_state_rm); + ddl_log_complete(&ddl_log_state_create); DBUG_RETURN(NULL); /* purecov: end */ } - DBUG_ASSERT( - create_info->tmp_table() || - thd->mdl_context.is_lock_owner(MDL_key::TABLE, orig_table->db.str, - orig_table->table_name.str, MDL_SHARED)); table->s->table_creation_was_logged= save_table_creation_was_logged; - if (!create_info->tmp_table()) + if (!table->s->tmp_table) table->file->prepare_for_row_logging(); /* @@ -4922,10 +4743,11 @@ int select_create::postlock(THD *thd, TABLE **tables) if (unlikely(error)) return error; - if (thd->is_current_stmt_binlog_format_row() && !create_info->tmp_table()) - error= binlog_show_create_table(thd, *tables, create_info); - - return error; + TABLE const *const table = *tables; + if (thd->is_current_stmt_binlog_format_row() && + !table->s->tmp_table) + return binlog_show_create_table(thd, *tables, create_info); + return 0; } @@ -4952,11 +4774,7 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) if (!(table= create_table_from_items(thd, &values, &extra_lock))) { - /* - TODO: Use create_info->table_was_deleted - (now binlog.binlog_stm_binlog fails). - */ - if (create_info->or_replace() && !atomic_replace) + if (create_info->or_replace()) { /* Original table was deleted. We have to log it */ log_drop_table(thd, &table_list->db, &table_list->table_name, @@ -4970,8 +4788,6 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) DBUG_RETURN(-1); } - DBUG_ASSERT(table == table_list->table); - if (create_info->tmp_table()) { /* @@ -4981,26 +4797,17 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) list to keep them inaccessible from inner statements. e.g. CREATE TEMPORARY TABLE `t1` AS SELECT * FROM `t1`; */ - saved_tmp_table_share= thd->save_tmp_table_share(table); + saved_tmp_table_share= thd->save_tmp_table_share(table_list->table); } if (extra_lock) { DBUG_ASSERT(m_plock == NULL); - if (table->s->tmp_table) - { - /* Table is a temporary table, don't write table map to binary log */ + if (create_info->tmp_table()) m_plock= &m_lock; - } else - { - /* - Table is a normal table. Inform binlog_write_table_maps() that - it should write the table map for the current table. - */ m_plock= &thd->extra_lock; - } *m_plock= extra_lock; } @@ -5092,14 +4899,6 @@ static int binlog_show_create_table(THD *thd, TABLE *table, create_info, WITH_DB_NAME); DBUG_ASSERT(result == 0); /* show_create_table() always return 0 */ - /* - NOTE: why it does show_create_table() even if !mysql_bin_log.is_open()? - - Because Galera needs it even if there is no binlog. - (I assume Galera will hijack the binlog information and use it itself - if there is no binlog). That is the the only thing that makes sence - looking at the if statement... Monty - */ if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) { int errcode= query_error_code(thd, thd->killed == NOT_KILLED); @@ -5221,12 +5020,30 @@ bool select_create::send_eof() is in select_insert::prepare_eof(). For that reason, we mark the flag at this point. */ - if (create_info->tmp_table()) + if (table->s->tmp_table) thd->transaction->stmt.mark_created_temp_table(); if (thd->slave_thread) thd->variables.binlog_annotate_row_events= 0; + debug_crash_here("ddl_log_create_before_binlog"); + + /* + In case of crash, we have to add DROP TABLE to the binary log as + the CREATE TABLE will already be logged if we are not using row based + replication. + */ + if (!thd->is_current_stmt_binlog_format_row()) + { + if (ddl_log_state_create.is_active()) // Not temporary table + ddl_log_update_phase(&ddl_log_state_create, DDL_CREATE_TABLE_PHASE_LOG); + /* + We can ignore if we replaced an old table as ddl_log_state_create will + now handle the logging of the drop if needed. + */ + ddl_log_complete(&ddl_log_state_rm); + } + if (prepare_eof()) { abort_result_set(); @@ -5234,7 +5051,7 @@ bool select_create::send_eof() } debug_crash_here("ddl_log_create_after_prepare_eof"); - if (create_info->tmp_table()) + if (table->s->tmp_table) { /* Now is good time to add the new table to THD temporary tables list. @@ -5260,11 +5077,11 @@ bool select_create::send_eof() tables. This can fail, but we should unlock the table nevertheless. */ - if (!create_info->tmp_table()) + if (!table->s->tmp_table) { #ifdef WITH_WSREP if (WSREP(thd) && - create_info->db_type->db_type == DB_TYPE_INNODB) + table->file->ht->db_type == DB_TYPE_INNODB) { if (thd->wsrep_trx_id() == WSREP_UNDEFINED_TRX_ID) { @@ -5299,46 +5116,15 @@ bool select_create::send_eof() thd->get_stmt_da()->set_overwrite_status(true); } #endif /* WITH_WSREP */ - if (atomic_replace) - { - table_list= orig_table; - create_info->table= orig_table->table; - thd->transaction->on= true; - table->file->ha_reset(); - /* - Remove the temporary table structures from memory but keep the table - files. - */ - thd->drop_temporary_table(table, NULL, false); - table= NULL; - - if (create_info->finalize_atomic_replace(thd, orig_table)) - { - abort_result_set(); - DBUG_RETURN(true); - } - } - - if (binlog_query()) - { - abort_result_set(); - DBUG_RETURN(true); - } - - debug_crash_here("ddl_log_create_after_binlog"); + thd->binlog_xid= thd->query_id; + /* Remember xid's for the case of row based logging */ + ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); + ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); trans_commit_stmt(thd); if (!(thd->variables.option_bits & OPTION_GTID_BEGIN)) trans_commit_implicit(thd); thd->binlog_xid= 0; - /* - If are using statement based replication the table will be deleted here - in case of a crash as we can't use xid to check if the query was logged - (as the query was logged before commit!) - */ - create_info->finalize_ddl(thd, false); - - #ifdef WITH_WSREP if (WSREP(thd)) { @@ -5370,22 +5156,17 @@ bool select_create::send_eof() ddl_log.org_database= table_list->db; ddl_log.org_table= table_list->table_name; ddl_log.org_table_id= create_info->tabledef_version; - /* - Since atomic replace doesn't do mysql_rm_table_no_locks() we have - to log DROP entry now. It was already prepared in create_table_impl(). - */ - if (create_info->drop_entry.query.length) - { - DBUG_ASSERT(atomic_replace); - backup_log_ddl(&create_info->drop_entry); - } backup_log_ddl(&ddl_log); } - else if (binlog_query()) - { - abort_result_set(); - DBUG_RETURN(true); - } + /* + If are using statement based replication the table will be deleted here + in case of a crash as we can't use xid to check if the query was logged + (as the query was logged before commit!) + */ + debug_crash_here("ddl_log_create_after_binlog"); + ddl_log_complete(&ddl_log_state_rm); + ddl_log_complete(&ddl_log_state_create); + debug_crash_here("ddl_log_create_log_complete"); /* exit_done must only be set after last potential call to @@ -5393,9 +5174,10 @@ bool select_create::send_eof() */ exit_done= 1; // Avoid double calls + send_ok_packet(); + if (m_plock) { - DBUG_ASSERT(!atomic_replace); MYSQL_LOCK *lock= *m_plock; *m_plock= NULL; m_plock= NULL; @@ -5414,21 +5196,11 @@ bool select_create::send_eof() create_info-> pos_in_locked_tables, table, lock)) - { - send_ok_packet(); DBUG_RETURN(false); // ok - } /* Fail. Continue without locking the table */ - thd->clear_error(); } mysql_unlock_tables(thd, lock); } - else if (atomic_replace && create_info->pos_in_locked_tables && - /* send_eof() is done on success, passing false here */ - create_info->finalize_locked_tables(thd, false)) - DBUG_RETURN(true); - - send_ok_packet(); DBUG_RETURN(false); } @@ -5466,7 +5238,6 @@ void select_create::abort_result_set() thd->variables.option_bits&= ~OPTION_BIN_LOG; select_insert::abort_result_set(); thd->transaction->stmt.modified_non_trans_table= FALSE; - thd->transaction->on= true; thd->variables.option_bits= save_option_bits; /* possible error of writing binary log is ignored deliberately */ @@ -5474,7 +5245,9 @@ void select_create::abort_result_set() if (table) { - bool tmp_table= create_info->tmp_table(); + bool tmp_table= table->s->tmp_table; + bool table_creation_was_logged= (!tmp_table || + table->s->table_creation_was_logged); if (tmp_table) { DBUG_ASSERT(saved_tmp_table_share); @@ -5496,17 +5269,7 @@ void select_create::abort_result_set() m_plock= NULL; } - if (atomic_replace) - { - ulonglong save_options_bits= thd->variables.option_bits; - thd->variables.option_bits|= OPTION_NOT_AUTOCOMMIT; - (void) table->file->ha_external_lock(thd, F_UNLCK); - thd->variables.option_bits= save_options_bits; - (void) thd->drop_temporary_table(table, NULL, true); - } - else - drop_open_table(thd, table, &table_list->db, - &table_list->table_name); + drop_open_table(thd, table, &table_list->db, &table_list->table_name); table=0; // Safety if (thd->log_current_statement()) { @@ -5514,8 +5277,23 @@ void select_create::abort_result_set() { /* Remove logging of drop, create + insert rows */ binlog_reset_cache(thd); + /* Original table was deleted. We have to log it */ + if (table_creation_was_logged) + { + thd->binlog_xid= thd->query_id; + ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); + ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); + debug_crash_here("ddl_log_create_before_binlog"); + log_drop_table(thd, &table_list->db, &table_list->table_name, + &create_info->org_storage_engine_name, + create_info->db_type == partition_hton, + &create_info->tabledef_version, + tmp_table); + debug_crash_here("ddl_log_create_after_binlog"); + thd->binlog_xid= 0; + } } - else if (!tmp_table && !atomic_replace) + else if (!tmp_table) { backup_log_info ddl_log; bzero(&ddl_log, sizeof(ddl_log)); @@ -5530,8 +5308,8 @@ void select_create::abort_result_set() } } - create_info->finalize_ddl(thd, !binary_logged); - DBUG_ASSERT(!thd->binlog_xid); + ddl_log_complete(&ddl_log_state_rm); + ddl_log_complete(&ddl_log_state_create); if (create_info->table_was_deleted) { @@ -5539,8 +5317,6 @@ void select_create::abort_result_set() (void) trans_rollback_stmt(thd); thd->locked_tables_list.unlock_locked_table(thd, create_info->mdl_ticket); } - else if (atomic_replace && create_info->pos_in_locked_tables) - /* abort_result_set() is done on error, passing true here */ - (void) create_info->finalize_locked_tables(thd, true); + DBUG_VOID_RETURN; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2394207ea2d4b..69803242fc109 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7510,11 +7510,9 @@ void THD::reset_for_next_command(bool do_clear_error) DBUG_ENTER("THD::reset_for_next_command"); DBUG_ASSERT(!spcont); /* not for substatements of routines */ DBUG_ASSERT(!in_sub_stmt); - DBUG_ASSERT(transaction->on); - /* Table maps should have been reset after previous statement except in the - case where we have locked ables + case where we have locked tables */ DBUG_ASSERT(binlog_table_maps == 0 || locked_tables_mode == LTM_LOCK_TABLES); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index de2c2553e0ca3..7acbd29f20487 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6695,7 +6695,7 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt) goto error; log_entry= part_info->list; part_info->main_entry= log_entry; - if (ddl_log_write_execute_entry(log_entry->entry_pos, 0, + if (ddl_log_write_execute_entry(log_entry->entry_pos, &exec_log_entry)) goto error; release_part_info_log_entries(old_first_log_entry); @@ -6750,7 +6750,7 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt) goto error; log_entry= part_info->list; part_info->main_entry= log_entry; - if (ddl_log_write_execute_entry(log_entry->entry_pos, 0, + if (ddl_log_write_execute_entry(log_entry->entry_pos, &exec_log_entry)) goto error; release_part_info_log_entries(old_first_log_entry); @@ -6782,7 +6782,7 @@ static bool write_log_convert_partition(ALTER_PARTITION_PARAM_TYPE *lpt) if (write_log_convert_partition(lpt, &next_entry, (const char*)path)) goto error; DBUG_ASSERT(next_entry == part_info->list->entry_pos); - if (ddl_log_write_execute_entry(part_info->list->entry_pos, 0, + if (ddl_log_write_execute_entry(part_info->list->entry_pos, &part_info->execute_entry)) goto error; mysql_mutex_unlock(&LOCK_gdl); @@ -6837,7 +6837,7 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) goto error; log_entry= part_info->list; - if (ddl_log_write_execute_entry(log_entry->entry_pos, 0, + if (ddl_log_write_execute_entry(log_entry->entry_pos, &part_info->execute_entry)) goto error; mysql_mutex_unlock(&LOCK_gdl); @@ -6904,7 +6904,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) log_entry= part_info->list; part_info->main_entry= log_entry; /* Overwrite the revert execute log entry with this retry execute entry */ - if (ddl_log_write_execute_entry(log_entry->entry_pos, 0, + if (ddl_log_write_execute_entry(log_entry->entry_pos, &exec_log_entry)) goto error; release_part_info_log_entries(old_first_log_entry); @@ -7080,8 +7080,6 @@ static void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, { THD *thd= lpt->thd; partition_info *part_info= lpt->part_info->get_clone(thd); - /* TABLE is going to be released, we should not access old part_info anymore */ - lpt->part_info= part_info; TABLE *table= lpt->table; DBUG_ENTER("handle_alter_part_error"); DBUG_ASSERT(table->needs_reopen()); diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index e0d40337d9347..d290d0f5534a3 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -383,7 +383,7 @@ static bool exchange_name_with_ddl_log(THD *thd, DBUG_EXECUTE_IF("exchange_partition_fail_2", goto err_no_execute_written;); DBUG_EXECUTE_IF("exchange_partition_abort_2", DBUG_SUICIDE();); - if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos, 0, + if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos, &exec_log_entry))) goto err_no_execute_written; /* ddl_log is written and synced */ diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index c9886232d452b..1137e0e1b0983 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -200,7 +200,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent, else { /* Revert the renames of normal tables with the help of the ddl log */ - error|= ddl_log_revert(thd, &ddl_log_state); + ddl_log_revert(thd, &ddl_log_state); } err: @@ -209,10 +209,10 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent, static bool -rename_temporary_table(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table) +do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table) { LEX_CSTRING *new_alias; - DBUG_ENTER("rename_temporary_table"); + DBUG_ENTER("do_rename_temporary"); new_alias= (lower_case_table_names == 2) ? &new_table->alias : &new_table->table_name; @@ -229,6 +229,20 @@ rename_temporary_table(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table) /** + Parameters for do_rename +*/ + +struct rename_param +{ + LEX_CSTRING old_alias, new_alias; + LEX_CUSTRING old_version; + handlerton *from_table_hton; +}; + + +/** + check_rename() + Check pre-conditions for rename - From table should exists - To table should not exists. @@ -244,15 +258,15 @@ rename_temporary_table(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table) @retval <0 Can't do rename, but no error */ -int -rename_check_preconditions(THD *thd, rename_param *param, - Table_name *ren_table, - const LEX_CSTRING *new_db, - const LEX_CSTRING *new_table_name, - const LEX_CSTRING *new_table_alias, - bool if_exists) +static int +check_rename(THD *thd, rename_param *param, + TABLE_LIST *ren_table, + const LEX_CSTRING *new_db, + const LEX_CSTRING *new_table_name, + const LEX_CSTRING *new_table_alias, + bool if_exists) { - DBUG_ENTER("rename_check_preconditions"); + DBUG_ENTER("check_rename"); DBUG_PRINT("enter", ("if_exists: %d", (int) if_exists)); @@ -270,8 +284,7 @@ rename_check_preconditions(THD *thd, rename_param *param, if (!ha_table_exists(thd, &ren_table->db, ¶m->old_alias, ¶m->old_version, NULL, - ¶m->from_table_hton, NULL, - (param->rename_flags & FN_FROM_IS_TMP)) || + ¶m->from_table_hton) || !param->from_table_hton) { my_error(ER_NO_SUCH_TABLE, MYF(if_exists ? ME_NOTE : 0), @@ -291,8 +304,7 @@ rename_check_preconditions(THD *thd, rename_param *param, DBUG_RETURN(-1); } - if (ha_table_exists(thd, new_db, ¶m->new_alias, NULL, NULL, NULL, NULL, - (param->rename_flags & FN_TO_IS_TMP))) + if (ha_table_exists(thd, new_db, ¶m->new_alias, NULL, NULL, 0)) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), param->new_alias.str); DBUG_RETURN(1); // This can't be skipped @@ -305,6 +317,7 @@ rename_check_preconditions(THD *thd, rename_param *param, Rename a single table or a view SYNPOSIS + do_rename() thd Thread handle ren_table A table/view to be renamed new_db The database to which the table to be moved to @@ -316,47 +329,36 @@ rename_check_preconditions(THD *thd, rename_param *param, Rename a single table or a view. In case of failure, all changes will be reverted - Even if mysql_rename_tables() cannot be used with LOCK TABLES, - the table can still be locked if we come here from CREATE ... REPLACE. - - If ddl_log_state is NULL then we will not log the rename to the ddl log. - RETURN false Ok true rename failed */ -bool -rename_table_and_triggers(THD *thd, rename_param *param, - DDL_LOG_STATE *ddl_log_state, - Table_name *ren_table, const LEX_CSTRING *new_db, - bool skip_error, bool *force_if_exists) +static bool +do_rename(THD *thd, rename_param *param, DDL_LOG_STATE *ddl_log_state, + TABLE_LIST *ren_table, const LEX_CSTRING *new_db, + bool skip_error, bool *force_if_exists) { int rc= 1; handlerton *hton; LEX_CSTRING *old_alias, *new_alias; TRIGGER_RENAME_PARAM rename_param; - rename_param.rename_flags= param->rename_flags; - DBUG_ENTER("rename_table_and_triggers"); + DBUG_ENTER("do_rename"); DBUG_PRINT("enter", ("skip_error: %d", (int) skip_error)); old_alias= ¶m->old_alias; new_alias= ¶m->new_alias; hton= param->from_table_hton; + DBUG_ASSERT(!thd->locked_tables_mode); + #ifdef WITH_WSREP if (WSREP(thd) && hton && hton != view_pseudo_hton && !wsrep_should_replicate_ddl(thd, hton)) DBUG_RETURN(1); #endif - if (!(param->rename_flags & FN_FROM_IS_TMP)) - tdc_remove_table(thd, ren_table->db.str, ren_table->table_name.str); - - /* - In case of CREATE..REPLACE the temporary table does not have a - MDL lock - */ + tdc_remove_table(thd, ren_table->db.str, ren_table->table_name.str); if (hton != view_pseudo_hton) { @@ -374,23 +376,19 @@ rename_table_and_triggers(THD *thd, rename_param *param, thd->replication_flags= 0; - if (ddl_log_state && - ddl_log_rename_table(ddl_log_state, hton, - &ren_table->db, old_alias, new_db, new_alias, - DDL_RENAME_PHASE_TABLE, 0)) + if (ddl_log_rename_table(ddl_log_state, hton, + &ren_table->db, old_alias, new_db, new_alias)) DBUG_RETURN(1); debug_crash_here("ddl_log_rename_before_rename_table"); if (!(rc= mysql_rename_table(hton, &ren_table->db, old_alias, - new_db, new_alias, ¶m->old_version, - param->rename_flags))) + new_db, new_alias, ¶m->old_version, 0))) { /* Table rename succeded. It's safe to start recovery at rename trigger phase */ debug_crash_here("ddl_log_rename_before_phase_trigger"); - if (ddl_log_state) - ddl_log_update_phase(ddl_log_state, DDL_RENAME_PHASE_TRIGGER); + ddl_log_update_phase(ddl_log_state, DDL_RENAME_PHASE_TRIGGER); debug_crash_here("ddl_log_rename_before_rename_trigger"); @@ -403,13 +401,10 @@ rename_table_and_triggers(THD *thd, rename_param *param, new_alias))) { debug_crash_here("ddl_log_rename_before_stat_tables"); - if (!(param->rename_flags & FN_IS_TMP)) - { - (void) rename_table_in_stat_tables(thd, &ren_table->db, - &ren_table->table_name, - new_db, new_alias); - debug_crash_here("ddl_log_rename_after_stat_tables"); - } + (void) rename_table_in_stat_tables(thd, &ren_table->db, + &ren_table->table_name, + new_db, new_alias); + debug_crash_here("ddl_log_rename_after_stat_tables"); } else { @@ -424,8 +419,7 @@ rename_table_and_triggers(THD *thd, rename_param *param, &ren_table->db, old_alias, ¶m->old_version, NO_FK_CHECKS); debug_crash_here("ddl_log_rename_after_revert_rename_table"); - if (ddl_log_state) - ddl_log_disable_entry(ddl_log_state); + ddl_log_disable_entry(ddl_log_state); debug_crash_here("ddl_log_rename_after_disable_entry"); } } @@ -446,7 +440,6 @@ rename_table_and_triggers(THD *thd, rename_param *param, DBUG_RETURN(1); } - DBUG_ASSERT(ddl_log_state); ddl_log_rename_view(ddl_log_state, &ren_table->db, &ren_table->table_name, new_db, new_alias); debug_crash_here("ddl_log_rename_before_rename_view"); @@ -523,25 +516,24 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state, pair->from= ren_table; pair->to= new_table; - if (rename_temporary_table(thd, ren_table, new_table)) + if (do_rename_temporary(thd, ren_table, new_table)) goto revert_rename; } else { int error; rename_param param; - error= rename_check_preconditions(thd, ¶m, ren_table, - &new_table->db, &new_table->table_name, - &new_table->alias, - (skip_error || if_exists)); + error= check_rename(thd, ¶m, ren_table, &new_table->db, + &new_table->table_name, + &new_table->alias, (skip_error || if_exists)); if (error < 0) continue; // Ignore rename (if exists) if (error > 0) goto revert_rename; - if (rename_table_and_triggers(thd, ¶m, ddl_log_state, - ren_table, &new_table->db, - skip_error, force_if_exists)) + if (do_rename(thd, ¶m, ddl_log_state, + ren_table, &new_table->db, + skip_error, force_if_exists)) goto revert_rename; } } @@ -551,7 +543,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state, /* Revert temporary tables. Normal tables are reverted in the caller */ List_iterator_fast it(tmp_tables); while (TABLE_PAIR *pair= it++) - rename_temporary_table(thd, pair->to, pair->from); + do_rename_temporary(thd, pair->to, pair->from); DBUG_RETURN(1); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f1ff1ca2d1d90..3c00e4428a8bd 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -55,7 +55,6 @@ #include "sql_window.h" #include "tztime.h" -#include "debug.h" #include "debug_sync.h" // DEBUG_SYNC #include #include @@ -23006,7 +23005,6 @@ end_send(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) // error < 0 => duplicate row join->duplicate_rows++; } - debug_crash_here("ddl_log_create_after_send_data"); } join->send_records++; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c77759c3e8bcd..b47b9f4b89bc7 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2111,8 +2111,7 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, !create_info_arg->or_replace_slave_generated()) || create_info_arg->table_was_deleted)) packet->append(STRING_WITH_LEN("OR REPLACE ")); - if (share->tmp_table && - !(create_info_arg && create_info_arg->is_atomic_replace())) + if (share->tmp_table) packet->append(STRING_WITH_LEN("TEMPORARY ")); packet->append(STRING_WITH_LEN("TABLE ")); if (create_info_arg && create_info_arg->if_not_exists()) @@ -4818,7 +4817,7 @@ static int fill_schema_table_names(THD *thd, TABLE_LIST *tables, bool is_sequence; if (ha_table_exists(thd, db_name, table_name, NULL, NULL, - &hton, &is_sequence, 0)) + &hton, &is_sequence)) { if (hton == view_pseudo_hton) table->field[3]->store(STRING_WITH_LEN("VIEW"), cs); @@ -5048,7 +5047,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table, init_sql_alloc(key_memory_table_triggers_list, &tbl.mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0)); if (!Table_triggers_list::check_n_load(thd, db_name, - table_name, &tbl, true, 0)) + table_name, &tbl, 1)) { table_list.table= &tbl; res= schema_table->process_table(thd, &table_list, table, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ad58dd620d97b..34828d4d8c457 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -870,7 +870,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) if (write_log_replace_frm(lpt, part_info->list->entry_pos, (const char*) bak_path, (const char*) path) || - ddl_log_write_execute_entry(part_info->list->entry_pos, 0, + ddl_log_write_execute_entry(part_info->list->entry_pos, &part_info->execute_entry)) { mysql_mutex_unlock(&LOCK_gdl); @@ -1243,75 +1243,6 @@ static uint32 get_comment(THD *thd, uint32 comment_pos, return 0; } - -static -bool make_tmp_name(THD *thd, const char *prefix, const Table_name *orig, - Table_name *res) -{ - char res_name[NAME_LEN + 1]; - char file_name[NAME_LEN + 1]; - LEX_CSTRING table_name; - /* - Filename trimming should not depend on prefix length with variable PID and - thread ID. This makes tests happier. - */ - constexpr int MIN_PREFIX= 30; - - size_t len= my_snprintf(res_name, sizeof(res_name) - 1, - tmp_file_prefix "-%s-%lx-%llx-", prefix, - current_pid, thd->thread_id); - - const size_t pfx_len= len < MIN_PREFIX ? MIN_PREFIX : len; - uint len2= tablename_to_filename(orig->table_name.str, file_name, - sizeof(res_name) - pfx_len - 1); - - DBUG_ASSERT(len + len2 < sizeof(res_name) - 1); - memcpy(res_name + len, file_name, len2 + 1); - len+= len2; - - table_name.str= strmake_root(thd->mem_root, res_name, len); - if (!table_name.str) - return true; - - table_name.length= len; - res->db= orig->db; - res->table_name= table_name; - res->alias= table_name; - return false; -} - - -/** - Helper for making utility table names for atomic CREATE OR REPLACE. - - Creates two temporary names: "create" (used for new table) - and "backup" (used for saving old table). - - @param create_table[in/out] Original table name, on output holds new name - @param create_table_mode[out] Create flags or-ed with C_ALTER_TABLE -*/ - -bool HA_CREATE_INFO::make_tmp_table_list(THD *thd, TABLE_LIST **create_table, - int *create_table_mode) -{ - TABLE_LIST *new_table; - if (make_tmp_name(thd, "create", *create_table, &tmp_name) || - make_tmp_name(thd, "backup", *create_table, &backup_name) || - !(new_table= (TABLE_LIST *)thd->alloc(sizeof(TABLE_LIST)))) - { - my_error(ER_OUT_OF_RESOURCES, MYF(0)); - return true; - } - (*create_table_mode)|= C_ALTER_TABLE; - DBUG_ASSERT(!(options & HA_CREATE_TMP_ALTER)); - options|= HA_CREATE_TMP_ALTER; - new_table->init_one_table(&tmp_name.db, &tmp_name.table_name, - &tmp_name.alias, (*create_table)->lock_type); - *create_table= new_table; - return false; -} - - /** Execute the drop of a sequence, view or table (normal or temporary). @@ -1564,13 +1495,12 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)); - /* NOTE: alias holds original table name, table_name holds lowercase name */ alias= (lower_case_table_names == 2) ? table->alias : table_name; /* remove .frm file and engine files */ path_length= build_table_filename(path, sizeof(path) - 1, db.str, alias.str, reg_ext, 0); path_end= path + path_length - reg_ext_length; - } /* if (!drop_temporary) */ + } DEBUG_SYNC(thd, "rm_table_no_locks_before_delete_table"); if (drop_temporary) @@ -1669,7 +1599,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, &table_name); else res= ddl_log_drop_table(ddl_log_state, hton, &cpath, &db, - &table_name, 0); + &table_name); if (res) { error= -1; @@ -1746,17 +1676,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, int ferror= 0; DBUG_ASSERT(!was_view); - /* - We where not able to drop the table for the engine. We will now try - to drop the table for any engines (to handle the case where we don't have - an .frm file or when the the information in the .frm does not match the - engine type). - We start by discarding the previous drop attempt, as we have tried - this drop already and it failed. - */ - ddl_log_disable_entry(ddl_log_state); if (ddl_log_drop_table(ddl_log_state, 0, &cpath, &db, - &table_name, 0)) + &table_name)) { error= -1; goto err; @@ -1795,24 +1716,17 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, if (!was_view) { - if (likely(!error) || non_existing_table_error(error)) - { - debug_crash_here("ddl_log_drop_before_drop_trigger"); - ddl_log_update_phase(ddl_log_state, DDL_DROP_PHASE_TRIGGER); - debug_crash_here("ddl_log_drop_before_drop_trigger2"); - if (Table_triggers_list::drop_all_triggers(thd, &db, &table_name, 0, - MYF(MY_WME | - MY_IGNORE_ENOENT))) - error= error ? error : -1; - } - else - { - /* NOTE: table may not be dropped due to FK error */ - DBUG_ASSERT(error); - ddl_log_update_phase(ddl_log_state, DDL_DROP_PHASE_END); - } + debug_crash_here("ddl_log_drop_before_drop_trigger"); + ddl_log_update_phase(ddl_log_state, DDL_DROP_PHASE_TRIGGER); + debug_crash_here("ddl_log_drop_before_drop_trigger2"); } + if (likely(!error) || non_existing_table_error(error)) + { + if (Table_triggers_list::drop_all_triggers(thd, &db, &table_name, + MYF(MY_WME | MY_IGNORE_ENOENT))) + error= error ? error : -1; + } debug_crash_here("ddl_log_drop_after_drop_trigger"); report_error: @@ -1879,12 +1793,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, backup_log_ddl(&ddl_log); } } - /* - Foreign key check may fail and we didn't drop the table. - We are already at DDL_DROP_PHASE_END in this case and we - must not binlog DROP query. - */ - if (!was_view && table_dropped) + if (!was_view) ddl_log_update_phase(ddl_log_state, DDL_DROP_PHASE_BINLOG); if (!dont_log_query && @@ -2833,7 +2742,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, List_iterator_fast it(alter_info->create_list); List_iterator it2(alter_info->create_list); uint total_uneven_bit_length= 0; - bool tmp_table= (create_table_mode & C_ALTER_TABLE); + int select_field_count= C_CREATE_SELECT(create_table_mode); + bool tmp_table= create_table_mode == C_ALTER_TABLE; const bool create_simple= thd->lex->create_simple(); bool is_hash_field_needed= false; const Column_derived_attributes dattr(create_info->default_table_charset); @@ -2872,7 +2782,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(TRUE); } - select_field_pos= alter_info->field_count(); + select_field_pos= alter_info->create_list.elements - select_field_count; null_fields= 0; create_info->varchar= 0; max_key_length= file->max_key_length(); @@ -3047,7 +2957,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, from the select tables. This order may differ on master and slave. We therefore mark it as unsafe. */ - if (alter_info->select_field_count > 0 && auto_increment) + if (select_field_count > 0 && auto_increment) thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC); /* Create keys */ @@ -3086,18 +2996,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, } else fk_key->ref_columns.append(&fk_key->columns); - /* - If this is a self refering table from CREATE ... SELECT, - update the foreign key table name to the used (temporary) table name. - */ - if (create_info->tmp_name.is_set() && - (!fk_key->ref_db.str || - !lex_string_cmp(table_alias_charset, &db, &fk_key->ref_db)) && - !lex_string_cmp(table_alias_charset, &table_name, - &fk_key->ref_table)) - { - fk_key->ref_table= create_info->tmp_name.table_name; - } continue; } (*key_count)++; @@ -4386,209 +4284,12 @@ handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db, } -/** - Finalize atomic CREATE OR REPLACE. - - Renames old table to backup table (in case it exists), rename tmp table to - new table. These operations are covered with DDL logging in two chains: - - ddl_log_state_create: rolls back the tables to the original state before - the command was started. - - ddl_log_state_rm: keep the new table and drop the backup table. - - finalize_ddl() executes one of the above chains depending on error or success - state. - - @return true in case of error -*/ - -bool HA_CREATE_INFO::finalize_atomic_replace(THD *thd, TABLE_LIST *orig_table) -{ - rename_param param; - bool dummy; - const LEX_CSTRING db= orig_table->db; - const LEX_CSTRING table_name= orig_table->table_name; - LEX_CSTRING cpath; - char path[FN_REFLEN + 1]; - cpath.str= path; - bool locked_tables_decremented= false; - - DBUG_ASSERT(is_atomic_replace()); - - debug_crash_here("ddl_log_create_before_install_new"); - if (old_hton) - { - /* Old table exists, rename it to backup_name */ - ddl_log_link_chains(ddl_log_state_rm, ddl_log_state_create); - - cpath.length= build_table_filename(path, sizeof(path) - 1, - backup_name.db.str, - backup_name.table_name.str, - "", FN_IS_TMP); - - if (ddl_log_drop_table_init(ddl_log_state_rm, &backup_name.db, - &empty_clex_str) || - ddl_log_drop_table(ddl_log_state_rm, old_hton, &cpath, - &backup_name.db, &backup_name.table_name, - DDL_LOG_FLAG_FROM_IS_TMP)) - return true; - - debug_crash_here("ddl_log_create_after_log_drop_backup"); - if (ddl_log_rename_table(ddl_log_state_create, old_hton, - &db, &table_name, - &backup_name.db, &backup_name.table_name, - DDL_RENAME_PHASE_TRIGGER, - DDL_LOG_FLAG_FROM_IS_TMP)) - return true; - - debug_crash_here("ddl_log_create_after_log_rename_backup"); - - if (thd->locked_tables_mode == LTM_LOCK_TABLES || - thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES) - { - DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, - table_name.str, - MDL_EXCLUSIVE)); - /* - HA_EXTRA_PREPARE_FOR_DROP: after CREATE OR REPLACE table - must be not locked, removing it from thd->locked_tables_list. - */ - close_all_tables_for_name(thd, table->s, - HA_EXTRA_PREPARE_FOR_DROP, NULL); - table= NULL; - orig_table->table= NULL; - locked_tables_decremented= true; - } - - param.rename_flags= FN_TO_IS_TMP; - param.from_table_hton= old_hton; - param.old_version= org_tabledef_version; - param.old_alias= lower_case_table_names == 2 ? orig_table->alias : - table_name; - param.new_alias= backup_name.table_name; - if (rename_table_and_triggers(thd, ¶m, NULL, orig_table, - &backup_name.db, false, &dummy)) - { - if (locked_tables_decremented) - thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); - return true; - } - debug_crash_here("ddl_log_create_after_save_backup"); - } - - cpath.length= build_table_filename(path, sizeof(path) - 1, db.str, - table_name.str, "", 0); - param.rename_flags= FN_FROM_IS_TMP; - param.from_table_hton= db_type; - param.old_version= tabledef_version; - param.old_alias= tmp_name.table_name; - param.new_alias= table_name; - if (ddl_log_create_table(ddl_log_state_create, param.from_table_hton, - &cpath, &db, &table_name, false) || - rename_table_and_triggers(thd, ¶m, NULL, &tmp_name, &db, false, - &dummy)) - { - if (locked_tables_decremented) - thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); - return true; - } - debug_crash_here("ddl_log_create_after_install_new"); - return false; -} - - -/** - Execute ddl_log_state_rm or ddl_log_state_create depending on error or success - state. -*/ - -void HA_CREATE_INFO::finalize_ddl(THD *thd, bool roll_back) -{ - if (roll_back) - { - /* - Statement failed - - Forget drop of backup table - - Rollback create (drop temporary table, rename backup to original) - */ - debug_crash_here("ddl_log_create_fk_fail"); - ddl_log_complete(ddl_log_state_rm); - debug_crash_here("ddl_log_create_fk_fail2"); - (void) ddl_log_revert(thd, ddl_log_state_create); - debug_crash_here("ddl_log_create_fk_fail3"); - } - else - { - /* - Statement succeded - - Forget revert of create table - - Drop backup table - */ - debug_crash_here("ddl_log_create_log_complete"); - ddl_log_complete(ddl_log_state_create); - debug_crash_here("ddl_log_create_log_complete2"); - if (is_atomic_replace()) - (void) ddl_log_revert(thd, ddl_log_state_rm); - else - ddl_log_complete(ddl_log_state_rm); - debug_crash_here("ddl_log_create_log_complete3"); - } -} - - -/** - Finalize operation of LOCK TABLES mode for CREATE TABLE family of commands. - - @param operation_failed Notify if the callee CREATE fails the operation - @return true on error, false on success -*/ -bool HA_CREATE_INFO::finalize_locked_tables(THD *thd, bool operation_failed) -{ - DBUG_ASSERT(pos_in_locked_tables); - DBUG_ASSERT(thd->locked_tables_mode); - DBUG_ASSERT(thd->variables.option_bits & OPTION_TABLE_LOCK); - if (!operation_failed) - { - /* - Add back the deleted table and re-created table as a locked 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, false)) - { - thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); - return true; - } - if (is_atomic_replace() || !operation_failed) - { - /* - The lock was made exclusive in create_table_impl(). We have now - to bring it back to it's orginal state. - */ - TABLE *table= pos_in_locked_tables->table; - table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); - } - else - { - /* - In failed non-atomic we have nothing to downgrade: - original table was deleted and the lock was already removed. - */ - DBUG_ASSERT(!pos_in_locked_tables->table); - } - - return false; -} - - /** Create a table @param thd Thread object - @param orig_db Database for error messages or atomic replace - @param orig_table_name Table name for error messages or atomic replace + @param orig_db Database for error messages + @param orig_table_name Table name for error messages (it's different from table_name for ALTER TABLE) @param db Database @param table_name Table name @@ -4623,6 +4324,8 @@ bool HA_CREATE_INFO::finalize_locked_tables(THD *thd, bool operation_failed) static int create_table_impl(THD *thd, + DDL_LOG_STATE *ddl_log_state_create, + DDL_LOG_STATE *ddl_log_state_rm, const LEX_CSTRING &orig_db, const LEX_CSTRING &orig_table_name, const LEX_CSTRING &db, const LEX_CSTRING &table_name, @@ -4631,23 +4334,24 @@ int create_table_impl(THD *thd, int create_table_mode, bool *is_trans, KEY **key_info, uint *key_count, LEX_CUSTRING *frm) { - LEX_CSTRING *alias= const_cast(table_case_name(create_info, &table_name)); + LEX_CSTRING *alias; handler *file= 0; int error= 1; - bool frm_only= (create_table_mode & C_ALTER_TABLE_FRM_ONLY); - bool atomic_replace= create_info->is_atomic_replace(); - bool internal_tmp_table= (!atomic_replace && - (create_table_mode & C_ALTER_TABLE)) || - frm_only; - /* Easy check for ddl logging if we are creating a temporary table */ - DDL_LOG_STATE *ddl_log_state_create= - create_info->tmp_table() ? 0 : create_info->ddl_log_state_create; + bool frm_only= create_table_mode == C_ALTER_TABLE_FRM_ONLY; + bool internal_tmp_table= create_table_mode == C_ALTER_TABLE || frm_only; DBUG_ENTER("create_table_impl"); DBUG_PRINT("enter", ("db: '%s' table: '%s' tmp: %d path: %s", db.str, table_name.str, internal_tmp_table, path.str)); DBUG_ASSERT(create_info->default_table_charset); + /* Easy check for ddl logging if we are creating a temporary table */ + if (create_info->tmp_table()) + { + ddl_log_state_create= 0; + ddl_log_state_rm= 0; + } + if (fix_constraints_names(thd, &alter_info->check_constraint_list, create_info)) DBUG_RETURN(1); @@ -4676,6 +4380,8 @@ int create_table_impl(THD *thd, goto err; } + alias= const_cast(table_case_name(create_info, &table_name)); + /* Check if table exists */ if (create_info->tmp_table()) { @@ -4729,16 +4435,11 @@ int create_table_impl(THD *thd, goto err; } - handlerton *db_type= NULL; - LEX_CSTRING partition_engine_name= {NULL, 0}; - + handlerton *db_type; if (!internal_tmp_table && - ha_table_exists(thd, &orig_db, &orig_table_name, - &create_info->org_tabledef_version, - &partition_engine_name, &db_type, NULL, 0)) + ha_table_exists(thd, &db, &table_name, + &create_info->org_tabledef_version, NULL, &db_type)) { - create_info->old_hton= db_type; - if (ha_check_if_updates_are_ignored(thd, db_type, "CREATE")) { /* Don't create table. CREATE will still be logged in binary log */ @@ -4748,115 +4449,44 @@ int create_table_impl(THD *thd, if (options.or_replace()) { - (void) delete_statistics_for_table(thd, &orig_db, &orig_table_name); + (void) delete_statistics_for_table(thd, &db, &table_name); TABLE_LIST table_list; - TABLE *table= create_info->table; - table_list.init_one_table(&orig_db, &orig_table_name, 0, TL_READ); - table_list.table= table; + table_list.init_one_table(&db, &table_name, 0, TL_WRITE_ALLOW_WRITE); + table_list.table= create_info->table; if (check_if_log_table(&table_list, TRUE, "CREATE OR REPLACE")) goto err; + + /* + Rollback the empty transaction started in mysql_create_table() + call to open_and_lock_tables() when we are using LOCK TABLES. + */ + (void) trans_rollback_stmt(thd); + /* Remove normal table without logging. Keep tables locked */ + if (mysql_rm_table_no_locks(thd, &table_list, &thd->db, + ddl_log_state_rm, + 0, 0, 0, 0, 1, 1)) + goto err; - lex_string_set(&create_info->org_storage_engine_name, - ha_resolve_storage_engine_name(db_type)); - - if (db_type == view_pseudo_hton) - atomic_replace= false; - - if (atomic_replace) - { - /* NOTE: here FK referencing is checked */ - if (!(thd->variables.option_bits & OPTION_NO_FOREIGN_KEY_CHECKS)) - { - Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); - if (!create_info->table) - { - if (open_table(thd, &table_list, &ot_ctx)) - goto err; - table= table_list.table; - } - FOREIGN_KEY_INFO *fk; - bool res= table->referenced_by_foreign_table(thd, &fk); - if (!create_info->table) - { - (void) close_thread_table(thd, &thd->open_tables); - table= NULL; - } - if (res) - { - if (fk) - my_error(ER_ROW_IS_REFERENCED_2, MYF(0), fk->foreign_table->str); - goto err; - } - } - - if (thd->locked_tables_mode == LTM_LOCK_TABLES || - thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES) - { - if (wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED)) - goto err; - } - else - { - DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, - orig_db.str, - orig_table_name.str, - MDL_EXCLUSIVE)); - } - - /* - Prepare DROP entry for backup log. It will be logged before logging - the CREATE entry when the command succeeds. - */ - backup_log_info *drop_entry= &create_info->drop_entry; - drop_entry->query= { C_STRING_WITH_LEN("DROP") }; - if ((drop_entry->org_partitioned= (partition_engine_name.str != 0))) - drop_entry->org_storage_engine_name= partition_engine_name; - else - lex_string_set(&drop_entry->org_storage_engine_name, - ha_resolve_storage_engine_name(db_type)); - drop_entry->org_database= orig_db; - drop_entry->org_table= orig_table_name; - drop_entry->org_table_id= create_info->org_tabledef_version; - - DBUG_EXECUTE_IF("send_kill_after_delete", thd->set_killed(KILL_QUERY);); - } - else - { - /* - Rollback the empty transaction started in mysql_create_table() - call to open_and_lock_tables() when we are using LOCK TABLES. - */ - (void) trans_rollback_stmt(thd); - - /* Remove normal table without logging. Keep tables locked */ - if (mysql_rm_table_no_locks(thd, &table_list, &thd->db, - create_info->ddl_log_state_rm, - 0, 0, 0, 0, 1, 1)) - goto err; - - /* Locked table was closed */ - create_info->table= table_list.table; - - debug_crash_here("ddl_log_create_after_drop"); - - /* - We have to log this query, even if it failed later to ensure the - drop is done. - */ - thd->variables.option_bits|= OPTION_BINLOG_THIS; - create_info->table_was_deleted= 1; - - DBUG_EXECUTE_IF("send_kill_after_delete", thd->set_killed(KILL_QUERY);); + debug_crash_here("ddl_log_create_after_drop"); - /* - Restart statement transactions for the case of CREATE ... SELECT. - */ - if (thd->lex->first_select_lex()->item_list.elements && - restart_trans_for_tables(thd, thd->lex->query_tables)) - goto err; - } + /* + We have to log this query, even if it failed later to ensure the + drop is done. + */ + thd->variables.option_bits|= OPTION_BINLOG_THIS; + create_info->table_was_deleted= 1; + lex_string_set(&create_info->org_storage_engine_name, + ha_resolve_storage_engine_name(db_type)); + DBUG_EXECUTE_IF("send_kill_after_delete", + thd->set_killed(KILL_QUERY);); + /* + Restart statement transactions for the case of CREATE ... SELECT. + */ + if (thd->lex->first_select_lex()->item_list.elements && + restart_trans_for_tables(thd, thd->lex->query_tables)) + goto err; } else if (options.if_not_exists()) { @@ -4875,19 +4505,18 @@ int create_table_impl(THD *thd, } else { - DBUG_ASSERT(!atomic_replace); - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), orig_table_name.str); + my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name.str); goto err; } - } /* ha_table_exists() */ - } /* else (!create_info->tmp_table()) */ + } + } THD_STAGE_INFO(thd, stage_creating_table); if (check_engine(thd, orig_db.str, orig_table_name.str, create_info)) goto err; - if (create_table_mode & C_ASSISTED_DISCOVERY) + if (create_table_mode == C_ASSISTED_DISCOVERY) { /* check that it's used correctly */ DBUG_ASSERT(alter_info->create_list.elements == 0); @@ -4973,8 +4602,8 @@ int create_table_impl(THD *thd, if (!frm_only) { debug_crash_here("ddl_log_create_before_create_table"); - if (ha_create_table(thd, path.str, orig_db.str, orig_table_name.str, - create_info, frm, 0)) + if (ha_create_table(thd, path.str, db.str, table_name.str, create_info, + frm, 0)) { file->ha_create_partitioning_metadata(path.str, NULL, CHF_DELETE_FLAG); deletefrm(path.str); @@ -5030,40 +4659,21 @@ int create_table_impl(THD *thd, Simple wrapper around create_table_impl() to be used in various version of CREATE TABLE statement. - @param thd Thread object - @param orig_db Database for error messages or atomic replace - @param orig_table_name Table name for error messages or atomic replace - (it's different from table_name for ALTER TABLE) - @param db Database - @param table_name Table name - @param create_info Create information (like MAX_ROWS) - @param alter_info Description of fields and keys for new table - @param[out] is_trans Identifies the type of engine where the table - was created: either trans or non-trans. - @param create_table_mode C_ORDINARY_CREATE, C_ALTER_TABLE, - C_ASSISTED_DISCOVERY or C_ALTER_TABLE_FRM_ONLY. - or any positive number (for C_CREATE_SELECT). - If set to C_ALTER_TABLE_FRM_ONY then no frm or - table is created, only the frm image in memory. - @param[out] frm The frm image. - @result 1 unspecifed error 2 error; Don't log create statement 0 ok -1 Table was used with IF NOT EXISTS and table existed (warning, not error) - - TODO: orig_db, orig_table_name, db, table_name should be moved to create_info */ -int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *orig_db, - const LEX_CSTRING *orig_table_name, +int mysql_create_table_no_lock(THD *thd, + DDL_LOG_STATE *ddl_log_state_create, + DDL_LOG_STATE *ddl_log_state_rm, const LEX_CSTRING *db, const LEX_CSTRING *table_name, Table_specification_st *create_info, Alter_info *alter_info, bool *is_trans, - int create_table_mode, TABLE_LIST *table_list, - LEX_CUSTRING *frm) + int create_table_mode, TABLE_LIST *table_list) { KEY *not_used_1; uint not_used_2; @@ -5071,14 +4681,7 @@ int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *orig_db, uint path_length; char path[FN_REFLEN + 1]; LEX_CSTRING cpath; - LEX_CUSTRING frm_local; - - if (!frm) - { - /* Used in atomic replace */ - frm_local= {0, 0}; - frm= &frm_local; - } + LEX_CUSTRING frm= {0,0}; DBUG_ASSERT(create_info->default_table_charset); @@ -5087,9 +4690,9 @@ int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *orig_db, else { const LEX_CSTRING *alias= table_case_name(create_info, table_name); - uint flags= (create_info->options & HA_CREATE_TMP_ALTER) ? FN_IS_TMP : 0; path_length= build_table_filename(path, sizeof(path) - 1, db->str, - alias->str, "", flags); + alias->str, + "", 0); // Check if we hit FN_REFLEN bytes along with file extension. if (path_length+reg_ext_length > FN_REFLEN) { @@ -5100,12 +4703,12 @@ int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *orig_db, } lex_string_set3(&cpath, path, path_length); - res= create_table_impl(thd, *orig_db, *orig_table_name, *db, *table_name, - cpath, *create_info, create_info, alter_info, - create_table_mode, is_trans, ¬_used_1, ¬_used_2, - frm); - if (frm == &frm_local) - my_free(const_cast(frm_local.str)); + res= create_table_impl(thd, ddl_log_state_create, ddl_log_state_rm, + *db, *table_name, *db, *table_name, cpath, + *create_info, create_info, + alter_info, create_table_mode, + is_trans, ¬_used_1, ¬_used_2, &frm); + my_free(const_cast(frm.str)); if (!res && create_info->sequence) { @@ -5120,7 +4723,8 @@ int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *orig_db, DBUG_ASSERT(thd->is_error()); /* Drop the table as it wasn't completely done */ if (!mysql_rm_table_no_locks(thd, table_list, &thd->db, - NULL, 1, + (DDL_LOG_STATE*) 0, + 1, create_info->tmp_table(), false, true /* Sequence*/, true /* Don't log_query */, @@ -5161,9 +4765,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, int create_table_mode; uint save_thd_create_info_options; bool is_trans= FALSE; - int result; - TABLE_LIST *orig_table= create_table; - const bool atomic_replace= create_info->is_atomic_replace(); + bool result; DBUG_ENTER("mysql_create_table"); DBUG_ASSERT(create_info->default_table_charset); @@ -5172,8 +4774,6 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); - create_info->ddl_log_state_create= &ddl_log_state_create; - create_info->ddl_log_state_rm= &ddl_log_state_rm; /* Copy temporarily the statement flags to thd for lock_table_names() */ save_thd_create_info_options= thd->lex->create_info.options; @@ -5202,7 +4802,6 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, if ((create_info->table= create_table->table)) { pos_in_locked_tables= create_info->table->pos_in_locked_tables; - create_info->pos_in_locked_tables= pos_in_locked_tables; mdl_ticket= create_table->table->mdl_ticket; } @@ -5220,33 +4819,42 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, /* We can abort create table for any table type */ thd->abort_on_warning= thd->is_strict_mode(); - if (atomic_replace && - create_info->make_tmp_table_list(thd, &create_table, &create_table_mode)) + if (mysql_create_table_no_lock(thd, &ddl_log_state_create, &ddl_log_state_rm, + &create_table->db, &create_table->table_name, + create_info, alter_info, &is_trans, + create_table_mode, create_table) > 0) { result= 1; goto err; } - if (mysql_create_table_no_lock(thd, - &orig_table->db, - &orig_table->table_name, - &create_table->db, - &create_table->table_name, create_info, - alter_info, - &is_trans, create_table_mode, - create_table) > 0) + /* + Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES + on a non temporary table + */ + if (thd->locked_tables_mode && pos_in_locked_tables && + create_info->or_replace()) { - result= 1; - goto err; + DBUG_ASSERT(thd->variables.option_bits & OPTION_TABLE_LOCK); + /* + Add back the deleted table and re-created table as a locked 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, false)) + { + thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); + result= 1; + goto err; + } + else + { + TABLE *table= pos_in_locked_tables->table; + table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); + } } err: - if (atomic_replace) - { - create_table= orig_table; - create_info->table= orig_table->table; - } - thd->abort_on_warning= 0; /* In RBR or readonly server we don't need to log CREATE TEMPORARY TABLE */ @@ -5259,8 +4867,6 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, if (create_info->tmp_table()) thd->transaction->stmt.mark_created_temp_table(); - else if (!result && atomic_replace) - result= create_info->finalize_atomic_replace(thd, orig_table); /* Write log if no error or if we already deleted a table */ if (!result || thd->log_current_statement()) @@ -5281,16 +4887,12 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, we should log a delete of it. If create_info->table was not set, it's a normal table and table_creation_was_logged will be set when the share is created. - - NOTE: this is only needed for non-atomic CREATE OR REPLACE and - CREATE TEMPORARY TABLE. */ - DBUG_ASSERT(!atomic_replace); create_info->table->s->table_creation_was_logged= 1; } thd->binlog_xid= thd->query_id; ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - if (ddl_log_state_rm.is_active() && !atomic_replace) + if (ddl_log_state_rm.is_active()) ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); debug_crash_here("ddl_log_create_before_binlog"); if (unlikely(write_bin_log(thd, result ? FALSE : TRUE, thd->query(), @@ -5309,25 +4911,11 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, ddl_log.org_database= create_table->db; ddl_log.org_table= create_table->table_name; ddl_log.org_table_id= create_info->tabledef_version; - if (create_info->drop_entry.query.length) - { - DBUG_ASSERT(atomic_replace); - backup_log_ddl(&create_info->drop_entry); - } backup_log_ddl(&ddl_log); } } - - create_info->finalize_ddl(thd, result); - - /* - Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES - on a non temporary table - */ - if (thd->locked_tables_mode && pos_in_locked_tables && - create_info->or_replace()) - result|= (int) create_info->finalize_locked_tables(thd, result); - + ddl_log_complete(&ddl_log_state_rm); + ddl_log_complete(&ddl_log_state_create); DBUG_RETURN(result); } @@ -5635,15 +5223,10 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, bool src_table_exists= FALSE; uint not_used; int create_res; - TABLE_LIST *orig_table= table; - const bool atomic_replace= create_info->is_atomic_replace(); - int create_table_mode= C_ORDINARY_CREATE; DBUG_ENTER("mysql_create_like_table"); bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); - local_create_info.ddl_log_state_create= &ddl_log_state_create; - local_create_info.ddl_log_state_rm= &ddl_log_state_rm; #ifdef WITH_WSREP if (WSREP(thd) && !thd->wsrep_applier && @@ -5752,22 +5335,14 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, /* The following is needed only in case of lock tables */ if ((local_create_info.table= thd->lex->query_tables->table)) - { - pos_in_locked_tables= local_create_info.table->pos_in_locked_tables; - local_create_info.pos_in_locked_tables= pos_in_locked_tables; - } - - if (atomic_replace && - local_create_info.make_tmp_table_list(thd, &table, &create_table_mode)) - goto err; + pos_in_locked_tables= local_create_info.table->pos_in_locked_tables; res= ((create_res= mysql_create_table_no_lock(thd, - &orig_table->db, - &orig_table->table_name, + &ddl_log_state_create, &ddl_log_state_rm, &table->db, &table->table_name, &local_create_info, &local_alter_info, - &is_trans, create_table_mode, + &is_trans, C_ORDINARY_CREATE, table)) > 0); /* Remember to log if we deleted something */ do_logging= thd->log_current_statement(); @@ -5775,18 +5350,46 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, goto err; /* - Ensure that we have an exclusive lock on target table if we are creating - non-temporary table. We don't have or need the lock if the create failed - because of existing table when using "if exists". + Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES + on a non temporary table */ - DBUG_ASSERT((thd->locked_tables_mode && pos_in_locked_tables && - create_info->or_replace()) || atomic_replace || - (create_info->tmp_table()) || create_res < 0 || - thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str, - table->table_name.str, - MDL_EXCLUSIVE) || - (thd->locked_tables_mode && pos_in_locked_tables && - create_info->if_not_exists())); + if (thd->locked_tables_mode && pos_in_locked_tables && + create_info->or_replace()) + { + /* + Add back the deleted table and re-created table as a locked 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, false)) + { + thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); + res= 1; // We got an error + } + else + { + /* + Get pointer to the newly opened table. We need this to ensure we + don't reopen the table when doing statment logging below. + */ + table->table= pos_in_locked_tables->table; + table->table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); + } + } + else + { + /* + Ensure that we have an exclusive lock on target table if we are creating + non-temporary table. We don't have or need the lock if the create failed + because of existing table when using "if exists". + */ + DBUG_ASSERT((create_info->tmp_table()) || create_res < 0 || + thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str, + table->table_name.str, + MDL_EXCLUSIVE) || + (thd->locked_tables_mode && pos_in_locked_tables && + create_info->if_not_exists())); + } DEBUG_SYNC(thd, "create_table_like_before_binlog"); @@ -5811,20 +5414,10 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, if (thd->is_current_stmt_binlog_format_row() || force_generated_create) { /* - The logging for CREATE .. LIKE is a bit different from normal - create as we want in statement-based logging use the original statement. - - Generated statement means the CREATE TABLE statement without LIKE. Same - thing we do with CREATE .. SELECT in row based logging. It is needed to - get replication working if the original table didn't exists. - - However as an engine can change a table definition, it is probly better to - use CREATE TABLE instead of LIKE to ensure the table definition will be - same on both side. (This is just a guess). - - Since temporary tables are not replicated under row-based replication, - CREATE TABLE .. LIKE needs special treatment. We have some cases to - consider, according to the following decision table: + Since temporary tables are not replicated under row-based + replication, CREATE TABLE ... LIKE ... needs special + treatement. We have some cases to consider, according to the + following decision table: ==== ========= ========= ============================== Case Target Source Write to binary log @@ -5848,7 +5441,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, query.length(0); // Have to zero it since constructor doesn't Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN | MYSQL_OPEN_IGNORE_KILLED); - bool opened_new_table= FALSE; // Whether newly created table is open. + bool new_table= FALSE; // Whether newly created table is open. if (create_res != 0) { @@ -5867,22 +5460,6 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, save_open_strategy= table->open_strategy; table->open_strategy= TABLE_LIST::OPEN_NORMAL; - if (atomic_replace) - { - /* - NOTE: We acquire explicit lock for temporary table just to make - close_thread_table() happy. We open it like a normal table - because it's too complex to open it like tmp_table here. - */ - table->mdl_request.duration= MDL_EXPLICIT; - if (thd->mdl_context.acquire_lock(&table->mdl_request, - thd->variables.lock_wait_timeout)) - { - res= 1; - goto err; - } - } - /* In order for show_create_table() to work we need to open destination table if it is not already open (i.e. if it @@ -5899,7 +5476,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, res= 1; goto err; } - opened_new_table= TRUE; + new_table= TRUE; } /* We have to re-test if the table was a view as the view may not @@ -5922,52 +5499,26 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, */ create_info->used_fields|= HA_CREATE_USED_ENGINE; - const LEX_CSTRING *const db= - table->schema_table ? &INFORMATION_SCHEMA_NAME : &orig_table->db; - const char *force_db= NULL; - if (!thd->db.str || cmp(db, &thd->db)) - force_db= db->str; - int result __attribute__((unused))= - show_create_table_ex(thd, table, - force_db, orig_table->table_name.str, - &query, create_info, WITH_DB_NAME); + show_create_table(thd, table, &query, create_info, WITH_DB_NAME); DBUG_ASSERT(result == 0); // show_create_table() always return 0 do_logging= FALSE; - - thd->binlog_xid= thd->query_id; - ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - if (ddl_log_state_rm.is_active() && !atomic_replace) - ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); - debug_crash_here("ddl_log_create_before_binlog"); - if (write_bin_log(thd, TRUE, query.ptr(), query.length())) { res= 1; - thd->binlog_xid= 0; goto err; } - debug_crash_here("ddl_log_create_after_binlog"); - thd->binlog_xid= 0; - - if (opened_new_table) + if (new_table) { DBUG_ASSERT(thd->open_tables == table->table); /* When opening the table, we ignored the locked tables (MYSQL_OPEN_GET_NEW_TABLE). Now we can close the table without risking to close some locked table. - - For atomic_replace we must remove TABLE and TABLE_SHARE - from cache since they are the objects for temporary table. */ - if (atomic_replace) - table->table->s->tdc->flushed= true; close_thread_table(thd, &thd->open_tables); - if (atomic_replace) - thd->mdl_context.release_lock(table->mdl_request.ticket); } } } @@ -5991,11 +5542,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, /* Remember that tmp table creation was logged so that we know if we should log a delete of it. - - NOTE: this is only needed for non-atomic CREATE OR REPLACE and - CREATE TEMPORARY TABLE. */ - DBUG_ASSERT(!atomic_replace); local_create_info.table->s->table_creation_was_logged= 1; } } @@ -6003,26 +5550,13 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, } err: - if (atomic_replace) - { - table= orig_table; - local_create_info.table= orig_table->table; - - if (!res) - { - res= local_create_info.finalize_atomic_replace(thd, orig_table); - if (res) - do_logging= false; - } - } - if (do_logging) { thd->binlog_xid= thd->query_id; ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - if (ddl_log_state_rm.is_active() && !atomic_replace) + if (ddl_log_state_rm.is_active()) ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); - debug_crash_here("ddl_log_create_before_binlog"); + debug_crash_here("ddl_log_create_before_binlog"); if (res && create_info->table_was_deleted) { /* @@ -6030,7 +5564,6 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, We have to log it. */ DBUG_ASSERT(ddl_log_state_rm.is_active()); - DBUG_ASSERT(!atomic_replace); log_drop_table(thd, &table->db, &table->table_name, &create_info->org_storage_engine_name, create_info->db_type == partition_hton, @@ -6056,24 +5589,11 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ddl_log.org_database= table->db; ddl_log.org_table= table->table_name; ddl_log.org_table_id= local_create_info.tabledef_version; - if (local_create_info.drop_entry.query.length) - { - DBUG_ASSERT(atomic_replace); - backup_log_ddl(&local_create_info.drop_entry); - } backup_log_ddl(&ddl_log); } - local_create_info.finalize_ddl(thd, res); - - /* - Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES - on a non temporary table - */ - if (thd->locked_tables_mode && pos_in_locked_tables && - create_info->or_replace()) - res|= (int) local_create_info.finalize_locked_tables(thd, res); - + ddl_log_complete(&ddl_log_state_rm); + ddl_log_complete(&ddl_log_state_create); DBUG_RETURN(res != 0); } @@ -9981,8 +9501,7 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list, (void) ddl_log_rename_table(&ddl_log_state, old_db_type, &alter_ctx->db, &alter_ctx->table_name, - &alter_ctx->new_db, &alter_ctx->new_alias, - DDL_RENAME_PHASE_TABLE, 0); + &alter_ctx->new_db, &alter_ctx->new_alias); if (mysql_rename_table(old_db_type, &alter_ctx->db, &alter_ctx->table_name, &alter_ctx->new_db, &alter_ctx->new_alias, &table_version, 0)) @@ -10614,8 +10133,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, on the name, now we can safely try to find out for sure. */ if (!(alter_info->partition_flags & ALTER_PARTITION_CONVERT_IN) && - ha_table_exists(thd, &alter_ctx.new_db, &alter_ctx.new_name, - NULL, NULL, NULL, NULL, 0)) + ha_table_exists(thd, &alter_ctx.new_db, &alter_ctx.new_name)) { /* Table will be closed in do_command() */ my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alter_ctx.new_alias.str); @@ -11081,7 +10599,8 @@ do_continue:; Partitioning: part_info is passed via thd->work_part_info */ - error= create_table_impl(thd, alter_ctx.db, alter_ctx.table_name, + error= create_table_impl(thd, (DDL_LOG_STATE*) 0, (DDL_LOG_STATE*) 0, + alter_ctx.db, alter_ctx.table_name, alter_ctx.new_db, alter_ctx.tmp_name, alter_ctx.get_tmp_cstring_path(), thd->lex->create_info, create_info, alter_info, diff --git a/sql/sql_table.h b/sql/sql_table.h index 2cead6fa68387..c9e4d969482fa 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -27,10 +27,8 @@ class Alter_info; class Alter_table_ctx; -struct Atomic_info; class Column_definition; class Create_field; -struct Table_name; struct TABLE_LIST; class THD; struct TABLE; @@ -96,15 +94,50 @@ uint build_tmptable_filename(THD* thd, char *buff, size_t bufflen); bool add_keyword_to_query(THD *thd, String *result, const LEX_CSTRING *keyword, const LEX_CSTRING *add); +/* + mysql_create_table_no_lock can be called in one of the following + mutually exclusive situations: + + - Just a normal ordinary CREATE TABLE statement that explicitly + defines the table structure. + + - CREATE TABLE ... SELECT. It is special, because only in this case, + the list of fields is allowed to have duplicates, as long as one of the + duplicates comes from the select list, and the other doesn't. For + example in + + CREATE TABLE t1 (a int(5) NOT NUL) SELECT b+10 as a FROM t2; + + the list in alter_info->create_list will have two fields `a`. + + - ALTER TABLE, that creates a temporary table #sql-xxx, which will be later + renamed to replace the original table. + + - ALTER TABLE as above, but which only modifies the frm file, it only + creates an frm file for the #sql-xxx, the table in the engine is not + created. + + - Assisted discovery, CREATE TABLE statement without the table structure. + + These situations are distinguished by the following "create table mode" + values, where a CREATE ... SELECT is denoted by any non-negative number + (which should be the number of fields in the SELECT ... part), and other + cases use constants as defined below. +*/ +#define C_CREATE_SELECT(X) ((X) > 0 ? (X) : 0) +#define C_ORDINARY_CREATE 0 +#define C_ALTER_TABLE -1 +#define C_ALTER_TABLE_FRM_ONLY -2 +#define C_ASSISTED_DISCOVERY -3 + int mysql_create_table_no_lock(THD *thd, - const LEX_CSTRING *orig_db, - const LEX_CSTRING *orig_table_name, + DDL_LOG_STATE *ddl_log_state, + DDL_LOG_STATE *ddl_log_state_rm, const LEX_CSTRING *db, const LEX_CSTRING *table_name, Table_specification_st *create_info, Alter_info *alter_info, bool *is_trans, - int create_table_mode, TABLE_LIST *table, - LEX_CUSTRING *frm= NULL); + int create_table_mode, TABLE_LIST *table); handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db, @@ -138,31 +171,6 @@ bool mysql_compare_tables(TABLE *table, HA_CREATE_INFO *create_info, bool *metadata_equal); bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy); -/** - Parameters for rename_table_and_triggers() -*/ -struct rename_param -{ - LEX_CSTRING old_alias, new_alias; - LEX_CUSTRING old_version; - handlerton *from_table_hton; - int rename_flags; /* FN_FROM_IS_TMP, FN_TO_IS_TMP, etc */ - rename_param() : - from_table_hton(NULL), - rename_flags(0) {} -}; -bool -rename_table_and_triggers(THD *thd, rename_param *param, - DDL_LOG_STATE *ddl_log_state, - Table_name *ren_table, const LEX_CSTRING *new_db, - bool skip_error, bool *force_if_exists); -int -rename_check_preconditions(THD *thd, rename_param *param, - Table_name *ren_table, - const LEX_CSTRING *new_db, - const LEX_CSTRING *new_table_name, - const LEX_CSTRING *new_table_alias, - bool if_exists); bool mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db, const LEX_CSTRING *old_name, const LEX_CSTRING *new_db, const LEX_CSTRING *new_name, LEX_CUSTRING *id, diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 81dcda8b39f49..067b921eaf3a9 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1200,11 +1200,9 @@ bool Trigger::add_to_file_list(void* param_arg) */ static bool rm_trigger_file(char *path, const LEX_CSTRING *db, - const LEX_CSTRING *table_name, uint flags, - myf MyFlags) + const LEX_CSTRING *table_name, myf MyFlags) { - build_table_filename(path, FN_REFLEN - 1, db->str, table_name->str, TRG_EXT, - flags); + build_table_filename(path, FN_REFLEN-1, db->str, table_name->str, TRG_EXT, 0); return mysql_file_delete(key_file_trg, path, MyFlags); } @@ -1246,8 +1244,7 @@ bool rm_trigname_file(char *path, const LEX_CSTRING *db, */ bool Table_triggers_list::save_trigger_file(THD *thd, const LEX_CSTRING *db, - const LEX_CSTRING *table_name, - uint flags) + const LEX_CSTRING *table_name) { char file_buff[FN_REFLEN]; LEX_CSTRING file; @@ -1257,7 +1254,7 @@ bool Table_triggers_list::save_trigger_file(THD *thd, const LEX_CSTRING *db, DBUG_RETURN(true); file.length= build_table_filename(file_buff, FN_REFLEN - 1, db->str, table_name->str, - TRG_EXT, flags); + TRG_EXT, 0); file.str= file_buff; DBUG_RETURN(sql_create_definition_file(NULL, &file, &triggers_file_type, (uchar*) this, @@ -1367,12 +1364,12 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables, drop or create ddl_log recovery will ensure that all related trigger files are deleted or the original ones are restored. */ - if (rm_trigger_file(path, &tables->db, &tables->table_name, 0, MYF(MY_WME))) + if (rm_trigger_file(path, &tables->db, &tables->table_name, MYF(MY_WME))) goto err; } else { - if (save_trigger_file(thd, &tables->db, &tables->table_name, 0)) + if (save_trigger_file(thd, &tables->db, &tables->table_name)) goto err; } @@ -1531,8 +1528,7 @@ bool Table_triggers_list::prepare_record_accessors(TABLE *table) bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, TABLE *table, - bool names_only, - uint flags) + bool names_only) { char path_buff[FN_REFLEN]; LEX_CSTRING path; @@ -1541,7 +1537,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, DBUG_ENTER("Table_triggers_list::check_n_load"); path.length= build_table_filename(path_buff, FN_REFLEN - 1, - db->str, table_name->str, TRG_EXT, flags); + db->str, table_name->str, TRG_EXT, 0); path.str= path_buff; // QQ: should we analyze errno somehow ? @@ -2038,7 +2034,7 @@ bool add_table_for_trigger(THD *thd, bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *name, - uint flags, myf MyFlags) + myf MyFlags) { TABLE table; char path[FN_REFLEN]; @@ -2049,11 +2045,11 @@ bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db, init_sql_alloc(key_memory_Table_trigger_dispatcher, &table.mem_root, 8192, 0, MYF(MY_WME)); - if (Table_triggers_list::check_n_load(thd, db, name, &table, true, flags)) + if (Table_triggers_list::check_n_load(thd, db, name, &table, 1)) { result= 1; /* We couldn't parse trigger file, best to just remove it */ - rm_trigger_file(path, db, name, flags, MyFlags); + rm_trigger_file(path, db, name, MyFlags); goto end; } if (table.triggers) @@ -2087,7 +2083,7 @@ bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db, } } } - if (rm_trigger_file(path, db, name, flags, MyFlags)) + if (rm_trigger_file(path, db, name, MyFlags)) result= 1; delete table.triggers; } @@ -2129,8 +2125,7 @@ change_table_name_in_triggers(THD *thd, const LEX_CSTRING *old_db_name, const LEX_CSTRING *new_db_name, const LEX_CSTRING *old_table_name, - const LEX_CSTRING *new_table_name, - uint flags) + const LEX_CSTRING *new_table_name) { struct change_table_name_param param; sql_mode_t save_sql_mode= thd->variables.sql_mode; @@ -2146,15 +2141,13 @@ change_table_name_in_triggers(THD *thd, if (unlikely(thd->is_fatal_error)) return TRUE; /* OOM */ - if (save_trigger_file(thd, new_db_name, new_table_name, - (flags & FN_TO_IS_TMP))) + if (save_trigger_file(thd, new_db_name, new_table_name)) return TRUE; - if (rm_trigger_file(path_buff, old_db_name, old_table_name, - (flags & FN_FROM_IS_TMP), MYF(MY_WME))) + if (rm_trigger_file(path_buff, old_db_name, old_table_name, MYF(MY_WME))) { (void) rm_trigger_file(path_buff, new_db_name, new_table_name, - (flags & FN_TO_IS_TMP), MYF(MY_WME)); + MYF(MY_WME)); return TRUE; } return FALSE; @@ -2304,8 +2297,7 @@ Table_triggers_list::prepare_for_rename(THD *thd, my_strcasecmp(table_alias_charset, old_alias->str, new_table->str)); - if (Table_triggers_list::check_n_load(thd, db, old_table, table, TRUE, - param->rename_flags)) + if (Table_triggers_list::check_n_load(thd, db, old_table, table, TRUE)) { result= 1; goto end; @@ -2392,17 +2384,15 @@ bool Table_triggers_list::change_table_name(THD *thd, This method interfaces the mysql server code protected by an exclusive metadata lock. */ - DBUG_ASSERT((param->rename_flags & FN_FROM_IS_TMP) || - thd->mdl_context.is_lock_owner(MDL_key::TABLE, db->str, + DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db->str, old_table->str, MDL_EXCLUSIVE)); if (table->triggers) { - if (unlikely(table->triggers-> - change_table_name_in_triggers(thd, db, new_db, old_alias, - new_table, - param->rename_flags))) + if (unlikely(table->triggers->change_table_name_in_triggers(thd, db, new_db, + old_alias, + new_table))) { result= 1; goto end; @@ -2420,9 +2410,9 @@ bool Table_triggers_list::change_table_name(THD *thd, (void) table->triggers->change_table_name_in_trignames( upgrading50to51 ? new_db : NULL, db, old_alias, err_trigger); - (void) table->triggers-> - change_table_name_in_triggers(thd, db, new_db, new_table, old_alias, - (param->rename_flags ^ FN_IS_TMP)); + (void) table->triggers->change_table_name_in_triggers( + thd, db, new_db, + new_table, old_alias); result= 1; goto end; } diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index d1aaa9702892b..774dca7cba142 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -3,7 +3,7 @@ /* Copyright (c) 2004, 2011, Oracle and/or its affiliates. - Copyright (c) 2017, 2022, MariaDB Corporation. + Copyright (c) 2017, 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 @@ -89,12 +89,10 @@ class TRIGGER_RENAME_PARAM TABLE table; bool upgrading50to51; bool got_error; - int rename_flags; TRIGGER_RENAME_PARAM() { upgrading50to51= got_error= 0; - rename_flags= 0; table.reset(); } ~TRIGGER_RENAME_PARAM() @@ -257,14 +255,12 @@ class Table_triggers_list: public Sql_alloc bool old_row_is_record1); void empty_lists(); bool create_lists_needed_for_files(MEM_ROOT *root); - bool save_trigger_file(THD *thd, const LEX_CSTRING *db, - const LEX_CSTRING *table_name, uint flags); + bool save_trigger_file(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name); static bool check_n_load(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, - TABLE *table, bool names_only, uint flags); + TABLE *table, bool names_only); static bool drop_all_triggers(THD *thd, const LEX_CSTRING *db, - const LEX_CSTRING *table_name, uint flags, - myf MyFlags); + const LEX_CSTRING *table_name, myf MyFlags); static bool prepare_for_rename(THD *thd, TRIGGER_RENAME_PARAM *param, const LEX_CSTRING *db, const LEX_CSTRING *old_alias, @@ -337,8 +333,7 @@ class Table_triggers_list: public Sql_alloc const LEX_CSTRING *old_db_name, const LEX_CSTRING *new_db_name, const LEX_CSTRING *old_table_name, - const LEX_CSTRING *new_table_name, - uint flags); + const LEX_CSTRING *new_table_name); bool check_for_broken_triggers() { diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 283714bdd1b4e..a0ef89ff0f5fc 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) 2012, 2022, 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 @@ -116,18 +116,18 @@ static const char *fk_info_str(THD *thd, FOREIGN_KEY_INFO *fk_info) error was emitted. */ -bool -TABLE::referenced_by_foreign_table(THD *thd, FOREIGN_KEY_INFO **fk_info) const +static bool +fk_truncate_illegal_if_parent(THD *thd, TABLE *table) { + FOREIGN_KEY_INFO *fk_info; List fk_list; List_iterator_fast it; - *fk_info= NULL; /* Bail out early if the table is not referenced by a foreign key. In this case, the table could only be, if at all, a child table. */ - if (! file->referenced_by_foreign_key()) + if (! table->file->referenced_by_foreign_key()) return FALSE; /* @@ -136,7 +136,7 @@ TABLE::referenced_by_foreign_table(THD *thd, FOREIGN_KEY_INFO **fk_info) const of foreign keys referencing this table in order to check the name of the child (dependent) tables. */ - file->get_parent_foreign_key_list(thd, &fk_list); + table->file->get_parent_foreign_key_list(thd, &fk_list); /* Out of memory when building list. */ if (unlikely(thd->is_error())) @@ -145,22 +145,25 @@ TABLE::referenced_by_foreign_table(THD *thd, FOREIGN_KEY_INFO **fk_info) const it.init(fk_list); /* Loop over the set of foreign keys for which this table is a parent. */ - while ((*fk_info= it++)) + while ((fk_info= it++)) { - if (lex_string_cmp(system_charset_info, (*fk_info)->referenced_db, - &s->db) || - lex_string_cmp(system_charset_info, (*fk_info)->referenced_table, - &s->table_name) || - lex_string_cmp(system_charset_info, (*fk_info)->foreign_db, - &s->db) || - lex_string_cmp(system_charset_info, (*fk_info)->foreign_table, - &s->table_name)) + if (lex_string_cmp(system_charset_info, fk_info->referenced_db, + &table->s->db) || + lex_string_cmp(system_charset_info, fk_info->referenced_table, + &table->s->table_name) || + lex_string_cmp(system_charset_info, fk_info->foreign_db, + &table->s->db) || + lex_string_cmp(system_charset_info, fk_info->foreign_table, + &table->s->table_name)) break; } /* Table is parent in a non-self-referencing foreign key. */ - if (*fk_info) - return TRUE; /* tested by main.trigger-trans */ + if (fk_info) + { + my_error(ER_TRUNCATE_ILLEGAL_FK, MYF(0), fk_info_str(thd, fk_info)); + return TRUE; + } return FALSE; } @@ -190,7 +193,6 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref, int error= 0; uint flags= 0; TABLE *table; - FOREIGN_KEY_INFO *fk_info; DBUG_ENTER("Sql_cmd_truncate_table::handler_truncate"); /* @@ -231,13 +233,8 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref, /* Whether to truncate regardless of foreign keys. */ if (! (thd->variables.option_bits & OPTION_NO_FOREIGN_KEY_CHECKS)) - if (table_ref->table->referenced_by_foreign_table(thd, &fk_info)) - { - /* Table is parent in a non-self-referencing foreign key. */ - if (fk_info) - my_error(ER_TRUNCATE_ILLEGAL_FK, MYF(0), fk_info_str(thd, fk_info)); + if (fk_truncate_illegal_if_parent(thd, table_ref->table)) DBUG_RETURN(TRUNCATE_FAILED_SKIP_BINLOG); - } table= table_ref->table; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 2334cd747e626..689f01c26d817 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1101,8 +1101,7 @@ static int mysql_register_view(THD *thd, DDL_LOG_STATE *ddl_log_state, fn_format(path_buff, file.str, dir.str, "", MY_UNPACK_FILENAME); path.length= strlen(path_buff); - if (ha_table_exists(thd, &view->db, &view->table_name, - NULL, NULL, NULL, NULL, 0)) + if (ha_table_exists(thd, &view->db, &view->table_name)) { old_view_exists= 1; if (lex->create_info.if_not_exists()) diff --git a/sql/structs.h b/sql/structs.h index 1c3873196da94..b36f8e6a1a01a 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -2,7 +2,7 @@ #define STRUCTS_INCLUDED /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. - Copyright (c) 2009, 2022, MariaDB Corporation. + Copyright (c) 2009, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1016,14 +1016,4 @@ class Timeval: public timeval }; -struct Table_name -{ - LEX_CSTRING db; - LEX_CSTRING table_name; - LEX_CSTRING alias; - bool is_set() const - { - return table_name.str; - } -}; #endif /* STRUCTS_INCLUDED */ diff --git a/sql/table.cc b/sql/table.cc index cf1c6e6b3b61a..d5f5d617e9408 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3723,13 +3723,6 @@ bool TABLE::vcol_fix_expr(THD *thd) return false; } - if (!thd->Item_change_list::is_empty()) - { - DBUG_ASSERT(!saved_change_list); - saved_change_list= new Item_change_list; - thd->move_elements_to(saved_change_list); - } - Vcol_expr_context expr_ctx(thd, this); if (expr_ctx.init()) return true; @@ -3750,12 +3743,7 @@ bool TABLE::vcol_fix_expr(THD *thd) bool TABLE::vcol_cleanup_expr(THD *thd) { if (vcol_refix_list.is_empty()) - { - DBUG_ASSERT(!saved_change_list); return false; - } - - thd->rollback_item_tree_changes(); List_iterator it(vcol_refix_list); bool result= false; @@ -3763,15 +3751,6 @@ bool TABLE::vcol_cleanup_expr(THD *thd) while (Virtual_column_info *vcol= it++) result|= vcol->cleanup_session_expr(); - if (saved_change_list) - { - DBUG_ASSERT(!vcol_refix_list.is_empty()); - DBUG_ASSERT(!saved_change_list->is_empty()); - saved_change_list->move_elements_to(thd); - delete saved_change_list; - saved_change_list= NULL; - } - DBUG_ASSERT(!result || thd->get_stmt_da()->is_error()); return result; } diff --git a/sql/table.h b/sql/table.h index 482503828b132..3aabee9a087bc 100644 --- a/sql/table.h +++ b/sql/table.h @@ -35,7 +35,6 @@ #include "sql_i_s.h" #include "sql_type.h" /* vers_kind_t */ #include "privilege.h" /* privilege_t */ -#include "structs.h" /* Buffer for unix timestamp in microseconds: @@ -54,7 +53,6 @@ class Item; /* Needed by ORDER */ typedef Item (*Item_ptr); -class Item_change_list; class Item_subselect; class Item_field; class GRANT_TABLE; @@ -93,7 +91,6 @@ typedef ulonglong nested_join_map; #define tmp_file_prefix "#sql" /**< Prefix for tmp tables */ #define tmp_file_prefix_length 4 -#define backup_file_prefix tmp_file_prefix "-backup-" #define TMP_TABLE_KEY_EXTRA 8 /** @@ -354,7 +351,6 @@ typedef struct st_grant_info enum tmp_table_type { - TMP_TABLE_ATOMIC_REPLACE= -1, NO_TMP_TABLE= 0, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE, INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE }; @@ -724,13 +720,12 @@ class TABLE_STATISTICS_CB void abort_stats_load() { stats_state.abort_load(); } }; - /** This structure is shared between different table objects. There is one instance of table share per one table in the database. */ -struct TABLE_SHARE: public Table_name +struct TABLE_SHARE { TABLE_SHARE() {} /* Remove gcc warning */ @@ -780,6 +775,8 @@ struct TABLE_SHARE: public Table_name To ensure this one can use set_table_cache() methods. */ LEX_CSTRING table_cache_key; + LEX_CSTRING db; /* Pointer to db */ + LEX_CSTRING table_name; /* Table name (for open) */ LEX_CSTRING path; /* Path to .frm file (from datadir) */ LEX_CSTRING normalized_path; /* unpack_filename(path) */ LEX_CSTRING connect_string; @@ -1527,7 +1524,6 @@ struct TABLE bool get_fields_in_item_tree; /* Signal to fix_field */ List vcol_refix_list; private: - Item_change_list *saved_change_list; bool m_needs_reopen; bool created; /* For tmp tables. TRUE <=> tmp table was actually created.*/ public: @@ -1846,7 +1842,6 @@ struct TABLE /* Used in DELETE, DUP REPLACE and insert history row */ void vers_update_end(); void find_constraint_correlated_indexes(); - bool referenced_by_foreign_table(THD *thd, FOREIGN_KEY_INFO **fk_info) const; /** Number of additional fields used in versioned tables */ #define VERSIONING_FIELDS 2 @@ -2212,8 +2207,7 @@ struct TABLE_CHAIN void set_end_pos(TABLE_LIST **pos) { end_pos= pos; } }; - -struct TABLE_LIST: public Table_name +struct TABLE_LIST { TABLE_LIST() {} /* Remove gcc warning */ @@ -2300,7 +2294,10 @@ struct TABLE_LIST: public Table_name TABLE_LIST *next_local; /* link in a global list of all queries tables */ TABLE_LIST *next_global, **prev_global; + LEX_CSTRING db; + LEX_CSTRING table_name; LEX_CSTRING schema_table_name; + LEX_CSTRING alias; const char *option; /* Used by cache index */ Item *on_expr; /* Used with outer join */ Name_resolution_context *on_context; /* For ON expressions */ diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index d5f43dabec0ac..d0194ed49a2d4 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -341,7 +341,6 @@ SET(INNOBASE_SOURCES include/srv0start.h include/srw_lock.h include/sux_lock.h - include/sql_funcs.h include/trx0i_s.h include/trx0purge.h include/trx0rec.h diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 5fe03354fb3aa..7110fe70182e3 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1650,9 +1650,7 @@ dict_table_rename_in_cache( table->name.m_name); dict_mem_foreign_table_name_lookup_set(foreign, FALSE); } - - const bool tmp_id = (strchr(foreign->id, '\xFF') != NULL); - if (!tmp_id && strchr(foreign->id, '/')) { + if (strchr(foreign->id, '/')) { /* This is a >= 4.0.18 format id */ ulint db_len; @@ -1796,16 +1794,10 @@ dict_table_rename_in_cache( } table->foreign_set.erase(it); + fk_set.insert(foreign); - if (!tmp_id) { - fk_set.insert(foreign); - - if (foreign->referenced_table) { - foreign->referenced_table - ->referenced_set.insert(foreign); - } - } else { - dict_foreign_free(foreign); + if (foreign->referenced_table) { + foreign->referenced_table->referenced_set.insert(foreign); } } @@ -3305,18 +3297,66 @@ foreign constraint parser to get the referenced table. heap memory passed in */ char* dict_get_referenced_table( - LEX_CSTRING database_name, /*!< in: table db name */ - LEX_CSTRING table_name, /*!< in: table name */ - dict_table_t** table, /*!< out: table object or NULL */ - mem_heap_t* heap) /*!< in/out: heap memory */ + const char* name, /*!< in: foreign key table name */ + const char* database_name, /*!< in: table db name */ + ulint database_name_len, /*!< in: db name length */ + const char* table_name, /*!< in: table name */ + ulint table_name_len, /*!< in: table name length */ + dict_table_t** table, /*!< out: table object or NULL */ + mem_heap_t* heap, /*!< in/out: heap memory */ + CHARSET_INFO* from_cs) /*!< in: table name charset */ { + char* ref; + char db_name[MAX_DATABASE_NAME_LEN]; + char tbl_name[MAX_TABLE_NAME_LEN]; + CHARSET_INFO* to_cs = &my_charset_filename; + uint errors; + ut_ad(database_name || name); + ut_ad(table_name); + + if (!strncmp(table_name, srv_mysql50_table_name_prefix, + sizeof(srv_mysql50_table_name_prefix) - 1)) { + /* This is a pre-5.1 table name + containing chars other than [A-Za-z0-9]. + Discard the prefix and use raw UTF-8 encoding. */ + table_name += sizeof(srv_mysql50_table_name_prefix) - 1; + table_name_len -= sizeof(srv_mysql50_table_name_prefix) - 1; + + to_cs = system_charset_info; + } + + table_name_len = strconvert(from_cs, table_name, table_name_len, to_cs, + tbl_name, MAX_TABLE_NAME_LEN, &errors); + table_name = tbl_name; + + if (database_name) { + to_cs = &my_charset_filename; + if (!strncmp(database_name, srv_mysql50_table_name_prefix, + sizeof(srv_mysql50_table_name_prefix) - 1)) { + database_name + += sizeof(srv_mysql50_table_name_prefix) - 1; + database_name_len + -= sizeof(srv_mysql50_table_name_prefix) - 1; + to_cs = system_charset_info; + } + + database_name_len = strconvert( + from_cs, database_name, database_name_len, to_cs, + db_name, MAX_DATABASE_NAME_LEN, &errors); + database_name = db_name; + } else { + /* Use the database name of the foreign key table */ + + database_name = name; + database_name_len = dict_get_db_name_len(name); + } + /* Copy database_name, '/', table_name, '\0' */ - const size_t len = database_name.length + table_name.length + 1; - char* ref = static_cast(mem_heap_alloc(heap, len + 1)); - memcpy(ref, database_name.str, database_name.length); - ref[database_name.length] = '/'; - memcpy(ref + database_name.length + 1, table_name.str, - table_name.length + 1); + const size_t len = database_name_len + table_name_len + 1; + ref = static_cast(mem_heap_alloc(heap, len + 1)); + memcpy(ref, database_name, database_name_len); + ref[database_name_len] = '/'; + memcpy(ref + database_name_len + 1, table_name, table_name_len + 1); /* Values; 0 = Store and compare as given; case sensitive 1 = Store and compare in lower; case insensitive @@ -3324,10 +3364,10 @@ dict_get_referenced_table( if (lower_case_table_names == 2) { innobase_casedn_str(ref); *table = dict_sys.load_table({ref, len}); - memcpy(ref, database_name.str, database_name.length); - ref[database_name.length] = '/'; - memcpy(ref + database_name.length + 1, - table_name.str, table_name.length + 1); + memcpy(ref, database_name, database_name_len); + ref[database_name_len] = '/'; + memcpy(ref + database_name_len + 1, table_name, table_name_len + 1); + } else { #ifndef _WIN32 if (lower_case_table_names == 1) { diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index c0ab4bbc521f0..0e937ebe63bcc 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -3143,8 +3143,8 @@ dict_load_foreigns( rec, DICT_FLD__SYS_FOREIGN_FOR_NAME__ID, &len); /* Copy the string because the page may be modified or evicted - after mtr.commit() below (-2 is for \xFF\xFF in tmp constraints). */ - char fk_id[MAX_TABLE_NAME_LEN + NAME_LEN - 2]; + after mtr.commit() below. */ + char fk_id[MAX_TABLE_NAME_LEN + NAME_LEN]; err = DB_SUCCESS; if (UNIV_LIKELY(len < sizeof fk_id)) { memcpy(fk_id, field, len); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 4ffc393575a32..89670e0432c87 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1359,7 +1359,7 @@ static dberr_t fts_drop_table(trx_t *trx, const char *table_name, bool rename) char *tmp= dict_mem_create_temporary_tablename(heap, table->name.m_name, table->id); dberr_t err= row_rename_table_for_mysql(table->name.m_name, tmp, trx, - RENAME_IGNORE_FK); + false); mem_heap_free(heap); if (err != DB_SUCCESS) { @@ -1410,7 +1410,7 @@ fts_rename_one_aux_table( fts_table_new_name[table_new_name_len] = 0; return row_rename_table_for_mysql( - fts_table_old_name, fts_table_new_name, trx, RENAME_IGNORE_FK); + fts_table_old_name, fts_table_new_name, trx, false); } /****************************************************************//** diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e01e16cda4bc9..d91a2436ca65a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5237,7 +5237,7 @@ normalize_table_name_c_low( db_ptr = ptr + 1; norm_len = db_len + name_len + sizeof "/"; - ut_a(norm_len < FN_REFLEN); + ut_a(norm_len < FN_REFLEN - 1); memcpy(norm_name, db_ptr, db_len); @@ -12189,8 +12189,6 @@ create_table_info_t::create_foreign_keys() const char* ref_column_names[MAX_COLS_PER_FK]; char create_name[MAX_DATABASE_NAME_LEN + 1 + MAX_TABLE_NAME_LEN + 1]; - char db_name[MAX_DATABASE_NAME_LEN + 1]; - char t_name[MAX_TABLE_NAME_LEN + 1]; dict_index_t* index = NULL; fkerr_t index_error = FK_SUCCESS; dict_index_t* err_index = NULL; @@ -12198,50 +12196,18 @@ create_table_info_t::create_foreign_keys() const bool tmp_table = m_flags2 & DICT_TF2_TEMPORARY; const CHARSET_INFO* cs = thd_charset(m_thd); const char* operation = "Create "; - const char* basename; + const char* name = m_table_name; enum_sql_command sqlcom = enum_sql_command(thd_sql_command(m_thd)); - LEX_CSTRING name= {m_table_name, strlen(m_table_name)}; if (sqlcom == SQLCOM_ALTER_TABLE) { - dict_table_t* alter_table; - mem_heap_t* heap = mem_heap_create(10000); - DBUG_ASSERT(!m_create_info->is_atomic_replace()); - LEX_CSTRING table_name = m_form->s->table_name; - CHARSET_INFO* to_cs = &my_charset_filename; - - if (!strncmp(table_name.str, srv_mysql50_table_name_prefix, - sizeof srv_mysql50_table_name_prefix - 1)) { - table_name.str - += sizeof srv_mysql50_table_name_prefix - 1; - table_name.length - -= sizeof srv_mysql50_table_name_prefix - 1; - to_cs = system_charset_info; - } - - uint errors; - LEX_CSTRING t; - t.str = t_name; - t.length = strconvert(cs, LEX_STRING_WITH_LEN(table_name), - to_cs, t_name, MAX_TABLE_NAME_LEN, - &errors); - LEX_CSTRING d = m_form->s->db; - - if (!strncmp(d.str, srv_mysql50_table_name_prefix, - sizeof srv_mysql50_table_name_prefix - 1)) { - d.str += sizeof srv_mysql50_table_name_prefix - 1; - d.length -= sizeof srv_mysql50_table_name_prefix - 1; - to_cs = system_charset_info; - } else { - to_cs = &my_charset_filename; - } - - d.length = strconvert(cs, LEX_STRING_WITH_LEN(d), to_cs, - db_name, MAX_DATABASE_NAME_LEN, - &errors); - d.str = db_name; - - char* n = dict_get_referenced_table(d, t, &alter_table, heap); + dict_table_t* table_to_alter; + mem_heap_t* heap = mem_heap_create(10000); + ulint highest_id_so_far; + char* n = dict_get_referenced_table( + name, LEX_STRING_WITH_LEN(m_form->s->db), + LEX_STRING_WITH_LEN(m_form->s->table_name), + &table_to_alter, heap, cs); /* Starting from 4.0.18 and 4.1.2, we generate foreign key id's in the format databasename/tablename_ibfk_[number], where @@ -12251,33 +12217,38 @@ create_table_info_t::create_foreign_keys() /* If we are altering a temporary table, the table name after ALTER TABLE does not correspond to the internal table name, and - alter_table=nullptr. But, we do not support FOREIGN KEY - constraints for temporary tables. */ + table_to_alter is NULL. TODO: should we fix this somehow? */ - if (alter_table) { - n = alter_table->name.m_name; - number = 1 + dict_table_get_highest_foreign_id( - alter_table); + if (table_to_alter) { + n = table_to_alter->name.m_name; + highest_id_so_far = dict_table_get_highest_foreign_id( + table_to_alter); + } else { + highest_id_so_far = 0; } - *innobase_convert_name(create_name, sizeof create_name, - n, strlen(n), m_thd) = '\0'; + char* bufend = innobase_convert_name( + create_name, sizeof create_name, n, strlen(n), m_thd); + create_name[bufend - create_name] = '\0'; + number = highest_id_so_far + 1; mem_heap_free(heap); operation = "Alter "; - } else if (strstr(m_table_name, "#P#") - || strstr(m_table_name, "#p#")) { + } else if (strstr(name, "#P#") || strstr(name, "#p#")) { /* Partitioned table */ create_name[0] = '\0'; } else { - *innobase_convert_name(create_name, sizeof create_name, - LEX_STRING_WITH_LEN(name), m_thd)= '\0'; + char* bufend = innobase_convert_name(create_name, + sizeof create_name, + name, + strlen(name), m_thd); + create_name[bufend - create_name] = '\0'; } Alter_info* alter_info = m_create_info->alter_info; ut_ad(alter_info); List_iterator_fast key_it(alter_info->key_list); - dict_table_t* table = dict_sys.find_table({name.str, name.length}); + dict_table_t* table = dict_sys.find_table({name,strlen(name)}); if (!table) { ib_foreign_warn(m_trx, DB_CANNOT_ADD_CONSTRAINT, create_name, "%s table %s foreign key constraint" @@ -12287,8 +12258,6 @@ create_table_info_t::create_foreign_keys() return (DB_CANNOT_ADD_CONSTRAINT); } - basename = table->name.basename(); - while (Key* key = key_it++) { if (key->type != Key::FOREIGN_KEY) continue; @@ -12326,27 +12295,27 @@ create_table_info_t::create_foreign_keys() col->field_name.length); success = find_col(table, column_names + i); if (!success) { + key_text k(fk); ib_foreign_warn( m_trx, DB_CANNOT_ADD_CONSTRAINT, create_name, "%s table %s foreign key %s constraint" " failed. Column %s was not found.", - operation, create_name, - key_text(fk).str(), + operation, create_name, k.str(), column_names[i]); dict_foreign_free(foreign); return (DB_CANNOT_ADD_CONSTRAINT); } ++i; if (i >= MAX_COLS_PER_FK) { + key_text k(fk); ib_foreign_warn( m_trx, DB_CANNOT_ADD_CONSTRAINT, create_name, "%s table %s foreign key %s constraint" " failed. Too many columns: %u (%u " "allowed).", - operation, create_name, - key_text(fk).str(), i, + operation, create_name, k.str(), i, MAX_COLS_PER_FK); dict_foreign_free(foreign); return (DB_CANNOT_ADD_CONSTRAINT); @@ -12358,9 +12327,9 @@ create_table_info_t::create_foreign_keys() &index_error, &err_col, &err_index); if (!index) { + key_text k(fk); foreign_push_index_error(m_trx, operation, create_name, - key_text(fk).str(), - column_names, + k.str(), column_names, index_error, err_col, err_index, table); dict_foreign_free(foreign); @@ -12369,7 +12338,6 @@ create_table_info_t::create_foreign_keys() if (fk->constraint_name.str) { ulint db_len; - const bool tmp= m_create_info->is_atomic_replace(); /* Catenate 'databasename/' to the constraint name specified by the user: we conceive the constraint as @@ -12379,17 +12347,13 @@ create_table_info_t::create_foreign_keys() db_len = dict_get_db_name_len(table->name.m_name); foreign->id = static_cast(mem_heap_alloc( - foreign->heap, (tmp ? 3 : 2) - + db_len + fk->constraint_name.length)); - - char *pos = foreign->id; - memcpy(pos, table->name.m_name, db_len); - pos += db_len; - *(pos++) = '/'; - if (tmp) { - *(pos++) = '\xFF'; - } - strcpy(pos, fk->constraint_name.str); + foreign->heap, + db_len + fk->constraint_name.length + 2)); + + memcpy(foreign->id, table->name.m_name, db_len); + foreign->id[db_len] = '/'; + strcpy(foreign->id + db_len + 1, + fk->constraint_name.str); } if (foreign->id == NULL) { @@ -12431,79 +12395,32 @@ create_table_info_t::create_foreign_keys() memcpy(foreign->foreign_col_names, column_names, i * sizeof(void*)); - LEX_CSTRING table_name = fk->ref_table; - CHARSET_INFO* to_cs = &my_charset_filename; - uint errors; - LEX_CSTRING t = table_name; - LEX_CSTRING d = fk->ref_db; - - if (!d.str) { - d.str = table->name.m_name; - d.length = size_t(basename - table->name.m_name - 1); - } - - if (m_create_info->is_atomic_replace() - && basename == &table->name.m_name[d.length + 1] - && !memcmp(d.str, table->name.m_name, d.length) - && !strcmp(basename, table_name.str)) { - /* Do not convert names when encountering - self-referential constraints during - CREATE OR REPLACE TABLE. */ - goto name_converted; - } - - if (!strncmp(table_name.str, srv_mysql50_table_name_prefix, - sizeof srv_mysql50_table_name_prefix - 1)) { - table_name.str - += sizeof srv_mysql50_table_name_prefix - 1; - table_name.length - -= sizeof srv_mysql50_table_name_prefix - 1; - to_cs = system_charset_info; - } - - t.str = t_name; - t.length = strconvert(cs, LEX_STRING_WITH_LEN(table_name), - to_cs, t_name, - MAX_TABLE_NAME_LEN, &errors); - - if (!strncmp(d.str, srv_mysql50_table_name_prefix, - sizeof srv_mysql50_table_name_prefix - 1)) { - d.str += sizeof srv_mysql50_table_name_prefix - 1; - d.length -= sizeof srv_mysql50_table_name_prefix - 1; - to_cs = system_charset_info; - } else if (d.str == table->name.m_name) { - goto name_converted; - } else { - to_cs = &my_charset_filename; - } + foreign->referenced_table_name = dict_get_referenced_table( + name, LEX_STRING_WITH_LEN(fk->ref_db), + LEX_STRING_WITH_LEN(fk->ref_table), + &foreign->referenced_table, foreign->heap, cs); - if (d.str != table->name.m_name) { - d.length = strconvert(cs, LEX_STRING_WITH_LEN(d), - to_cs, db_name, - MAX_DATABASE_NAME_LEN, - &errors); - d.str = db_name; + if (!foreign->referenced_table_name) { + return (DB_OUT_OF_MEMORY); } -name_converted: - foreign->referenced_table_name = dict_get_referenced_table( - d, t, &foreign->referenced_table, foreign->heap); if (!foreign->referenced_table && m_trx->check_foreigns) { char buf[MAX_TABLE_NAME_LEN + 1] = ""; + char* bufend; - *innobase_convert_name( + bufend = innobase_convert_name( buf, MAX_TABLE_NAME_LEN, foreign->referenced_table_name, - strlen(foreign->referenced_table_name), m_thd) - = '\0'; + strlen(foreign->referenced_table_name), m_thd); + buf[bufend - buf] = '\0'; + key_text k(fk); ib_foreign_warn(m_trx, DB_CANNOT_ADD_CONSTRAINT, create_name, "%s table %s with foreign key %s " "constraint failed. Referenced table " "%s not found in the data dictionary.", - operation, create_name, - key_text(fk).str(), buf); - return DB_CANNOT_ADD_CONSTRAINT; + operation, create_name, k.str(), buf); + return (DB_CANNOT_ADD_CONSTRAINT); } /* Don't allow foreign keys on partitioned tables yet. */ @@ -12526,6 +12443,7 @@ create_table_info_t::create_foreign_keys() success = find_col(foreign->referenced_table, ref_column_names + j); if (!success) { + key_text k(fk); ib_foreign_warn( m_trx, DB_CANNOT_ADD_CONSTRAINT, @@ -12534,9 +12452,9 @@ create_table_info_t::create_foreign_keys() "constraint failed. " "Column %s was not found.", operation, create_name, - key_text(fk).str(), - ref_column_names[j]); - return DB_CANNOT_ADD_CONSTRAINT; + k.str(), ref_column_names[j]); + + return (DB_CANNOT_ADD_CONSTRAINT); } } ++j; @@ -12556,15 +12474,16 @@ create_table_info_t::create_foreign_keys() &err_index); if (!index) { + key_text k(fk); foreign_push_index_error( - m_trx, operation, create_name, - key_text(fk).str(), + m_trx, operation, create_name, k.str(), column_names, index_error, err_col, err_index, foreign->referenced_table); - return DB_CANNOT_ADD_CONSTRAINT; + + return (DB_CANNOT_ADD_CONSTRAINT); } } else { - ut_a(!m_trx->check_foreigns); + ut_a(m_trx->check_foreigns == FALSE); index = NULL; } @@ -12601,6 +12520,7 @@ create_table_info_t::create_foreign_keys() NULL if the column is not allowed to be NULL! */ + key_text k(fk); ib_foreign_warn( m_trx, DB_CANNOT_ADD_CONSTRAINT, @@ -12611,9 +12531,9 @@ create_table_info_t::create_foreign_keys() "but column '%s' is defined as " "NOT NULL.", operation, create_name, - key_text(fk).str(), col_name); + k.str(), col_name); - return DB_CANNOT_ADD_CONSTRAINT; + return (DB_CANNOT_ADD_CONSTRAINT); } } } @@ -13755,10 +13675,10 @@ int ha_innobase::delete_table(const char *name) @param[in,out] trx InnoDB data dictionary transaction @param[in] from old table name @param[in] to new table name -@param[in] fk how to handle FOREIGN KEY +@param[in] use_fk whether to enforce FOREIGN KEY @return DB_SUCCESS or error code */ static dberr_t innobase_rename_table(trx_t *trx, const char *from, - const char *to, rename_fk fk) + const char *to, bool use_fk) { dberr_t error; char norm_to[FN_REFLEN]; @@ -13776,7 +13696,7 @@ static dberr_t innobase_rename_table(trx_t *trx, const char *from, ut_ad(trx->will_lock); - error = row_rename_table_for_mysql(norm_from, norm_to, trx, fk); + error = row_rename_table_for_mysql(norm_from, norm_to, trx, use_fk); if (error != DB_SUCCESS) { if (error == DB_TABLE_NOT_FOUND @@ -13801,8 +13721,7 @@ static dberr_t innobase_rename_table(trx_t *trx, const char *from, #endif /* _WIN32 */ trx_start_if_not_started(trx, true); error = row_rename_table_for_mysql( - par_case_name, norm_to, trx, - RENAME_IGNORE_FK); + par_case_name, norm_to, trx, false); } } @@ -13983,7 +13902,7 @@ int ha_innobase::truncate() if (error == DB_SUCCESS) { error = innobase_rename_table(trx, ib_table->name.m_name, - temp_name, RENAME_REBUILD); + temp_name, false); if (error == DB_SUCCESS) { error = trx->drop_table(*ib_table); @@ -14176,11 +14095,7 @@ ha_innobase::rename_table( row_mysql_lock_data_dictionary(trx); if (error == DB_SUCCESS) { - error = innobase_rename_table(trx, from, to, - thd_sql_command(thd) - == SQLCOM_ALTER_TABLE - ? RENAME_ALTER_COPY - : RENAME_FK); + error = innobase_rename_table(trx, from, to, true); } DEBUG_SYNC(thd, "after_innobase_rename_table"); @@ -16159,7 +16074,6 @@ ha_innobase::external_lock( /* MySQL is releasing a table lock */ - ut_ad(trx->n_mysql_tables_in_use); trx->n_mysql_tables_in_use--; m_mysql_has_locked = false; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 7cbdf862eb9c8..0b933265fcf8d 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -30,7 +30,6 @@ Smart ALTER TABLE #include #include #include -#include /* Include necessary InnoDB headers */ #include "btr0sea.h" @@ -3191,8 +3190,6 @@ innobase_get_foreign_key_info( ulint num_fk = 0; Alter_info* alter_info = ha_alter_info->alter_info; const CHARSET_INFO* cs = thd_charset(trx->mysql_thd); - char db_name[MAX_DATABASE_NAME_LEN + 1]; - char t_name[MAX_TABLE_NAME_LEN + 1]; DBUG_ENTER("innobase_get_foreign_key_info"); @@ -3257,51 +3254,14 @@ innobase_get_foreign_key_info( add_fk[num_fk] = dict_mem_foreign_create(); - LEX_CSTRING table_name = fk_key->ref_table; - CHARSET_INFO* to_cs = &my_charset_filename; - - if (!strncmp(table_name.str, srv_mysql50_table_name_prefix, - sizeof srv_mysql50_table_name_prefix - 1)) { - table_name.str - += sizeof srv_mysql50_table_name_prefix - 1; - table_name.length - -= sizeof srv_mysql50_table_name_prefix - 1; - to_cs = system_charset_info; - } - - uint errors; - LEX_CSTRING t; - t.str = t_name; - t.length = strconvert(cs, LEX_STRING_WITH_LEN(table_name), - to_cs, t_name, MAX_TABLE_NAME_LEN, - &errors); - LEX_CSTRING d = fk_key->ref_db; - if (!d.str) { - d.str = table->name.m_name; - d.length = table->name.dblen(); - } - - if (!strncmp(d.str, srv_mysql50_table_name_prefix, - sizeof srv_mysql50_table_name_prefix - 1)) { - d.str += sizeof srv_mysql50_table_name_prefix - 1; - d.length -= sizeof srv_mysql50_table_name_prefix - 1; - to_cs = system_charset_info; - } else if (d.str == table->name.m_name) { - goto name_converted; - } else { - to_cs = &my_charset_filename; - } - - d.length = strconvert(cs, LEX_STRING_WITH_LEN(d), to_cs, - db_name, MAX_DATABASE_NAME_LEN, - &errors); - d.str = db_name; - -name_converted: dict_sys.lock(SRW_LOCK_CALL); referenced_table_name = dict_get_referenced_table( - d, t, &referenced_table, add_fk[num_fk]->heap); + table->name.m_name, + LEX_STRING_WITH_LEN(fk_key->ref_db), + LEX_STRING_WITH_LEN(fk_key->ref_table), + &referenced_table, + add_fk[num_fk]->heap, cs); /* Test the case when referenced_table failed to open, if trx->check_foreigns is not set, we should @@ -10212,12 +10172,10 @@ commit_try_rebuild( char* old_name= mem_heap_strdup(ctx->heap, user_table->name.m_name); dberr_t error = row_rename_table_for_mysql(user_table->name.m_name, - ctx->tmp_name, trx, - RENAME_REBUILD); + ctx->tmp_name, trx, false); if (error == DB_SUCCESS) { error = row_rename_table_for_mysql( - rebuilt_table->name.m_name, old_name, trx, - RENAME_REBUILD); + rebuilt_table->name.m_name, old_name, trx, false); if (error == DB_SUCCESS) { /* The statistics for the surviving indexes will be re-inserted in alter_stats_rebuild(). */ diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index fef0e4f9857d9..d867d2f297a7c 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -61,11 +61,15 @@ foreign constraint parser to get the referenced table. heap memory passed in */ char* dict_get_referenced_table( - LEX_CSTRING database_name, /*!< in: table db name */ - LEX_CSTRING table_name, /*!< in: table name */ +/*======================*/ + const char* name, /*!< in: foreign key table name */ + const char* database_name, /*!< in: table db name */ + ulint database_name_len,/*!< in: db name length */ + const char* table_name, /*!< in: table name */ + ulint table_name_len, /*!< in: table name length */ dict_table_t** table, /*!< out: table object or NULL */ - mem_heap_t* heap) /*!< in/out: heap memory */ - MY_ATTRIBUTE((nonnull)); + mem_heap_t* heap, /*!< in: heap memory */ + CHARSET_INFO* from_cs); /*!< in: table name charset */ /*********************************************************************//** Frees a foreign key struct. */ void diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 232ba9293d7e7..3c624621b1ddd 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2021, 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 @@ -369,17 +369,6 @@ row_import_tablespace_for_mysql( row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in MySQL */ MY_ATTRIBUTE((nonnull, warn_unused_result)); -enum rename_fk { - /** ignore FOREIGN KEY constraints */ - RENAME_IGNORE_FK= 0, - /** parse and enforce FOREIGN KEY constaints */ - RENAME_FK, - /** Rename a table as part of a native table-rebuilding DDL operation */ - RENAME_REBUILD, - /** Rename as part of ALTER TABLE...ALGORITHM=COPY */ - RENAME_ALTER_COPY -}; - /*********************************************************************//** Renames a table for MySQL. @return error code or DB_SUCCESS */ @@ -389,7 +378,7 @@ row_rename_table_for_mysql( const char* old_name, /*!< in: old table name */ const char* new_name, /*!< in: new table name */ trx_t* trx, /*!< in/out: transaction */ - rename_fk fk) /*!< in: how to handle + bool use_fk) /*!< in: whether to parse and enforce FOREIGN KEY constraints */ MY_ATTRIBUTE((nonnull, warn_unused_result)); diff --git a/storage/innobase/include/sql_funcs.h b/storage/innobase/include/sql_funcs.h deleted file mode 100644 index 1506a2a5a4813..0000000000000 --- a/storage/innobase/include/sql_funcs.h +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2022, 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 -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-1335 USA - -*****************************************************************************/ - -/** - @file include/sql_funcs.h - - SQL procedures for InnoDB system tables operation -*/ - -/** - Rename foreign keys for rename table - - @see row_rename_table_for_mysql() -*/ -constexpr const char *rename_constraint_ids= -R"===(PROCEDURE RENAME_CONSTRAINT_IDS () IS - gen_constr_prefix CHAR; - new_db_name CHAR; - foreign_id CHAR; - foreign_id2 CHAR; - constr_name CHAR; - new_foreign_id CHAR; - old_db_name_len INT; - new_db_name_len INT; - id_len INT; - offset INT; - offset2 INT; - constr_name_len INT; - found INT; - BEGIN - found := 1; - old_db_name_len := INSTR(:old_table_name, '/') - 1; - new_db_name_len := INSTR(:new_table_name, '/') - 1; - new_db_name := SUBSTR(:new_table_name, 0, - new_db_name_len); - gen_constr_prefix := CONCAT(:old_table_name_utf8, - '_ibfk_'); - WHILE found = 1 LOOP - SELECT ID INTO foreign_id - FROM SYS_FOREIGN - WHERE FOR_NAME = :old_table_name - AND TO_BINARY(FOR_NAME) - = TO_BINARY(:old_table_name) - LOCK IN SHARE MODE; - IF (SQL % NOTFOUND) THEN - found := 0; - ELSE - UPDATE SYS_FOREIGN - SET FOR_NAME = :new_table_name - WHERE ID = foreign_id; - id_len := LENGTH(foreign_id); - foreign_id2 := foreign_id; - offset := INSTR(foreign_id, ')===" "\xFF" R"===('); - IF (SUBSTR(foreign_id, offset, 1) = ')===" "\xFF" R"===(') THEN - offset2 := offset + 1; - ELSE - offset2 := offset; - END IF; - IF (:old_is_tmp > 0 AND offset > 0) THEN - foreign_id := CONCAT(SUBSTR(foreign_id2, 0, offset - 1), - SUBSTR(foreign_id2, offset2, id_len - offset2)); - id_len := id_len - 1; - END IF; - IF (INSTR(foreign_id, '/') > 0) THEN - IF (INSTR(foreign_id, - gen_constr_prefix) > 0) - THEN - offset := INSTR(foreign_id, '_ibfk_') - 1; - new_foreign_id := - CONCAT(:new_table_utf8, - SUBSTR(foreign_id, offset, id_len - offset)); - ELSE - constr_name_len := id_len - old_db_name_len; - constr_name := SUBSTR(foreign_id, old_db_name_len, - constr_name_len); - IF (:new_is_tmp > 0) THEN - new_foreign_id := CONCAT(new_db_name, ')===" "/\xFF\xFF" R"===(', - SUBSTR(constr_name, 1, constr_name_len - 1)); - ELSE - new_foreign_id := CONCAT(new_db_name, constr_name); - END IF; - END IF; - UPDATE SYS_FOREIGN - SET ID = new_foreign_id - WHERE ID = foreign_id2; - UPDATE SYS_FOREIGN_COLS - SET ID = new_foreign_id - WHERE ID = foreign_id2; - END IF; - END IF; - END LOOP; - UPDATE SYS_FOREIGN SET REF_NAME = :new_table_name - WHERE REF_NAME = :old_table_name - AND TO_BINARY(REF_NAME) - = TO_BINARY(:old_table_name); -END;)==="; diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index d7f87d6613987..a8619e788af06 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -67,8 +67,6 @@ Created 9/17/2000 Heikki Tuuri #include -#include "sql_funcs.h" - /*******************************************************************//** Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */ static @@ -2546,7 +2544,7 @@ row_rename_table_for_mysql( const char* old_name, /*!< in: old table name */ const char* new_name, /*!< in: new table name */ trx_t* trx, /*!< in/out: transaction */ - rename_fk fk) /*!< in: how to handle + bool use_fk) /*!< in: whether to parse and enforce FOREIGN KEY constraints */ { dict_table_t* table = NULL; @@ -2631,9 +2629,9 @@ row_rename_table_for_mysql( goto funct_exit; - } else if (fk == RENAME_ALTER_COPY && !old_is_tmp && new_is_tmp) { - /* Non-native ALTER TABLE is renaming the - original table to a temporary name. We want to preserve + } else if (use_fk && !old_is_tmp && new_is_tmp) { + /* MySQL is doing an ALTER TABLE command and it renames the + original table to a temporary table name. We want to preserve the original foreign key constraint definitions despite the name change. An exception is those constraints for which the ALTER TABLE contained DROP FOREIGN KEY .*/ @@ -2677,7 +2675,7 @@ row_rename_table_for_mysql( goto rollback_and_exit; } - if (fk == RENAME_IGNORE_FK || fk == RENAME_FK || !new_is_tmp) { + if (!new_is_tmp) { /* Rename all constraints. */ char new_table_name[MAX_TABLE_NAME_LEN + 1]; char old_table_utf8[MAX_TABLE_NAME_LEN + 1]; @@ -2721,16 +2719,73 @@ row_rename_table_for_mysql( } pars_info_add_str_literal(info, "new_table_utf8", new_table_name); - /* Old foreign ID for temporary constraint was written like this: - db_name/\xFFconstraint_name */ - pars_info_add_int4_literal(info, "old_is_tmp", - (fk == RENAME_FK) && old_is_tmp); - /* New foreign ID for temporary constraint is written like this: - db_name/\xFF\xFFconstraint_name */ - pars_info_add_int4_literal(info, "new_is_tmp", - (fk == RENAME_FK) && new_is_tmp); - err = que_eval_sql(info, rename_constraint_ids, trx); + err = que_eval_sql( + info, + "PROCEDURE RENAME_CONSTRAINT_IDS () IS\n" + "gen_constr_prefix CHAR;\n" + "new_db_name CHAR;\n" + "foreign_id CHAR;\n" + "new_foreign_id CHAR;\n" + "old_db_name_len INT;\n" + "old_t_name_len INT;\n" + "new_db_name_len INT;\n" + "id_len INT;\n" + "offset INT;\n" + "found INT;\n" + "BEGIN\n" + "found := 1;\n" + "old_db_name_len := INSTR(:old_table_name, '/')-1;\n" + "new_db_name_len := INSTR(:new_table_name, '/')-1;\n" + "new_db_name := SUBSTR(:new_table_name, 0,\n" + " new_db_name_len);\n" + "old_t_name_len := LENGTH(:old_table_name);\n" + "gen_constr_prefix := CONCAT(:old_table_name_utf8,\n" + " '_ibfk_');\n" + "WHILE found = 1 LOOP\n" + " SELECT ID INTO foreign_id\n" + " FROM SYS_FOREIGN\n" + " WHERE FOR_NAME = :old_table_name\n" + " AND TO_BINARY(FOR_NAME)\n" + " = TO_BINARY(:old_table_name)\n" + " LOCK IN SHARE MODE;\n" + " IF (SQL % NOTFOUND) THEN\n" + " found := 0;\n" + " ELSE\n" + " UPDATE SYS_FOREIGN\n" + " SET FOR_NAME = :new_table_name\n" + " WHERE ID = foreign_id;\n" + " id_len := LENGTH(foreign_id);\n" + " IF (INSTR(foreign_id, '/') > 0) THEN\n" + " IF (INSTR(foreign_id,\n" + " gen_constr_prefix) > 0)\n" + " THEN\n" + " offset := INSTR(foreign_id, '_ibfk_') - 1;\n" + " new_foreign_id :=\n" + " CONCAT(:new_table_utf8,\n" + " SUBSTR(foreign_id, offset,\n" + " id_len - offset));\n" + " ELSE\n" + " new_foreign_id :=\n" + " CONCAT(new_db_name,\n" + " SUBSTR(foreign_id,\n" + " old_db_name_len,\n" + " id_len - old_db_name_len));\n" + " END IF;\n" + " UPDATE SYS_FOREIGN\n" + " SET ID = new_foreign_id\n" + " WHERE ID = foreign_id;\n" + " UPDATE SYS_FOREIGN_COLS\n" + " SET ID = new_foreign_id\n" + " WHERE ID = foreign_id;\n" + " END IF;\n" + " END IF;\n" + "END LOOP;\n" + "UPDATE SYS_FOREIGN SET REF_NAME = :new_table_name\n" + "WHERE REF_NAME = :old_table_name\n" + " AND TO_BINARY(REF_NAME)\n" + " = TO_BINARY(:old_table_name);\n" + "END;\n", trx); } else if (n_constraints_to_drop > 0) { /* Drop some constraints of tmp tables. */ @@ -2794,7 +2849,7 @@ row_rename_table_for_mysql( err = dict_load_foreigns( new_name, nullptr, trx->id, !old_is_tmp || trx->check_foreigns, - fk == RENAME_FK || fk == RENAME_ALTER_COPY + use_fk ? DICT_ERR_IGNORE_NONE : DICT_ERR_IGNORE_FK_NOKEY, fk_tables); diff --git a/storage/maria/ha_s3.cc b/storage/maria/ha_s3.cc index f432c15820485..c00f42d74c1fa 100644 --- a/storage/maria/ha_s3.cc +++ b/storage/maria/ha_s3.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2019, 2022, MariaDB Corporation. +/* Copyright (C) 2019, 2021 MariaDB Corporation 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 @@ -1031,8 +1031,7 @@ static int ha_s3_init(void *p) s3_hton->show_status= 0; s3_hton->prepare_for_backup= 0; s3_hton->end_backup= 0; - s3_hton->flags= HTON_EXPENSIVE_RENAME | - ((s3_slave_ignore_updates ? HTON_IGNORE_UPDATES : 0) | + s3_hton->flags= ((s3_slave_ignore_updates ? HTON_IGNORE_UPDATES : 0) | (s3_replicate_alter_as_create_select ? HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE : 0)); /* Copy global arguments to s3_access_key and s3_secret_key */ diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 3e305c282e90c..f470d3691c141 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -2881,7 +2881,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info, if (param->testflag & T_SAFE_REPAIR) { - /* Don't repair if we lost more than one row */ + /* Don't repair if we loosed more than one row */ if (sort_info.new_info->s->state.state.records+1 < start_records) { share->state.state.records= start_records; From 749c12782298dce721656cd357e339643a7d8af4 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Mon, 13 Jun 2022 09:44:40 +0200 Subject: [PATCH 078/113] MDEV-5215 prerequisite of prerequisite: if DB is not mentioned in connect ignore errors of switching to it --- client/mysqltest.cc | 25 +++++++++++--- mysql-test/main/init_connect.result | 32 ++++++++--------- mysql-test/main/init_connect.test | 34 +++++++++---------- mysql-test/main/userstat-badlogin-4824.result | 4 +-- mysql-test/main/userstat-badlogin-4824.test | 4 +-- .../include/event_aggregate_load.inc | 8 ++--- .../r/connection_type_notwin.result | 2 +- .../suite/perfschema/r/event_aggregate.result | 8 ++--- .../perfschema/r/event_aggregate_no_a.result | 8 ++--- .../r/event_aggregate_no_a_no_h.result | 8 ++--- .../r/event_aggregate_no_a_no_u.result | 8 ++--- .../r/event_aggregate_no_a_no_u_no_h.result | 8 ++--- .../perfschema/r/event_aggregate_no_h.result | 8 ++--- .../perfschema/r/event_aggregate_no_u.result | 8 ++--- .../r/event_aggregate_no_u_no_h.result | 8 ++--- .../perfschema/t/connection_type_notwin.test | 2 +- .../suite/plugins/r/server_audit.result | 4 +-- 17 files changed, 98 insertions(+), 81 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index f9e6610e87401..99d02094c80fd 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5794,6 +5794,7 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host, con - connection structure to be used host, user, pass, - connection parameters db, port, sock + default_db - 0 if db was explicitly passed DESCRIPTION This function will try to establish a connection to server and handle @@ -5811,7 +5812,8 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host, int connect_n_handle_errors(struct st_command *command, MYSQL* con, const char* host, const char* user, const char* pass, - const char* db, int port, const char* sock) + const char* db, int port, const char* sock, + my_bool default_db) { DYNAMIC_STRING *ds; int failed_attempts= 0; @@ -5852,8 +5854,10 @@ int connect_n_handle_errors(struct st_command *command, mysql_options(con, MYSQL_OPT_CONNECT_ATTR_RESET, 0); mysql_options4(con, MYSQL_OPT_CONNECT_ATTR_ADD, "program_name", "mysqltest"); - while (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0, - CLIENT_MULTI_STATEMENTS)) + while (!mysql_real_connect(con, host, user, pass, + (default_db ? "" : db), + port, (sock ? sock : 0), + CLIENT_MULTI_STATEMENTS)) { /* If we have used up all our connections check whether this @@ -5893,6 +5897,13 @@ int connect_n_handle_errors(struct st_command *command, return 0; /* Not connected */ } + if (default_db && db && db[0] != '\0') + { + mysql_select_db(con, db); + // Ignore errors intentionally + } + + var_set_errno(0); handle_no_error(command); revert_properties(); @@ -5946,6 +5957,7 @@ void do_connect(struct st_command *command) int connect_timeout= 0; char *csname=0; struct st_connection* con_slot; + my_bool default_db; static DYNAMIC_STRING ds_connection_name; static DYNAMIC_STRING ds_host; @@ -6152,7 +6164,12 @@ void do_connect(struct st_command *command) /* Use default db name */ if (ds_database.length == 0) + { dynstr_set(&ds_database, opt_db); + default_db= 1; + } + else + default_db= 0; if (opt_plugin_dir && *opt_plugin_dir) mysql_options(con_slot->mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir); @@ -6167,7 +6184,7 @@ void do_connect(struct st_command *command) if (connect_n_handle_errors(command, con_slot->mysql, ds_host.str,ds_user.str, ds_password.str, ds_database.str, - con_port, ds_sock.str)) + con_port, ds_sock.str, default_db)) { DBUG_PRINT("info", ("Inserting connection %s in connection pool", ds_connection_name.str)); diff --git a/mysql-test/main/init_connect.result b/mysql-test/main/init_connect.result index 11bb603615647..1476d84607861 100644 --- a/mysql-test/main/init_connect.result +++ b/mysql-test/main/init_connect.result @@ -1,23 +1,23 @@ -connect con0,localhost,root,,; +connect con0,localhost,root,,test; connection con0; select hex(@a); hex(@a) NULL -connect con1,localhost,user_1,,; +connect con1,localhost,user_1,,test; connection con1; select hex(@a); hex(@a) 610063 connection con0; set global init_connect="set @a=2;set @b=3"; -connect con2,localhost,user_1,,; +connect con2,localhost,user_1,,test; connection con2; select @a, @b; @a @b 2 3 connection con0; set GLOBAL init_connect=DEFAULT; -connect con3,localhost,user_1,,; +connect con3,localhost,user_1,,test; connection con3; select @a; @a @@ -25,7 +25,7 @@ NULL connection con0; set global init_connect="drop table if exists t1; create table t1(a char(10));\ insert into t1 values ('\0');insert into t1 values('abc')"; -connect con4,localhost,user_1,,; +connect con4,localhost,user_1,,test; connection con4; select hex(a) from t1; hex(a) @@ -33,7 +33,7 @@ hex(a) 616263 connection con0; set GLOBAL init_connect="adsfsdfsdfs"; -connect con5,localhost,user_1,,; +connect con5,localhost,user_1,,test; connection con5; select @a; ERROR 08S01: Aborted connection to db: 'test' user: 'user_1' host: 'localhost' (init_connect command failed) @@ -53,7 +53,7 @@ create table t2 (y int); create user mysqltest1@localhost; grant all privileges on test.* to mysqltest1@localhost; set global init_connect="create procedure p1() select * from t1"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; call p1(); x @@ -69,7 +69,7 @@ begin\ select * from t1;\ set @x = x; end"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; call p1(42); count(*) @@ -84,7 +84,7 @@ select @x; connection con0; disconnect con1; set global init_connect="call p1(4711)"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; select @x; @x @@ -92,7 +92,7 @@ select @x; connection con0; disconnect con1; set global init_connect="drop procedure if exists p1"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; call p1(); ERROR 42000: PROCEDURE test.p1 does not exist @@ -119,7 +119,7 @@ end; end loop; end| set global init_connect="call p1(@sum)"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; select @sum; @sum @@ -136,7 +136,7 @@ execute stmt1 using @v; deallocate prepare stmt1; end| set global init_connect="call p1('t1', 11)"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; select * from t1; x @@ -154,7 +154,7 @@ select count(*) into n from t1; return n; end| set global init_connect="set @x = f1()"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; select @x; @x @@ -162,7 +162,7 @@ select @x; connection con0; disconnect con1; set global init_connect="create view v1 as select f1()"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; select * from v1; f1() @@ -170,7 +170,7 @@ f1() connection con0; disconnect con1; set global init_connect="drop view v1"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; select * from v1; ERROR 42S02: Table 'test.v1' doesn't exist @@ -182,7 +182,7 @@ after insert on t2 for each row insert into t1 values (new.y); set global init_connect="insert into t2 values (13), (17), (19)"; -connect con1,localhost,mysqltest1,,; +connect con1,localhost,mysqltest1,,test; connection con1; select * from t1; x diff --git a/mysql-test/main/init_connect.test b/mysql-test/main/init_connect.test index e96d02fe0d1ba..60549c3458e5d 100644 --- a/mysql-test/main/init_connect.test +++ b/mysql-test/main/init_connect.test @@ -10,31 +10,31 @@ --source include/add_anonymous_users.inc -connect (con0,localhost,root,,); +connect (con0,localhost,root,,test); connection con0; select hex(@a); -connect (con1,localhost,user_1,,); +connect (con1,localhost,user_1,,test); connection con1; select hex(@a); connection con0; set global init_connect="set @a=2;set @b=3"; -connect (con2,localhost,user_1,,); +connect (con2,localhost,user_1,,test); connection con2; select @a, @b; connection con0; set GLOBAL init_connect=DEFAULT; -connect (con3,localhost,user_1,,); +connect (con3,localhost,user_1,,test); connection con3; select @a; connection con0; set global init_connect="drop table if exists t1; create table t1(a char(10));\ insert into t1 values ('\0');insert into t1 values('abc')"; -connect (con4,localhost,user_1,,); +connect (con4,localhost,user_1,,test); connection con4; select hex(a) from t1; connection con0; set GLOBAL init_connect="adsfsdfsdfs"; -connect (con5,localhost,user_1,,); +connect (con5,localhost,user_1,,test); connection con5; # BUG#11755281/47032: ERROR 2006 / ERROR 2013 INSTEAD OF PROPER ERROR MESSAGE # We now throw a proper error message here: @@ -72,7 +72,7 @@ grant all privileges on test.* to mysqltest1@localhost; # Create a simple procedure # set global init_connect="create procedure p1() select * from t1"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; call p1(); drop procedure p1; @@ -88,7 +88,7 @@ begin\ select * from t1;\ set @x = x; end"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; call p1(42); select @x; @@ -99,7 +99,7 @@ disconnect con1; # Just call it - this will not generate any output # set global init_connect="call p1(4711)"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; select @x; @@ -109,7 +109,7 @@ disconnect con1; # Drop the procedure # set global init_connect="drop procedure if exists p1"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; --error ER_SP_DOES_NOT_EXIST call p1(); @@ -145,7 +145,7 @@ end| delimiter ;| # Call the procedure with a cursor set global init_connect="call p1(@sum)"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; select @sum; @@ -167,7 +167,7 @@ end| delimiter ;| # Call the procedure with prepared statements set global init_connect="call p1('t1', 11)"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; select * from t1; @@ -188,7 +188,7 @@ end| delimiter ;| # Invoke a function set global init_connect="set @x = f1()"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; select @x; @@ -198,7 +198,7 @@ disconnect con1; # Create a view # set global init_connect="create view v1 as select f1()"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; select * from v1; @@ -208,7 +208,7 @@ disconnect con1; # Drop the view # set global init_connect="drop view v1"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; --error ER_NO_SUCH_TABLE select * from v1; @@ -225,7 +225,7 @@ drop function f1; # after insert on t2\ # for each row\ # insert into t1 values (new.y)"; -#connect (con1,localhost,mysqltest1,,); +#connect (con1,localhost,mysqltest1,,test); #connection con1; #insert into t2 values (2), (4); #select * from t1; @@ -240,7 +240,7 @@ create trigger trg1 # Invoke trigger set global init_connect="insert into t2 values (13), (17), (19)"; -connect (con1,localhost,mysqltest1,,); +connect (con1,localhost,mysqltest1,,test); connection con1; select * from t1; diff --git a/mysql-test/main/userstat-badlogin-4824.result b/mysql-test/main/userstat-badlogin-4824.result index 757b20e0ce0d8..b32b05e649df3 100644 --- a/mysql-test/main/userstat-badlogin-4824.result +++ b/mysql-test/main/userstat-badlogin-4824.result @@ -2,7 +2,7 @@ set @save_userstat=@@global.userstat; create user foo@localhost identified by 'foo'; flush user_statistics; set global userstat=1; -connect foo, localhost, foo, foo; +connect foo, localhost, foo, foo, test; select 1; 1 1 @@ -12,7 +12,7 @@ select user, bytes_received from information_schema.user_statistics where user = user bytes_received foo 18 connect(localhost,foo,bar,test,MASTER_PORT,MASTER_SOCKET); -connect foo, localhost, foo, bar; +connect foo, localhost, foo, bar, test; ERROR 28000: Access denied for user 'foo'@'localhost' (using password: YES) connection default; select user, bytes_received from information_schema.user_statistics where user = 'foo'; diff --git a/mysql-test/main/userstat-badlogin-4824.test b/mysql-test/main/userstat-badlogin-4824.test index 12cca9f12b3d3..3db3e10da1523 100644 --- a/mysql-test/main/userstat-badlogin-4824.test +++ b/mysql-test/main/userstat-badlogin-4824.test @@ -12,7 +12,7 @@ create user foo@localhost identified by 'foo'; flush user_statistics; set global userstat=1; -connect(foo, localhost, foo, foo); +connect(foo, localhost, foo, foo, test); select 1; disconnect foo; connection default; @@ -27,7 +27,7 @@ select user, bytes_received from information_schema.user_statistics where user = --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR -connect(foo, localhost, foo, bar); +connect(foo, localhost, foo, bar, test); connection default; diff --git a/mysql-test/suite/perfschema/include/event_aggregate_load.inc b/mysql-test/suite/perfschema/include/event_aggregate_load.inc index b27a3113318bf..a4815eafd0fcd 100644 --- a/mysql-test/suite/perfschema/include/event_aggregate_load.inc +++ b/mysql-test/suite/perfschema/include/event_aggregate_load.inc @@ -39,7 +39,7 @@ execute dump_hosts; # # To avoid noise from main, the background threads are disabled. -connect (con1, localhost, user1, , ); +connect (con1, localhost, user1, ,test); --connection default @@ -122,7 +122,7 @@ execute dump_hosts; # select * from performance_schema.events_waits_history_long; # select PROCESSLIST_USER, PROCESSLIST_HOST, INSTRUMENTED from performance_schema.threads; -connect (con2, localhost, user2, , ); +connect (con2, localhost, user2, ,test); --connection default @@ -201,7 +201,7 @@ execute dump_accounts; execute dump_users; execute dump_hosts; -connect (con3, localhost, user3, , ); +connect (con3, localhost, user3, ,test); --connection default @@ -280,7 +280,7 @@ execute dump_accounts; execute dump_users; execute dump_hosts; -connect (con4, localhost, user4, , ); +connect (con4, localhost, user4, ,test); --connection default diff --git a/mysql-test/suite/perfschema/r/connection_type_notwin.result b/mysql-test/suite/perfschema/r/connection_type_notwin.result index d0415cf8df693..079c71345b10d 100644 --- a/mysql-test/suite/perfschema/r/connection_type_notwin.result +++ b/mysql-test/suite/perfschema/r/connection_type_notwin.result @@ -20,7 +20,7 @@ SET @old_general_log_file= @@global.general_log_file; SET GLOBAL general_log_file = '.../log/rewrite_general_con.log'; SET GLOBAL log_output = 'FILE,TABLE'; SET GLOBAL general_log= 'ON'; -connect con1, localhost, root,,; +connect con1, localhost, root,,test; select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE from performance_schema.threads where PROCESSLIST_ID = connection_id(); diff --git a/mysql-test/suite/perfschema/r/event_aggregate.result b/mysql-test/suite/perfschema/r/event_aggregate.result index 4ad4c77394159..805378f585024 100644 --- a/mysql-test/suite/perfschema/r/event_aggregate.result +++ b/mysql-test/suite/perfschema/r/event_aggregate.result @@ -83,7 +83,7 @@ root 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 1 1 -connect con1, localhost, user1, , ; +connect con1, localhost, user1, ,test; connection default; "================== Step 2 ==================" call dump_thread(); @@ -339,7 +339,7 @@ user1 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 2 2 -connect con2, localhost, user2, , ; +connect con2, localhost, user2, ,test; connection default; "================== Step 4 ==================" call dump_thread(); @@ -663,7 +663,7 @@ user2 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 3 3 -connect con3, localhost, user3, , ; +connect con3, localhost, user3, ,test; connection default; "================== Step 6 ==================" call dump_thread(); @@ -1045,7 +1045,7 @@ user3 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 4 4 -connect con4, localhost, user4, , ; +connect con4, localhost, user4, ,test; connection default; "================== Step 8 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/event_aggregate_no_a.result b/mysql-test/suite/perfschema/r/event_aggregate_no_a.result index 9ce3bb7efe84e..30948c2e611a3 100644 --- a/mysql-test/suite/perfschema/r/event_aggregate_no_a.result +++ b/mysql-test/suite/perfschema/r/event_aggregate_no_a.result @@ -82,7 +82,7 @@ root 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 1 1 -connect con1, localhost, user1, , ; +connect con1, localhost, user1, ,test; connection default; "================== Step 2 ==================" call dump_thread(); @@ -308,7 +308,7 @@ user1 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 2 2 -connect con2, localhost, user2, , ; +connect con2, localhost, user2, ,test; connection default; "================== Step 4 ==================" call dump_thread(); @@ -574,7 +574,7 @@ user2 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 3 3 -connect con3, localhost, user3, , ; +connect con3, localhost, user3, ,test; connection default; "================== Step 6 ==================" call dump_thread(); @@ -870,7 +870,7 @@ user3 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 4 4 -connect con4, localhost, user4, , ; +connect con4, localhost, user4, ,test; connection default; "================== Step 8 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_h.result b/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_h.result index 6590c162dda2a..956ea6c6488bd 100644 --- a/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_h.result +++ b/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_h.result @@ -68,7 +68,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS root 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con1, localhost, user1, , ; +connect con1, localhost, user1, ,test; connection default; "================== Step 2 ==================" call dump_thread(); @@ -266,7 +266,7 @@ root 1 1 user1 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con2, localhost, user2, , ; +connect con2, localhost, user2, ,test; connection default; "================== Step 4 ==================" call dump_thread(); @@ -504,7 +504,7 @@ user1 1 1 user2 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con3, localhost, user3, , ; +connect con3, localhost, user3, ,test; connection default; "================== Step 6 ==================" call dump_thread(); @@ -772,7 +772,7 @@ user2 1 1 user3 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con4, localhost, user4, , ; +connect con4, localhost, user4, ,test; connection default; "================== Step 8 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_u.result b/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_u.result index b7cf3b8a5ce4c..fbaa9a8d83f6b 100644 --- a/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_u.result +++ b/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_u.result @@ -81,7 +81,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 1 1 -connect con1, localhost, user1, , ; +connect con1, localhost, user1, ,test; connection default; "================== Step 2 ==================" call dump_thread(); @@ -277,7 +277,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 2 2 -connect con2, localhost, user2, , ; +connect con2, localhost, user2, ,test; connection default; "================== Step 4 ==================" call dump_thread(); @@ -485,7 +485,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 3 3 -connect con3, localhost, user3, , ; +connect con3, localhost, user3, ,test; connection default; "================== Step 6 ==================" call dump_thread(); @@ -695,7 +695,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 4 4 -connect con4, localhost, user4, , ; +connect con4, localhost, user4, ,test; connection default; "================== Step 8 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_u_no_h.result b/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_u_no_h.result index 24de36da22b7e..af535623e9a3d 100644 --- a/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_u_no_h.result +++ b/mysql-test/suite/perfschema/r/event_aggregate_no_a_no_u_no_h.result @@ -67,7 +67,7 @@ execute dump_users; USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con1, localhost, user1, , ; +connect con1, localhost, user1, ,test; connection default; "================== Step 2 ==================" call dump_thread(); @@ -235,7 +235,7 @@ execute dump_users; USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con2, localhost, user2, , ; +connect con2, localhost, user2, ,test; connection default; "================== Step 4 ==================" call dump_thread(); @@ -415,7 +415,7 @@ execute dump_users; USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con3, localhost, user3, , ; +connect con3, localhost, user3, ,test; connection default; "================== Step 6 ==================" call dump_thread(); @@ -597,7 +597,7 @@ execute dump_users; USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con4, localhost, user4, , ; +connect con4, localhost, user4, ,test; connection default; "================== Step 8 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/event_aggregate_no_h.result b/mysql-test/suite/perfschema/r/event_aggregate_no_h.result index 2f0c96d72344c..1209d37667e58 100644 --- a/mysql-test/suite/perfschema/r/event_aggregate_no_h.result +++ b/mysql-test/suite/perfschema/r/event_aggregate_no_h.result @@ -69,7 +69,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS root 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con1, localhost, user1, , ; +connect con1, localhost, user1, ,test; connection default; "================== Step 2 ==================" call dump_thread(); @@ -297,7 +297,7 @@ root 1 1 user1 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con2, localhost, user2, , ; +connect con2, localhost, user2, ,test; connection default; "================== Step 4 ==================" call dump_thread(); @@ -593,7 +593,7 @@ user1 1 1 user2 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con3, localhost, user3, , ; +connect con3, localhost, user3, ,test; connection default; "================== Step 6 ==================" call dump_thread(); @@ -947,7 +947,7 @@ user2 1 1 user3 1 1 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con4, localhost, user4, , ; +connect con4, localhost, user4, ,test; connection default; "================== Step 8 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/event_aggregate_no_u.result b/mysql-test/suite/perfschema/r/event_aggregate_no_u.result index 618201d9b8536..39da9783c9697 100644 --- a/mysql-test/suite/perfschema/r/event_aggregate_no_u.result +++ b/mysql-test/suite/perfschema/r/event_aggregate_no_u.result @@ -82,7 +82,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 1 1 -connect con1, localhost, user1, , ; +connect con1, localhost, user1, ,test; connection default; "================== Step 2 ==================" call dump_thread(); @@ -308,7 +308,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 2 2 -connect con2, localhost, user2, , ; +connect con2, localhost, user2, ,test; connection default; "================== Step 4 ==================" call dump_thread(); @@ -574,7 +574,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 3 3 -connect con3, localhost, user3, , ; +connect con3, localhost, user3, ,test; connection default; "================== Step 6 ==================" call dump_thread(); @@ -870,7 +870,7 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 4 4 -connect con4, localhost, user4, , ; +connect con4, localhost, user4, ,test; connection default; "================== Step 8 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/event_aggregate_no_u_no_h.result b/mysql-test/suite/perfschema/r/event_aggregate_no_u_no_h.result index d6dd322a70c1e..818c61e0630e7 100644 --- a/mysql-test/suite/perfschema/r/event_aggregate_no_u_no_h.result +++ b/mysql-test/suite/perfschema/r/event_aggregate_no_u_no_h.result @@ -68,7 +68,7 @@ execute dump_users; USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con1, localhost, user1, , ; +connect con1, localhost, user1, ,test; connection default; "================== Step 2 ==================" call dump_thread(); @@ -266,7 +266,7 @@ execute dump_users; USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con2, localhost, user2, , ; +connect con2, localhost, user2, ,test; connection default; "================== Step 4 ==================" call dump_thread(); @@ -504,7 +504,7 @@ execute dump_users; USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con3, localhost, user3, , ; +connect con3, localhost, user3, ,test; connection default; "================== Step 6 ==================" call dump_thread(); @@ -772,7 +772,7 @@ execute dump_users; USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS -connect con4, localhost, user4, , ; +connect con4, localhost, user4, ,test; connection default; "================== Step 8 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/t/connection_type_notwin.test b/mysql-test/suite/perfschema/t/connection_type_notwin.test index 07028e1fb81fe..bb96d69076365 100644 --- a/mysql-test/suite/perfschema/t/connection_type_notwin.test +++ b/mysql-test/suite/perfschema/t/connection_type_notwin.test @@ -33,7 +33,7 @@ eval SET GLOBAL general_log_file = '$MYSQLTEST_VARDIR/log/rewrite_general_con.lo SET GLOBAL log_output = 'FILE,TABLE'; SET GLOBAL general_log= 'ON'; -connect(con1, localhost, root,,); +connect(con1, localhost, root,,test); select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE from performance_schema.threads diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result index 9768040aa943c..c676c671a8701 100644 --- a/mysql-test/suite/plugins/r/server_audit.result +++ b/mysql-test/suite/plugins/r/server_audit.result @@ -476,8 +476,8 @@ TIME,HOSTNAME,plug,localhost,ID,0,DISCONNECT,,,0 TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proxies_priv, TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,global_priv, TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'GRANT PROXY ON plug_dest TO plug',0 -TIME,HOSTNAME,plug,localhost,ID,0,CONNECT,test,,0 -TIME,HOSTNAME,plug,localhost,ID,0,PROXY_CONNECT,test,`plug_dest`@`%`,0 +TIME,HOSTNAME,plug,localhost,ID,0,CONNECT,,,0 +TIME,HOSTNAME,plug,localhost,ID,0,PROXY_CONNECT,,`plug_dest`@`%`,0 TIME,HOSTNAME,plug,localhost,ID,ID,QUERY,test,'select USER(),CURRENT_USER()',0 TIME,HOSTNAME,plug,localhost,ID,0,DISCONNECT,test,,0 TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,db, From 594bed9b427704001fc4beca9943006a605305f4 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Mon, 13 Jun 2022 14:37:59 +0200 Subject: [PATCH 079/113] MDEV-5215 prerequisite: remove test and test_* database hacks in the test suite --- mysql-test/include/concurrent.inc | 2 +- mysql-test/include/grant_cache.inc | 4 +- mysql-test/main/brackets.result | 2 - .../main/concurrent_innodb_safelog.result | 2 +- .../main/concurrent_innodb_unsafelog.result | 2 +- mysql-test/main/create_drop_role.result | 1 - mysql-test/main/cte_grant.result | 5 +- mysql-test/main/cte_grant.test | 5 +- mysql-test/main/delete_returning_grant.result | 1 + mysql-test/main/delete_returning_grant.test | 1 + mysql-test/main/derived.result | 1 + mysql-test/main/derived.test | 1 + mysql-test/main/events_grant.result | 2 + mysql-test/main/events_grant.test | 1 + mysql-test/main/flush_notembedded.result | 1 + mysql-test/main/flush_notembedded.test | 1 + mysql-test/main/grant.result | 66 ++++++++++---- mysql-test/main/grant.test | 31 ++++--- mysql-test/main/grant2.result | 25 +++--- mysql-test/main/grant2.test | 24 ++--- mysql-test/main/grant3.result | 1 + mysql-test/main/grant3.test | 1 + mysql-test/main/grant_cache_no_prot.result | 6 +- mysql-test/main/grant_cache_ps_prot.result | 6 +- mysql-test/main/grant_read_only.result | 8 +- mysql-test/main/grant_read_only.test | 4 +- mysql-test/main/information_schema.result | 2 +- mysql-test/main/information_schema_db.result | 7 +- mysql-test/main/information_schema_db.test | 7 +- mysql-test/main/init_connect.result | 11 ++- mysql-test/main/init_connect.test | 11 ++- .../invisible_field_grant_completely.result | 3 +- .../invisible_field_grant_completely.test | 3 +- .../main/invisible_field_grant_system.result | 3 +- .../main/invisible_field_grant_system.test | 3 +- mysql-test/main/join_cache.result | 3 +- mysql-test/main/lock_multi.result | 1 - mysql-test/main/lock_view.result | 1 - mysql-test/main/long_host.result | 11 +-- mysql-test/main/long_host.test | 12 +-- .../main/mysql_upgrade_to_100502.result | 6 +- mysql-test/main/mysql_upgrade_to_100502.test | 6 +- mysql-test/main/mysqldump.result | 4 + mysql-test/main/mysqldump.test | 4 + mysql-test/main/not_embedded_server.result | 1 + mysql-test/main/not_embedded_server.test | 1 + mysql-test/main/partition_symlink.result | 1 + mysql-test/main/partition_symlink.test | 1 + mysql-test/main/plugin_auth.result | 32 +++---- mysql-test/main/plugin_auth.test | 30 +++---- mysql-test/main/plugin_auth_qa_1.result | 35 ++++---- mysql-test/main/plugin_auth_qa_1.test | 35 ++++---- mysql-test/main/plugin_auth_qa_2.result | 2 + mysql-test/main/plugin_auth_qa_2.test | 2 + mysql-test/main/ps_show_log.result | 2 +- mysql-test/main/ps_show_log.test | 2 +- mysql-test/main/read_only.result | 3 + mysql-test/main/read_only.test | 3 + mysql-test/main/read_only_innodb.result | 4 +- mysql-test/main/read_only_innodb.test | 4 +- mysql-test/main/show_check.result | 6 +- mysql-test/main/show_check.test | 6 +- mysql-test/main/sp-security.result | 26 +++--- mysql-test/main/sp-security.test | 24 ++--- mysql-test/main/sql_mode.result | 2 +- mysql-test/main/sql_mode.test | 2 +- .../main/system_mysql_db_fix40123.result | 2 +- .../main/system_mysql_db_fix50030.result | 2 +- .../main/system_mysql_db_fix50117.result | 2 +- mysql-test/main/user_limits.result | 16 ++-- mysql-test/main/user_limits.test | 14 +-- mysql-test/main/userstat-badlogin-4824.result | 2 +- mysql-test/main/userstat-badlogin-4824.test | 2 +- mysql-test/main/view_grant.result | 88 +++++++++---------- mysql-test/main/view_grant.test | 74 ++++++++-------- .../binlog_dmls_on_tmp_tables_readonly.result | 2 +- mysql-test/suite/binlog/r/binlog_grant.result | 11 ++- mysql-test/suite/binlog/r/read_only.result | 2 +- .../suite/binlog/r/read_only_statement.result | 2 +- .../t/binlog_dmls_on_tmp_tables_readonly.test | 2 +- mysql-test/suite/binlog/t/binlog_grant.test | 10 ++- mysql-test/suite/binlog/t/read_only.inc | 2 +- .../engines/funcs/r/rpl_temporary.result | 5 +- .../suite/funcs_1/datadict/is_routines.inc | 2 +- .../suite/funcs_1/datadict/is_schemata.inc | 2 +- .../suite/funcs_1/datadict/is_views.inc | 6 +- .../funcs_1/datadict/processlist_priv.inc | 2 + .../suite/funcs_1/r/innodb_trig_03.result | 2 +- .../suite/funcs_1/r/innodb_trig_03e.result | 38 ++++---- .../suite/funcs_1/r/innodb_trig_0407.result | 6 +- .../suite/funcs_1/r/innodb_trig_08.result | 1 + .../suite/funcs_1/r/is_basics_mixed.result | 1 + .../funcs_1/r/is_check_constraints.result | 2 +- .../is_column_privileges_is_mysql_test.result | 1 - mysql-test/suite/funcs_1/r/is_routines.result | 2 +- .../funcs_1/r/is_routines_embedded.result | 2 +- .../funcs_1/r/is_schema_privileges.result | 38 +------- .../is_schema_privileges_is_mysql_test.result | 18 ---- mysql-test/suite/funcs_1/r/is_schemata.result | 2 +- .../funcs_1/r/is_schemata_embedded.result | 2 +- .../r/is_schemata_is_mysql_test.result | 2 - .../suite/funcs_1/r/is_statistics.result | 12 +++ .../suite/funcs_1/r/is_user_privileges.result | 2 +- mysql-test/suite/funcs_1/r/is_views.result | 6 +- .../suite/funcs_1/r/is_views_embedded.result | 6 +- .../suite/funcs_1/r/memory_trig_03.result | 2 +- .../suite/funcs_1/r/memory_trig_03e.result | 35 ++++---- .../suite/funcs_1/r/memory_trig_0407.result | 6 +- .../suite/funcs_1/r/memory_trig_08.result | 1 + .../suite/funcs_1/r/myisam_trig_03.result | 2 +- .../suite/funcs_1/r/myisam_trig_03e.result | 35 ++++---- .../suite/funcs_1/r/myisam_trig_0407.result | 6 +- .../suite/funcs_1/r/myisam_trig_08.result | 1 + .../funcs_1/r/processlist_priv_no_prot.result | 14 +++ .../funcs_1/r/processlist_priv_ps.result | 14 +++ .../suite/funcs_1/t/is_basics_mixed.test | 1 + .../suite/funcs_1/t/is_check_constraints.test | 2 +- .../suite/funcs_1/t/is_schema_privileges.test | 4 +- mysql-test/suite/funcs_1/t/is_statistics.test | 2 + .../suite/funcs_1/t/is_user_privileges.test | 2 +- .../suite/funcs_1/triggers/triggers_03.inc | 2 +- .../funcs_1/triggers/triggers_03e_columns.inc | 8 +- .../triggers/triggers_03e_db_level.inc | 9 +- .../triggers/triggers_03e_db_table_mix.inc | 6 +- .../funcs_1/triggers/triggers_03e_definer.inc | 4 +- .../funcs_1/triggers/triggers_03e_prepare.inc | 9 +- .../triggers/triggers_03e_table_level.inc | 8 +- .../triggers/triggers_03e_transaction.inc | 3 +- .../suite/funcs_1/triggers/triggers_0407.inc | 8 +- .../suite/funcs_1/triggers/triggers_08.inc | 1 + .../galera/r/galera_create_procedure.result | 1 + .../galera/r/galera_create_trigger.result | 1 + .../suite/galera/r/galera_read_only.result | 1 + mysql-test/suite/galera/r/galera_roles.result | 4 +- .../galera/t/galera_create_procedure.test | 1 + .../suite/galera/t/galera_create_trigger.test | 1 + .../suite/galera/t/galera_read_only.test | 1 + mysql-test/suite/galera/t/galera_roles.test | 4 +- .../suite/innodb/r/partition_locking.result | 2 +- .../suite/innodb/t/partition_locking.test | 2 +- mysql-test/suite/parts/inc/part_exch_qa_7.inc | 1 + .../parts/r/partition_exch_qa_7_innodb.result | 1 + .../parts/r/partition_exch_qa_7_myisam.result | 1 + .../suite/perfschema/r/connect_attrs.result | 2 +- .../perfschema/r/global_read_lock.result | 2 +- .../suite/perfschema/r/privilege.result | 5 +- .../perfschema/r/privilege_table_io.result | 2 - .../suite/perfschema/r/read_only.result | 4 +- .../suite/perfschema/t/connect_attrs.test | 2 +- .../suite/perfschema/t/global_read_lock.test | 2 +- mysql-test/suite/perfschema/t/privilege.test | 5 +- mysql-test/suite/perfschema/t/read_only.test | 4 +- mysql-test/suite/plugins/r/dialog.result | 1 + mysql-test/suite/plugins/r/multiauth.result | 14 +++ mysql-test/suite/plugins/r/pam.result | 4 + .../suite/plugins/r/pam_cleartext.result | 2 + mysql-test/suite/plugins/r/pam_v1.result | 2 + .../suite/plugins/r/qc_info_priv.result | 1 + .../suite/plugins/r/server_audit.result | 6 +- mysql-test/suite/plugins/r/unix_socket.result | 2 + mysql-test/suite/plugins/t/dialog.test | 1 + mysql-test/suite/plugins/t/multiauth.test | 21 +++++ mysql-test/suite/plugins/t/pam.test | 2 + mysql-test/suite/plugins/t/pam_init.inc | 2 + mysql-test/suite/plugins/t/qc_info_priv.test | 1 + mysql-test/suite/plugins/t/server_audit.test | 2 +- mysql-test/suite/plugins/t/unix_socket.test | 5 ++ mysql-test/suite/roles/acl_statistics.result | 8 +- mysql-test/suite/roles/definer.result | 11 ++- mysql-test/suite/roles/definer.test | 10 ++- .../suite/roles/flush_roles-12366.result | 4 - mysql-test/suite/roles/recursive.inc | 1 + mysql-test/suite/roles/recursive.result | 7 ++ mysql-test/suite/roles/recursive_dbug.result | 7 ++ mysql-test/suite/roles/set_role-9614.result | 4 - .../roles/set_role-database-recursive.result | 2 - .../roles/show_create_database-10463.result | 4 - mysql-test/suite/roles/show_grants.result | 2 - mysql-test/suite/rpl/r/rpl_read_only.result | 1 + mysql-test/suite/rpl/r/rpl_temporary.result | 5 +- mysql-test/suite/rpl/t/rpl_read_only.test | 1 + mysql-test/suite/rpl/t/rpl_temporary.test | 6 +- .../sys_vars/inc/secure_timestamp_func.inc | 6 +- .../r/automatic_sp_privileges_func.result | 2 + ...og_bin_trust_function_creators_func.result | 1 + .../suite/sys_vars/r/read_only_func.result | 1 + .../sys_vars/r/secure_timestamp_no.result | 6 +- .../sys_vars/r/secure_timestamp_rpl.result | 6 +- .../sys_vars/r/secure_timestamp_super.result | 6 +- .../sys_vars/r/secure_timestamp_yes.result | 6 +- .../t/automatic_sp_privileges_func.test | 2 + .../log_bin_trust_function_creators_func.test | 1 + .../suite/sys_vars/t/read_only_func.test | 1 + .../suite/versioning/r/not_embedded.result | 2 +- .../suite/versioning/t/not_embedded.test | 2 +- scripts/mysql_test_db.sql | 8 -- 196 files changed, 778 insertions(+), 564 deletions(-) diff --git a/mysql-test/include/concurrent.inc b/mysql-test/include/concurrent.inc index 0a49ae13d4b41..1d65549f8f48b 100644 --- a/mysql-test/include/concurrent.inc +++ b/mysql-test/include/concurrent.inc @@ -49,7 +49,7 @@ let $keep_locks= `SELECT @@global.tx_isolation IN ('REPEATABLE-READ','SERIALIZAB # # Set up privileges and remove user level locks, if exist. # -GRANT USAGE ON test.* TO mysqltest@localhost; +GRANT ALL ON test.* TO mysqltest@localhost; --echo --echo ** diff --git a/mysql-test/include/grant_cache.inc b/mysql-test/include/grant_cache.inc index 467c117056345..b3e96d160fa24 100644 --- a/mysql-test/include/grant_cache.inc +++ b/mysql-test/include/grant_cache.inc @@ -84,9 +84,11 @@ show status like "Qcache_hits%"; # Create the test users grant SELECT on mysqltest.* to mysqltest_1@localhost; +grant SELECT on test.t1 to mysqltest_1@localhost; grant SELECT on mysqltest.t1 to mysqltest_2@localhost; grant SELECT on test.t1 to mysqltest_2@localhost; grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost; +grant SELECT(a) on test.t1 to mysqltest_3@localhost; # The following queries should be fetched from cache connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK); @@ -115,7 +117,7 @@ show status like "Qcache_not_cached"; # Don't use '' as user because it will pick Unix login -connect (unkuser,localhost,unkuser,,,$MASTER_MYPORT,$MASTER_MYSOCK); +connect (unkuser,localhost,unkuser,,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); connection unkuser; show grants for current_user(); diff --git a/mysql-test/main/brackets.result b/mysql-test/main/brackets.result index 3fd19ef968a10..f87afdc0f4793 100644 --- a/mysql-test/main/brackets.result +++ b/mysql-test/main/brackets.result @@ -489,8 +489,6 @@ drop table t1; # select * from ( mysql.db ); Host Db User Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Execute_priv Event_priv Trigger_priv Delete_history_priv -% test Y Y Y Y Y Y N Y Y Y Y Y Y Y Y N N Y Y Y -% test\_% Y Y Y Y Y Y N Y Y Y Y Y Y Y Y N N Y Y Y create table t1 (a int); insert into t1 values (7), (2), (7); select * from (t1); diff --git a/mysql-test/main/concurrent_innodb_safelog.result b/mysql-test/main/concurrent_innodb_safelog.result index 7d120547570aa..40f89c7c65bc8 100644 --- a/mysql-test/main/concurrent_innodb_safelog.result +++ b/mysql-test/main/concurrent_innodb_safelog.result @@ -7,7 +7,7 @@ SELECT @@global.tx_isolation; @@global.tx_isolation REPEATABLE-READ # keep_locks == 1 -GRANT USAGE ON test.* TO mysqltest@localhost; +GRANT ALL ON test.* TO mysqltest@localhost; ** ** two UPDATE's running and both changing distinct result sets diff --git a/mysql-test/main/concurrent_innodb_unsafelog.result b/mysql-test/main/concurrent_innodb_unsafelog.result index 9ae80328c0b4c..3771438bc6651 100644 --- a/mysql-test/main/concurrent_innodb_unsafelog.result +++ b/mysql-test/main/concurrent_innodb_unsafelog.result @@ -8,7 +8,7 @@ SELECT @@global.tx_isolation; @@global.tx_isolation READ-COMMITTED # keep_locks == 0 -GRANT USAGE ON test.* TO mysqltest@localhost; +GRANT ALL ON test.* TO mysqltest@localhost; ** ** two UPDATE's running and both changing distinct result sets diff --git a/mysql-test/main/create_drop_role.result b/mysql-test/main/create_drop_role.result index b7ec45daeae80..7f43751c00722 100644 --- a/mysql-test/main/create_drop_role.result +++ b/mysql-test/main/create_drop_role.result @@ -51,7 +51,6 @@ u1@localhost SHOW DATABASES; Database information_schema -test SELECT CURRENT_ROLE; CURRENT_ROLE NULL diff --git a/mysql-test/main/cte_grant.result b/mysql-test/main/cte_grant.result index 96588d26b6cfa..7a982fcee9af6 100644 --- a/mysql-test/main/cte_grant.result +++ b/mysql-test/main/cte_grant.result @@ -2,7 +2,7 @@ connect root,localhost,root,,test; connection root; create database mysqltest; create user mysqltest_1@localhost; -connect user1,localhost,mysqltest_1,,test; +connect user1,localhost,mysqltest_1,,"*NO-ONE*"; connection user1; connection root; create table mysqltest.t1 (a int, b int); @@ -77,8 +77,7 @@ values (3,10), (7,11), (1,17), (4,15), (2,11), (3,10), (1,15); create user foo@localhost; grant SELECT on db.t1 to foo@localhost; grant SELECT(a) on db.t2 to foo@localhost; -connect con1,localhost,foo,,; -use db; +connect con1,localhost,foo,,db; with cte as (select * from t1 where i < 4) select * from cte; i diff --git a/mysql-test/main/cte_grant.test b/mysql-test/main/cte_grant.test index c6627c05829d1..3e6d50095693d 100644 --- a/mysql-test/main/cte_grant.test +++ b/mysql-test/main/cte_grant.test @@ -12,7 +12,7 @@ create database mysqltest; --enable_warnings create user mysqltest_1@localhost; -connect (user1,localhost,mysqltest_1,,test); +connect (user1,localhost,mysqltest_1,,"*NO-ONE*"); connection user1; connection root; @@ -96,8 +96,7 @@ create user foo@localhost; grant SELECT on db.t1 to foo@localhost; grant SELECT(a) on db.t2 to foo@localhost; ---connect (con1,localhost,foo,,) -use db; +--connect (con1,localhost,foo,,db) with cte as (select * from t1 where i < 4) select * from cte; with cte as (select * from t1 where i < 4 group by i) diff --git a/mysql-test/main/delete_returning_grant.result b/mysql-test/main/delete_returning_grant.result index b41d48a71128e..30fdf41cf67d4 100644 --- a/mysql-test/main/delete_returning_grant.result +++ b/mysql-test/main/delete_returning_grant.result @@ -10,6 +10,7 @@ CREATE DATABASE mysqltest; CREATE TABLE mysqltest.t1 SELECT * FROM t1; GRANT DELETE ON mysqltest.* TO mysqltest_1@localhost; GRANT SELECT(b) ON mysqltest.t1 TO mysqltest_1@localhost; +GRANT SELECT ON test.* TO mysqltest_1@localhost; connect user1,localhost,mysqltest_1,,test; connection user1; DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b; diff --git a/mysql-test/main/delete_returning_grant.test b/mysql-test/main/delete_returning_grant.test index 67613603a7281..d21af3922619a 100644 --- a/mysql-test/main/delete_returning_grant.test +++ b/mysql-test/main/delete_returning_grant.test @@ -23,6 +23,7 @@ CREATE TABLE mysqltest.t1 SELECT * FROM t1; GRANT DELETE ON mysqltest.* TO mysqltest_1@localhost; GRANT SELECT(b) ON mysqltest.t1 TO mysqltest_1@localhost; +GRANT SELECT ON test.* TO mysqltest_1@localhost; connect (user1,localhost,mysqltest_1,,test); diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result index b6310f1a09f25..0d38dd2f9668c 100644 --- a/mysql-test/main/derived.result +++ b/mysql-test/main/derived.result @@ -205,6 +205,7 @@ SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1; x 1 create user mysqltest_1; +grant all on test.* to mysqltest_1; create table t1 select 1 as a; connect con1,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK; connection con1; diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test index 904114e33b9b2..c839ba93a869d 100644 --- a/mysql-test/main/derived.test +++ b/mysql-test/main/derived.test @@ -109,6 +109,7 @@ SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1; # # Connect without a database as user mysqltest_1 create user mysqltest_1; +grant all on test.* to mysqltest_1; create table t1 select 1 as a; connect (con1,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK); connection con1; diff --git a/mysql-test/main/events_grant.result b/mysql-test/main/events_grant.result index 5bdbbf0f8f1ea..5952097a8d2e3 100644 --- a/mysql-test/main/events_grant.result +++ b/mysql-test/main/events_grant.result @@ -13,6 +13,7 @@ CREATE DATABASE events_test2; CREATE USER ev_test@localhost; GRANT ALL ON events_test.* to ev_test@localhost; GRANT ALL ON events_test2.* to ev_test@localhost; +GRANT ALL ON test.* TO ev_test@localhost; REVOKE EVENT ON events_test2.* FROM ev_test@localhost; connect ev_con1,localhost,ev_test,,events_test2; select "NEW CONNECTION"; @@ -24,6 +25,7 @@ ev_test@localhost events_test2 SHOW GRANTS; Grants for ev_test@localhost GRANT USAGE ON *.* TO `ev_test`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `ev_test`@`localhost` GRANT ALL PRIVILEGES ON `events_test`.* TO `ev_test`@`localhost` GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, TRIGGER, DELETE HISTORY ON `events_test2`.* TO `ev_test`@`localhost` "Here comes an error:"; diff --git a/mysql-test/main/events_grant.test b/mysql-test/main/events_grant.test index cd5b691154226..2fe39a6cf2dde 100644 --- a/mysql-test/main/events_grant.test +++ b/mysql-test/main/events_grant.test @@ -16,6 +16,7 @@ CREATE DATABASE events_test2; CREATE USER ev_test@localhost; GRANT ALL ON events_test.* to ev_test@localhost; GRANT ALL ON events_test2.* to ev_test@localhost; +GRANT ALL ON test.* TO ev_test@localhost; REVOKE EVENT ON events_test2.* FROM ev_test@localhost; #now we are on con1 connect (ev_con1,localhost,ev_test,,events_test2); diff --git a/mysql-test/main/flush_notembedded.result b/mysql-test/main/flush_notembedded.result index 25ddeba17d34a..b0fa8a6dfbcda 100644 --- a/mysql-test/main/flush_notembedded.result +++ b/mysql-test/main/flush_notembedded.result @@ -9,6 +9,7 @@ create table mysqltest1.t1 (a int); create user u1@localhost; grant reload on *.* to u1@localhost; grant select on mysqltest1.* to u1@localhost; +grant all on test.* to u1@localhost; connect u1,localhost,u1; flush tables mysqltest1.t1 for export; ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1' diff --git a/mysql-test/main/flush_notembedded.test b/mysql-test/main/flush_notembedded.test index af3b8a00c55ec..193ac026cb44f 100644 --- a/mysql-test/main/flush_notembedded.test +++ b/mysql-test/main/flush_notembedded.test @@ -13,6 +13,7 @@ create table mysqltest1.t1 (a int); create user u1@localhost; grant reload on *.* to u1@localhost; grant select on mysqltest1.* to u1@localhost; +grant all on test.* to u1@localhost; connect u1,localhost,u1; error ER_DBACCESS_DENIED_ERROR; flush tables mysqltest1.t1 for export; diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result index 5e86ea3d810ba..9e0ec851a8584 100644 --- a/mysql-test/main/grant.result +++ b/mysql-test/main/grant.result @@ -517,7 +517,7 @@ grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost; grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost; grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost; grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost; -connect conn1,localhost,mysqltest_3,,; +connect conn1,localhost,mysqltest_3,,"*NO-ONE*",; connection conn1; SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES WHERE GRANTEE = '''mysqltest_3''@''localhost''' @@ -859,24 +859,29 @@ mysqltest_8 '%' mysqltest_8 'host8' Schema privileges grant select on mysqltest.* to mysqltest_8@''; +grant select on test.* to mysqltest_8@''; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` GRANT SELECT ON `mysqltest`.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` grant select on mysqltest.* to mysqltest_8@; show grants for mysqltest_8@; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` GRANT SELECT ON `mysqltest`.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` grant select on mysqltest.* to mysqltest_8; show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` GRANT SELECT ON `mysqltest`.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` select * from information_schema.schema_privileges where grantee like "'mysqltest_8'%"; GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE 'mysqltest_8'@'%' def mysqltest SELECT NO +'mysqltest_8'@'%' def test SELECT NO connect conn3,localhost,mysqltest_8,,; select * from t1; a @@ -886,25 +891,31 @@ revoke select on mysqltest.* from mysqltest_8@''; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` select * from information_schema.schema_privileges where grantee like "'mysqltest_8'%"; GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE +'mysqltest_8'@'%' def test SELECT NO flush privileges; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` show grants for mysqltest_8@; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` grant select on mysqltest.* to mysqltest_8@''; flush privileges; show grants for mysqltest_8@; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` GRANT SELECT ON `mysqltest`.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` revoke select on mysqltest.* from mysqltest_8@''; flush privileges; Column privileges @@ -913,19 +924,23 @@ grant update (a) on t1 to mysqltest_8; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE (a) ON `test`.`t1` TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE (a) ON `test`.`t1` TO `mysqltest_8`@`%` flush privileges; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE (a) ON `test`.`t1` TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE (a) ON `test`.`t1` TO `mysqltest_8`@`%` select * from information_schema.column_privileges; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE @@ -939,37 +954,45 @@ revoke update (a) on t1 from mysqltest_8@''; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` select * from information_schema.column_privileges; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE flush privileges; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` Table privileges grant update on t1 to mysqltest_8@''; grant update on t1 to mysqltest_8; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE ON `test`.`t1` TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE ON `test`.`t1` TO `mysqltest_8`@`%` flush privileges; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE ON `test`.`t1` TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE ON `test`.`t1` TO `mysqltest_8`@`%` select * from information_schema.table_privileges; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE @@ -985,9 +1008,11 @@ revoke update on t1 from mysqltest_8@''; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` select * from information_schema.table_privileges; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE 'mariadb.sys'@'localhost' def mysql global_priv SELECT NO @@ -996,9 +1021,11 @@ flush privileges; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` "DROP USER" should clear privileges grant all privileges on mysqltest.* to mysqltest_8@''; grant select on mysqltest.* to mysqltest_8@''; @@ -1008,11 +1035,13 @@ grant all privileges on mysqltest.* to mysqltest_8; show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT ALL PRIVILEGES ON `mysqltest`.* TO `mysqltest_8`@`%` GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT ALL PRIVILEGES ON `mysqltest`.* TO `mysqltest_8`@`%` GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO `mysqltest_8`@`%` select * from information_schema.user_privileges @@ -1030,11 +1059,13 @@ show grants for mysqltest_8@''; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` GRANT ALL PRIVILEGES ON `mysqltest`.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO `mysqltest_8`@`%` show grants for mysqltest_8; Grants for mysqltest_8@% GRANT USAGE ON *.* TO `mysqltest_8`@`%` GRANT ALL PRIVILEGES ON `mysqltest`.* TO `mysqltest_8`@`%` +GRANT SELECT ON `test`.* TO `mysqltest_8`@`%` GRANT UPDATE, UPDATE (a) ON `test`.`t1` TO `mysqltest_8`@`%` drop user mysqltest_8@''; show grants for mysqltest_8@''; @@ -1066,7 +1097,7 @@ GRANT SHOW VIEW ON mysqltest2.v_ny TO 'mysqltest_1'@'localhost' IDENTIFIE GRANT SELECT ON mysqltest2.v_yn TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1'; GRANT SELECT ON mysqltest2.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1'; GRANT SHOW VIEW,SELECT ON mysqltest2.v_yy TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1'; -connect mysqltest_1, localhost, mysqltest_1, mysqltest_1,; +connect mysqltest_1, localhost, mysqltest_1, mysqltest_1,"*NO-ONE*"; SHOW CREATE VIEW mysqltest2.v_nn; ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table `mysqltest2`.`v_nn` SHOW CREATE TABLE mysqltest2.v_nn; @@ -1550,7 +1581,7 @@ select db, routine_name, routine_type, proc_priv from mysql.procs_priv where use db routine_name routine_type proc_priv mysqltest1 f1 FUNCTION Execute mysqltest1 p1 PROCEDURE Execute -connect bug36544_con1,localhost,mysqluser1,,; +connect bug36544_con1,localhost,mysqluser1,,"*NO-ONE*"; call mysqltest1.p1(); select mysqltest1.f1(); mysqltest1.f1() @@ -1579,7 +1610,7 @@ Grants for mysqluser1@localhost GRANT USAGE ON *.* TO `mysqluser1`@`localhost` select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost'; db routine_name routine_type proc_priv -connect bug36544_con2,localhost,mysqluser1,,; +connect bug36544_con2,localhost,mysqluser1,,"*NO-ONE*"; # Newly created user should not be able to access any of the routines. call mysqltest1.p1(); ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.p1' @@ -1661,7 +1692,7 @@ select db, routine_name, routine_type, proc_priv from mysql.procs_priv where use db routine_name routine_type proc_priv select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1' and host='localhost'; db table_name table_priv -connect bug36544_con3,localhost,mysqluser1,,; +connect bug36544_con3,localhost,mysqluser1,,"*NO-ONE*"; # Newly created user should not be able to access to any of the # stored routines or tables. call mysqltest1.p1(); @@ -1693,7 +1724,7 @@ select db, table_name, table_priv from mysql.tables_priv where user='mysqluser10 db table_name table_priv mysqltest1 t11 Select mysqltest1 t22 Select -connect bug36544_con4,localhost,mysqluser10,,; +connect bug36544_con4,localhost,mysqluser10,,"*NO-ONE*"; call mysqltest1.p1(); select mysqltest1.f1(); mysqltest1.f1() @@ -1826,7 +1857,7 @@ SHOW GRANTS FOR 'user1'@'localhost'; Grants for user1@localhost GRANT USAGE ON *.* TO `user1`@`localhost` GRANT CREATE, CREATE ROUTINE ON `db1`.* TO `user1`@`localhost` -connect con1,localhost,user1,,; +connect con1,localhost,user1,,"*NO-ONE*"; ** Connect as user1 and create a procedure. ** The creation will imply implicitly assigned ** EXECUTE and ALTER ROUTINE privileges to @@ -1843,7 +1874,7 @@ BEGIN SET @x = 0; REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; END ;|| -connect con2,localhost,user2,,; +connect con2,localhost,user2,,"*NO-ONE*"; ** Connect as user2 and create a procedure. ** Implicitly assignment of privileges will ** fail because the user2@localhost is an @@ -2676,13 +2707,13 @@ DROP USER foo@'127.0.0.1'; create user foo@localhost; create database foodb; grant create routine on foodb.* to foo@localhost; -connect con1,localhost,foo; +connect con1,localhost,foo,,foodb; create procedure fooproc() select 'i am fooproc'; show grants; Grants for foo@localhost GRANT USAGE ON *.* TO `foo`@`localhost` GRANT CREATE ROUTINE ON `foodb`.* TO `foo`@`localhost` -GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO `foo`@`localhost` +GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `foodb`.`fooproc` TO `foo`@`localhost` disconnect con1; connection default; rename table mysql.procs_priv to mysql.procs_priv1; @@ -2701,9 +2732,9 @@ show grants for foo@localhost; Grants for foo@localhost GRANT USAGE ON *.* TO `foo`@`localhost` GRANT CREATE ROUTINE ON `foodb`.* TO `foo`@`localhost` -GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO `foo`@`localhost` +GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `foodb`.`fooproc` TO `foo`@`localhost` drop user foo@localhost; -drop procedure fooproc; +drop procedure foodb.fooproc; drop database foodb; # # Bug#11756966 - 48958: STORED PROCEDURES CAN BE LEVERAGED TO BYPASS @@ -2713,14 +2744,13 @@ DROP DATABASE IF EXISTS secret; DROP DATABASE IF EXISTS no_such_db; CREATE DATABASE secret; GRANT USAGE ON *.* TO untrusted@localhost; -connect con1, localhost, untrusted; +connect con1, localhost, untrusted,,"*NO-ONE*"; SHOW GRANTS; Grants for untrusted@localhost GRANT USAGE ON *.* TO `untrusted`@`localhost` SHOW DATABASES; Database information_schema -test # Both statements below should fail with the same error. # They used to give different errors, thereby # hinting that the secret database exists. @@ -2780,7 +2810,7 @@ DROP USER dummy@localhost; CREATE USER foo; CREATE DATABASE db; CREATE TABLE db.t (a INT); -connect con1,localhost,foo,,; +connect con1,localhost,foo,,"*NO-ONE*"; GRANT ALL ON db.t TO foo; ERROR 42000: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, GRANT, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW ... command denied to user 'foo'@'localhost' for table `db`.`t` GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, GRANT OPTION, REFERENCES, @@ -2834,12 +2864,14 @@ DROP USER bar3@localhost; # # MDEV-17946 : Unsorted acl_dbs after RENAME USER # +CREATE USER a; CREATE USER foo; GRANT SELECT ON test.* TO foo; -RENAME USER '' TO 'name'; +RENAME USER 'a' TO 'name'; GRANT UPDATE ON test.* TO foo; -RENAME USER 'name' to ''; +RENAME USER 'name' to 'a'; DROP USER foo; +DROP USER a; # # End of 10.4 tests # diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test index a243967a9c7be..69bb050778db8 100644 --- a/mysql-test/main/grant.test +++ b/mysql-test/main/grant.test @@ -327,7 +327,7 @@ grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost; grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost; grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost; grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost; -connect (conn1,localhost,mysqltest_3,,); +connect (conn1,localhost,mysqltest_3,,"*NO-ONE*",); connection conn1; SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES WHERE GRANTEE = '''mysqltest_3''@''localhost''' @@ -596,6 +596,7 @@ select user, QUOTE(host) from mysql.user where user="mysqltest_8"; --echo Schema privileges grant select on mysqltest.* to mysqltest_8@''; +grant select on test.* to mysqltest_8@''; show grants for mysqltest_8@''; grant select on mysqltest.* to mysqltest_8@; show grants for mysqltest_8@; @@ -723,7 +724,7 @@ GRANT SELECT ON mysqltest2.v_yn TO 'mysqltest_1'@'localhost' IDENTIFIE GRANT SELECT ON mysqltest2.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1'; GRANT SHOW VIEW,SELECT ON mysqltest2.v_yy TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1'; -connect (mysqltest_1, localhost, mysqltest_1, mysqltest_1,); +connect (mysqltest_1, localhost, mysqltest_1, mysqltest_1,"*NO-ONE*"); # fail because of missing SHOW VIEW (have generic SELECT) --error ER_TABLEACCESS_DENIED_ERROR @@ -1369,7 +1370,7 @@ grant execute on procedure mysqltest1.p1 to mysqluser1@localhost; --echo # in privilege tables and in in-memory structures. show grants for mysqluser1@localhost; select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost'; ---connect (bug36544_con1,localhost,mysqluser1,,) +--connect (bug36544_con1,localhost,mysqluser1,,"*NO-ONE*") call mysqltest1.p1(); select mysqltest1.f1(); @@ -1396,7 +1397,7 @@ select mysqltest1.f1(); create user mysqluser1@localhost; show grants for mysqluser1@localhost; select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost'; ---connect (bug36544_con2,localhost,mysqluser1,,) +--connect (bug36544_con2,localhost,mysqluser1,,"*NO-ONE*") --echo # Newly created user should not be able to access any of the routines. --error ER_PROCACCESS_DENIED_ERROR call mysqltest1.p1(); @@ -1463,7 +1464,7 @@ create user mysqluser1@localhost; show grants for mysqluser1@localhost; select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost'; select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1' and host='localhost'; ---connect (bug36544_con3,localhost,mysqluser1,,) +--connect (bug36544_con3,localhost,mysqluser1,,"*NO-ONE*") --echo # Newly created user should not be able to access to any of the --echo # stored routines or tables. --error ER_PROCACCESS_DENIED_ERROR @@ -1484,7 +1485,7 @@ select * from mysqltest1.t22; show grants for mysqluser10@localhost; select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser10' and host='localhost'; select db, table_name, table_priv from mysql.tables_priv where user='mysqluser10' and host='localhost'; ---connect (bug36544_con4,localhost,mysqluser10,,) +--connect (bug36544_con4,localhost,mysqluser10,,"*NO-ONE*") call mysqltest1.p1(); select mysqltest1.f1(); select * from mysqltest1.t11; @@ -1677,7 +1678,7 @@ GRANT CREATE ON db1.* TO 'user2'@'%'; GRANT CREATE ROUTINE ON db1.* TO 'user2'@'%'; FLUSH PRIVILEGES; SHOW GRANTS FOR 'user1'@'localhost'; -connect (con1,localhost,user1,,); +connect (con1,localhost,user1,,"*NO-ONE*"); --echo ** Connect as user1 and create a procedure. --echo ** The creation will imply implicitly assigned --echo ** EXECUTE and ALTER ROUTINE privileges to @@ -1693,7 +1694,7 @@ CREATE PROCEDURE db1.proc1(p1 INT) END ;|| DELIMITER ;|| -connect (con2,localhost,user2,,); +connect (con2,localhost,user2,,"*NO-ONE*"); --echo ** Connect as user2 and create a procedure. --echo ** Implicitly assignment of privileges will --echo ** fail because the user2@localhost is an @@ -2170,7 +2171,7 @@ DROP USER foo@'127.0.0.1'; create user foo@localhost; create database foodb; grant create routine on foodb.* to foo@localhost; -connect con1,localhost,foo; +connect con1,localhost,foo,,foodb; create procedure fooproc() select 'i am fooproc'; show grants; disconnect con1; @@ -2183,7 +2184,7 @@ show grants for foo@localhost; flush privileges; show grants for foo@localhost; drop user foo@localhost; -drop procedure fooproc; +drop procedure foodb.fooproc; drop database foodb; @@ -2200,7 +2201,7 @@ DROP DATABASE IF EXISTS no_such_db; CREATE DATABASE secret; GRANT USAGE ON *.* TO untrusted@localhost; -connect (con1, localhost, untrusted); +connect (con1, localhost, untrusted,,"*NO-ONE*"); SHOW GRANTS; SHOW DATABASES; @@ -2265,7 +2266,7 @@ CREATE USER foo; CREATE DATABASE db; CREATE TABLE db.t (a INT); ---connect (con1,localhost,foo,,) +--connect (con1,localhost,foo,,"*NO-ONE*") --error ER_TABLEACCESS_DENIED_ERROR GRANT ALL ON db.t TO foo; @@ -2336,12 +2337,14 @@ DROP USER bar3@localhost; --echo # --echo # MDEV-17946 : Unsorted acl_dbs after RENAME USER --echo # +CREATE USER a; CREATE USER foo; GRANT SELECT ON test.* TO foo; -RENAME USER '' TO 'name'; +RENAME USER 'a' TO 'name'; GRANT UPDATE ON test.* TO foo; -RENAME USER 'name' to ''; +RENAME USER 'name' to 'a'; DROP USER foo; +DROP USER a; --echo # --echo # End of 10.4 tests diff --git a/mysql-test/main/grant2.result b/mysql-test/main/grant2.result index 9d9b4c802927b..0192c83296a1a 100644 --- a/mysql-test/main/grant2.result +++ b/mysql-test/main/grant2.result @@ -12,7 +12,7 @@ flush privileges; grant all privileges on `my\_1`.* to mysqltest_1@localhost with grant option; grant create user on *.* to mysqltest_1@localhost; create user mysqltest_2@localhost; -connect user_a,localhost,mysqltest_1,,; +connect user_a,localhost,mysqltest_1,,"*NO-ONE*"; connection user_a; grant select on `my\_1`.* to mysqltest_2@localhost; grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass'; @@ -20,14 +20,14 @@ ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql disconnect user_a; connection default; grant update on mysql.* to mysqltest_1@localhost; -connect user_b,localhost,mysqltest_1,,; +connect user_b,localhost,mysqltest_1,,"*NO-ONE*"; connection user_b; grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass'; grant select on `my\_1`.* to mysqltest_3@localhost; disconnect user_b; connection default; grant insert on mysql.* to mysqltest_1@localhost; -connect user_c,localhost,mysqltest_1,,; +connect user_c,localhost,mysqltest_1,,"*NO-ONE*"; connection user_c; grant select on `my\_1`.* to mysqltest_3@localhost; grant select on `my\_1`.* to mysqltest_4@localhost identified by 'pass'; @@ -40,7 +40,7 @@ delete from mysql.columns_priv where user like 'mysqltest\_%'; flush privileges; grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option; grant create user on *.* to mysqltest_1@localhost; -connect user1,localhost,mysqltest_1,,; +connect user1,localhost,mysqltest_1,,"*NO-ONE*"; connection user1; select current_user(); current_user() @@ -73,7 +73,7 @@ delete from mysql.db where user like 'mysqltest\_%'; flush privileges; create database mysqltest_1; grant all privileges on `mysqltest\_1`.* to mysqltest_1@localhost with grant option; -connect user2,localhost,mysqltest_1,,; +connect user2,localhost,mysqltest_1,,"*NO-ONE*"; connection user2; select current_user(); current_user() @@ -82,7 +82,6 @@ show databases; Database information_schema mysqltest_1 -test grant all privileges on `mysqltest_1`.* to mysqltest_1@localhost with grant option; ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_1' disconnect user2; @@ -157,7 +156,7 @@ disconnect con9; connection default; create database mysqltest_1; grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost; -connect con10,localhost,mysqltest_1,,; +connect con10,localhost,mysqltest_1,,"*NO-ONE*"; connection con10; set sql_log_off = 1; ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation @@ -309,7 +308,7 @@ GRANT SELECT ON "mysql".* TO "%@a"@"a" drop user '%@a'@'a'; create user mysqltest_2@localhost; grant create user on *.* to mysqltest_2@localhost; -connect user3,localhost,mysqltest_2,,; +connect user3,localhost,mysqltest_2,,"*NO-ONE*"; connection user3; select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%' ; ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table `mysql`.`user` @@ -321,7 +320,7 @@ connection default; drop user mysqltest_2@localhost; create user mysqltest_3@localhost; grant INSERT,DELETE,UPDATE on mysql.* to mysqltest_3@localhost; -connect user4,localhost,mysqltest_3,,; +connect user4,localhost,mysqltest_3,,"*NO-ONE*"; connection user4; show grants; Grants for mysqltest_3@localhost @@ -390,7 +389,7 @@ revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.0/255.0.0.0'; delete from mysql.user where user like 'mysqltest\_1'; flush privileges; drop database mysqltest_1; -connect n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect n5,localhost,test,,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; connection n5; set password = password("changed"); ERROR 42000: You are using MariaDB as an anonymous user and anonymous users are not allowed to modify user settings @@ -496,13 +495,13 @@ drop database mysqltest_2; drop user mysqltest_u1@localhost; grant all on `mysqltest\_%`.* to mysqltest_1@localhost with grant option; grant usage on *.* to mysqltest_2@localhost; -connect con18600_1,localhost,mysqltest_1,,; +connect con18600_1,localhost,mysqltest_1,,"*NO-ONE*"; create database mysqltest_1; use mysqltest_1; create table t1 (f1 int); grant create on `mysqltest\_1`.* to mysqltest_2@localhost; grant select on mysqltest_1.t1 to mysqltest_2@localhost; -connect con3,localhost,mysqltest_2,,; +connect con3,localhost,mysqltest_2,,"*NO-ONE*"; connection con3; create database mysqltest_3; ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest_3' @@ -527,7 +526,7 @@ CREATE TABLE t2 (b INT, c INT); INSERT INTO t2 VALUES (1,100),(2,200); GRANT SELECT ON t1 TO mysqltest1@localhost; GRANT SELECT (b) ON t2 TO mysqltest1@localhost; -connect conn1,localhost,mysqltest1,,; +connect conn1,localhost,mysqltest1,,"*NO-ONE*"; connection conn1; USE db1; SELECT c FROM t2; diff --git a/mysql-test/main/grant2.test b/mysql-test/main/grant2.test index b8098488709db..2866aeb348a0c 100644 --- a/mysql-test/main/grant2.test +++ b/mysql-test/main/grant2.test @@ -30,7 +30,7 @@ flush privileges; grant all privileges on `my\_1`.* to mysqltest_1@localhost with grant option; grant create user on *.* to mysqltest_1@localhost; create user mysqltest_2@localhost; -connect (user_a,localhost,mysqltest_1,,); +connect (user_a,localhost,mysqltest_1,,"*NO-ONE*"); connection user_a; grant select on `my\_1`.* to mysqltest_2@localhost; --error ER_DBACCESS_DENIED_ERROR @@ -38,14 +38,14 @@ grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass'; disconnect user_a; connection default; grant update on mysql.* to mysqltest_1@localhost; -connect (user_b,localhost,mysqltest_1,,); +connect (user_b,localhost,mysqltest_1,,"*NO-ONE*"); connection user_b; grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass'; grant select on `my\_1`.* to mysqltest_3@localhost; disconnect user_b; connection default; grant insert on mysql.* to mysqltest_1@localhost; -connect (user_c,localhost,mysqltest_1,,); +connect (user_c,localhost,mysqltest_1,,"*NO-ONE*"); connection user_c; grant select on `my\_1`.* to mysqltest_3@localhost; grant select on `my\_1`.* to mysqltest_4@localhost identified by 'pass'; @@ -63,7 +63,7 @@ flush privileges; grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option; grant create user on *.* to mysqltest_1@localhost; -connect (user1,localhost,mysqltest_1,,); +connect (user1,localhost,mysqltest_1,,"*NO-ONE*"); connection user1; select current_user(); grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option; @@ -97,7 +97,7 @@ flush privileges; # create database mysqltest_1; grant all privileges on `mysqltest\_1`.* to mysqltest_1@localhost with grant option; -connect (user2,localhost,mysqltest_1,,); +connect (user2,localhost,mysqltest_1,,"*NO-ONE*"); connection user2; select current_user(); show databases; @@ -198,7 +198,7 @@ connection default; # create database mysqltest_1; grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost; -connect (con10,localhost,mysqltest_1,,); +connect (con10,localhost,mysqltest_1,,"*NO-ONE*"); connection con10; --error ER_SPECIFIC_ACCESS_DENIED_ERROR set sql_log_off = 1; @@ -342,7 +342,7 @@ drop user '%@a'@'a'; # create user mysqltest_2@localhost; grant create user on *.* to mysqltest_2@localhost; -connect (user3,localhost,mysqltest_2,,); +connect (user3,localhost,mysqltest_2,,"*NO-ONE*"); connection user3; --error ER_TABLEACCESS_DENIED_ERROR select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%' ; @@ -356,7 +356,7 @@ drop user mysqltest_2@localhost; # INSERT/UPDATE/DELETE is ok too create user mysqltest_3@localhost; grant INSERT,DELETE,UPDATE on mysql.* to mysqltest_3@localhost; -connect (user4,localhost,mysqltest_3,,); +connect (user4,localhost,mysqltest_3,,"*NO-ONE*"); connection user4; show grants; --error ER_TABLEACCESS_DENIED_ERROR @@ -420,7 +420,7 @@ drop database mysqltest_1; --source include/add_anonymous_users.inc # But anonymous users can't change their password -connect (n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +connect (n5,localhost,test,,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); connection n5; --error ER_PASSWORD_ANONYMOUS_USER set password = password("changed"); @@ -589,7 +589,7 @@ drop user mysqltest_u1@localhost; # grant all on `mysqltest\_%`.* to mysqltest_1@localhost with grant option; grant usage on *.* to mysqltest_2@localhost; -connect (con18600_1,localhost,mysqltest_1,,); +connect (con18600_1,localhost,mysqltest_1,,"*NO-ONE*"); create database mysqltest_1; use mysqltest_1; @@ -597,7 +597,7 @@ create table t1 (f1 int); grant create on `mysqltest\_1`.* to mysqltest_2@localhost; grant select on mysqltest_1.t1 to mysqltest_2@localhost; -connect (con3,localhost,mysqltest_2,,); +connect (con3,localhost,mysqltest_2,,"*NO-ONE*"); connection con3; --error ER_DBACCESS_DENIED_ERROR create database mysqltest_3; @@ -631,7 +631,7 @@ INSERT INTO t2 VALUES (1,100),(2,200); GRANT SELECT ON t1 TO mysqltest1@localhost; GRANT SELECT (b) ON t2 TO mysqltest1@localhost; -connect (conn1,localhost,mysqltest1,,); +connect (conn1,localhost,mysqltest1,,"*NO-ONE*"); connection conn1; USE db1; --error ER_COLUMNACCESS_DENIED_ERROR diff --git a/mysql-test/main/grant3.result b/mysql-test/main/grant3.result index 160153b1674a8..a2869da42687b 100644 --- a/mysql-test/main/grant3.result +++ b/mysql-test/main/grant3.result @@ -201,6 +201,7 @@ set global sql_mode=default; create database db1; create user foo@localhost; grant create on db1.* to foo@localhost; +grant all privileges on test.* to foo@localhost; connect foo,localhost,foo; create temporary table t as values (1),(2),(3); use db1; diff --git a/mysql-test/main/grant3.test b/mysql-test/main/grant3.test index 5337d59efd863..7842233d9bdc4 100644 --- a/mysql-test/main/grant3.test +++ b/mysql-test/main/grant3.test @@ -214,6 +214,7 @@ set global sql_mode=default; create database db1; create user foo@localhost; grant create on db1.* to foo@localhost; +grant all privileges on test.* to foo@localhost; connect foo,localhost,foo; create temporary table t as values (1),(2),(3); use db1; diff --git a/mysql-test/main/grant_cache_no_prot.result b/mysql-test/main/grant_cache_no_prot.result index 1ecfc3084225a..daf382d65d31d 100644 --- a/mysql-test/main/grant_cache_no_prot.result +++ b/mysql-test/main/grant_cache_no_prot.result @@ -58,15 +58,18 @@ show status like "Qcache_hits%"; Variable_name Value Qcache_hits 0 grant SELECT on mysqltest.* to mysqltest_1@localhost; +grant SELECT on test.t1 to mysqltest_1@localhost; grant SELECT on mysqltest.t1 to mysqltest_2@localhost; grant SELECT on test.t1 to mysqltest_2@localhost; grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost; +grant SELECT(a) on test.t1 to mysqltest_3@localhost; connect user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK; connection user1; show grants for current_user(); Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO `mysqltest_1`@`localhost` GRANT SELECT ON `mysqltest`.* TO `mysqltest_1`@`localhost` +GRANT SELECT ON `test`.`t1` TO `mysqltest_1`@`localhost` show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 6 @@ -127,7 +130,7 @@ Qcache_hits 3 show status like "Qcache_not_cached"; Variable_name Value Qcache_not_cached 1 -connect unkuser,localhost,unkuser,,,$MASTER_MYPORT,$MASTER_MYSOCK; +connect unkuser,localhost,unkuser,,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; connection unkuser; show grants for current_user(); Grants for @localhost @@ -199,6 +202,7 @@ show grants; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO `mysqltest_1`@`localhost` GRANT SELECT ON `mysqltest`.* TO `mysqltest_1`@`localhost` +GRANT SELECT ON `test`.`t1` TO `mysqltest_1`@`localhost` select a from t1; ERROR 3D000: No database selected select * from mysqltest.t1,test.t1; diff --git a/mysql-test/main/grant_cache_ps_prot.result b/mysql-test/main/grant_cache_ps_prot.result index d6f343d64597b..0fde04ac0f33b 100644 --- a/mysql-test/main/grant_cache_ps_prot.result +++ b/mysql-test/main/grant_cache_ps_prot.result @@ -58,15 +58,18 @@ show status like "Qcache_hits%"; Variable_name Value Qcache_hits 0 grant SELECT on mysqltest.* to mysqltest_1@localhost; +grant SELECT on test.t1 to mysqltest_1@localhost; grant SELECT on mysqltest.t1 to mysqltest_2@localhost; grant SELECT on test.t1 to mysqltest_2@localhost; grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost; +grant SELECT(a) on test.t1 to mysqltest_3@localhost; connect user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK; connection user1; show grants for current_user(); Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO `mysqltest_1`@`localhost` GRANT SELECT ON `mysqltest`.* TO `mysqltest_1`@`localhost` +GRANT SELECT ON `test`.`t1` TO `mysqltest_1`@`localhost` show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 6 @@ -127,7 +130,7 @@ Qcache_hits 3 show status like "Qcache_not_cached"; Variable_name Value Qcache_not_cached 1 -connect unkuser,localhost,unkuser,,,$MASTER_MYPORT,$MASTER_MYSOCK; +connect unkuser,localhost,unkuser,,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; connection unkuser; show grants for current_user(); Grants for @localhost @@ -199,6 +202,7 @@ show grants; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO `mysqltest_1`@`localhost` GRANT SELECT ON `mysqltest`.* TO `mysqltest_1`@`localhost` +GRANT SELECT ON `test`.`t1` TO `mysqltest_1`@`localhost` select a from t1; ERROR 3D000: No database selected select * from mysqltest.t1,test.t1; diff --git a/mysql-test/main/grant_read_only.result b/mysql-test/main/grant_read_only.result index e7855dc941164..18d97cc412f5f 100644 --- a/mysql-test/main/grant_read_only.result +++ b/mysql-test/main/grant_read_only.result @@ -27,10 +27,10 @@ DROP TABLE t1; # CREATE TABLE t1 (a INT); CREATE USER user1@localhost IDENTIFIED BY ''; -GRANT INSERT, UPDATE, DELETE, READ_ONLY ADMIN ON *.* TO user1@localhost; +GRANT SELECT, INSERT, UPDATE, DELETE, READ_ONLY ADMIN ON *.* TO user1@localhost; SHOW GRANTS FOR user1@localhost; Grants for user1@localhost -GRANT INSERT, UPDATE, DELETE, READ_ONLY ADMIN ON *.* TO `user1`@`localhost` +GRANT SELECT, INSERT, UPDATE, DELETE, READ_ONLY ADMIN ON *.* TO `user1`@`localhost` SET @@GLOBAL.read_only=1; connect con1,localhost,user1,,; connection con1; @@ -50,10 +50,10 @@ DROP TABLE t1; # CREATE TABLE t1 (a INT); CREATE USER user1@localhost IDENTIFIED BY ''; -GRANT INSERT, UPDATE, DELETE, SUPER ON *.* TO user1@localhost; +GRANT SELECT, INSERT, UPDATE, DELETE, SUPER ON *.* TO user1@localhost; SHOW GRANTS FOR user1@localhost; Grants for user1@localhost -GRANT INSERT, UPDATE, DELETE, SUPER ON *.* TO `user1`@`localhost` +GRANT SELECT, INSERT, UPDATE, DELETE, SUPER ON *.* TO `user1`@`localhost` SET @@GLOBAL.read_only=1; connect con1,localhost,user1,,; connection con1; diff --git a/mysql-test/main/grant_read_only.test b/mysql-test/main/grant_read_only.test index a951987fa7f30..f42bb24fe8330 100644 --- a/mysql-test/main/grant_read_only.test +++ b/mysql-test/main/grant_read_only.test @@ -36,7 +36,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INT); CREATE USER user1@localhost IDENTIFIED BY ''; ## TODO: it works even without INSERT/UPDATE/DELETE: file a bug report! -GRANT INSERT, UPDATE, DELETE, READ_ONLY ADMIN ON *.* TO user1@localhost; +GRANT SELECT, INSERT, UPDATE, DELETE, READ_ONLY ADMIN ON *.* TO user1@localhost; SHOW GRANTS FOR user1@localhost; SET @@GLOBAL.read_only=1; @@ -61,7 +61,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INT); CREATE USER user1@localhost IDENTIFIED BY ''; ## TODO: it works even without INSERT/UPDATE/DELETE: file a bug report! -GRANT INSERT, UPDATE, DELETE, SUPER ON *.* TO user1@localhost; +GRANT SELECT, INSERT, UPDATE, DELETE, SUPER ON *.* TO user1@localhost; SHOW GRANTS FOR user1@localhost; SET @@GLOBAL.read_only=1; diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result index 88026081e8992..5b815d3f4333e 100644 --- a/mysql-test/main/information_schema.result +++ b/mysql-test/main/information_schema.result @@ -842,7 +842,7 @@ Database Table In_use Name_locked mysql user 0 0 show status where variable_name like "%database%"; Variable_name Value -Acl_database_grants 2 +Acl_database_grants 0 Com_show_databases 3 show variables where variable_name like "skip_show_databas"; Variable_name Value diff --git a/mysql-test/main/information_schema_db.result b/mysql-test/main/information_schema_db.result index 6a6e5c498515d..725b1a125ad78 100644 --- a/mysql-test/main/information_schema_db.result +++ b/mysql-test/main/information_schema_db.result @@ -40,7 +40,7 @@ create table t1 (f1 int(10) unsigned not null, f2 varchar(100) not null, primary key (f1), unique key (f2)); -connect user1,localhost,mysqltest_1,,; +connect user1,localhost,mysqltest_1,,"*NO-ONE*"; connection user1; select * from information_schema.tables; call mbase.p1(); @@ -93,8 +93,7 @@ create user testdb_1@localhost; grant all on testdb_1.* to testdb_1@localhost with grant option; create user testdb_2@localhost; grant all on test.* to testdb_2@localhost with grant option; -connect testdb_1,localhost,testdb_1,,test; -use testdb_1; +connect testdb_1,localhost,testdb_1,,testdb_1; create table t1 (f1 char(4)); create view v1 as select f1 from t1; grant insert on v1 to testdb_2@localhost; @@ -221,7 +220,7 @@ create table testdb_1.t1 (a int); create view testdb_1.v1 as select * from testdb_1.t1; grant show view on testdb_1.* to mysqltest_1@localhost; grant select on testdb_1.v1 to mysqltest_1@localhost; -connect user1,localhost,mysqltest_1,,test; +connect user1,localhost,mysqltest_1,,"*NO-ONE*"; connection user1; select table_schema, table_name, view_definition from information_schema.views where table_name='v1'; diff --git a/mysql-test/main/information_schema_db.test b/mysql-test/main/information_schema_db.test index e60557a9526c1..fabc42e38b837 100644 --- a/mysql-test/main/information_schema_db.test +++ b/mysql-test/main/information_schema_db.test @@ -62,7 +62,7 @@ create table t1 f2 varchar(100) not null, primary key (f1), unique key (f2)); -connect (user1,localhost,mysqltest_1,,); +connect (user1,localhost,mysqltest_1,,"*NO-ONE*"); connection user1; --disable_result_log select * from information_schema.tables; @@ -122,8 +122,7 @@ grant all on testdb_1.* to testdb_1@localhost with grant option; create user testdb_2@localhost; grant all on test.* to testdb_2@localhost with grant option; -connect (testdb_1,localhost,testdb_1,,test); -use testdb_1; +connect (testdb_1,localhost,testdb_1,,testdb_1); create table t1 (f1 char(4)); create view v1 as select f1 from t1; grant insert on v1 to testdb_2@localhost; @@ -234,7 +233,7 @@ create view testdb_1.v1 as select * from testdb_1.t1; grant show view on testdb_1.* to mysqltest_1@localhost; grant select on testdb_1.v1 to mysqltest_1@localhost; -connect (user1,localhost,mysqltest_1,,test); +connect (user1,localhost,mysqltest_1,,"*NO-ONE*"); connection user1; select table_schema, table_name, view_definition from information_schema.views where table_name='v1'; diff --git a/mysql-test/main/init_connect.result b/mysql-test/main/init_connect.result index 1476d84607861..876a6a14b4e5f 100644 --- a/mysql-test/main/init_connect.result +++ b/mysql-test/main/init_connect.result @@ -1,23 +1,23 @@ -connect con0,localhost,root,,test; +connect con0,localhost,root,,; connection con0; select hex(@a); hex(@a) NULL -connect con1,localhost,user_1,,test; +connect con1,localhost,user_1,,"*NO-ONE*"; connection con1; select hex(@a); hex(@a) 610063 connection con0; set global init_connect="set @a=2;set @b=3"; -connect con2,localhost,user_1,,test; +connect con2,localhost,user_1,,"*NO-ONE*"; connection con2; select @a, @b; @a @b 2 3 connection con0; set GLOBAL init_connect=DEFAULT; -connect con3,localhost,user_1,,test; +connect con3,localhost,user_1,,"*NO-ONE*"; connection con3; select @a; @a @@ -25,6 +25,8 @@ NULL connection con0; set global init_connect="drop table if exists t1; create table t1(a char(10));\ insert into t1 values ('\0');insert into t1 values('abc')"; +create user 'user_1'@'localhost'; +GRANT DROP,CREATE,SELECT,INSERT ON test.* TO 'user_1'@'localhost'; connect con4,localhost,user_1,,test; connection con4; select hex(a) from t1; @@ -46,6 +48,7 @@ disconnect con2; disconnect con3; disconnect con4; disconnect con5; +drop user 'user_1'@'localhost'; End of 4.1 tests create table t1 (x int); insert into t1 values (3), (5), (7); diff --git a/mysql-test/main/init_connect.test b/mysql-test/main/init_connect.test index 60549c3458e5d..c210ea10850d8 100644 --- a/mysql-test/main/init_connect.test +++ b/mysql-test/main/init_connect.test @@ -10,25 +10,27 @@ --source include/add_anonymous_users.inc -connect (con0,localhost,root,,test); +connect (con0,localhost,root,,); connection con0; select hex(@a); -connect (con1,localhost,user_1,,test); +connect (con1,localhost,user_1,,"*NO-ONE*"); connection con1; select hex(@a); connection con0; set global init_connect="set @a=2;set @b=3"; -connect (con2,localhost,user_1,,test); +connect (con2,localhost,user_1,,"*NO-ONE*"); connection con2; select @a, @b; connection con0; set GLOBAL init_connect=DEFAULT; -connect (con3,localhost,user_1,,test); +connect (con3,localhost,user_1,,"*NO-ONE*"); connection con3; select @a; connection con0; set global init_connect="drop table if exists t1; create table t1(a char(10));\ insert into t1 values ('\0');insert into t1 values('abc')"; +create user 'user_1'@'localhost'; +GRANT DROP,CREATE,SELECT,INSERT ON test.* TO 'user_1'@'localhost'; connect (con4,localhost,user_1,,test); connection con4; select hex(a) from t1; @@ -54,6 +56,7 @@ disconnect con2; disconnect con3; disconnect con4; disconnect con5; +drop user 'user_1'@'localhost'; --source include/delete_anonymous_users.inc diff --git a/mysql-test/main/invisible_field_grant_completely.result b/mysql-test/main/invisible_field_grant_completely.result index b1b313072b2b3..f0992baf7b14b 100644 --- a/mysql-test/main/invisible_field_grant_completely.result +++ b/mysql-test/main/invisible_field_grant_completely.result @@ -19,12 +19,11 @@ grant insert(a) on t1 to user_1; grant update(a) on t1 to user_1; grant select(a) on t1 to user_1; grant delete on t1 to user_1; -connect con1, localhost, user_1,,test; +connect con1, localhost, user_1,,d; connection con1; select user(); user() user_1@localhost -use d; select * from t1; a 1 diff --git a/mysql-test/main/invisible_field_grant_completely.test b/mysql-test/main/invisible_field_grant_completely.test index aeca66b97d26f..b27071ada5672 100644 --- a/mysql-test/main/invisible_field_grant_completely.test +++ b/mysql-test/main/invisible_field_grant_completely.test @@ -21,10 +21,9 @@ grant insert(a) on t1 to user_1; grant update(a) on t1 to user_1; grant select(a) on t1 to user_1; grant delete on t1 to user_1; -connect (con1, localhost, user_1,,test); +connect (con1, localhost, user_1,,d); connection con1; select user(); -use d; select * from t1; insert into t1 values(2); select * from t1; diff --git a/mysql-test/main/invisible_field_grant_system.result b/mysql-test/main/invisible_field_grant_system.result index d2e40c391c42f..86e40736f1116 100644 --- a/mysql-test/main/invisible_field_grant_system.result +++ b/mysql-test/main/invisible_field_grant_system.result @@ -19,12 +19,11 @@ grant insert(a) on t1 to user_1; grant update(a) on t1 to user_1; grant select(a) on t1 to user_1; grant delete on t1 to user_1; -connect con1, localhost, user_1,,test; +connect con1, localhost, user_1,,d; connection con1; select user(); user() user_1@localhost -use d; select * from t1; a 1 diff --git a/mysql-test/main/invisible_field_grant_system.test b/mysql-test/main/invisible_field_grant_system.test index fd54ea72a5ac9..04ea5f14be130 100644 --- a/mysql-test/main/invisible_field_grant_system.test +++ b/mysql-test/main/invisible_field_grant_system.test @@ -18,10 +18,9 @@ grant insert(a) on t1 to user_1; grant update(a) on t1 to user_1; grant select(a) on t1 to user_1; grant delete on t1 to user_1; -connect (con1, localhost, user_1,,test); +connect (con1, localhost, user_1,,d); connection con1; select user(); -use d; select * from t1; insert into t1 values(2); select * from t1; diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index b32a278d3a187..938167035a254 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -6056,8 +6056,7 @@ SET join_cache_level = 3; explain SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.db WHERE Select_priv = PAGE_FAULTS_MINOR; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL Using where -1 SIMPLE db hash_ALL NULL #hash#$hj 1 information_schema.PROFILING.PAGE_FAULTS_MINOR 2 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables set join_cache_level=@save_join_cache_level; create table t1 (c1 date not null, key (c1)) engine=innodb; insert t1 values ('2017-12-27'); diff --git a/mysql-test/main/lock_multi.result b/mysql-test/main/lock_multi.result index 30cd63e60ed73..52196d835ec79 100644 --- a/mysql-test/main/lock_multi.result +++ b/mysql-test/main/lock_multi.result @@ -128,7 +128,6 @@ mysql.global_priv optimize status OK UNLOCK TABLES; connection reader; host -localhost USE test; connection locker; use test; diff --git a/mysql-test/main/lock_view.result b/mysql-test/main/lock_view.result index 47a7e58ea0d46..8137300f3e364 100644 --- a/mysql-test/main/lock_view.result +++ b/mysql-test/main/lock_view.result @@ -181,7 +181,6 @@ information_schema mysqltest1 mysqltest2 performance_schema -test lock table mysqltest3.v3ps write; select * from mysqltest3.v3ps; user diff --git a/mysql-test/main/long_host.result b/mysql-test/main/long_host.result index 57b637de5874f..52b479b66f7c8 100644 --- a/mysql-test/main/long_host.result +++ b/mysql-test/main/long_host.result @@ -20,7 +20,7 @@ create table mariadbtestdb.t3 (a int); SET @saved_dbug = @@GLOBAL.debug_dbug; set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_long_host,getaddrinfo_fake_good_ipv4"; # check connect -connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,; +connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; connection con1; select current_user(); current_user() @@ -43,7 +43,7 @@ a connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; -connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,; +connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; connection con1; select * from mariadbtestdb.t1; ERROR 42000: SELECT command denied to user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345' for table `mariadbtestdb`.`t1` @@ -53,7 +53,7 @@ ERROR 42000: SELECT command denied to user 'user5678901_345678902_345678903_3456 connection default; grant SELECT ON mariadbtestdb.* TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; -connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,; +connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; connection con1; select * from mariadbtestdb.t1; a b @@ -66,7 +66,7 @@ connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; grant SELECT ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; -connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,; +connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; connection con1; select * from mariadbtestdb.t1; a b @@ -79,7 +79,7 @@ connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; grant SELECT (a) ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; -connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,; +connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,; connection con1; select * from mariadbtestdb.t1; ERROR 42000: SELECT command denied to user 'user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678'@'host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345' for table `mariadbtestdb`.`t1` @@ -96,6 +96,7 @@ CREATE ROLE role5678901_345678902_345678903_345678904_345678905_345678906_345678 ERROR HY000: String 'role5678901_345678902_345678903_345678904_345678905_345678906_34567...' is too long for user name (should be no longer than 128) grant SELECT (a) ON mariadbtestdb.t1 TO role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; +GRANT CREATE ROUTINE on test.* to user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; grant role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678 to user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; connect con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,; diff --git a/mysql-test/main/long_host.test b/mysql-test/main/long_host.test index 0c082bf6fb41b..301744a1f11f0 100644 --- a/mysql-test/main/long_host.test +++ b/mysql-test/main/long_host.test @@ -36,7 +36,7 @@ set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_long_host,ge --echo # check connect -connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,); +connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); connection con1; select current_user(); @@ -61,7 +61,7 @@ select * from mariadbtestdb2.t2; connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; -connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,); +connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); connection con1; --error ER_TABLEACCESS_DENIED_ERROR select * from mariadbtestdb.t1; @@ -74,7 +74,7 @@ select * from mariadbtestdb2.t2; connection default; grant SELECT ON mariadbtestdb.* TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; -connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,); +connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); connection con1; select * from mariadbtestdb.t1; --error ER_TABLEACCESS_DENIED_ERROR @@ -87,7 +87,7 @@ connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; grant SELECT ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; -connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,); +connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); connection con1; select * from mariadbtestdb.t1; --error ER_TABLEACCESS_DENIED_ERROR @@ -101,7 +101,7 @@ connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; grant SELECT (a) ON mariadbtestdb.t1 TO user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; -connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,test,$MASTER_MYPORT,); +connect (con1,"127.0.0.1","user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678",,"*NO-ONE*",$MASTER_MYPORT,); connection con1; --error ER_TABLEACCESS_DENIED_ERROR select * from mariadbtestdb.t1; @@ -126,6 +126,8 @@ grant SELECT (a) ON mariadbtestdb.t1 TO role5678901_345678902_345678903_34567890 REVOKE ALL PRIVILEGES, GRANT OPTION FROM user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; +GRANT CREATE ROUTINE on test.* to user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; + grant role5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678 to user5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678@host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345; disconnect con1; diff --git a/mysql-test/main/mysql_upgrade_to_100502.result b/mysql-test/main/mysql_upgrade_to_100502.result index 1509580909283..7235b16aa5aa6 100644 --- a/mysql-test/main/mysql_upgrade_to_100502.result +++ b/mysql-test/main/mysql_upgrade_to_100502.result @@ -84,15 +84,15 @@ GRANT BINLOG MONITOR, SLAVE MONITOR ON *.* TO `user_replclient`@`localhost` SHOW GRANTS FOR user_replslave@localhost; Grants for user_replslave@localhost GRANT REPLICATION SLAVE, SLAVE MONITOR ON *.* TO `user_replslave`@`localhost` -connect con1,localhost,user_super_replslave,,test; +connect con1,localhost,user_super_replslave,,"*NO-ONE*"; connection con1; SHOW SLAVE STATUS; disconnect con1; -connect con1,localhost,user_replclient,,test; +connect con1,localhost,user_replclient,,"*NO-ONE*"; connection con1; SHOW SLAVE STATUS; disconnect con1; -connect con1,localhost,user_replslave,,test; +connect con1,localhost,user_replslave,,"*NO-ONE*"; connection con1; SHOW RELAYLOG EVENTS; disconnect con1; diff --git a/mysql-test/main/mysql_upgrade_to_100502.test b/mysql-test/main/mysql_upgrade_to_100502.test index b5a44080f171a..fc47f0c94aa38 100644 --- a/mysql-test/main/mysql_upgrade_to_100502.test +++ b/mysql-test/main/mysql_upgrade_to_100502.test @@ -87,21 +87,21 @@ SHOW GRANTS FOR user_replclient@localhost; --echo # SHOW GRANTS FOR user_replslave@localhost; ---connect (con1,localhost,user_super_replslave,,test) +--connect (con1,localhost,user_super_replslave,,"*NO-ONE*") --connection con1 --disable_result_log SHOW SLAVE STATUS; --enable_result_log --disconnect con1 ---connect (con1,localhost,user_replclient,,test) +--connect (con1,localhost,user_replclient,,"*NO-ONE*") --connection con1 --disable_result_log SHOW SLAVE STATUS; --enable_result_log --disconnect con1 ---connect (con1,localhost,user_replslave,,test) +--connect (con1,localhost,user_replslave,,"*NO-ONE*") --connection con1 --disable_ps_protocol --disable_result_log diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index 0191238ce7140..1e827ac6e5948 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -3727,6 +3727,7 @@ use test; # Bug#21215 mysqldump creating incomplete backups without warning # create user mysqltest_1@localhost; +grant all on test.* to mysqltest_1@localhost; create table t1(a int, b varchar(34)); reset master; mysqldump: Couldn't execute 'FLUSH /*!40101 LOCAL */ TABLES': Access denied; you need (at least one of) the RELOAD privilege(s) for this operation (1227) @@ -5784,6 +5785,8 @@ drop tables t2, t1; # MDEV-22037: Add ability to skip content of some tables # (work around for MDEV-20939) # +create user a; +grant SELECT on test.* to a; use mysql; # check that all tables we need are not empty select count(*) >= 1 from mysql.proc; @@ -5797,6 +5800,7 @@ FOUND 1 /INSERT INTO `proc`/ in MDEV-20939.sql NOT FOUND /INSERT INTO `db`/ in MDEV-20939.sql FOUND 1 /CREATE TABLE `db`/ in MDEV-20939.sql FOUND 1 /CREATE TABLE `proc`/ in MDEV-20939.sql +drop user a; use test; # End of 10.1 tests # diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test index c03ae71b539d4..d9020791289c0 100644 --- a/mysql-test/main/mysqldump.test +++ b/mysql-test/main/mysqldump.test @@ -1381,6 +1381,7 @@ use test; # Create user without sufficient privs to perform the requested operation create user mysqltest_1@localhost; +grant all on test.* to mysqltest_1@localhost; create table t1(a int, b varchar(34)); # To get consistent output, reset the master, starts over from first log @@ -2696,6 +2697,8 @@ drop tables t2, t1; --echo # (work around for MDEV-20939) --echo # +create user a; +grant SELECT on test.* to a; use mysql; --echo # check that all tables we need are not empty @@ -2721,6 +2724,7 @@ let SEARCH_PATTERN=CREATE TABLE `proc`; source include/search_pattern_in_file.inc; --remove_file $MYSQLTEST_VARDIR/tmp/MDEV-20939.sql +drop user a; use test; --echo # End of 10.1 tests diff --git a/mysql-test/main/not_embedded_server.result b/mysql-test/main/not_embedded_server.result index 0b952f93ad830..19e862e07a5c8 100644 --- a/mysql-test/main/not_embedded_server.result +++ b/mysql-test/main/not_embedded_server.result @@ -31,6 +31,7 @@ CREATE TABLE t2 (key2 INT); INSERT INTO t1 VALUES (1),(2); CREATE FUNCTION f() RETURNS INT RETURN 1; GRANT FILE ON *.* TO 'nopriv_user'@'localhost'; +GRANT SELECT,INSERT,CREATE ON test.* TO 'nopriv_user'@'localhost'; FLUSH PRIVILEGES; connect con1,localhost,nopriv_user,,; connection con1; diff --git a/mysql-test/main/not_embedded_server.test b/mysql-test/main/not_embedded_server.test index 20f75db25d507..079c0c85bcd96 100644 --- a/mysql-test/main/not_embedded_server.test +++ b/mysql-test/main/not_embedded_server.test @@ -59,6 +59,7 @@ INSERT INTO t1 VALUES (1),(2); CREATE FUNCTION f() RETURNS INT RETURN 1; GRANT FILE ON *.* TO 'nopriv_user'@'localhost'; +GRANT SELECT,INSERT,CREATE ON test.* TO 'nopriv_user'@'localhost'; FLUSH PRIVILEGES; diff --git a/mysql-test/main/partition_symlink.result b/mysql-test/main/partition_symlink.result index 17ddecbe19d14..06aef8ea4c6e1 100644 --- a/mysql-test/main/partition_symlink.result +++ b/mysql-test/main/partition_symlink.result @@ -47,6 +47,7 @@ DROP TABLE t1, t2; # test.t1 have partitions in mysqltest2-directory! # user root: CREATE USER mysqltest_1@localhost; +GRANT ALL ON test.* to mysqltest_1@localhost; CREATE DATABASE mysqltest2; USE mysqltest2; CREATE TABLE t1 (a INT) ENGINE = MyISAM; diff --git a/mysql-test/main/partition_symlink.test b/mysql-test/main/partition_symlink.test index 07d653ee4d64e..5eba9658b1ca6 100644 --- a/mysql-test/main/partition_symlink.test +++ b/mysql-test/main/partition_symlink.test @@ -77,6 +77,7 @@ DROP TABLE t1, t2; -- echo # user root: --disable_service_connection CREATE USER mysqltest_1@localhost; + GRANT ALL ON test.* to mysqltest_1@localhost; CREATE DATABASE mysqltest2; USE mysqltest2; CREATE TABLE t1 (a INT) ENGINE = MyISAM; diff --git a/mysql-test/main/plugin_auth.result b/mysql-test/main/plugin_auth.result index ac10bd067071b..12a5156eeb136 100644 --- a/mysql-test/main/plugin_auth.result +++ b/mysql-test/main/plugin_auth.result @@ -11,8 +11,8 @@ SELECT plugin,authentication_string FROM mysql.user WHERE User='plug'; plugin authentication_string test_plugin_server plug_dest ## test plugin auth -connect(localhost,plug,plug_dest,test,MYSQL_PORT,MYSQL_SOCK); -connect plug_con,localhost,plug,plug_dest; +connect(localhost,plug,plug_dest,,MYSQL_PORT,MYSQL_SOCK); +connect plug_con,localhost,plug,plug_dest,"*NO-ONE*"; ERROR 28000: Access denied for user 'plug'@'localhost' (using password: YES) GRANT PROXY ON plug_dest TO plug; test proxies_priv columns @@ -33,7 +33,7 @@ proxies_priv CREATE TABLE `proxies_priv` ( PRIMARY KEY (`Host`,`User`,`Proxied_host`,`Proxied_user`), KEY `Grantor` (`Grantor`) ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='User proxy privileges' -connect plug_con,localhost,plug,plug_dest; +connect plug_con,localhost,plug,plug_dest,"*NO-ONE*"; select USER(),CURRENT_USER(); USER() CURRENT_USER() plug@localhost plug_dest@% @@ -46,14 +46,14 @@ connect(localhost,plug,bad_credentials,test,MYSQL_PORT,MYSQL_SOCK); connect plug_con,localhost,plug,bad_credentials; ERROR 28000: Access denied for user 'plug'@'localhost' (using password: YES) ## test bad default plugin : nothing bad happens, as that plugin was't required by the server -connect plug_con_wrongp,localhost,plug,plug_dest,,,,,wrong_plugin_name; +connect plug_con_wrongp,localhost,plug,plug_dest,"*NO-ONE*",,,,wrong_plugin_name; select USER(),CURRENT_USER(); USER() CURRENT_USER() plug@localhost plug_dest@% connection default; disconnect plug_con_wrongp; ## test correct default plugin -connect plug_con_rightp,localhost,plug,plug_dest,,,,,auth_test_plugin; +connect plug_con_rightp,localhost,plug,plug_dest,"*NO-ONE*",,,,auth_test_plugin; select USER(),CURRENT_USER(); USER() CURRENT_USER() plug@localhost plug_dest@% @@ -67,7 +67,7 @@ DROP USER grant_user; ## test utf-8 user name CREATE USER `Ÿ` IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; GRANT PROXY ON plug_dest TO `Ÿ`; -connect non_ascii,localhost,Ÿ,plug_dest; +connect non_ascii,localhost,Ÿ,plug_dest,"*NO-ONE*"; select USER(),CURRENT_USER(); USER() CURRENT_USER() Ÿ@localhost plug_dest@% @@ -80,7 +80,8 @@ CREATE DATABASE test_grant_db; GRANT ALL PRIVILEGES ON test_grant_db.* TO new_grant_user IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; GRANT PROXY ON plug_dest TO new_grant_user; -connect plug_con_grant,localhost,new_grant_user,plug_dest; +GRANT CREATE, DROP ON test_grant_db.* TO 'plug_dest'@'%'; +connect plug_con_grant,localhost,new_grant_user,plug_dest,"*NO-ONE*"; select USER(),CURRENT_USER(); USER() CURRENT_USER() new_grant_user@localhost plug_dest@% @@ -96,11 +97,10 @@ IDENTIFIED BY 'new_password'; connect(localhost,new_grant_user,plug_dest,test,MYSQL_PORT,MYSQL_SOCK); connect plug_con_grant_deny,localhost,new_grant_user,plug_dest; ERROR 28000: Access denied for user 'new_grant_user'@'localhost' (using password: YES) -connect plug_con_grant,localhost,new_grant_user,new_password; +connect plug_con_grant,localhost,new_grant_user,new_password,test_grant_db; select USER(),CURRENT_USER(); USER() CURRENT_USER() new_grant_user@localhost new_grant_user@% -USE test_grant_db; CREATE TABLE t1 (a INT); DROP TABLE t1; connection default; @@ -137,7 +137,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp # this should fail : no such grant REVOKE PROXY ON grant_plug_dest FROM grant_plug; ERROR 42000: There is no such grant defined for user 'grant_plug' on host '%' -connect grant_plug_dest_con,localhost,grant_plug_dest,grant_plug_dest_passwd; +connect grant_plug_dest_con,localhost,grant_plug_dest,grant_plug_dest_passwd,"*NO-ONE*"; ## testing what an ordinary user can grant this should fail : no rights to grant all GRANT PROXY ON ''@'%%' TO grant_plug; @@ -219,7 +219,7 @@ ERROR HY000: Variable 'proxy_user' is a read only variable SELECT @@LOCAL.proxy_user; @@LOCAL.proxy_user NULL -connect plug_con,localhost,plug,plug_dest; +connect plug_con,localhost,plug,plug_dest,"*NO-ONE*"; SELECT @@LOCAL.proxy_user; @@LOCAL.proxy_user 'plug'@'%' @@ -248,7 +248,7 @@ ERROR HY000: Variable 'external_user' is a read only variable SELECT @@LOCAL.external_user; @@LOCAL.external_user NULL -connect plug_con,localhost,plug,plug_dest; +connect plug_con,localhost,plug,plug_dest,"*NO-ONE*"; SELECT @@LOCAL.external_user; @@LOCAL.external_user plug_dest @@ -347,7 +347,7 @@ CREATE USER uplain@localhost IDENTIFIED WITH 'cleartext_plugin_server' AS 'cleartext_test'; ## test plugin auth ERROR 28000: Access denied for user 'uplain'@'localhost' (using password: YES) -connect cleartext_con,localhost,uplain,cleartext_test; +connect cleartext_con,localhost,uplain,cleartext_test,"*NO-ONE*"; select USER(),CURRENT_USER(); USER() CURRENT_USER() uplain@localhost uplain@localhost @@ -453,7 +453,7 @@ ERROR 1045 (28000): Access denied for user 'unknown'@'localhost' (using password CREATE USER bug12610784@localhost; SET PASSWORD FOR bug12610784@localhost = PASSWORD('secret'); ERROR 28000: Access denied for user 'bug12610784'@'localhost' (using password: NO) -connect b12610784,localhost,bug12610784,secret,test; +connect b12610784,localhost,bug12610784,secret,"*NO-ONE*"; connection default; disconnect b12610784; DROP USER bug12610784@localhost; @@ -466,14 +466,14 @@ IDENTIFIED WITH 'test_plugin_server' AS 'bug12818542_dest'; CREATE USER bug12818542_dest@localhost IDENTIFIED BY 'bug12818542_dest_passwd'; GRANT PROXY ON bug12818542_dest@localhost TO bug12818542@localhost; -connect bug12818542_con,localhost,bug12818542,bug12818542_dest; +connect bug12818542_con,localhost,bug12818542,bug12818542_dest,"*NO-ONE*"; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() bug12818542@localhost bug12818542_dest@localhost SET PASSWORD = PASSWORD('bruhaha'); connection default; disconnect bug12818542_con; -connect bug12818542_con2,localhost,bug12818542,bug12818542_dest; +connect bug12818542_con2,localhost,bug12818542,bug12818542_dest,"*NO-ONE*"; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() bug12818542@localhost bug12818542_dest@localhost diff --git a/mysql-test/main/plugin_auth.test b/mysql-test/main/plugin_auth.test index 48f35ac65e255..1c471cab9b56f 100644 --- a/mysql-test/main/plugin_auth.test +++ b/mysql-test/main/plugin_auth.test @@ -21,7 +21,7 @@ SELECT plugin,authentication_string FROM mysql.user WHERE User='plug'; --echo ## test plugin auth --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK --error ER_ACCESS_DENIED_ERROR : this should fail : no grant -connect(plug_con,localhost,plug,plug_dest); +connect(plug_con,localhost,plug,plug_dest,"*NO-ONE*"); GRANT PROXY ON plug_dest TO plug; --echo test proxies_priv columns @@ -30,7 +30,7 @@ SELECT * FROM mysql.proxies_priv WHERE user !='root'; --echo test mysql.proxies_priv; SHOW CREATE TABLE mysql.proxies_priv; -connect(plug_con,localhost,plug,plug_dest); +connect(plug_con,localhost,plug,plug_dest,"*NO-ONE*"); select USER(),CURRENT_USER(); --echo ## test SET PASSWORD @@ -46,13 +46,13 @@ disconnect plug_con; connect(plug_con,localhost,plug,bad_credentials); --echo ## test bad default plugin : nothing bad happens, as that plugin was't required by the server -connect(plug_con_wrongp,localhost,plug,plug_dest,,,,,wrong_plugin_name); +connect(plug_con_wrongp,localhost,plug,plug_dest,"*NO-ONE*",,,,wrong_plugin_name); select USER(),CURRENT_USER(); connection default; disconnect plug_con_wrongp; --echo ## test correct default plugin -connect(plug_con_rightp,localhost,plug,plug_dest,,,,,auth_test_plugin); +connect(plug_con_rightp,localhost,plug,plug_dest,"*NO-ONE*",,,,auth_test_plugin); select USER(),CURRENT_USER(); connection default; disconnect plug_con_rightp; @@ -68,7 +68,7 @@ CREATE USER `Ÿ` IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; GRANT PROXY ON plug_dest TO `Ÿ`; -connect(non_ascii,localhost,Ÿ,plug_dest); +connect(non_ascii,localhost,Ÿ,plug_dest,"*NO-ONE*"); select USER(),CURRENT_USER(); connection default; @@ -84,8 +84,9 @@ GRANT ALL PRIVILEGES ON test_grant_db.* TO new_grant_user IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; GRANT PROXY ON plug_dest TO new_grant_user; +GRANT CREATE, DROP ON test_grant_db.* TO 'plug_dest'@'%'; -connect(plug_con_grant,localhost,new_grant_user,plug_dest); +connect(plug_con_grant,localhost,new_grant_user,plug_dest,"*NO-ONE*"); select USER(),CURRENT_USER(); USE test_grant_db; CREATE TABLE t1 (a INT); @@ -102,9 +103,8 @@ GRANT ALL PRIVILEGES ON test_grant_db.* TO new_grant_user --error ER_ACCESS_DENIED_ERROR connect(plug_con_grant_deny,localhost,new_grant_user,plug_dest); -connect(plug_con_grant,localhost,new_grant_user,new_password); +connect(plug_con_grant,localhost,new_grant_user,new_password,test_grant_db); select USER(),CURRENT_USER(); -USE test_grant_db; CREATE TABLE t1 (a INT); DROP TABLE t1; connection default; @@ -159,7 +159,7 @@ GRANT ALL SELECT,PROXY ON grant_plug_dest TO grant_plug; --error ER_NONEXISTING_GRANT REVOKE PROXY ON grant_plug_dest FROM grant_plug; -connect(grant_plug_dest_con,localhost,grant_plug_dest,grant_plug_dest_passwd); +connect(grant_plug_dest_con,localhost,grant_plug_dest,grant_plug_dest_passwd,"*NO-ONE*"); --echo ## testing what an ordinary user can grant --echo this should fail : no rights to grant all @@ -262,7 +262,7 @@ SET GLOBAL proxy_user = 'test'; SET LOCAL proxy_user = 'test'; SELECT @@LOCAL.proxy_user; -connect(plug_con,localhost,plug,plug_dest); +connect(plug_con,localhost,plug,plug_dest,"*NO-ONE*"); SELECT @@LOCAL.proxy_user; connection default; disconnect plug_con; @@ -288,7 +288,7 @@ SET GLOBAL external_user = 'test'; SET LOCAL external_user = 'test'; SELECT @@LOCAL.external_user; -connect(plug_con,localhost,plug,plug_dest); +connect(plug_con,localhost,plug,plug_dest,"*NO-ONE*"); SELECT @@LOCAL.external_user; connection default; disconnect plug_con; @@ -418,7 +418,7 @@ CREATE USER uplain@localhost IDENTIFIED WITH 'cleartext_plugin_server' connect(cleartext_fail_con,localhost,uplain,cleartext_test2); --enable_query_log -connect(cleartext_con,localhost,uplain,cleartext_test); +connect(cleartext_con,localhost,uplain,cleartext_test,"*NO-ONE*"); select USER(),CURRENT_USER(); connection default; @@ -533,7 +533,7 @@ SET PASSWORD FOR bug12610784@localhost = PASSWORD('secret'); --error ER_ACCESS_DENIED_ERROR connect(b12610784,localhost,bug12610784,,test); --enable_query_log -connect(b12610784,localhost,bug12610784,secret,test); +connect(b12610784,localhost,bug12610784,secret,"*NO-ONE*"); connection default; disconnect b12610784; DROP USER bug12610784@localhost; @@ -550,7 +550,7 @@ CREATE USER bug12818542_dest@localhost IDENTIFIED BY 'bug12818542_dest_passwd'; GRANT PROXY ON bug12818542_dest@localhost TO bug12818542@localhost; -connect(bug12818542_con,localhost,bug12818542,bug12818542_dest); +connect(bug12818542_con,localhost,bug12818542,bug12818542_dest,"*NO-ONE*"); SELECT USER(),CURRENT_USER(); SET PASSWORD = PASSWORD('bruhaha'); @@ -558,7 +558,7 @@ SET PASSWORD = PASSWORD('bruhaha'); connection default; disconnect bug12818542_con; -connect(bug12818542_con2,localhost,bug12818542,bug12818542_dest); +connect(bug12818542_con2,localhost,bug12818542,bug12818542_dest,"*NO-ONE*"); SELECT USER(),CURRENT_USER(); connection default; diff --git a/mysql-test/main/plugin_auth_qa_1.result b/mysql-test/main/plugin_auth_qa_1.result index 24c86f1e2a8f5..d33662ab618e8 100644 --- a/mysql-test/main/plugin_auth_qa_1.result +++ b/mysql-test/main/plugin_auth_qa_1.result @@ -6,9 +6,11 @@ mariadb.sys mysql_native_password CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; GRANT PROXY ON `plug%dest` TO plug_user; +GRANT ALL ON test_user_db.* TO plug_user; ERROR 1045 (28000): Access denied for user 'plug_user'@'localhost' (using password: YES) REVOKE PROXY ON `plug%dest` FROM plug_user; GRANT PROXY ON plug_dest TO plug_user; +GRANT ALL ON test_user_db.* TO 'plug_dest'@'%'; current_user() plug_dest@% user() @@ -52,6 +54,7 @@ CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; 1) ERROR 1045 (28000): Access denied for user 'plug_user'@'localhost' (using password: YES) GRANT PROXY ON plug_dest TO plug_user; +GRANT ALL ON test_user_db.* TO 'plug_dest'@'%'; 2) current_user() plug_dest@% @@ -103,14 +106,14 @@ CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; GRANT PROXY ON plug_dest TO plug_user; -connect plug_user,localhost,plug_user,plug_dest; +connect plug_user,localhost,plug_user,plug_dest,"*NO-ONE*"; select USER(),CURRENT_USER(); USER() CURRENT_USER() plug_user@localhost plug_dest@% connection default; disconnect plug_user; RENAME USER plug_user TO new_user; -connect plug_user,localhost,new_user,plug_dest; +connect plug_user,localhost,new_user,plug_dest,"*NO-ONE*"; select USER(),CURRENT_USER(); USER() CURRENT_USER() new_user@localhost plug_dest@% @@ -134,7 +137,7 @@ CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; GRANT PROXY ON plug_dest TO plug_user; -connect plug_user,localhost,plug_user,plug_dest; +connect plug_user,localhost,plug_user,plug_dest,"*NO-ONE*"; select USER(),CURRENT_USER(); USER() CURRENT_USER() plug_user@localhost plug_dest@% @@ -176,7 +179,7 @@ User plugin authentication_string mariadb.sys mysql_native_password new_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119 new_user test_plugin_server new_dest -connect plug_user,localhost,new_user,new_dest; +connect plug_user,localhost,new_user,new_dest,"*NO-ONE*"; select USER(),CURRENT_USER(); USER() CURRENT_USER() new_user@localhost new_dest@% @@ -192,7 +195,7 @@ new_dest mysql_native_password *01422E86A6FFF84618914AF149F9AEF64B84170A new_user test_plugin_server new_dest plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119 GRANT ALL PRIVILEGES ON test.* TO new_user; -connect plug_user,localhost,new_dest,new_dest_passwd; +connect plug_user,localhost,new_dest,new_dest_passwd,"*NO-ONE*"; select USER(),CURRENT_USER(); USER() CURRENT_USER() new_dest@localhost new_dest@% @@ -207,7 +210,7 @@ User plugin authentication_string test_plugin_server proxied_user mariadb.sys mysql_native_password proxied_user mysql_native_password *D7A51428CD38DB3C5293B9321DA1228BFB1611DD -connect proxy_con,localhost,proxied_user,proxied_user_passwd; +connect proxy_con,localhost,proxied_user,proxied_user_passwd,"*NO-ONE*"; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() proxied_user@localhost proxied_user@% @@ -219,13 +222,13 @@ connection default; disconnect proxy_con; ERROR 28000: Access denied for user 'proxy_user'@'localhost' (using password: YES) GRANT PROXY ON proxied_user TO ''@'%%'; -connect proxy_con,localhost,proxied_user,proxied_user_passwd; +connect proxy_con,localhost,proxied_user,proxied_user_passwd,"*NO-ONE*"; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() proxied_user@localhost proxied_user@% connection default; disconnect proxy_con; -connect proxy_con,localhost,proxy_user,proxied_user; +connect proxy_con,localhost,proxy_user,proxied_user,"*NO-ONE*"; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() proxy_user@localhost proxied_user@% @@ -244,7 +247,7 @@ User plugin authentication_string test_plugin_server proxied_user mariadb.sys mysql_native_password proxied_user mysql_native_password *D7A51428CD38DB3C5293B9321DA1228BFB1611DD -connect proxy_con,localhost,proxied_user,proxied_user_passwd; +connect proxy_con,localhost,proxied_user,proxied_user_passwd,"*NO-ONE*"; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() proxied_user@localhost proxied_user@% @@ -255,13 +258,13 @@ connection default; disconnect proxy_con; ERROR 28000: Access denied for user 'proxy_user'@'localhost' (using password: YES) GRANT PROXY ON proxied_user TO ''@'%%'; -connect proxy_con,localhost,proxied_user,proxied_user_passwd; +connect proxy_con,localhost,proxied_user,proxied_user_passwd,"*NO-ONE*"; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() proxied_user@localhost proxied_user@% connection default; disconnect proxy_con; -connect proxy_con,localhost,proxy_user,proxied_user; +connect proxy_con,localhost,proxy_user,proxied_user,"*NO-ONE*"; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() proxy_user@localhost proxied_user@% @@ -291,11 +294,11 @@ proxied_user_2 mysql_native_password *3D948F77C6A988AFDCA9755AB2A6724362557220 proxied_user_3 mysql_native_password *41A18925D237DEE738C76581153990B037F462E3 proxied_user_4 mysql_native_password *F990073A9B96FF535C2D0721406042B8751E593F proxied_user_5 mysql_native_password *5AA915C5D0B5B1336336FD2BF7768BC09FD1F5B2 -connect proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd'; -connect proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd; -connect proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd; -connect proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd; -connect proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd; +connect proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd',"*NO-ONE*"; +connect proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd,"*NO-ONE*"; +connect proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd,"*NO-ONE*"; +connect proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd,"*NO-ONE*"; +connect proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd,"*NO-ONE*"; connection proxy_con_1; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() diff --git a/mysql-test/main/plugin_auth_qa_1.test b/mysql-test/main/plugin_auth_qa_1.test index 1c53da598443c..100670dc8e743 100644 --- a/mysql-test/main/plugin_auth_qa_1.test +++ b/mysql-test/main/plugin_auth_qa_1.test @@ -16,10 +16,12 @@ SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; GRANT PROXY ON `plug%dest` TO plug_user; +GRANT ALL ON test_user_db.* TO plug_user; --error 1 --exec $MYSQL -u plug_user --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 REVOKE PROXY ON `plug%dest` FROM plug_user; GRANT PROXY ON plug_dest TO plug_user; +GRANT ALL ON test_user_db.* TO 'plug_dest'@'%'; --replace_result $MASTER_MYSOCK MASTER_MYSOCK --exec $MYSQL -u plug_user --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 REVOKE PROXY ON plug_dest FROM plug_user; @@ -56,6 +58,7 @@ CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; --error 1 --exec $MYSQL -u plug_user --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 GRANT PROXY ON plug_dest TO plug_user; +GRANT ALL ON test_user_db.* TO 'plug_dest'@'%'; --echo 2) --replace_result $MASTER_MYSOCK MASTER_MYSOCK --exec $MYSQL -u plug_user --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 @@ -105,12 +108,12 @@ CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; GRANT PROXY ON plug_dest TO plug_user; -connect(plug_user,localhost,plug_user,plug_dest); +connect(plug_user,localhost,plug_user,plug_dest,"*NO-ONE*"); select USER(),CURRENT_USER(); connection default; disconnect plug_user; RENAME USER plug_user TO new_user; -connect(plug_user,localhost,new_user,plug_dest); +connect(plug_user,localhost,new_user,plug_dest,"*NO-ONE*"); select USER(),CURRENT_USER(); connection default; --sorted_result @@ -128,7 +131,7 @@ CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; GRANT PROXY ON plug_dest TO plug_user; -connect(plug_user,localhost,plug_user,plug_dest); +connect(plug_user,localhost,plug_user,plug_dest,"*NO-ONE*"); select USER(),CURRENT_USER(); connection default; disconnect plug_user; @@ -156,7 +159,7 @@ FLUSH PRIVILEGES; GRANT PROXY ON new_dest TO new_user; --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; -connect(plug_user,localhost,new_user,new_dest); +connect(plug_user,localhost,new_user,new_dest,"*NO-ONE*"); select USER(),CURRENT_USER(); connection default; disconnect plug_user; @@ -166,7 +169,7 @@ CREATE USER new_dest IDENTIFIED BY 'new_dest_passwd'; --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; GRANT ALL PRIVILEGES ON test.* TO new_user; -connect(plug_user,localhost,new_dest,new_dest_passwd); +connect(plug_user,localhost,new_dest,new_dest_passwd,"*NO-ONE*"); select USER(),CURRENT_USER(); connection default; disconnect plug_user; @@ -178,7 +181,7 @@ CREATE USER ''@'%%' IDENTIFIED WITH test_plugin_server AS 'proxied_user'; CREATE USER proxied_user IDENTIFIED BY 'proxied_user_passwd'; --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; -connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +connect(proxy_con,localhost,proxied_user,proxied_user_passwd,"*NO-ONE*"); SELECT USER(),CURRENT_USER(); --echo ========== test 2.2.1 ====================================== SELECT @@proxy_user; @@ -189,11 +192,11 @@ disconnect proxy_con; connect(proxy_con,localhost,proxy_user,proxied_user); --enable_query_log GRANT PROXY ON proxied_user TO ''@'%%'; -connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +connect(proxy_con,localhost,proxied_user,proxied_user_passwd,"*NO-ONE*"); SELECT USER(),CURRENT_USER(); connection default; disconnect proxy_con; -connect(proxy_con,localhost,proxy_user,proxied_user); +connect(proxy_con,localhost,proxy_user,proxied_user,"*NO-ONE*"); SELECT USER(),CURRENT_USER(); --echo ========== test 2.2.1 ====================================== SELECT @@proxy_user; @@ -206,7 +209,7 @@ GRANT ALL PRIVILEGES ON test_user_db.* TO ''@'%%' CREATE USER proxied_user IDENTIFIED BY 'proxied_user_passwd'; --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; -connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +connect(proxy_con,localhost,proxied_user,proxied_user_passwd,"*NO-ONE*"); SELECT USER(),CURRENT_USER(); SELECT @@proxy_user; connection default; @@ -216,11 +219,11 @@ disconnect proxy_con; connect(proxy_con,localhost,proxy_user,proxied_user); --enable_query_log GRANT PROXY ON proxied_user TO ''@'%%'; -connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +connect(proxy_con,localhost,proxied_user,proxied_user_passwd,"*NO-ONE*"); SELECT USER(),CURRENT_USER(); connection default; disconnect proxy_con; -connect(proxy_con,localhost,proxy_user,proxied_user); +connect(proxy_con,localhost,proxy_user,proxied_user,"*NO-ONE*"); SELECT USER(),CURRENT_USER(); SELECT @@proxy_user; connection default; @@ -240,11 +243,11 @@ GRANT PROXY ON proxied_user_4 TO ''@'%%'; GRANT PROXY ON proxied_user_5 TO ''@'%%'; --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; -connect(proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd'); -connect(proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd); -connect(proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd); -connect(proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd); -connect(proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd); +connect(proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd',"*NO-ONE*"); +connect(proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd,"*NO-ONE*"); +connect(proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd,"*NO-ONE*"); +connect(proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd,"*NO-ONE*"); +connect(proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd,"*NO-ONE*"); connection proxy_con_1; SELECT USER(),CURRENT_USER(); SELECT @@proxy_user; diff --git a/mysql-test/main/plugin_auth_qa_2.result b/mysql-test/main/plugin_auth_qa_2.result index de3023a3e4285..c4ec8c0a36482 100644 --- a/mysql-test/main/plugin_auth_qa_2.result +++ b/mysql-test/main/plugin_auth_qa_2.result @@ -5,6 +5,7 @@ CREATE USER qa_test_1_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_1_dest' CREATE USER qa_test_1_dest IDENTIFIED BY 'dest_passwd'; GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_1_dest identified by 'dest_passwd'; GRANT PROXY ON qa_test_1_dest TO qa_test_1_user; +GRANT ALL ON test_user_db.* TO 'qa_test_1_user'@'%'; SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; User plugin authentication_string mariadb.sys mysql_native_password @@ -33,6 +34,7 @@ CREATE USER authenticated_as IDENTIFIED BY 'dest_passwd'; GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_2_dest identified by 'dest_passwd'; GRANT PROXY ON qa_test_2_dest TO qa_test_2_user; GRANT PROXY ON authenticated_as TO qa_test_2_user; +GRANT ALL ON test_user_db.* TO 'authenticated_as'@'%'; SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; User plugin authentication_string authenticated_as mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22 diff --git a/mysql-test/main/plugin_auth_qa_2.test b/mysql-test/main/plugin_auth_qa_2.test index 17e627ab77387..bed5eec59e9cf 100644 --- a/mysql-test/main/plugin_auth_qa_2.test +++ b/mysql-test/main/plugin_auth_qa_2.test @@ -17,6 +17,7 @@ CREATE USER qa_test_1_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_1_dest' CREATE USER qa_test_1_dest IDENTIFIED BY 'dest_passwd'; GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_1_dest identified by 'dest_passwd'; GRANT PROXY ON qa_test_1_dest TO qa_test_1_user; +GRANT ALL ON test_user_db.* TO 'qa_test_1_user'@'%'; --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; SELECT @@proxy_user; @@ -39,6 +40,7 @@ CREATE USER authenticated_as IDENTIFIED BY 'dest_passwd'; GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_2_dest identified by 'dest_passwd'; GRANT PROXY ON qa_test_2_dest TO qa_test_2_user; GRANT PROXY ON authenticated_as TO qa_test_2_user; +GRANT ALL ON test_user_db.* TO 'authenticated_as'@'%'; --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; SELECT @@proxy_user; diff --git a/mysql-test/main/ps_show_log.result b/mysql-test/main/ps_show_log.result index 63cd7789de4d0..dbe078e7d1b6f 100644 --- a/mysql-test/main/ps_show_log.result +++ b/mysql-test/main/ps_show_log.result @@ -51,7 +51,7 @@ DEALLOCATE PREPARE stmt_1; # and check that attempt to execute the statements SHOW BINLOG EVENTS/ # SHOW RELAYLOG EVENTS as a prepred statements by a user without required # privileges results in error. -connect con2,localhost,u1,,test; +connect con2,localhost,u1,,"*NO-ONE*"; PREPARE stmt_1 FROM 'SHOW BINLOG EVENTS'; EXECUTE stmt_1; ERROR 42000: Access denied; you need (at least one of) the BINLOG MONITOR privilege(s) for this operation diff --git a/mysql-test/main/ps_show_log.test b/mysql-test/main/ps_show_log.test index 95000d2d7e0e5..411b15600e130 100644 --- a/mysql-test/main/ps_show_log.test +++ b/mysql-test/main/ps_show_log.test @@ -51,7 +51,7 @@ DEALLOCATE PREPARE stmt_1; --echo # SHOW RELAYLOG EVENTS as a prepred statements by a user without required --echo # privileges results in error. ---connect (con2,localhost,u1,,test) +--connect (con2,localhost,u1,,"*NO-ONE*") PREPARE stmt_1 FROM 'SHOW BINLOG EVENTS'; --error ER_SPECIFIC_ACCESS_DENIED_ERROR diff --git a/mysql-test/main/read_only.result b/mysql-test/main/read_only.result index 83dfada5f2988..65cc12ffce99c 100644 --- a/mysql-test/main/read_only.result +++ b/mysql-test/main/read_only.result @@ -2,6 +2,7 @@ set @start_read_only= @@global.read_only; DROP TABLE IF EXISTS t1,t2,t3; create user test@localhost; grant CREATE, SELECT, DROP on *.* to test@localhost; +grant ALL on test.* to test@localhost; connect con1,localhost,test,,test; connection default; set global read_only=0; @@ -151,6 +152,7 @@ create user `mysqltest_u1`@`%`; grant all on mysqltest_db2.* to `mysqltest_u1`@`%`; create database mysqltest_db1; grant all on mysqltest_db1.* to `mysqltest_u1`@`%`; +grant select on test.* to `mysqltest_u1`@`%`; flush privileges; connect con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,; connection con_bug27440; @@ -191,6 +193,7 @@ USE test; CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1), (2); CREATE USER user1; +GRANT ALL on test.* to user1; connect con1, localhost, user1; connection default; SET GLOBAL read_only= 1; diff --git a/mysql-test/main/read_only.test b/mysql-test/main/read_only.test index 5314b11154ffb..107a67c31fa33 100644 --- a/mysql-test/main/read_only.test +++ b/mysql-test/main/read_only.test @@ -17,6 +17,7 @@ DROP TABLE IF EXISTS t1,t2,t3; create user test@localhost; grant CREATE, SELECT, DROP on *.* to test@localhost; +grant ALL on test.* to test@localhost; connect (con1,localhost,test,,test); @@ -265,6 +266,7 @@ create user `mysqltest_u1`@`%`; grant all on mysqltest_db2.* to `mysqltest_u1`@`%`; create database mysqltest_db1; grant all on mysqltest_db1.* to `mysqltest_u1`@`%`; +grant select on test.* to `mysqltest_u1`@`%`; flush privileges; connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,); connection con_bug27440; @@ -312,6 +314,7 @@ CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1), (2); CREATE USER user1; +GRANT ALL on test.* to user1; connect (con1, localhost, user1); connection default; diff --git a/mysql-test/main/read_only_innodb.result b/mysql-test/main/read_only_innodb.result index abfc5322ed0a6..cfc8f2ecb1740 100644 --- a/mysql-test/main/read_only_innodb.result +++ b/mysql-test/main/read_only_innodb.result @@ -1,6 +1,6 @@ DROP TABLE IF EXISTS table_11733 ; create user test@localhost; -grant CREATE, SELECT, DROP on *.* to test@localhost; +grant CREATE, SELECT, DROP, INSERT on *.* to test@localhost; connect con1,localhost,test,,test; connection default; set global read_only=0; @@ -25,7 +25,7 @@ drop table table_11733 ; drop user test@localhost; disconnect con1; create user test@localhost; -GRANT CREATE, SELECT, DROP ON *.* TO test@localhost; +GRANT CREATE, SELECT, DROP, LOCK TABLES ON *.* TO test@localhost; connect con1, localhost, test, , test; connection default; CREATE TABLE t1(a INT) ENGINE=INNODB; diff --git a/mysql-test/main/read_only_innodb.test b/mysql-test/main/read_only_innodb.test index 4b00c32b1853d..e2c2979c39353 100644 --- a/mysql-test/main/read_only_innodb.test +++ b/mysql-test/main/read_only_innodb.test @@ -15,7 +15,7 @@ DROP TABLE IF EXISTS table_11733 ; # so we use a non-SUPER one: create user test@localhost; -grant CREATE, SELECT, DROP on *.* to test@localhost; +grant CREATE, SELECT, DROP, INSERT on *.* to test@localhost; connect (con1,localhost,test,,test); @@ -50,7 +50,7 @@ disconnect con1; # # Test 1: read only mode create user test@localhost; -GRANT CREATE, SELECT, DROP ON *.* TO test@localhost; +GRANT CREATE, SELECT, DROP, LOCK TABLES ON *.* TO test@localhost; connect(con1, localhost, test, , test); connection default; diff --git a/mysql-test/main/show_check.result b/mysql-test/main/show_check.result index 35428b34599f6..5058f6d6db096 100644 --- a/mysql-test/main/show_check.result +++ b/mysql-test/main/show_check.result @@ -545,7 +545,7 @@ ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table `my drop database mysqltest; ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest' disconnect con1; -connect con2,localhost,mysqltest_2,,test; +connect con2,localhost,mysqltest_2,,"*NO-ONE*"; connection con2; select * from mysqltest.t1; ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table `mysqltest`.`t1` @@ -556,7 +556,7 @@ ERROR 42000: DROP command denied to user 'mysqltest_2'@'localhost' for table `my drop database mysqltest; ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest' disconnect con2; -connect con3,localhost,mysqltest_3,,test; +connect con3,localhost,mysqltest_3,,"*NO-ONE*"; connection con3; select * from mysqltest.t1; ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table `mysqltest`.`t1` @@ -1471,7 +1471,7 @@ DROP EVENT ev1; SHOW STORAGE ENGINES; CREATE USER test_u@localhost; GRANT PROCESS ON *.* TO test_u@localhost; -connect conn1, localhost, test_u,,; +connect conn1, localhost, test_u,,"*NO-ONE*"; SHOW ENGINE MYISAM MUTEX; SHOW ENGINE MYISAM STATUS; disconnect conn1; diff --git a/mysql-test/main/show_check.test b/mysql-test/main/show_check.test index 15beaaf04015c..2a001866186fc 100644 --- a/mysql-test/main/show_check.test +++ b/mysql-test/main/show_check.test @@ -349,7 +349,7 @@ drop database mysqltest; disconnect con1; --source include/wait_until_disconnected.inc -connect (con2,localhost,mysqltest_2,,test); +connect (con2,localhost,mysqltest_2,,"*NO-ONE*"); connection con2; --error ER_TABLEACCESS_DENIED_ERROR select * from mysqltest.t1; @@ -362,7 +362,7 @@ drop database mysqltest; disconnect con2; --source include/wait_until_disconnected.inc -connect (con3,localhost,mysqltest_3,,test); +connect (con3,localhost,mysqltest_3,,"*NO-ONE*"); connection con3; --error ER_TABLEACCESS_DENIED_ERROR select * from mysqltest.t1; @@ -1255,7 +1255,7 @@ SHOW STORAGE ENGINES; CREATE USER test_u@localhost; GRANT PROCESS ON *.* TO test_u@localhost; -connect (conn1, localhost, test_u,,); +connect (conn1, localhost, test_u,,"*NO-ONE*"); --disable_result_log SHOW ENGINE MYISAM MUTEX; diff --git a/mysql-test/main/sp-security.result b/mysql-test/main/sp-security.result index 8a1f46c7c3555..cb158e979d274 100644 --- a/mysql-test/main/sp-security.result +++ b/mysql-test/main/sp-security.result @@ -42,8 +42,8 @@ set sql_mode=''; grant execute on procedure db1_secret.stamp to ''@'%'; grant execute on function db1_secret.db to ''@'%'; set sql_mode=default; -connect con2user1,localhost,user1,,; -connect con3anon,localhost,anon,,; +connect con2user1,localhost,user1,,"*NO-ONE*"; +connect con3anon,localhost,anon,,"*NO-ONE*"; connection con2user1; call db1_secret.stamp(2); select db1_secret.db(); @@ -128,7 +128,7 @@ use db2; create procedure p () insert into t2 values (1); call p(); ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table `db2`.`t2` -connect con4user2,localhost,user2,,; +connect con4user2,localhost,user2,,"*NO-ONE*"; connection con4user2; use db2; call p(); @@ -203,9 +203,9 @@ show grants for userc@localhost; Grants for userc@localhost GRANT USAGE ON *.* TO `userc`@`localhost` GRANT EXECUTE ON PROCEDURE `sptest`.`p1` TO `userc`@`localhost` WITH GRANT OPTION -connect con2usera,localhost,usera,,; -connect con3userb,localhost,userb,,; -connect con4userc,localhost,userc,,; +connect con2usera,localhost,usera,,"*NO-ONE*"; +connect con3userb,localhost,userb,,"*NO-ONE*"; +connect con4userc,localhost,userc,,"*NO-ONE*"; connection con2usera; call sptest.p1(1); grant execute on procedure sptest.p1 to userb@localhost; @@ -270,6 +270,7 @@ use mysqltest// create table t1 (s1 int)// create user user1@localhost// grant select on t1 to user1@localhost// +grant select on test.* to user1@localhost// create function bug_9503 () returns int sql security invoker begin declare v int; select min(s1) into v from t1; return v; end// connect user1,localhost,user1,,test; @@ -349,6 +350,7 @@ return 'ok'; end; | create user user_bug12812@localhost IDENTIFIED BY 'ABC'| +grant select,create view on test.* to user_bug12812@localhost| connect test_user_12812,localhost,user_bug12812,ABC,test; SELECT test.bug12812()| ERROR 42000: execute command denied to user 'user_bug12812'@'localhost' for routine 'test.bug12812' @@ -398,6 +400,7 @@ sql security definer select * from db_bug14533.t1; grant execute on procedure db_bug14533.bug14533_1 to user_bug14533@localhost; grant execute on procedure db_bug14533.bug14533_2 to user_bug14533@localhost; +grant select on test.* to user_bug14533@localhost; connect user_bug14533,localhost,user_bug14533,,test; call db_bug14533.bug14533_1(); Field Type Null Key Default Extra @@ -670,7 +673,7 @@ create database mysqltest_db; create user bug57061_user@localhost; create function mysqltest_db.f1() returns int return 0; create procedure mysqltest_db.p1() begin end; -connect conn1, localhost, bug57061_user,,; +connect conn1, localhost, bug57061_user,,"*NO-ONE*"; # Attempt to drop routine on which user doesn't have privileges # should result in the same 'access denied' type of error whether # routine exists or not. @@ -695,7 +698,7 @@ CREATE DATABASE db1; CREATE PROCEDURE db1.p1() SELECT 1; CREATE USER user2@localhost IDENTIFIED BY ''; GRANT SELECT(db) ON mysql.proc TO user2@localhost; -connect con2, localhost, user2; +connect con2, localhost, user2,,"*NO-ONE*"; # The statement below before disclosed info from body_utf8 column. SHOW CREATE PROCEDURE db1.p1; ERROR 42000: PROCEDURE p1 does not exist @@ -714,6 +717,7 @@ DROP USER user2@localhost; DROP DATABASE db1; create user foo@local_ost; create user foo@`local\_ost` identified via mysql_old_password using '0123456789ABCDEF'; +grant select,create routine on test.* to foo@local_ost; create database foodb; grant create routine on foodb.* to foo@local_ost; connect con1,localhost,foo; @@ -723,11 +727,13 @@ foo@localhost foo@local_ost show grants; Grants for foo@local_ost GRANT USAGE ON *.* TO `foo`@`local_ost` +GRANT SELECT, CREATE ROUTINE ON `test`.* TO `foo`@`local_ost` GRANT CREATE ROUTINE ON `foodb`.* TO `foo`@`local_ost` create procedure fooproc() select 'i am fooproc'; show grants; Grants for foo@local_ost GRANT USAGE ON *.* TO `foo`@`local_ost` +GRANT SELECT, CREATE ROUTINE ON `test`.* TO `foo`@`local_ost` GRANT CREATE ROUTINE ON `foodb`.* TO `foo`@`local_ost` GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO `foo`@`local_ost` disconnect con1; @@ -747,6 +753,7 @@ create function mysqltest_db.f1() returns int return 0; create procedure mysqltest_db.p1() begin end; # Create user with no privileges on mysqltest_db database. create user bug12602983_user@localhost; +grant create view on test.* to bug12602983_user@localhost; connect conn1, localhost, bug12602983_user,,; # Attempt to execute routine on which user doesn't have privileges # should result in the same 'access denied' error whether @@ -794,8 +801,7 @@ CREATE USER u1@localhost; GRANT CREATE ROUTINE ON u1.* TO u1@localhost; GRANT ALTER ROUTINE ON FUNCTION u1.f1 TO u1@localhost; GRANT ALTER ROUTINE ON PROCEDURE u1.p1 TO u1@localhost; -connect u1, localhost, u1,,; -USE u1; +connect u1, localhost, u1,,u1; CREATE OR REPLACE FUNCTION f1() RETURNS INT BEGIN RETURN 2; END; $$ CREATE OR REPLACE PROCEDURE p1() BEGIN SELECT 1; END; $$ disconnect u1; diff --git a/mysql-test/main/sp-security.test b/mysql-test/main/sp-security.test index e11e8911b60e0..a0bf1334fa72c 100644 --- a/mysql-test/main/sp-security.test +++ b/mysql-test/main/sp-security.test @@ -67,8 +67,8 @@ grant execute on procedure db1_secret.stamp to ''@'%'; grant execute on function db1_secret.db to ''@'%'; set sql_mode=default; -connect (con2user1,localhost,user1,,); -connect (con3anon,localhost,anon,,); +connect (con2user1,localhost,user1,,"*NO-ONE*"); +connect (con3anon,localhost,anon,,"*NO-ONE*"); # @@ -195,7 +195,7 @@ create procedure p () insert into t2 values (1); --error ER_TABLEACCESS_DENIED_ERROR call p(); -connect (con4user2,localhost,user2,,); +connect (con4user2,localhost,user2,,"*NO-ONE*"); connection con4user2; use db2; @@ -284,9 +284,9 @@ show grants for usera@localhost; grant execute on procedure sptest.p1 to userc@localhost with grant option; show grants for userc@localhost; -connect (con2usera,localhost,usera,,); -connect (con3userb,localhost,userb,,); -connect (con4userc,localhost,userc,,); +connect (con2usera,localhost,usera,,"*NO-ONE*"); +connect (con3userb,localhost,userb,,"*NO-ONE*"); +connect (con4userc,localhost,userc,,"*NO-ONE*"); connection con2usera; call sptest.p1(1); @@ -357,6 +357,7 @@ use mysqltest// create table t1 (s1 int)// create user user1@localhost// grant select on t1 to user1@localhost// +grant select on test.* to user1@localhost// create function bug_9503 () returns int sql security invoker begin declare v int; select min(s1) into v from t1; return v; end// delimiter ;// @@ -467,6 +468,7 @@ begin end; | create user user_bug12812@localhost IDENTIFIED BY 'ABC'| +grant select,create view on test.* to user_bug12812@localhost| --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (test_user_12812,localhost,user_bug12812,ABC,test)| --error ER_PROCACCESS_DENIED_ERROR @@ -543,6 +545,7 @@ create procedure bug14533_2() grant execute on procedure db_bug14533.bug14533_1 to user_bug14533@localhost; grant execute on procedure db_bug14533.bug14533_2 to user_bug14533@localhost; +grant select on test.* to user_bug14533@localhost; connect (user_bug14533,localhost,user_bug14533,,test); @@ -926,7 +929,7 @@ create database mysqltest_db; create user bug57061_user@localhost; create function mysqltest_db.f1() returns int return 0; create procedure mysqltest_db.p1() begin end; -connect (conn1, localhost, bug57061_user,,); +connect (conn1, localhost, bug57061_user,,"*NO-ONE*"); --echo # Attempt to drop routine on which user doesn't have privileges --echo # should result in the same 'access denied' type of error whether --echo # routine exists or not. @@ -958,7 +961,7 @@ CREATE PROCEDURE db1.p1() SELECT 1; CREATE USER user2@localhost IDENTIFIED BY ''; GRANT SELECT(db) ON mysql.proc TO user2@localhost; -connect (con2, localhost, user2); +connect (con2, localhost, user2,,"*NO-ONE*"); --echo # The statement below before disclosed info from body_utf8 column. --error ER_SP_DOES_NOT_EXIST SHOW CREATE PROCEDURE db1.p1; @@ -981,6 +984,7 @@ DROP DATABASE db1; # create user foo@local_ost; create user foo@`local\_ost` identified via mysql_old_password using '0123456789ABCDEF'; +grant select,create routine on test.* to foo@local_ost; create database foodb; grant create routine on foodb.* to foo@local_ost; connect con1,localhost,foo; @@ -1009,6 +1013,7 @@ create procedure mysqltest_db.p1() begin end; --echo # Create user with no privileges on mysqltest_db database. create user bug12602983_user@localhost; +grant create view on test.* to bug12602983_user@localhost; connect (conn1, localhost, bug12602983_user,,); @@ -1066,8 +1071,7 @@ GRANT CREATE ROUTINE ON u1.* TO u1@localhost; GRANT ALTER ROUTINE ON FUNCTION u1.f1 TO u1@localhost; GRANT ALTER ROUTINE ON PROCEDURE u1.p1 TO u1@localhost; -connect (u1, localhost, u1,,); -USE u1; +connect (u1, localhost, u1,,u1); DELIMITER $$; CREATE OR REPLACE FUNCTION f1() RETURNS INT BEGIN RETURN 2; END; $$ CREATE OR REPLACE PROCEDURE p1() BEGIN SELECT 1; END; $$ diff --git a/mysql-test/main/sql_mode.result b/mysql-test/main/sql_mode.result index 6ac65302d47f5..31308cd6a2f51 100644 --- a/mysql-test/main/sql_mode.result +++ b/mysql-test/main/sql_mode.result @@ -505,7 +505,7 @@ connection default; set @OLD_SQL_MODE=@@SESSION.SQL_MODE; set session sql_mode='PAD_CHAR_TO_FULL_LENGTH'; flush privileges; -connect user_32753,localhost,mysqltest_32753,,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect user_32753,localhost,mysqltest_32753,,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; select current_user(); current_user() mysqltest_32753@localhost diff --git a/mysql-test/main/sql_mode.test b/mysql-test/main/sql_mode.test index b1c5f05e6181a..bfcaff392539d 100644 --- a/mysql-test/main/sql_mode.test +++ b/mysql-test/main/sql_mode.test @@ -302,7 +302,7 @@ flush privileges; # if user-table is affected by PAD_CHAR_TO_FULL_LENGTH, our connect will fail # --error 1045 -connect (user_32753,localhost,mysqltest_32753,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +connect (user_32753,localhost,mysqltest_32753,,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); select current_user(); # clean up diff --git a/mysql-test/main/system_mysql_db_fix40123.result b/mysql-test/main/system_mysql_db_fix40123.result index 31a334878ece0..2ed1e8ae618ca 100644 --- a/mysql-test/main/system_mysql_db_fix40123.result +++ b/mysql-test/main/system_mysql_db_fix40123.result @@ -100,7 +100,7 @@ db CREATE TABLE `db` ( ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Database privileges' show create table user; View Create View character_set_client collation_connection -user CREATE ALGORITHM=UNDEFINED DEFINER=`mariadb.sys`@`localhost` SQL SECURITY DEFINER VIEW `user` AS select `global_priv`.`Host` AS `Host`,`global_priv`.`User` AS `User`,if(json_value(`global_priv`.`Priv`,'$.plugin') in ('mysql_native_password','mysql_old_password'),ifnull(json_value(`global_priv`.`Priv`,'$.authentication_string'),''),'') AS `Password`,if(json_value(`global_priv`.`Priv`,'$.access') & 1,'Y','N') AS `Select_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 2,'Y','N') AS `Insert_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 4,'Y','N') AS `Update_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 8,'Y','N') AS `Delete_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 16,'Y','N') AS `Create_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 32,'Y','N') AS `Drop_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 64,'Y','N') AS `Reload_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 128,'Y','N') AS `Shutdown_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 256,'Y','N') AS `Process_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 512,'Y','N') AS `File_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 1024,'Y','N') AS `Grant_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 2048,'Y','N') AS `References_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 4096,'Y','N') AS `Index_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 8192,'Y','N') AS `Alter_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 16384,'Y','N') AS `Show_db_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 32768,'Y','N') AS `Super_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 65536,'Y','N') AS `Create_tmp_table_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 131072,'Y','N') AS `Lock_tables_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 262144,'Y','N') AS `Execute_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 524288,'Y','N') AS `Repl_slave_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 1048576,'Y','N') AS `Repl_client_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 2097152,'Y','N') AS `Create_view_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 4194304,'Y','N') AS `Show_view_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 8388608,'Y','N') AS `Create_routine_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 16777216,'Y','N') AS `Alter_routine_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 33554432,'Y','N') AS `Create_user_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 67108864,'Y','N') AS `Event_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 134217728,'Y','N') AS `Trigger_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 268435456,'Y','N') AS `Create_tablespace_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 536870912,'Y','N') AS `Delete_history_priv`,elt(ifnull(json_value(`global_priv`.`Priv`,'$.ssl_type'),0) + 1,'','ANY','X509','SPECIFIED') AS `ssl_type`,ifnull(json_value(`global_priv`.`Priv`,'$.ssl_cipher'),'') AS `ssl_cipher`,ifnull(json_value(`global_priv`.`Priv`,'$.x509_issuer'),'') AS `x509_issuer`,ifnull(json_value(`global_priv`.`Priv`,'$.x509_subject'),'') AS `x509_subject`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_questions'),0) as unsigned) AS `max_questions`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_updates'),0) as unsigned) AS `max_updates`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_connections'),0) as unsigned) AS `max_connections`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_user_connections'),0) as signed) AS `max_user_connections`,ifnull(json_value(`global_priv`.`Priv`,'$.plugin'),'') AS `plugin`,ifnull(json_value(`global_priv`.`Priv`,'$.authentication_string'),'') AS `authentication_string`,if(ifnull(json_value(`global_priv`.`Priv`,'$.password_last_changed'),1) = 0,'Y','N') AS `password_expired`,elt(ifnull(json_value(`global_priv`.`Priv`,'$.is_role'),0) + 1,'N','Y') AS `is_role`,ifnull(json_value(`global_priv`.`Priv`,'$.default_role'),'') AS `default_role`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_statement_time'),0.0) as decimal(12,6)) AS `max_statement_time` from `global_priv` latin1 latin1_swedish_ci +user CREATE ALGORITHM=UNDEFINED DEFINER=`mariadb.sys`@`localhost` SQL SECURITY DEFINER VIEW `user` AS select `test`.`global_priv`.`Host` AS `Host`,`test`.`global_priv`.`User` AS `User`,if(json_value(`test`.`global_priv`.`Priv`,'$.plugin') in ('mysql_native_password','mysql_old_password'),ifnull(json_value(`test`.`global_priv`.`Priv`,'$.authentication_string'),''),'') AS `Password`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1,'Y','N') AS `Select_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2,'Y','N') AS `Insert_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4,'Y','N') AS `Update_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8,'Y','N') AS `Delete_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16,'Y','N') AS `Create_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 32,'Y','N') AS `Drop_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 64,'Y','N') AS `Reload_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 128,'Y','N') AS `Shutdown_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 256,'Y','N') AS `Process_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 512,'Y','N') AS `File_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1024,'Y','N') AS `Grant_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2048,'Y','N') AS `References_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4096,'Y','N') AS `Index_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8192,'Y','N') AS `Alter_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16384,'Y','N') AS `Show_db_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 32768,'Y','N') AS `Super_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 65536,'Y','N') AS `Create_tmp_table_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 131072,'Y','N') AS `Lock_tables_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 262144,'Y','N') AS `Execute_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 524288,'Y','N') AS `Repl_slave_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1048576,'Y','N') AS `Repl_client_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2097152,'Y','N') AS `Create_view_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4194304,'Y','N') AS `Show_view_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8388608,'Y','N') AS `Create_routine_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16777216,'Y','N') AS `Alter_routine_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 33554432,'Y','N') AS `Create_user_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 67108864,'Y','N') AS `Event_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 134217728,'Y','N') AS `Trigger_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 268435456,'Y','N') AS `Create_tablespace_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 536870912,'Y','N') AS `Delete_history_priv`,elt(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.ssl_type'),0) + 1,'','ANY','X509','SPECIFIED') AS `ssl_type`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.ssl_cipher'),'') AS `ssl_cipher`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.x509_issuer'),'') AS `x509_issuer`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.x509_subject'),'') AS `x509_subject`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_questions'),0) as unsigned) AS `max_questions`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_updates'),0) as unsigned) AS `max_updates`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_connections'),0) as unsigned) AS `max_connections`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_user_connections'),0) as signed) AS `max_user_connections`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.plugin'),'') AS `plugin`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.authentication_string'),'') AS `authentication_string`,if(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.password_last_changed'),1) = 0,'Y','N') AS `password_expired`,elt(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.is_role'),0) + 1,'N','Y') AS `is_role`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.default_role'),'') AS `default_role`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_statement_time'),0.0) as decimal(12,6)) AS `max_statement_time` from `global_priv` latin1 latin1_swedish_ci show create table func; Table Create Table func CREATE TABLE `func` ( diff --git a/mysql-test/main/system_mysql_db_fix50030.result b/mysql-test/main/system_mysql_db_fix50030.result index 8055211e5b2c3..b99b8678b1aad 100644 --- a/mysql-test/main/system_mysql_db_fix50030.result +++ b/mysql-test/main/system_mysql_db_fix50030.result @@ -104,7 +104,7 @@ db CREATE TABLE `db` ( ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Database privileges' show create table user; View Create View character_set_client collation_connection -user CREATE ALGORITHM=UNDEFINED DEFINER=`mariadb.sys`@`localhost` SQL SECURITY DEFINER VIEW `user` AS select `global_priv`.`Host` AS `Host`,`global_priv`.`User` AS `User`,if(json_value(`global_priv`.`Priv`,'$.plugin') in ('mysql_native_password','mysql_old_password'),ifnull(json_value(`global_priv`.`Priv`,'$.authentication_string'),''),'') AS `Password`,if(json_value(`global_priv`.`Priv`,'$.access') & 1,'Y','N') AS `Select_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 2,'Y','N') AS `Insert_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 4,'Y','N') AS `Update_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 8,'Y','N') AS `Delete_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 16,'Y','N') AS `Create_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 32,'Y','N') AS `Drop_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 64,'Y','N') AS `Reload_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 128,'Y','N') AS `Shutdown_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 256,'Y','N') AS `Process_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 512,'Y','N') AS `File_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 1024,'Y','N') AS `Grant_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 2048,'Y','N') AS `References_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 4096,'Y','N') AS `Index_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 8192,'Y','N') AS `Alter_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 16384,'Y','N') AS `Show_db_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 32768,'Y','N') AS `Super_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 65536,'Y','N') AS `Create_tmp_table_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 131072,'Y','N') AS `Lock_tables_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 262144,'Y','N') AS `Execute_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 524288,'Y','N') AS `Repl_slave_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 1048576,'Y','N') AS `Repl_client_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 2097152,'Y','N') AS `Create_view_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 4194304,'Y','N') AS `Show_view_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 8388608,'Y','N') AS `Create_routine_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 16777216,'Y','N') AS `Alter_routine_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 33554432,'Y','N') AS `Create_user_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 67108864,'Y','N') AS `Event_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 134217728,'Y','N') AS `Trigger_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 268435456,'Y','N') AS `Create_tablespace_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 536870912,'Y','N') AS `Delete_history_priv`,elt(ifnull(json_value(`global_priv`.`Priv`,'$.ssl_type'),0) + 1,'','ANY','X509','SPECIFIED') AS `ssl_type`,ifnull(json_value(`global_priv`.`Priv`,'$.ssl_cipher'),'') AS `ssl_cipher`,ifnull(json_value(`global_priv`.`Priv`,'$.x509_issuer'),'') AS `x509_issuer`,ifnull(json_value(`global_priv`.`Priv`,'$.x509_subject'),'') AS `x509_subject`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_questions'),0) as unsigned) AS `max_questions`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_updates'),0) as unsigned) AS `max_updates`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_connections'),0) as unsigned) AS `max_connections`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_user_connections'),0) as signed) AS `max_user_connections`,ifnull(json_value(`global_priv`.`Priv`,'$.plugin'),'') AS `plugin`,ifnull(json_value(`global_priv`.`Priv`,'$.authentication_string'),'') AS `authentication_string`,if(ifnull(json_value(`global_priv`.`Priv`,'$.password_last_changed'),1) = 0,'Y','N') AS `password_expired`,elt(ifnull(json_value(`global_priv`.`Priv`,'$.is_role'),0) + 1,'N','Y') AS `is_role`,ifnull(json_value(`global_priv`.`Priv`,'$.default_role'),'') AS `default_role`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_statement_time'),0.0) as decimal(12,6)) AS `max_statement_time` from `global_priv` latin1 latin1_swedish_ci +user CREATE ALGORITHM=UNDEFINED DEFINER=`mariadb.sys`@`localhost` SQL SECURITY DEFINER VIEW `user` AS select `test`.`global_priv`.`Host` AS `Host`,`test`.`global_priv`.`User` AS `User`,if(json_value(`test`.`global_priv`.`Priv`,'$.plugin') in ('mysql_native_password','mysql_old_password'),ifnull(json_value(`test`.`global_priv`.`Priv`,'$.authentication_string'),''),'') AS `Password`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1,'Y','N') AS `Select_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2,'Y','N') AS `Insert_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4,'Y','N') AS `Update_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8,'Y','N') AS `Delete_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16,'Y','N') AS `Create_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 32,'Y','N') AS `Drop_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 64,'Y','N') AS `Reload_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 128,'Y','N') AS `Shutdown_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 256,'Y','N') AS `Process_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 512,'Y','N') AS `File_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1024,'Y','N') AS `Grant_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2048,'Y','N') AS `References_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4096,'Y','N') AS `Index_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8192,'Y','N') AS `Alter_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16384,'Y','N') AS `Show_db_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 32768,'Y','N') AS `Super_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 65536,'Y','N') AS `Create_tmp_table_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 131072,'Y','N') AS `Lock_tables_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 262144,'Y','N') AS `Execute_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 524288,'Y','N') AS `Repl_slave_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1048576,'Y','N') AS `Repl_client_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2097152,'Y','N') AS `Create_view_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4194304,'Y','N') AS `Show_view_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8388608,'Y','N') AS `Create_routine_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16777216,'Y','N') AS `Alter_routine_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 33554432,'Y','N') AS `Create_user_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 67108864,'Y','N') AS `Event_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 134217728,'Y','N') AS `Trigger_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 268435456,'Y','N') AS `Create_tablespace_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 536870912,'Y','N') AS `Delete_history_priv`,elt(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.ssl_type'),0) + 1,'','ANY','X509','SPECIFIED') AS `ssl_type`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.ssl_cipher'),'') AS `ssl_cipher`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.x509_issuer'),'') AS `x509_issuer`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.x509_subject'),'') AS `x509_subject`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_questions'),0) as unsigned) AS `max_questions`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_updates'),0) as unsigned) AS `max_updates`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_connections'),0) as unsigned) AS `max_connections`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_user_connections'),0) as signed) AS `max_user_connections`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.plugin'),'') AS `plugin`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.authentication_string'),'') AS `authentication_string`,if(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.password_last_changed'),1) = 0,'Y','N') AS `password_expired`,elt(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.is_role'),0) + 1,'N','Y') AS `is_role`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.default_role'),'') AS `default_role`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_statement_time'),0.0) as decimal(12,6)) AS `max_statement_time` from `global_priv` latin1 latin1_swedish_ci show create table func; Table Create Table func CREATE TABLE `func` ( diff --git a/mysql-test/main/system_mysql_db_fix50117.result b/mysql-test/main/system_mysql_db_fix50117.result index 214b7ee572dbf..8e48c2accb74b 100644 --- a/mysql-test/main/system_mysql_db_fix50117.result +++ b/mysql-test/main/system_mysql_db_fix50117.result @@ -84,7 +84,7 @@ db CREATE TABLE `db` ( ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Database privileges' show create table user; View Create View character_set_client collation_connection -user CREATE ALGORITHM=UNDEFINED DEFINER=`mariadb.sys`@`localhost` SQL SECURITY DEFINER VIEW `user` AS select `global_priv`.`Host` AS `Host`,`global_priv`.`User` AS `User`,if(json_value(`global_priv`.`Priv`,'$.plugin') in ('mysql_native_password','mysql_old_password'),ifnull(json_value(`global_priv`.`Priv`,'$.authentication_string'),''),'') AS `Password`,if(json_value(`global_priv`.`Priv`,'$.access') & 1,'Y','N') AS `Select_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 2,'Y','N') AS `Insert_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 4,'Y','N') AS `Update_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 8,'Y','N') AS `Delete_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 16,'Y','N') AS `Create_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 32,'Y','N') AS `Drop_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 64,'Y','N') AS `Reload_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 128,'Y','N') AS `Shutdown_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 256,'Y','N') AS `Process_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 512,'Y','N') AS `File_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 1024,'Y','N') AS `Grant_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 2048,'Y','N') AS `References_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 4096,'Y','N') AS `Index_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 8192,'Y','N') AS `Alter_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 16384,'Y','N') AS `Show_db_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 32768,'Y','N') AS `Super_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 65536,'Y','N') AS `Create_tmp_table_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 131072,'Y','N') AS `Lock_tables_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 262144,'Y','N') AS `Execute_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 524288,'Y','N') AS `Repl_slave_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 1048576,'Y','N') AS `Repl_client_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 2097152,'Y','N') AS `Create_view_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 4194304,'Y','N') AS `Show_view_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 8388608,'Y','N') AS `Create_routine_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 16777216,'Y','N') AS `Alter_routine_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 33554432,'Y','N') AS `Create_user_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 67108864,'Y','N') AS `Event_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 134217728,'Y','N') AS `Trigger_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 268435456,'Y','N') AS `Create_tablespace_priv`,if(json_value(`global_priv`.`Priv`,'$.access') & 536870912,'Y','N') AS `Delete_history_priv`,elt(ifnull(json_value(`global_priv`.`Priv`,'$.ssl_type'),0) + 1,'','ANY','X509','SPECIFIED') AS `ssl_type`,ifnull(json_value(`global_priv`.`Priv`,'$.ssl_cipher'),'') AS `ssl_cipher`,ifnull(json_value(`global_priv`.`Priv`,'$.x509_issuer'),'') AS `x509_issuer`,ifnull(json_value(`global_priv`.`Priv`,'$.x509_subject'),'') AS `x509_subject`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_questions'),0) as unsigned) AS `max_questions`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_updates'),0) as unsigned) AS `max_updates`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_connections'),0) as unsigned) AS `max_connections`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_user_connections'),0) as signed) AS `max_user_connections`,ifnull(json_value(`global_priv`.`Priv`,'$.plugin'),'') AS `plugin`,ifnull(json_value(`global_priv`.`Priv`,'$.authentication_string'),'') AS `authentication_string`,if(ifnull(json_value(`global_priv`.`Priv`,'$.password_last_changed'),1) = 0,'Y','N') AS `password_expired`,elt(ifnull(json_value(`global_priv`.`Priv`,'$.is_role'),0) + 1,'N','Y') AS `is_role`,ifnull(json_value(`global_priv`.`Priv`,'$.default_role'),'') AS `default_role`,cast(ifnull(json_value(`global_priv`.`Priv`,'$.max_statement_time'),0.0) as decimal(12,6)) AS `max_statement_time` from `global_priv` latin1 latin1_swedish_ci +user CREATE ALGORITHM=UNDEFINED DEFINER=`mariadb.sys`@`localhost` SQL SECURITY DEFINER VIEW `user` AS select `test`.`global_priv`.`Host` AS `Host`,`test`.`global_priv`.`User` AS `User`,if(json_value(`test`.`global_priv`.`Priv`,'$.plugin') in ('mysql_native_password','mysql_old_password'),ifnull(json_value(`test`.`global_priv`.`Priv`,'$.authentication_string'),''),'') AS `Password`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1,'Y','N') AS `Select_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2,'Y','N') AS `Insert_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4,'Y','N') AS `Update_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8,'Y','N') AS `Delete_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16,'Y','N') AS `Create_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 32,'Y','N') AS `Drop_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 64,'Y','N') AS `Reload_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 128,'Y','N') AS `Shutdown_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 256,'Y','N') AS `Process_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 512,'Y','N') AS `File_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1024,'Y','N') AS `Grant_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2048,'Y','N') AS `References_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4096,'Y','N') AS `Index_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8192,'Y','N') AS `Alter_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16384,'Y','N') AS `Show_db_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 32768,'Y','N') AS `Super_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 65536,'Y','N') AS `Create_tmp_table_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 131072,'Y','N') AS `Lock_tables_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 262144,'Y','N') AS `Execute_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 524288,'Y','N') AS `Repl_slave_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1048576,'Y','N') AS `Repl_client_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2097152,'Y','N') AS `Create_view_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4194304,'Y','N') AS `Show_view_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8388608,'Y','N') AS `Create_routine_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16777216,'Y','N') AS `Alter_routine_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 33554432,'Y','N') AS `Create_user_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 67108864,'Y','N') AS `Event_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 134217728,'Y','N') AS `Trigger_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 268435456,'Y','N') AS `Create_tablespace_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 536870912,'Y','N') AS `Delete_history_priv`,elt(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.ssl_type'),0) + 1,'','ANY','X509','SPECIFIED') AS `ssl_type`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.ssl_cipher'),'') AS `ssl_cipher`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.x509_issuer'),'') AS `x509_issuer`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.x509_subject'),'') AS `x509_subject`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_questions'),0) as unsigned) AS `max_questions`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_updates'),0) as unsigned) AS `max_updates`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_connections'),0) as unsigned) AS `max_connections`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_user_connections'),0) as signed) AS `max_user_connections`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.plugin'),'') AS `plugin`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.authentication_string'),'') AS `authentication_string`,if(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.password_last_changed'),1) = 0,'Y','N') AS `password_expired`,elt(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.is_role'),0) + 1,'N','Y') AS `is_role`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.default_role'),'') AS `default_role`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_statement_time'),0.0) as decimal(12,6)) AS `max_statement_time` from `global_priv` latin1 latin1_swedish_ci show create table func; Table Create Table func CREATE TABLE `func` ( diff --git a/mysql-test/main/user_limits.result b/mysql-test/main/user_limits.result index acb34754caaf0..1cb4f9c03e86c 100644 --- a/mysql-test/main/user_limits.result +++ b/mysql-test/main/user_limits.result @@ -7,7 +7,7 @@ delete from mysql.tables_priv where user like 'mysqltest\_%'; delete from mysql.columns_priv where user like 'mysqltest\_%'; flush privileges; create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2; +grant all on test.* to mysqltest_1@localhost with max_queries_per_hour 2; flush user_resources; connect mqph, localhost, mysqltest_1,,; connection mqph; @@ -26,7 +26,7 @@ drop user mysqltest_1@localhost; disconnect mqph; disconnect mqph2; create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2; +grant all on test.* to mysqltest_1@localhost with max_updates_per_hour 2; flush user_resources; connect muph, localhost, mysqltest_1,,; connection muph; @@ -53,7 +53,7 @@ drop user mysqltest_1@localhost; disconnect muph; disconnect muph2; create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2; +grant all on test.* to mysqltest_1@localhost with max_connections_per_hour 2; flush user_resources; connect mcph1, localhost, mysqltest_1,,; connection mcph1; @@ -77,7 +77,7 @@ connection default; drop user mysqltest_1@localhost; flush privileges; create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost with max_user_connections 2; +grant all on test.* to mysqltest_1@localhost with max_user_connections 2; flush user_resources; connect muc1, localhost, mysqltest_1,,; connection muc1; @@ -109,10 +109,12 @@ grant usage on *.* to mysqltest_1@localhost with max_user_connections -1; show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO `mysqltest_1`@`localhost` WITH MAX_USER_CONNECTIONS -1 +GRANT ALL PRIVILEGES ON `test`.* TO `mysqltest_1`@`localhost` flush user_resources; show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO `mysqltest_1`@`localhost` WITH MAX_USER_CONNECTIONS -1 +GRANT ALL PRIVILEGES ON `test`.* TO `mysqltest_1`@`localhost` connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); connect muc5, localhost, mysqltest_1,,; ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource (current value: -1) @@ -130,7 +132,7 @@ select @@session.max_user_connections, @@global.max_user_connections; @@session.max_user_connections @@global.max_user_connections 2 2 create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost; +grant all on test.* to mysqltest_1@localhost; flush user_resources; connect muca1, localhost, mysqltest_1,,; connection muca1; @@ -193,7 +195,7 @@ set global max_user_connections= @my_max_user_connections; # MDEV-17852 Altered connection limits for user have no effect # create user foo@'%' with max_user_connections 1; -connect con1,localhost,foo; +connect con1,localhost,foo,,"*NO-ONE*"; select current_user(); current_user() foo@% @@ -202,7 +204,7 @@ connect con2,localhost,foo; ERROR 42000: User 'foo' has exceeded the 'max_user_connections' resource (current value: 1) connection default; alter user foo with max_user_connections 2; -connect con3,localhost,foo; +connect con3,localhost,foo,,"*NO-ONE*"; select current_user(); current_user() foo@% diff --git a/mysql-test/main/user_limits.test b/mysql-test/main/user_limits.test index 36524febd8d3d..10e15ca3c9c19 100644 --- a/mysql-test/main/user_limits.test +++ b/mysql-test/main/user_limits.test @@ -27,7 +27,7 @@ flush privileges; # Test of MAX_QUERIES_PER_HOUR limit create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2; +grant all on test.* to mysqltest_1@localhost with max_queries_per_hour 2; # This ensures that counters are reset and makes test scheduling independent flush user_resources; connect (mqph, localhost, mysqltest_1,,); @@ -48,7 +48,7 @@ disconnect mqph2; # Test of MAX_UPDATES_PER_HOUR limit create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2; +grant all on test.* to mysqltest_1@localhost with max_updates_per_hour 2; flush user_resources; connect (muph, localhost, mysqltest_1,,); connection muph; @@ -73,7 +73,7 @@ disconnect muph2; # Test of MAX_CONNECTIONS_PER_HOUR limit create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2; +grant all on test.* to mysqltest_1@localhost with max_connections_per_hour 2; flush user_resources; connect (mcph1, localhost, mysqltest_1,,); connection mcph1; @@ -101,7 +101,7 @@ drop user mysqltest_1@localhost; # We need this to reset internal mqh_used variable flush privileges; create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost with max_user_connections 2; +grant all on test.* to mysqltest_1@localhost with max_user_connections 2; flush user_resources; connect (muc1, localhost, mysqltest_1,,); connection muc1; @@ -155,7 +155,7 @@ set global max_user_connections= 2; select @@session.max_user_connections, @@global.max_user_connections; # Let us check that global limit works create user mysqltest_1@localhost; -grant usage on *.* to mysqltest_1@localhost; +grant all on test.* to mysqltest_1@localhost; flush user_resources; connect (muca1, localhost, mysqltest_1,,); connection muca1; @@ -225,14 +225,14 @@ set global max_user_connections= @my_max_user_connections; --echo # MDEV-17852 Altered connection limits for user have no effect --echo # create user foo@'%' with max_user_connections 1; ---connect con1,localhost,foo +--connect con1,localhost,foo,,"*NO-ONE*" select current_user(); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK --error ER_USER_LIMIT_REACHED --connect con2,localhost,foo --connection default alter user foo with max_user_connections 2; ---connect con3,localhost,foo +--connect con3,localhost,foo,,"*NO-ONE*" select current_user(); --disconnect con3 --disconnect con1 diff --git a/mysql-test/main/userstat-badlogin-4824.result b/mysql-test/main/userstat-badlogin-4824.result index b32b05e649df3..2d34f78e006df 100644 --- a/mysql-test/main/userstat-badlogin-4824.result +++ b/mysql-test/main/userstat-badlogin-4824.result @@ -2,7 +2,7 @@ set @save_userstat=@@global.userstat; create user foo@localhost identified by 'foo'; flush user_statistics; set global userstat=1; -connect foo, localhost, foo, foo, test; +connect foo, localhost, foo, foo, "*NO-ONE*"; select 1; 1 1 diff --git a/mysql-test/main/userstat-badlogin-4824.test b/mysql-test/main/userstat-badlogin-4824.test index 3db3e10da1523..8ee5d189f779b 100644 --- a/mysql-test/main/userstat-badlogin-4824.test +++ b/mysql-test/main/userstat-badlogin-4824.test @@ -12,7 +12,7 @@ create user foo@localhost identified by 'foo'; flush user_statistics; set global userstat=1; -connect(foo, localhost, foo, foo, test); +connect(foo, localhost, foo, foo, "*NO-ONE*"); select 1; disconnect foo; connection default; diff --git a/mysql-test/main/view_grant.result b/mysql-test/main/view_grant.result index 370035147a164..3754a55eea8a8 100644 --- a/mysql-test/main/view_grant.result +++ b/mysql-test/main/view_grant.result @@ -46,11 +46,12 @@ revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; revoke all privileges on test.* from mysqltest_1@localhost; drop database mysqltest; drop view test.v1; +disconnect user1; create database mysqltest; create table mysqltest.t1 (a int, b int); create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; grant select (c) on mysqltest.v1 to mysqltest_1@localhost; -connection user1; +connect user1,localhost,mysqltest_1,,mysqltest; select c from mysqltest.v1; c select d from mysqltest.v1; @@ -70,6 +71,7 @@ c select d from mysqltest.v1; ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1' connection root; +disconnect user1; revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; @@ -88,7 +90,7 @@ grant select on mysqltest.v2 to mysqltest_1@localhost; grant select on mysqltest.v3 to mysqltest_1@localhost; grant select on mysqltest.v4 to mysqltest_1@localhost; grant show view on mysqltest.v5 to mysqltest_1@localhost; -connection user1; +connect user1,localhost,mysqltest_1,,mysqltest; select c from mysqltest.v1; c select c from mysqltest.v2; @@ -132,7 +134,7 @@ grant select on mysqltest.v5 to mysqltest_1@localhost; connection user1; show create view mysqltest.v5; View Create View character_set_client collation_connection -v5 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v5` AS select `mysqltest`.`t1`.`a` + 1 AS `c`,`mysqltest`.`t1`.`b` + 1 AS `d` from `mysqltest`.`t1` latin1 latin1_swedish_ci +v5 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v5` AS select `t1`.`a` + 1 AS `c`,`t1`.`b` + 1 AS `d` from `t1` latin1 latin1_swedish_ci explain select c from mysqltest.v1; ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table show create view mysqltest.v1; @@ -141,13 +143,14 @@ connection root; grant show view on mysqltest.v1 to mysqltest_1@localhost; grant select on mysqltest.t1 to mysqltest_1@localhost; revoke select on mysqltest.v5 from mysqltest_1@localhost; -connection user1; +disconnect user1; +connect user1,localhost,mysqltest_1,,mysqltest; explain select c from mysqltest.v1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 0 Const row not found show create view mysqltest.v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` AS select `mysqltest`.`t1`.`a` + 1 AS `c`,`mysqltest`.`t1`.`b` + 1 AS `d` from `mysqltest`.`t1` latin1 latin1_swedish_ci +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` + 1 AS `c`,`t1`.`b` + 1 AS `d` from `t1` latin1 latin1_swedish_ci explain select c from mysqltest.v2; ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table show create view mysqltest.v2; @@ -164,34 +167,36 @@ explain select c from mysqltest.v5; ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table `mysqltest`.`v5` connection root; grant show view on mysqltest.* to mysqltest_1@localhost; -connection user1; +disconnect user1; +connect user1,localhost,mysqltest_1,,mysqltest; explain select c from mysqltest.v1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 0 Const row not found show create view mysqltest.v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` AS select `mysqltest`.`t1`.`a` + 1 AS `c`,`mysqltest`.`t1`.`b` + 1 AS `d` from `mysqltest`.`t1` latin1 latin1_swedish_ci +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` + 1 AS `c`,`t1`.`b` + 1 AS `d` from `t1` latin1 latin1_swedish_ci explain select c from mysqltest.v2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY system NULL NULL NULL NULL 0 Const row not found 2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table show create view mysqltest.v2; View Create View character_set_client collation_connection -v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v2` AS select `mysqltest`.`t1`.`a` + 1 AS `c`,`mysqltest`.`t1`.`b` + 1 AS `d` from `mysqltest`.`t1` latin1 latin1_swedish_ci +v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` + 1 AS `c`,`t1`.`b` + 1 AS `d` from `t1` latin1 latin1_swedish_ci explain select c from mysqltest.v3; ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table show create view mysqltest.v3; View Create View character_set_client collation_connection -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v3` AS select `mysqltest`.`t2`.`a` + 1 AS `c`,`mysqltest`.`t2`.`b` + 1 AS `d` from `mysqltest`.`t2` latin1 latin1_swedish_ci +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t2`.`a` + 1 AS `c`,`t2`.`b` + 1 AS `d` from `t2` latin1 latin1_swedish_ci explain select c from mysqltest.v4; ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table show create view mysqltest.v4; View Create View character_set_client collation_connection -v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v4` AS select `mysqltest`.`t2`.`a` + 1 AS `c`,`mysqltest`.`t2`.`b` + 1 AS `d` from `mysqltest`.`t2` latin1 latin1_swedish_ci +v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t2`.`a` + 1 AS `c`,`t2`.`b` + 1 AS `d` from `t2` latin1 latin1_swedish_ci connection root; revoke all privileges on mysqltest.* from mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; connection root; create database mysqltest; create table mysqltest.t1 (a int, b int, primary key(a)); @@ -208,8 +213,7 @@ grant update (a) on mysqltest.v2 to mysqltest_1@localhost; grant update on mysqltest.v1 to mysqltest_1@localhost; grant update on mysqltest.t3 to mysqltest_1@localhost; grant select on mysqltest.* to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect user1,localhost,mysqltest_1,,mysqltest; update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c; select * from t1; a b @@ -251,11 +255,11 @@ update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c; ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table `mysqltest`.`v3` update v3 set a=a+c; ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table `mysqltest`.`v3` -use test; connection root; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; connection root; create database mysqltest; create table mysqltest.t1 (a int, b int, primary key(a)); @@ -267,7 +271,7 @@ create view mysqltest.v2 (a,c) as select a, b+1 from mysqltest.t1; create user mysqltest_1@localhost; grant delete on mysqltest.v1 to mysqltest_1@localhost; grant select on mysqltest.* to mysqltest_1@localhost; -connection user1; +connect user1,localhost,mysqltest_1,,mysqltest; use mysqltest; delete from v1 where c < 4; select * from t1; @@ -284,8 +288,8 @@ delete v2 from t2,v2 where t2.x=v2.c; ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table `mysqltest`.`v2` delete from v2 where c < 4; ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table `mysqltest`.`v2` -use test; connection root; +disconnect user1; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; @@ -300,7 +304,7 @@ create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; create user mysqltest_1@localhost; grant insert on mysqltest.v1 to mysqltest_1@localhost; grant select on mysqltest.* to mysqltest_1@localhost; -connection user1; +connect user1,localhost,mysqltest_1,,mysqltest; use mysqltest; insert into v1 values (5,6); select * from t1; @@ -319,11 +323,11 @@ insert into v2 values (5,6); ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table `mysqltest`.`v2` insert into v2 select x,y from t2; ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table `mysqltest`.`v2` -use test; connection root; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; connection root; create database mysqltest; create table mysqltest.t1 (a int, b int); @@ -332,7 +336,7 @@ create user mysqltest_1@localhost; grant update on mysqltest.t1 to mysqltest_1@localhost; grant update(b) on mysqltest.t2 to mysqltest_1@localhost; grant create view,update on test.* to mysqltest_1@localhost; -connection user1; +connect user1,localhost,mysqltest_1,,test; create view v1 as select * from mysqltest.t1; create view v2 as select b from mysqltest.t2; create view mysqltest.v1 as select * from mysqltest.t1; @@ -366,26 +370,26 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; drop view v1,v2,v4; +disconnect user1; connection root; create database mysqltest; create table mysqltest.t1 (a int); create user mysqltest_1@localhost; grant all privileges on mysqltest.* to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect user1,localhost,mysqltest_1,,mysqltest; create view v1 as select * from t1; -use test; connection root; revoke all privileges on mysqltest.* from mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; connection root; create database mysqltest; create table mysqltest.t1 (a int, b int); create user mysqltest_1@localhost; grant select on mysqltest.t1 to mysqltest_1@localhost; grant create view,select on test.* to mysqltest_1@localhost; -connection user1; +connect user1,localhost,mysqltest_1,,test; create view v1 as select * from mysqltest.t1; connection root; show create view v1; @@ -401,6 +405,7 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop view v1; drop database mysqltest; +disconnect user1; connection root; create database mysqltest; use mysqltest; @@ -423,8 +428,7 @@ grant select on v2 to mysqltest_1@localhost; grant select on v3 to mysqltest_1@localhost; grant select on v4 to mysqltest_1@localhost; grant select on v5 to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect user1,localhost,mysqltest_1,,mysqltest; select * from v1; f2() NULL @@ -437,7 +441,6 @@ select * from v4; ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them select * from v5; ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them -use test; connection root; drop view v1, v2, v3, v4, v5; drop function f2; @@ -446,6 +449,7 @@ use test; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; connection root; create database mysqltest; use mysqltest; @@ -461,13 +465,11 @@ create user mysqltest_1@localhost; grant select on t1 to mysqltest_1@localhost; grant execute on function f2 to mysqltest_1@localhost; grant create view on mysqltest.* to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect user1,localhost,mysqltest_1,,mysqltest; create algorithm=TEMPTABLE view v1 as select f2() from t1; create algorithm=MERGE view v2 as select f2() from t1; create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1; create algorithm=MERGE SQL SECURITY INVOKER view v4 as select f2() from t1; -use test; connection root; create view v5 as select * from v1; revoke execute on function f2 from mysqltest_1@localhost; @@ -490,6 +492,7 @@ use test; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; connection root; create database mysqltest; use mysqltest; @@ -501,14 +504,12 @@ grant select on t1 to mysqltest_1@localhost; grant select on v1 to mysqltest_1@localhost; grant create view on mysqltest.* to mysqltest_1@localhost; drop table v1; -connection user1; -use mysqltest; +connect user1,localhost,mysqltest_1,,mysqltest; create algorithm=TEMPTABLE view v1 as select *, a as b from t1; create algorithm=MERGE view v2 as select *, a as b from t1; create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select *, a as b from t1; create algorithm=MERGE SQL SECURITY INVOKER view v4 as select *, a as b from t1; create view v5 as select * from v1; -use test; connection root; revoke select on t1 from mysqltest_1@localhost; select * from v1; @@ -528,6 +529,7 @@ use test; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; connection root; create database mysqltest; use mysqltest; @@ -544,8 +546,7 @@ grant select on v2 to mysqltest_1@localhost; grant select on v3 to mysqltest_1@localhost; grant select on v4 to mysqltest_1@localhost; grant select on v5 to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect user1,localhost,mysqltest_1,,mysqltest; select * from v1; a b 1 1 @@ -558,7 +559,6 @@ select * from v4; ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them select * from v5; ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them -use test; connection root; drop view v1, v2, v3, v4, v5; drop table t1; @@ -566,6 +566,7 @@ use test; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; create user 'test14256'@'%'; grant all on test.* to 'test14256'@'%'; connect test14256,localhost,test14256,,test; @@ -601,13 +602,11 @@ View Create View character_set_client collation_connection v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci create user mysqltest_1@localhost; GRANT SELECT, LOCK TABLES ON mysqltest.* TO mysqltest_1@localhost; -connection user1; -use mysqltest; +connect user1,localhost,mysqltest_1,,mysqltest; LOCK TABLES v1 READ; SHOW CREATE TABLE v1; ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table `mysqltest`.`v1` UNLOCK TABLES; -use test; connection root; use test; drop user mysqltest_1@localhost; @@ -647,7 +646,7 @@ GRANT UPDATE ON mysqltest1.v_tu TO readonly@localhost; GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly@localhost; GRANT DELETE ON mysqltest1.v_td TO readonly@localhost; GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly@localhost; -connect n1,localhost,readonly,,; +connect n1,localhost,readonly,,mysqltest1; connection n1; SELECT * FROM mysqltest1.v_t1; ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them @@ -720,7 +719,7 @@ DROP TABLE t1; USE test; CREATE USER mysqltest_db1@localhost identified by 'PWD'; GRANT ALL ON mysqltest_db1.* TO mysqltest_db1@localhost WITH GRANT OPTION; -connect session1,localhost,mysqltest_db1,PWD,test; +connect session1,localhost,mysqltest_db1,PWD,"*NO-ONE*"; CREATE SCHEMA mysqltest_db1 ; USE mysqltest_db1 ; CREATE TABLE t1 (f1 INTEGER); @@ -1085,9 +1084,7 @@ CREATE VIEW v1 AS SELECT f1, f2 FROM t1; CREATE USER foo; GRANT SELECT (f1) ON t1 TO foo; GRANT SELECT (f1) ON v1 TO foo; -connect addconfoo, localhost, foo,,; -connection addconfoo; -USE db1; +connect addconfoo, localhost, foo,,db1; SELECT f1 FROM t1; f1 SELECT f2 FROM t1; @@ -1431,11 +1428,11 @@ CREATE TABLE t2 ( a INT, b INT ); CREATE VIEW v1 AS SELECT a, b FROM t1; GRANT SELECT( a ) ON v1 TO mysqluser1@localhost; GRANT UPDATE( b ) ON t2 TO mysqluser1@localhost; -connect connection1, localhost, mysqluser1, , test; +connect connection1, localhost, mysqluser1, ,mysqltest1; SELECT * FROM mysqltest1.v1; ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table `mysqltest1`.`v1` CREATE VIEW v1 AS SELECT * FROM mysqltest1.t2; -ERROR 42000: ANY command denied to user 'mysqluser1'@'localhost' for table `mysqltest1`.`t2` +ERROR 42000: CREATE VIEW command denied to user 'mysqluser1'@'localhost' for table `mysqltest1`.`v1` disconnect connection1; connection default; DROP TABLE t1, t2; @@ -1858,7 +1855,7 @@ where t2.id = v1.id; create sql security invoker view v42 as select v2.id as id, v2.val as val from mysqltest2.t2 as t2, mysqltest2.v2_merge as v2 where t2.id = v2.id; -connect conn_11766767, localhost, user_11766767,,; +connect conn_11766767, localhost, user_11766767,,mysqltest2; # # A) Check how we handle privilege checking in multi-update for # directly used views. @@ -1959,6 +1956,7 @@ drop database mysqltest2; CREATE SCHEMA foo; CREATE VIEW foo.v AS SELECT * FROM JSON_TABLE('[1,2,3]', '$[*]' COLUMNS (num INT PATH '$[0]')) AS jt; CREATE USER foo@localhost; +GRANT SELECT on test.* to foo@localhost; connect con1,localhost,foo,,; SELECT * FROM foo.v; ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table `foo`.`v` diff --git a/mysql-test/main/view_grant.test b/mysql-test/main/view_grant.test index 83bbeb3be7775..9094c616a1f17 100644 --- a/mysql-test/main/view_grant.test +++ b/mysql-test/main/view_grant.test @@ -71,6 +71,7 @@ revoke all privileges on test.* from mysqltest_1@localhost; drop database mysqltest; drop view test.v1; +disconnect user1; # # grants per columns @@ -84,7 +85,7 @@ create table mysqltest.t1 (a int, b int); create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; grant select (c) on mysqltest.v1 to mysqltest_1@localhost; -connection user1; +connect (user1,localhost,mysqltest_1,,mysqltest); select c from mysqltest.v1; # there are no privileges on column 'd' --error ER_COLUMNACCESS_DENIED_ERROR @@ -112,6 +113,7 @@ select c from mysqltest.v1; select d from mysqltest.v1; connection root; +disconnect user1; revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; @@ -139,7 +141,7 @@ grant select on mysqltest.v3 to mysqltest_1@localhost; grant select on mysqltest.v4 to mysqltest_1@localhost; grant show view on mysqltest.v5 to mysqltest_1@localhost; -connection user1; +connect (user1,localhost,mysqltest_1,,mysqltest); # all SELECTs works, except v5 which lacks SELECT privs select c from mysqltest.v1; select c from mysqltest.v2; @@ -188,7 +190,8 @@ connection root; grant show view on mysqltest.v1 to mysqltest_1@localhost; grant select on mysqltest.t1 to mysqltest_1@localhost; revoke select on mysqltest.v5 from mysqltest_1@localhost; -connection user1; +disconnect user1; +connect (user1,localhost,mysqltest_1,,mysqltest); # EXPLAIN works explain select c from mysqltest.v1; show create view mysqltest.v1; @@ -213,7 +216,8 @@ explain select c from mysqltest.v5; # allow to see any view in mysqltest database connection root; grant show view on mysqltest.* to mysqltest_1@localhost; -connection user1; +disconnect user1; +connect (user1,localhost,mysqltest_1,,mysqltest); explain select c from mysqltest.v1; show create view mysqltest.v1; explain select c from mysqltest.v2; @@ -231,6 +235,7 @@ connection root; revoke all privileges on mysqltest.* from mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; # # UPDATE privileges on VIEW columns and whole VIEW @@ -256,8 +261,7 @@ grant update on mysqltest.v1 to mysqltest_1@localhost; grant update on mysqltest.t3 to mysqltest_1@localhost; grant select on mysqltest.* to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect (user1,localhost,mysqltest_1,,mysqltest); # update with rights on VIEW column update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c; select * from t1; @@ -281,11 +285,11 @@ update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c; --error ER_TABLEACCESS_DENIED_ERROR update v3 set a=a+c; -use test; connection root; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; # # DELETE privileges on VIEW @@ -306,7 +310,7 @@ create user mysqltest_1@localhost; grant delete on mysqltest.v1 to mysqltest_1@localhost; grant select on mysqltest.* to mysqltest_1@localhost; -connection user1; +connect (user1,localhost,mysqltest_1,,mysqltest); use mysqltest; # update with rights on VIEW column delete from v1 where c < 4; @@ -319,8 +323,8 @@ delete v2 from t2,v2 where t2.x=v2.c; --error ER_TABLEACCESS_DENIED_ERROR delete from v2 where c < 4; -use test; connection root; +disconnect user1; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; @@ -344,7 +348,7 @@ create user mysqltest_1@localhost; grant insert on mysqltest.v1 to mysqltest_1@localhost; grant select on mysqltest.* to mysqltest_1@localhost; -connection user1; +connect (user1,localhost,mysqltest_1,,mysqltest); use mysqltest; # update with rights on VIEW column insert into v1 values (5,6); @@ -357,11 +361,11 @@ insert into v2 values (5,6); --error ER_TABLEACCESS_DENIED_ERROR insert into v2 select x,y from t2; -use test; connection root; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; # # test of CREATE VIEW privileges if we have limited privileges @@ -379,7 +383,7 @@ grant update on mysqltest.t1 to mysqltest_1@localhost; grant update(b) on mysqltest.t2 to mysqltest_1@localhost; grant create view,update on test.* to mysqltest_1@localhost; -connection user1; +connect (user1,localhost,mysqltest_1,,test); create view v1 as select * from mysqltest.t1; create view v2 as select b from mysqltest.t2; @@ -426,6 +430,7 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; drop view v1,v2,v4; +disconnect user1; # # user with global DB privileges @@ -438,15 +443,14 @@ create table mysqltest.t1 (a int); create user mysqltest_1@localhost; grant all privileges on mysqltest.* to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect (user1,localhost,mysqltest_1,,mysqltest); create view v1 as select * from t1; -use test; connection root; revoke all privileges on mysqltest.* from mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; # # view definer grants revoking @@ -462,7 +466,7 @@ create user mysqltest_1@localhost; grant select on mysqltest.t1 to mysqltest_1@localhost; grant create view,select on test.* to mysqltest_1@localhost; -connection user1; +connect (user1,localhost,mysqltest_1,,test); create view v1 as select * from mysqltest.t1; @@ -478,6 +482,7 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop view v1; drop database mysqltest; +disconnect user1; # # rights on execution of view underlying functiond (Bug#9505) @@ -512,8 +517,7 @@ grant select on v3 to mysqltest_1@localhost; grant select on v4 to mysqltest_1@localhost; grant select on v5 to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect (user1,localhost,mysqltest_1,,mysqltest); select * from v1; select * from v2; --error ER_VIEW_INVALID @@ -522,7 +526,6 @@ select * from v3; select * from v4; --error ER_VIEW_INVALID select * from v5; -use test; connection root; drop view v1, v2, v3, v4, v5; @@ -532,6 +535,7 @@ use test; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; # # revertion of previous test, definer of view lost his/her rights to execute @@ -561,13 +565,11 @@ grant select on t1 to mysqltest_1@localhost; grant execute on function f2 to mysqltest_1@localhost; grant create view on mysqltest.* to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect (user1,localhost,mysqltest_1,,mysqltest); create algorithm=TEMPTABLE view v1 as select f2() from t1; create algorithm=MERGE view v2 as select f2() from t1; create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1; create algorithm=MERGE SQL SECURITY INVOKER view v4 as select f2() from t1; -use test; connection root; create view v5 as select * from v1; @@ -588,6 +590,7 @@ use test; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; # # definer/invoker rights for columns @@ -607,14 +610,12 @@ grant select on v1 to mysqltest_1@localhost; grant create view on mysqltest.* to mysqltest_1@localhost; drop table v1; -connection user1; -use mysqltest; +connect (user1,localhost,mysqltest_1,,mysqltest); create algorithm=TEMPTABLE view v1 as select *, a as b from t1; create algorithm=MERGE view v2 as select *, a as b from t1; create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select *, a as b from t1; create algorithm=MERGE SQL SECURITY INVOKER view v4 as select *, a as b from t1; create view v5 as select * from v1; -use test; connection root; revoke select on t1 from mysqltest_1@localhost; @@ -633,6 +634,7 @@ use test; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; connection root; @@ -655,8 +657,7 @@ grant select on v3 to mysqltest_1@localhost; grant select on v4 to mysqltest_1@localhost; grant select on v5 to mysqltest_1@localhost; -connection user1; -use mysqltest; +connect (user1,localhost,mysqltest_1,,mysqltest); select * from v1; select * from v2; --error ER_VIEW_INVALID @@ -665,7 +666,6 @@ select * from v3; select * from v4; --error ER_VIEW_INVALID select * from v5; -use test; connection root; drop view v1, v2, v3, v4, v5; @@ -674,6 +674,7 @@ use test; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; drop user mysqltest_1@localhost; drop database mysqltest; +disconnect user1; # # Bug#14256 definer in view definition is not fully qualified @@ -723,14 +724,12 @@ SHOW CREATE VIEW v1; create user mysqltest_1@localhost; GRANT SELECT, LOCK TABLES ON mysqltest.* TO mysqltest_1@localhost; -connection user1; +connect (user1,localhost,mysqltest_1,,mysqltest); -use mysqltest; LOCK TABLES v1 READ; --error ER_TABLEACCESS_DENIED_ERROR SHOW CREATE TABLE v1; UNLOCK TABLES; -use test; connection root; use test; @@ -776,7 +775,7 @@ GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly@localhost; GRANT DELETE ON mysqltest1.v_td TO readonly@localhost; GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly@localhost; -connect (n1,localhost,readonly,,); +connect (n1,localhost,readonly,,mysqltest1); connection n1; --error ER_VIEW_INVALID @@ -858,7 +857,7 @@ eval GRANT ALL ON mysqltest_db1.* TO mysqltest_db1@localhost WITH GRANT OPTION; # The session with the non root user is needed. --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -connect (session1,localhost,mysqltest_db1,PWD,test); +connect (session1,localhost,mysqltest_db1,PWD,"*NO-ONE*"); CREATE SCHEMA mysqltest_db1 ; USE mysqltest_db1 ; @@ -1270,9 +1269,7 @@ CREATE USER foo; GRANT SELECT (f1) ON t1 TO foo; GRANT SELECT (f1) ON v1 TO foo; -connect (addconfoo, localhost, foo,,); -connection addconfoo; -USE db1; +connect (addconfoo, localhost, foo,,db1); SELECT f1 FROM t1; --error ER_COLUMNACCESS_DENIED_ERROR @@ -1714,7 +1711,7 @@ CREATE VIEW v1 AS SELECT a, b FROM t1; GRANT SELECT( a ) ON v1 TO mysqluser1@localhost; GRANT UPDATE( b ) ON t2 TO mysqluser1@localhost; ---connect (connection1, localhost, mysqluser1, , test) +--connect (connection1, localhost, mysqluser1, ,mysqltest1) --error ER_TABLEACCESS_DENIED_ERROR SELECT * FROM mysqltest1.v1; @@ -2106,7 +2103,7 @@ create sql security invoker view v42 as where t2.id = v2.id; -connect (conn_11766767, localhost, user_11766767,,); +connect (conn_11766767, localhost, user_11766767,,mysqltest2); --echo # --echo # A) Check how we handle privilege checking in multi-update for @@ -2215,6 +2212,7 @@ CREATE SCHEMA foo; CREATE VIEW foo.v AS SELECT * FROM JSON_TABLE('[1,2,3]', '$[*]' COLUMNS (num INT PATH '$[0]')) AS jt; CREATE USER foo@localhost; +GRANT SELECT on test.* to foo@localhost; connect (con1,localhost,foo,,); --error ER_TABLEACCESS_DENIED_ERROR SELECT * FROM foo.v; diff --git a/mysql-test/suite/binlog/r/binlog_dmls_on_tmp_tables_readonly.result b/mysql-test/suite/binlog/r/binlog_dmls_on_tmp_tables_readonly.result index b366bde4dafd2..1b60e50c09d54 100644 --- a/mysql-test/suite/binlog/r/binlog_dmls_on_tmp_tables_readonly.result +++ b/mysql-test/suite/binlog/r/binlog_dmls_on_tmp_tables_readonly.result @@ -2,7 +2,7 @@ DROP TABLE IF EXISTS t1 ; # READ_ONLY does nothing to SUPER users # so we use a non-SUPER one: CREATE USER test@localhost; -GRANT CREATE, SELECT, DROP ON *.* TO test@localhost; +GRANT CREATE TEMPORARY TABLES, SELECT, DROP ON *.* TO test@localhost; connect con1,localhost,test,,test; connection default; SET GLOBAL READ_ONLY=1; diff --git a/mysql-test/suite/binlog/r/binlog_grant.result b/mysql-test/suite/binlog/r/binlog_grant.result index af4c02411d547..edf705614eb57 100644 --- a/mysql-test/suite/binlog/r/binlog_grant.result +++ b/mysql-test/suite/binlog/r/binlog_grant.result @@ -2,9 +2,11 @@ connection default; reset master; set @saved_binlog_format = @@global.binlog_format; create user mysqltest_1@localhost; +GRANT SELECT on test.* to mysqltest_1@localhost; show grants for mysqltest_1@localhost; Grants for mysqltest_1@localhost GRANT USAGE ON *.* TO `mysqltest_1`@`localhost` +GRANT SELECT ON `test`.* TO `mysqltest_1`@`localhost` connect plain,localhost,mysqltest_1,,test; connect root,localhost,root,,test; **** Variable SQL_LOG_BIN **** @@ -34,7 +36,7 @@ set global binlog_format = @saved_binlog_format; drop user mysqltest_1@localhost; CREATE USER 'mysqltest_1'@'localhost'; GRANT REPLICATION CLIENT ON *.* TO 'mysqltest_1'@'localhost'; -connect rpl,localhost,mysqltest_1,,; +connect rpl,localhost,mysqltest_1,,"*NO-ONE*"; connection rpl; SHOW MASTER LOGS; SHOW BINARY LOGS; @@ -88,7 +90,7 @@ DROP USER user1@localhost; # Test if PURGE BINLOG is allowed with BINLOG ADMIN CREATE USER user1@localhost; GRANT BINLOG ADMIN ON *.* TO user1@localhost; -connect user1,localhost,user1,,; +connect user1,localhost,user1,,"*NO-ONE*"; connection user1; PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00'; disconnect user1; @@ -97,7 +99,7 @@ DROP USER user1@localhost; # Test if PURGE BINLOG is allowed with SUPER CREATE USER user1@localhost; GRANT SUPER ON *.* TO user1@localhost; -connect user1,localhost,user1,,; +connect user1,localhost,user1,,"*NO-ONE*"; connection user1; PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00'; disconnect user1; @@ -117,7 +119,7 @@ DROP USER user1@localhost; # Test if SHOW BINLOG EVENTS is allowed with BINLOG MONITOR CREATE USER user1@localhost; GRANT BINLOG MONITOR ON *.* TO user1@localhost; -connect user1,localhost,user1,,; +connect user1,localhost,user1,,"*NO-ONE*"; connection user1; SHOW BINLOG EVENTS; disconnect user1; @@ -132,6 +134,7 @@ DROP USER user1@localhost; # CREATE USER user1@localhost; GRANT BINLOG REPLAY ON *.* TO user1@localhost; +GRANT ALL ON test.* TO user1@localhost; RESET MASTER; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2),(3); diff --git a/mysql-test/suite/binlog/r/read_only.result b/mysql-test/suite/binlog/r/read_only.result index 9a173d9a96e5d..1084970d11ac8 100644 --- a/mysql-test/suite/binlog/r/read_only.result +++ b/mysql-test/suite/binlog/r/read_only.result @@ -5,7 +5,7 @@ # gtid_strict_mode enabled # create user test@localhost; -grant CREATE, DROP, INSERT, SELECT on *.* to test@localhost; +grant CREATE TEMPORARY TABLES, DROP, INSERT, SELECT on *.* to test@localhost; create table t1 (a int) engine=myisam; insert into t1 values (1),(2); reset master; diff --git a/mysql-test/suite/binlog/r/read_only_statement.result b/mysql-test/suite/binlog/r/read_only_statement.result index 9a173d9a96e5d..1084970d11ac8 100644 --- a/mysql-test/suite/binlog/r/read_only_statement.result +++ b/mysql-test/suite/binlog/r/read_only_statement.result @@ -5,7 +5,7 @@ # gtid_strict_mode enabled # create user test@localhost; -grant CREATE, DROP, INSERT, SELECT on *.* to test@localhost; +grant CREATE TEMPORARY TABLES, DROP, INSERT, SELECT on *.* to test@localhost; create table t1 (a int) engine=myisam; insert into t1 values (1),(2); reset master; diff --git a/mysql-test/suite/binlog/t/binlog_dmls_on_tmp_tables_readonly.test b/mysql-test/suite/binlog/t/binlog_dmls_on_tmp_tables_readonly.test index 0fa35d57745d3..dd0cdd0f82e83 100644 --- a/mysql-test/suite/binlog/t/binlog_dmls_on_tmp_tables_readonly.test +++ b/mysql-test/suite/binlog/t/binlog_dmls_on_tmp_tables_readonly.test @@ -26,7 +26,7 @@ DROP TABLE IF EXISTS t1 ; --echo # READ_ONLY does nothing to SUPER users --echo # so we use a non-SUPER one: CREATE USER test@localhost; -GRANT CREATE, SELECT, DROP ON *.* TO test@localhost; +GRANT CREATE TEMPORARY TABLES, SELECT, DROP ON *.* TO test@localhost; connect (con1,localhost,test,,test); diff --git a/mysql-test/suite/binlog/t/binlog_grant.test b/mysql-test/suite/binlog/t/binlog_grant.test index ec8d2aeccd254..d573281f691ab 100644 --- a/mysql-test/suite/binlog/t/binlog_grant.test +++ b/mysql-test/suite/binlog/t/binlog_grant.test @@ -10,6 +10,7 @@ reset master; set @saved_binlog_format = @@global.binlog_format; create user mysqltest_1@localhost; +GRANT SELECT on test.* to mysqltest_1@localhost; show grants for mysqltest_1@localhost; connect (plain,localhost,mysqltest_1,,test); @@ -60,7 +61,7 @@ drop user mysqltest_1@localhost; # SHOW MASTER LOGS and SHOW BINARY. CREATE USER 'mysqltest_1'@'localhost'; GRANT REPLICATION CLIENT ON *.* TO 'mysqltest_1'@'localhost'; ---connect(rpl,localhost,mysqltest_1,,) +--connect(rpl,localhost,mysqltest_1,,"*NO-ONE*") --connection rpl # We are only interested if the following commands succeed and not on @@ -128,7 +129,7 @@ DROP USER user1@localhost; --echo # Test if PURGE BINLOG is allowed with BINLOG ADMIN CREATE USER user1@localhost; GRANT BINLOG ADMIN ON *.* TO user1@localhost; ---connect(user1,localhost,user1,,) +--connect(user1,localhost,user1,,"*NO-ONE*") --connection user1 PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00'; --disconnect user1 @@ -139,7 +140,7 @@ DROP USER user1@localhost; --echo # Test if PURGE BINLOG is allowed with SUPER CREATE USER user1@localhost; GRANT SUPER ON *.* TO user1@localhost; ---connect(user1,localhost,user1,,) +--connect(user1,localhost,user1,,"*NO-ONE*") --connection user1 PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00'; --disconnect user1 @@ -163,7 +164,7 @@ DROP USER user1@localhost; --echo # Test if SHOW BINLOG EVENTS is allowed with BINLOG MONITOR CREATE USER user1@localhost; GRANT BINLOG MONITOR ON *.* TO user1@localhost; ---connect(user1,localhost,user1,,) +--connect(user1,localhost,user1,,"*NO-ONE*") --connection user1 --disable_result_log SHOW BINLOG EVENTS; @@ -182,6 +183,7 @@ DROP USER user1@localhost; CREATE USER user1@localhost; GRANT BINLOG REPLAY ON *.* TO user1@localhost; +GRANT ALL ON test.* TO user1@localhost; RESET MASTER; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2),(3); diff --git a/mysql-test/suite/binlog/t/read_only.inc b/mysql-test/suite/binlog/t/read_only.inc index 37f1cb3b2b8af..78136b90d0e7b 100644 --- a/mysql-test/suite/binlog/t/read_only.inc +++ b/mysql-test/suite/binlog/t/read_only.inc @@ -6,7 +6,7 @@ --echo # create user test@localhost; -grant CREATE, DROP, INSERT, SELECT on *.* to test@localhost; +grant CREATE TEMPORARY TABLES, DROP, INSERT, SELECT on *.* to test@localhost; create table t1 (a int) engine=myisam; insert into t1 values (1),(2); reset master; diff --git a/mysql-test/suite/engines/funcs/r/rpl_temporary.result b/mysql-test/suite/engines/funcs/r/rpl_temporary.result index 650fe1db9e034..492e9ac3ac3d5 100644 --- a/mysql-test/suite/engines/funcs/r/rpl_temporary.result +++ b/mysql-test/suite/engines/funcs/r/rpl_temporary.result @@ -34,6 +34,8 @@ connection master; DROP TABLE t1; connection slave; connection master; +create user zedjzlcsjhd@localhost; +GRANT ALL on test.* to zedjzlcsjhd@localhost; connect con1,localhost,root,,; connect con2,localhost,root,,; connect con3,localhost,zedjzlcsjhd,,; @@ -83,6 +85,7 @@ f 5 7 drop table t1, t2; +drop user zedjzlcsjhd@localhost; use test; SET TIMESTAMP=1040323920; create table t1(f int); @@ -174,7 +177,7 @@ FLUSH PRIVILEGES; GRANT USAGE ON *.* TO user43748@127.0.0.1 IDENTIFIED BY 'meow'; GRANT PROCESS ON *.* TO user43748@127.0.0.1; -- try to KILL system-thread as that non-privileged user (on slave). -connect cont43748,127.0.0.1,user43748,meow,test,$SLAVE_MYPORT,; +connect cont43748,127.0.0.1,user43748,meow,"*NO-ONE*",$SLAVE_MYPORT,; connection cont43748; SELECT id INTO @id FROM information_schema.processlist WHERE user='system user' LIMIT 1; KILL @id; diff --git a/mysql-test/suite/funcs_1/datadict/is_routines.inc b/mysql-test/suite/funcs_1/datadict/is_routines.inc index 3bbd26a948d24..37e77e81a2847 100644 --- a/mysql-test/suite/funcs_1/datadict/is_routines.inc +++ b/mysql-test/suite/funcs_1/datadict/is_routines.inc @@ -193,7 +193,7 @@ connect (testuser2, localhost, testuser2, , db_datadict); SELECT * FROM information_schema.routines where routine_schema <> 'sys'; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -connect (testuser3, localhost, testuser3, , test); +connect (testuser3, localhost, testuser3, , "*NO-ONE*"); --replace_column 24 "YYYY-MM-DD hh:mm:ss" 25 "YYYY-MM-DD hh:mm:ss" SELECT * FROM information_schema.routines where routine_schema <> 'sys'; diff --git a/mysql-test/suite/funcs_1/datadict/is_schemata.inc b/mysql-test/suite/funcs_1/datadict/is_schemata.inc index 267d3c272b973..6ddd966d7a908 100644 --- a/mysql-test/suite/funcs_1/datadict/is_schemata.inc +++ b/mysql-test/suite/funcs_1/datadict/is_schemata.inc @@ -120,7 +120,7 @@ eval $my_select; eval $my_show; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -connect (testuser3, localhost, testuser3, , test); +connect (testuser3, localhost, testuser3, ,"*NO-ONE*"); # Shows neither db_datadict_1 nor db_datadict_2 eval $my_select; --sorted_result diff --git a/mysql-test/suite/funcs_1/datadict/is_views.inc b/mysql-test/suite/funcs_1/datadict/is_views.inc index 367b1b1ede4ca..acf12ce5d3980 100644 --- a/mysql-test/suite/funcs_1/datadict/is_views.inc +++ b/mysql-test/suite/funcs_1/datadict/is_views.inc @@ -109,15 +109,15 @@ WHERE table_schema = 'db_datadict' ORDER BY table_name; eval $select; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -connect (testuser1, localhost, testuser1, , test); +connect (testuser1, localhost, testuser1, ,"*NO-ONE*"); eval $select; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -connect (testuser2, localhost, testuser2, , test); +connect (testuser2, localhost, testuser2, ,"*NO-ONE*"); eval $select; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -connect (test_no_views, localhost, test_no_views, , test); +connect (test_no_views, localhost, test_no_views, ,"*NO-ONE*"); eval $select; # Cleanup diff --git a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc index 99a4340c5713d..90bc19f2784ee 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc @@ -132,6 +132,8 @@ DROP USER ddicttestuser1@'localhost'; DROP USER ddicttestuser2@'localhost'; CREATE USER ddicttestuser1@'localhost'; CREATE USER ddicttestuser2@'localhost'; +GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,CREATE TEMPORARY TABLES,CREATE VIEW,DROP on test.* to ddicttestuser1@'localhost'; +GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,CREATE TEMPORARY TABLES,CREATE VIEW,DROP on test.* to ddicttestuser2@'localhost'; SET PASSWORD FOR ddicttestuser1@'localhost' = PASSWORD('ddictpass'); SET PASSWORD FOR ddicttestuser2@'localhost' = PASSWORD('ddictpass'); diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_03.result b/mysql-test/suite/funcs_1/r/innodb_trig_03.result index 051e0d1e12574..f4bac5752a77d 100644 --- a/mysql-test/suite/funcs_1/r/innodb_trig_03.result +++ b/mysql-test/suite/funcs_1/r/innodb_trig_03.result @@ -241,7 +241,7 @@ show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost GRANT TRIGGER ON *.* TO `test_yesprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT UPDATE ON `priv_db`.* TO `test_yesprivs`@`localhost` -connect no_privs_424b,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect no_privs_424b,localhost,test_noprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; connect yes_privs_424b,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; connection default; connection no_privs_424b; diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_03e.result b/mysql-test/suite/funcs_1/r/innodb_trig_03e.result index 6ec5240792c3e..8a5717a7576b0 100644 --- a/mysql-test/suite/funcs_1/r/innodb_trig_03e.result +++ b/mysql-test/suite/funcs_1/r/innodb_trig_03e.result @@ -24,7 +24,8 @@ show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT USAGE ON *.* TO `test_noprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, INSERT ON `priv_db`.* TO `test_noprivs`@`localhost` -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; no trigger privilege on db level for create: -------------------------------------------- @@ -32,8 +33,8 @@ use priv_db; create trigger trg1_1 before INSERT on t1 for each row set new.f1 = 'trig 1_1-no'; ERROR 42000: TRIGGER command denied to user 'test_yesprivs'@'localhost' for table `priv_db`.`t1` -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -use priv_db; +connect no_privs,localhost,test_noprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connection no_privs; insert into t1 (f1) values ('insert-yes'); select f1 from t1 order by f1; f1 @@ -271,8 +272,10 @@ revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; create User test_noprivs@localhost; set password for test_noprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; +connect no_privs,localhost,test_noprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection no_privs; no trigger privilege on table level for create: ----------------------------------------------- @@ -824,10 +827,8 @@ Grants for test_noprivs@localhost GRANT USAGE ON *.* TO `test_noprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, INSERT, UPDATE ON `priv1_db`.* TO `test_noprivs`@`localhost` GRANT SELECT, INSERT ON `priv2_db`.* TO `test_noprivs`@`localhost` -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -use priv1_db; -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -use priv1_db; +connect yes_privs,localhost,test_yesprivs,PWD,priv1_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connect no_privs,localhost,test_noprivs,PWD,priv1_db,$MASTER_MYPORT,$MASTER_MYSOCK; trigger privilege on one db1 db level, not on db2 ------------------------------------------------- @@ -1055,7 +1056,8 @@ create User test_useprivs@localhost; set password for test_useprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; revoke ALL PRIVILEGES, GRANT OPTION FROM test_useprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; connection default; select current_user; current_user @@ -1085,11 +1087,11 @@ select f1 from t1 order by f1; f1 trig 1_1-yes prepare ins1 from 'insert into t1 (f1) values (''insert2-no'')'; -connect use_privs,localhost,test_useprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect use_privs,localhost,test_useprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connection use_privs; select current_user; current_user test_useprivs@localhost -use priv_db; prepare ins1 from 'insert into t1 (f1) values (''insert3-no'')'; execute ins1; select f1 from t1 order by f1; @@ -1301,7 +1303,8 @@ create table t1 (f1 char(20)) engine= innodb; create User test_yesprivs@localhost; set password for test_yesprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; connection default; select current_user; current_user @@ -1407,7 +1410,6 @@ create table t1 (f1 char(20)) engine= innodb; create User test_yesprivs@localhost; set password for test_yesprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; connection default; select current_user; current_user @@ -1418,11 +1420,11 @@ show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost GRANT USAGE ON *.* TO `test_yesprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, INSERT, UPDATE, TRIGGER ON `priv_db`.`t1` TO `test_yesprivs`@`localhost` +connect yes_privs,localhost,test_yesprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; connection yes_privs; select current_user; current_user test_yesprivs@localhost -use priv_db; set autocommit=0; create definer=current_user trigger trg1_1 before INSERT on t1 for each row @@ -1484,8 +1486,10 @@ show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT USAGE ON *.* TO `test_noprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, UPDATE ON `priv_db`.* TO `test_noprivs`@`localhost` -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; +connect no_privs,localhost,test_noprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection no_privs; update only on column: ---------------------- diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_0407.result b/mysql-test/suite/funcs_1/r/innodb_trig_0407.result index d551575960e1b..281e4e8d0f6c3 100644 --- a/mysql-test/suite/funcs_1/r/innodb_trig_0407.result +++ b/mysql-test/suite/funcs_1/r/innodb_trig_0407.result @@ -69,8 +69,10 @@ revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost; create User test_super@localhost; set password for test_super@localhost = password('PWD'); grant ALL on *.* to test_super@localhost with grant OPTION; -connect con1_general,localhost,test_general,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect con1_super,localhost,test_super,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect con1_general,localhost,test_general,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection con1_general; +connect con1_super,localhost,test_super,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection con1_super; connection default; Testcase 3.5.4: diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_08.result b/mysql-test/suite/funcs_1/r/innodb_trig_08.result index 2a57496800ed1..52820d6b0cd58 100644 --- a/mysql-test/suite/funcs_1/r/innodb_trig_08.result +++ b/mysql-test/suite/funcs_1/r/innodb_trig_08.result @@ -66,6 +66,7 @@ Testcase: 3.5: create User test_general@localhost; set password for test_general@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost; +grant SELECT,UPDATE,DELETE,INSERT on test.* to test_general@localhost; create User test_super@localhost; set password for test_super@localhost = password('PWD'); grant ALL on *.* to test_super@localhost with grant OPTION; diff --git a/mysql-test/suite/funcs_1/r/is_basics_mixed.result b/mysql-test/suite/funcs_1/r/is_basics_mixed.result index 95fc5ae59c382..267bb56331c60 100644 --- a/mysql-test/suite/funcs_1/r/is_basics_mixed.result +++ b/mysql-test/suite/funcs_1/r/is_basics_mixed.result @@ -15,6 +15,7 @@ DATABASE() information_schema DROP USER 'testuser1'@'localhost'; CREATE USER 'testuser1'@'localhost'; +GRANT SELECT ON test.* TO 'testuser1'@'localhost'; connect testuser1, localhost, testuser1, , test; SELECT DATABASE(); DATABASE() diff --git a/mysql-test/suite/funcs_1/r/is_check_constraints.result b/mysql-test/suite/funcs_1/r/is_check_constraints.result index ae9820b2c7032..34e5535dba060 100644 --- a/mysql-test/suite/funcs_1/r/is_check_constraints.result +++ b/mysql-test/suite/funcs_1/r/is_check_constraints.result @@ -108,7 +108,7 @@ def foo t3 b Column `b` > 0 def foo t3 b Table `b` > 10 def foo t3 b1 Table `b` < 123456789012345678901234567890123456789012345678901234567890123456789 disconnect con1; -CONNECT con2, localhost, boo2,, test; +CONNECT con2, localhost, boo2,,"*NO-ONE*"; SELECT * from information_schema.check_constraints; CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME LEVEL CHECK_CLAUSE disconnect con2; diff --git a/mysql-test/suite/funcs_1/r/is_column_privileges_is_mysql_test.result b/mysql-test/suite/funcs_1/r/is_column_privileges_is_mysql_test.result index 1492bd26b5dd1..e30bd86833fed 100644 --- a/mysql-test/suite/funcs_1/r/is_column_privileges_is_mysql_test.result +++ b/mysql-test/suite/funcs_1/r/is_column_privileges_is_mysql_test.result @@ -31,7 +31,6 @@ SHOW DATABASES LIKE 'mysql'; Database (mysql) SHOW DATABASES LIKE 'test'; Database (test) -test connection default; DROP USER 'testuser1'@'localhost'; DROP DATABASE db_datadict; diff --git a/mysql-test/suite/funcs_1/r/is_routines.result b/mysql-test/suite/funcs_1/r/is_routines.result index 1b293444b27fe..51477e441ad07 100644 --- a/mysql-test/suite/funcs_1/r/is_routines.result +++ b/mysql-test/suite/funcs_1/r/is_routines.result @@ -196,7 +196,7 @@ connect testuser2, localhost, testuser2, , db_datadict; SELECT * FROM information_schema.routines where routine_schema <> 'sys'; SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION sp_6_408002_2 def db_datadict_2 sp_6_408002_2 PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL NULL NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost latin1 latin1_swedish_ci latin1_swedish_ci -connect testuser3, localhost, testuser3, , test; +connect testuser3, localhost, testuser3, , "*NO-ONE*"; SELECT * FROM information_schema.routines where routine_schema <> 'sys'; SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION connection default; diff --git a/mysql-test/suite/funcs_1/r/is_routines_embedded.result b/mysql-test/suite/funcs_1/r/is_routines_embedded.result index dfd663a6a96ee..be2a3d4543294 100644 --- a/mysql-test/suite/funcs_1/r/is_routines_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_routines_embedded.result @@ -219,7 +219,7 @@ AddGeometryColumn def mysql AddGeometryColumn PROCEDURE NULL NULL NULL NULL NUL set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end NULL NULL SQL NO CONTAINS SQL NULL INVOKER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss mariadb.sys@localhost latin1 latin1_swedish_ci latin1_swedish_ci DropGeometryColumn def mysql DropGeometryColumn PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL begin set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end NULL NULL SQL NO CONTAINS SQL NULL INVOKER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss mariadb.sys@localhost latin1 latin1_swedish_ci latin1_swedish_ci -connect testuser3, localhost, testuser3, , test; +connect testuser3, localhost, testuser3, , "*NO-ONE*"; SELECT * FROM information_schema.routines where routine_schema <> 'sys'; SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION sp_6_408002_1 def db_datadict sp_6_408002_1 PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN diff --git a/mysql-test/suite/funcs_1/r/is_schema_privileges.result b/mysql-test/suite/funcs_1/r/is_schema_privileges.result index 1c8f50df7ceb8..69f78a98711b1 100644 --- a/mysql-test/suite/funcs_1/r/is_schema_privileges.result +++ b/mysql-test/suite/funcs_1/r/is_schema_privileges.result @@ -52,40 +52,6 @@ IS_GRANTABLE varchar(3) NO NULL SELECT GRANTEE, TABLE_CATALOG, TABLE_SCHEMA, PRIVILEGE_TYPE FROM information_schema.schema_privileges WHERE table_catalog IS NOT NULL; GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE -''@'%' def test SELECT -''@'%' def test INSERT -''@'%' def test UPDATE -''@'%' def test DELETE -''@'%' def test CREATE -''@'%' def test DROP -''@'%' def test REFERENCES -''@'%' def test INDEX -''@'%' def test ALTER -''@'%' def test CREATE TEMPORARY TABLES -''@'%' def test LOCK TABLES -''@'%' def test CREATE VIEW -''@'%' def test SHOW VIEW -''@'%' def test CREATE ROUTINE -''@'%' def test EVENT -''@'%' def test TRIGGER -''@'%' def test DELETE HISTORY -''@'%' def test\_% SELECT -''@'%' def test\_% INSERT -''@'%' def test\_% UPDATE -''@'%' def test\_% DELETE -''@'%' def test\_% CREATE -''@'%' def test\_% DROP -''@'%' def test\_% REFERENCES -''@'%' def test\_% INDEX -''@'%' def test\_% ALTER -''@'%' def test\_% CREATE TEMPORARY TABLES -''@'%' def test\_% LOCK TABLES -''@'%' def test\_% CREATE VIEW -''@'%' def test\_% SHOW VIEW -''@'%' def test\_% CREATE ROUTINE -''@'%' def test\_% EVENT -''@'%' def test\_% TRIGGER -''@'%' def test\_% DELETE HISTORY ############################################################################### # Testcase 3.2.15.2-3.2.15.4 INFORMATION_SCHEMA.SCHEMA_PRIVILEGES accessibility ############################################################################### @@ -106,7 +72,7 @@ GRANT INSERT ON db_datadict_2.t1 TO 'testuser1'@'localhost'; GRANT SELECT ON db_datadict_4.* TO 'testuser1'@'localhost' WITH GRANT OPTION; GRANT SELECT ON db_datadict_3.* TO 'testuser2'@'localhost'; GRANT SELECT ON db_datadict_1.* TO 'testuser2'@'localhost'; -connect testuser1, localhost, testuser1, , test; +connect testuser1, localhost, testuser1, ,"*NO-ONE*"; GRANT SELECT ON db_datadict_4.* TO 'testuser2'@'localhost'; # Root granted INSERT db_datadict_1 to me -> visible # Root granted SELECT db_datadict_1 to testuser2 -> invisible @@ -130,7 +96,7 @@ GRANT SELECT ON `db_datadict_4`.* TO `testuser1`@`localhost` WITH GRANT OPTION GRANT INSERT ON `db_datadict_2`.`t1` TO `testuser1`@`localhost` SHOW GRANTS FOR 'testuser2'@'localhost'; ERROR 42000: Access denied for user 'testuser1'@'localhost' to database 'mysql' -connect testuser2, localhost, testuser2, , test; +connect testuser2, localhost, testuser2, ,"*NO-ONE*"; # Root granted SELECT db_datadict_1 to me -> visible # Root granted INSERT db_datadict_1 to testuser1 -> invisible # Root granted INSERT db_datadict_2.t1 but not db_datadict_1 to testuser1 -> invisible diff --git a/mysql-test/suite/funcs_1/r/is_schema_privileges_is_mysql_test.result b/mysql-test/suite/funcs_1/r/is_schema_privileges_is_mysql_test.result index 2b285395cffd2..774b65b03bc4c 100644 --- a/mysql-test/suite/funcs_1/r/is_schema_privileges_is_mysql_test.result +++ b/mysql-test/suite/funcs_1/r/is_schema_privileges_is_mysql_test.result @@ -10,23 +10,6 @@ SELECT * FROM information_schema.schema_privileges WHERE table_schema IN ('information_schema','mysql','test') ORDER BY grantee, table_schema, privilege_type; GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE -''@'%' def test ALTER NO -''@'%' def test CREATE NO -''@'%' def test CREATE ROUTINE NO -''@'%' def test CREATE TEMPORARY TABLES NO -''@'%' def test CREATE VIEW NO -''@'%' def test DELETE NO -''@'%' def test DELETE HISTORY NO -''@'%' def test DROP NO -''@'%' def test EVENT NO -''@'%' def test INDEX NO -''@'%' def test INSERT NO -''@'%' def test LOCK TABLES NO -''@'%' def test REFERENCES NO -''@'%' def test SELECT NO -''@'%' def test SHOW VIEW NO -''@'%' def test TRIGGER NO -''@'%' def test UPDATE NO SHOW DATABASES LIKE 'information_schema'; Database (information_schema) information_schema @@ -48,7 +31,6 @@ SHOW DATABASES LIKE 'mysql'; Database (mysql) SHOW DATABASES LIKE 'test'; Database (test) -test connection default; DROP USER 'testuser1'@'localhost'; DROP DATABASE db_datadict; diff --git a/mysql-test/suite/funcs_1/r/is_schemata.result b/mysql-test/suite/funcs_1/r/is_schemata.result index ff33306b8f90d..1851c089b04c1 100644 --- a/mysql-test/suite/funcs_1/r/is_schemata.result +++ b/mysql-test/suite/funcs_1/r/is_schemata.result @@ -106,7 +106,7 @@ SHOW DATABASES LIKE 'db_datadict_%'; Database (db_datadict_%) db_datadict_1 db_datadict_2 -connect testuser3, localhost, testuser3, , test; +connect testuser3, localhost, testuser3, ,"*NO-ONE*"; SELECT * FROM information_schema.schemata WHERE schema_name LIKE 'db_datadict_%' ORDER BY schema_name; CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT diff --git a/mysql-test/suite/funcs_1/r/is_schemata_embedded.result b/mysql-test/suite/funcs_1/r/is_schemata_embedded.result index 9f129caa5bf28..fd7a86d4a42ba 100644 --- a/mysql-test/suite/funcs_1/r/is_schemata_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_schemata_embedded.result @@ -108,7 +108,7 @@ SHOW DATABASES LIKE 'db_datadict_%'; Database (db_datadict_%) db_datadict_1 db_datadict_2 -connect testuser3, localhost, testuser3, , test; +connect testuser3, localhost, testuser3, ,"*NO-ONE*"; SELECT * FROM information_schema.schemata WHERE schema_name LIKE 'db_datadict_%' ORDER BY schema_name; CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT diff --git a/mysql-test/suite/funcs_1/r/is_schemata_is_mysql_test.result b/mysql-test/suite/funcs_1/r/is_schemata_is_mysql_test.result index 516d1cc04dd32..4a18f7a0abab8 100644 --- a/mysql-test/suite/funcs_1/r/is_schemata_is_mysql_test.result +++ b/mysql-test/suite/funcs_1/r/is_schemata_is_mysql_test.result @@ -28,7 +28,6 @@ WHERE schema_name IN ('information_schema','mysql','test') ORDER BY schema_name; CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH SCHEMA_COMMENT def information_schema utf8mb3 utf8mb3_general_ci NULL -def test latin1 latin1_swedish_ci NULL SHOW DATABASES LIKE 'information_schema'; Database (information_schema) information_schema @@ -36,7 +35,6 @@ SHOW DATABASES LIKE 'mysql'; Database (mysql) SHOW DATABASES LIKE 'test'; Database (test) -test connection default; DROP USER 'testuser1'@'localhost'; DROP DATABASE db_datadict; diff --git a/mysql-test/suite/funcs_1/r/is_statistics.result b/mysql-test/suite/funcs_1/r/is_statistics.result index c9f8f494ed6da..cf9eda679abd5 100644 --- a/mysql-test/suite/funcs_1/r/is_statistics.result +++ b/mysql-test/suite/funcs_1/r/is_statistics.result @@ -170,6 +170,8 @@ DROP USER 'testuser1'@'localhost'; CREATE USER 'testuser1'@'localhost'; DROP USER 'testuser2'@'localhost'; CREATE USER 'testuser2'@'localhost'; +GRANT ALL ON test.* TO 'testuser1'@'localhost'; +GRANT ALL ON test.* TO 'testuser2'@'localhost'; CREATE TABLE db_datadict.t1 (f1 INT NOT NULL, PRIMARY KEY(f1), f2 INT, INDEX f2_ind(f2)) ENGINE = ; @@ -200,9 +202,11 @@ def db_datadict_2 t4 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH NO SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO `testuser1`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser1`@`localhost` SHOW GRANTS FOR 'testuser2'@'localhost'; Grants for testuser2@localhost GRANT USAGE ON *.* TO `testuser2`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser2`@`localhost` connect testuser1, localhost, testuser1, , test; SELECT * FROM information_schema.statistics WHERE table_schema LIKE 'db_datadict%' @@ -211,6 +215,7 @@ TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_ SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO `testuser1`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser1`@`localhost` SHOW GRANTS FOR 'testuser2'@'localhost'; ERROR 42000: Access denied for user 'testuser1'@'localhost' to database 'mysql' connect testuser2, localhost, testuser2, , test; @@ -223,6 +228,7 @@ ERROR 42000: Access denied for user 'testuser2'@'localhost' to database 'mysql' SHOW GRANTS FOR 'testuser2'@'localhost'; Grants for testuser2@localhost GRANT USAGE ON *.* TO `testuser2`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser2`@`localhost` connection default; GRANT SELECT ON db_datadict.t1 TO 'testuser1'@'localhost' WITH GRANT OPTION; GRANT SELECT(f1,f5) ON db_datadict_2.t3 TO 'testuser1'@'localhost'; @@ -243,11 +249,13 @@ def db_datadict_2 t4 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH NO SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO `testuser1`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser1`@`localhost` GRANT SELECT (f5, f1) ON `db_datadict_2`.`t3` TO `testuser1`@`localhost` GRANT SELECT ON `db_datadict`.`t1` TO `testuser1`@`localhost` WITH GRANT OPTION SHOW GRANTS FOR 'testuser2'@'localhost'; Grants for testuser2@localhost GRANT USAGE ON *.* TO `testuser2`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser2`@`localhost` connection testuser1; SELECT * FROM information_schema.statistics WHERE table_schema LIKE 'db_datadict%' @@ -262,6 +270,7 @@ def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH NO SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO `testuser1`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser1`@`localhost` GRANT SELECT (f5, f1) ON `db_datadict_2`.`t3` TO `testuser1`@`localhost` GRANT SELECT ON `db_datadict`.`t1` TO `testuser1`@`localhost` WITH GRANT OPTION SHOW GRANTS FOR 'testuser2'@'localhost'; @@ -276,11 +285,13 @@ ERROR 42000: Access denied for user 'testuser2'@'localhost' to database 'mysql' SHOW GRANTS FOR 'testuser2'@'localhost'; Grants for testuser2@localhost GRANT USAGE ON *.* TO `testuser2`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser2`@`localhost` connection default; REVOKE SELECT,GRANT OPTION ON db_datadict.t1 FROM 'testuser1'@'localhost'; SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO `testuser1`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser1`@`localhost` GRANT SELECT (f5, f1) ON `db_datadict_2`.`t3` TO `testuser1`@`localhost` connection testuser1; SELECT * FROM information_schema.statistics @@ -294,6 +305,7 @@ def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH NO SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO `testuser1`@`localhost` +GRANT ALL PRIVILEGES ON `test`.* TO `testuser1`@`localhost` GRANT SELECT (f5, f1) ON `db_datadict_2`.`t3` TO `testuser1`@`localhost` connection default; disconnect testuser1; diff --git a/mysql-test/suite/funcs_1/r/is_user_privileges.result b/mysql-test/suite/funcs_1/r/is_user_privileges.result index 4228c744e46d0..a2a6838358aca 100644 --- a/mysql-test/suite/funcs_1/r/is_user_privileges.result +++ b/mysql-test/suite/funcs_1/r/is_user_privileges.result @@ -371,7 +371,7 @@ ERROR 42000: SELECT command denied to user 'testuser2'@'localhost' for table `my SHOW GRANTS; Grants for testuser2@localhost GRANT INSERT, UPDATE ON *.* TO `testuser2`@`localhost` -connect testuser3, localhost, testuser3, , test; +connect testuser3, localhost, testuser3, ,"*NO-ONE*"; SELECT * FROM information_schema.user_privileges WHERE grantee LIKE '''testuser%''' ORDER BY grantee, table_catalog, privilege_type; diff --git a/mysql-test/suite/funcs_1/r/is_views.result b/mysql-test/suite/funcs_1/r/is_views.result index 97ce2d915d8f1..6a86e7464a0fb 100644 --- a/mysql-test/suite/funcs_1/r/is_views.result +++ b/mysql-test/suite/funcs_1/r/is_views.result @@ -93,18 +93,18 @@ WHERE table_schema = 'db_datadict' ORDER BY table_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM def db_datadict v_granted_glob select `db_datadict`.`t1`.`f2` AS `f2`,`db_datadict`.`t1`.`f3` AS `f3` from `db_datadict`.`t1` NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED def db_datadict v_granted_to_1 select `db_datadict`.`t1`.`f1` AS `f1`,`db_datadict`.`t1`.`f2` AS `f2`,`db_datadict`.`t1`.`f3` AS `f3` from `db_datadict`.`t1` NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED -connect testuser1, localhost, testuser1, , test; +connect testuser1, localhost, testuser1, ,"*NO-ONE*"; SELECT * FROM information_schema.views WHERE table_schema = 'db_datadict' ORDER BY table_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM def db_datadict v_granted_to_1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED -connect testuser2, localhost, testuser2, , test; +connect testuser2, localhost, testuser2, ,"*NO-ONE*"; SELECT * FROM information_schema.views WHERE table_schema = 'db_datadict' ORDER BY table_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM def db_datadict v_granted_glob NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED def db_datadict v_granted_to_1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED -connect test_no_views, localhost, test_no_views, , test; +connect test_no_views, localhost, test_no_views, ,"*NO-ONE*"; SELECT * FROM information_schema.views WHERE table_schema = 'db_datadict' ORDER BY table_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM diff --git a/mysql-test/suite/funcs_1/r/is_views_embedded.result b/mysql-test/suite/funcs_1/r/is_views_embedded.result index 136126d8ab560..f64562aadd164 100644 --- a/mysql-test/suite/funcs_1/r/is_views_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_views_embedded.result @@ -93,19 +93,19 @@ WHERE table_schema = 'db_datadict' ORDER BY table_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM def db_datadict v_granted_glob select `db_datadict`.`t1`.`f2` AS `f2`,`db_datadict`.`t1`.`f3` AS `f3` from `db_datadict`.`t1` NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED def db_datadict v_granted_to_1 select `db_datadict`.`t1`.`f1` AS `f1`,`db_datadict`.`t1`.`f2` AS `f2`,`db_datadict`.`t1`.`f3` AS `f3` from `db_datadict`.`t1` NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED -connect testuser1, localhost, testuser1, , test; +connect testuser1, localhost, testuser1, ,"*NO-ONE*"; SELECT * FROM information_schema.views WHERE table_schema = 'db_datadict' ORDER BY table_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM def db_datadict v_granted_glob NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED def db_datadict v_granted_to_1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED -connect testuser2, localhost, testuser2, , test; +connect testuser2, localhost, testuser2, ,"*NO-ONE*"; SELECT * FROM information_schema.views WHERE table_schema = 'db_datadict' ORDER BY table_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM def db_datadict v_granted_glob NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED def db_datadict v_granted_to_1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED -connect test_no_views, localhost, test_no_views, , test; +connect test_no_views, localhost, test_no_views, ,"*NO-ONE*"; SELECT * FROM information_schema.views WHERE table_schema = 'db_datadict' ORDER BY table_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM diff --git a/mysql-test/suite/funcs_1/r/memory_trig_03.result b/mysql-test/suite/funcs_1/r/memory_trig_03.result index b76e7d01f5964..477a2fa30358c 100644 --- a/mysql-test/suite/funcs_1/r/memory_trig_03.result +++ b/mysql-test/suite/funcs_1/r/memory_trig_03.result @@ -241,7 +241,7 @@ show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost GRANT TRIGGER ON *.* TO `test_yesprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT UPDATE ON `priv_db`.* TO `test_yesprivs`@`localhost` -connect no_privs_424b,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect no_privs_424b,localhost,test_noprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; connect yes_privs_424b,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; connection default; connection no_privs_424b; diff --git a/mysql-test/suite/funcs_1/r/memory_trig_03e.result b/mysql-test/suite/funcs_1/r/memory_trig_03e.result index c40cbd0ab7298..e1ed25be0c5f1 100644 --- a/mysql-test/suite/funcs_1/r/memory_trig_03e.result +++ b/mysql-test/suite/funcs_1/r/memory_trig_03e.result @@ -25,7 +25,8 @@ show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT USAGE ON *.* TO `test_noprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, INSERT ON `priv_db`.* TO `test_noprivs`@`localhost` -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; no trigger privilege on db level for create: -------------------------------------------- @@ -33,8 +34,8 @@ use priv_db; create trigger trg1_1 before INSERT on t1 for each row set new.f1 = 'trig 1_1-no'; ERROR 42000: TRIGGER command denied to user 'test_yesprivs'@'localhost' for table `priv_db`.`t1` -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -use priv_db; +connect no_privs,localhost,test_noprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connection no_privs; insert into t1 (f1) values ('insert-yes'); select f1 from t1 order by f1; f1 @@ -272,8 +273,10 @@ revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; create User test_noprivs@localhost; set password for test_noprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; +connect no_privs,localhost,test_noprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection no_privs; no trigger privilege on table level for create: ----------------------------------------------- @@ -825,10 +828,8 @@ Grants for test_noprivs@localhost GRANT USAGE ON *.* TO `test_noprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, INSERT, UPDATE ON `priv1_db`.* TO `test_noprivs`@`localhost` GRANT SELECT, INSERT ON `priv2_db`.* TO `test_noprivs`@`localhost` -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -use priv1_db; -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -use priv1_db; +connect yes_privs,localhost,test_yesprivs,PWD,priv1_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connect no_privs,localhost,test_noprivs,PWD,priv1_db,$MASTER_MYPORT,$MASTER_MYSOCK; trigger privilege on one db1 db level, not on db2 ------------------------------------------------- @@ -1056,7 +1057,8 @@ create User test_useprivs@localhost; set password for test_useprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; revoke ALL PRIVILEGES, GRANT OPTION FROM test_useprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; connection default; select current_user; current_user @@ -1086,11 +1088,11 @@ select f1 from t1 order by f1; f1 trig 1_1-yes prepare ins1 from 'insert into t1 (f1) values (''insert2-no'')'; -connect use_privs,localhost,test_useprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect use_privs,localhost,test_useprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connection use_privs; select current_user; current_user test_useprivs@localhost -use priv_db; prepare ins1 from 'insert into t1 (f1) values (''insert3-no'')'; execute ins1; select f1 from t1 order by f1; @@ -1302,7 +1304,8 @@ create table t1 (f1 char(20)) engine= memory; create User test_yesprivs@localhost; set password for test_yesprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; connection default; select current_user; current_user @@ -1423,8 +1426,10 @@ show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT USAGE ON *.* TO `test_noprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, UPDATE ON `priv_db`.* TO `test_noprivs`@`localhost` -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; +connect no_privs,localhost,test_noprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection no_privs; update only on column: ---------------------- diff --git a/mysql-test/suite/funcs_1/r/memory_trig_0407.result b/mysql-test/suite/funcs_1/r/memory_trig_0407.result index ceae360946c0e..c9a15b46aba07 100644 --- a/mysql-test/suite/funcs_1/r/memory_trig_0407.result +++ b/mysql-test/suite/funcs_1/r/memory_trig_0407.result @@ -69,8 +69,10 @@ revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost; create User test_super@localhost; set password for test_super@localhost = password('PWD'); grant ALL on *.* to test_super@localhost with grant OPTION; -connect con1_general,localhost,test_general,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect con1_super,localhost,test_super,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect con1_general,localhost,test_general,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection con1_general; +connect con1_super,localhost,test_super,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection con1_super; connection default; Testcase 3.5.4: diff --git a/mysql-test/suite/funcs_1/r/memory_trig_08.result b/mysql-test/suite/funcs_1/r/memory_trig_08.result index c9d6454dc5b2c..c37266bb40c91 100644 --- a/mysql-test/suite/funcs_1/r/memory_trig_08.result +++ b/mysql-test/suite/funcs_1/r/memory_trig_08.result @@ -66,6 +66,7 @@ Testcase: 3.5: create User test_general@localhost; set password for test_general@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost; +grant SELECT,UPDATE,DELETE,INSERT on test.* to test_general@localhost; create User test_super@localhost; set password for test_super@localhost = password('PWD'); grant ALL on *.* to test_super@localhost with grant OPTION; diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_03.result b/mysql-test/suite/funcs_1/r/myisam_trig_03.result index b76e7d01f5964..477a2fa30358c 100644 --- a/mysql-test/suite/funcs_1/r/myisam_trig_03.result +++ b/mysql-test/suite/funcs_1/r/myisam_trig_03.result @@ -241,7 +241,7 @@ show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost GRANT TRIGGER ON *.* TO `test_yesprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT UPDATE ON `priv_db`.* TO `test_yesprivs`@`localhost` -connect no_privs_424b,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect no_privs_424b,localhost,test_noprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; connect yes_privs_424b,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; connection default; connection no_privs_424b; diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_03e.result b/mysql-test/suite/funcs_1/r/myisam_trig_03e.result index 71cf064d2019c..26862e3880358 100644 --- a/mysql-test/suite/funcs_1/r/myisam_trig_03e.result +++ b/mysql-test/suite/funcs_1/r/myisam_trig_03e.result @@ -25,7 +25,8 @@ show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT USAGE ON *.* TO `test_noprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, INSERT ON `priv_db`.* TO `test_noprivs`@`localhost` -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; no trigger privilege on db level for create: -------------------------------------------- @@ -33,8 +34,8 @@ use priv_db; create trigger trg1_1 before INSERT on t1 for each row set new.f1 = 'trig 1_1-no'; ERROR 42000: TRIGGER command denied to user 'test_yesprivs'@'localhost' for table `priv_db`.`t1` -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -use priv_db; +connect no_privs,localhost,test_noprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connection no_privs; insert into t1 (f1) values ('insert-yes'); select f1 from t1 order by f1; f1 @@ -272,8 +273,10 @@ revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; create User test_noprivs@localhost; set password for test_noprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; +connect no_privs,localhost,test_noprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection no_privs; no trigger privilege on table level for create: ----------------------------------------------- @@ -825,10 +828,8 @@ Grants for test_noprivs@localhost GRANT USAGE ON *.* TO `test_noprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, INSERT, UPDATE ON `priv1_db`.* TO `test_noprivs`@`localhost` GRANT SELECT, INSERT ON `priv2_db`.* TO `test_noprivs`@`localhost` -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -use priv1_db; -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -use priv1_db; +connect yes_privs,localhost,test_yesprivs,PWD,priv1_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connect no_privs,localhost,test_noprivs,PWD,priv1_db,$MASTER_MYPORT,$MASTER_MYSOCK; trigger privilege on one db1 db level, not on db2 ------------------------------------------------- @@ -1056,7 +1057,8 @@ create User test_useprivs@localhost; set password for test_useprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; revoke ALL PRIVILEGES, GRANT OPTION FROM test_useprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; connection default; select current_user; current_user @@ -1086,11 +1088,11 @@ select f1 from t1 order by f1; f1 trig 1_1-yes prepare ins1 from 'insert into t1 (f1) values (''insert2-no'')'; -connect use_privs,localhost,test_useprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect use_privs,localhost,test_useprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK; +connection use_privs; select current_user; current_user test_useprivs@localhost -use priv_db; prepare ins1 from 'insert into t1 (f1) values (''insert3-no'')'; execute ins1; select f1 from t1 order by f1; @@ -1302,7 +1304,8 @@ create table t1 (f1 char(20)) engine= myisam; create User test_yesprivs@localhost; set password for test_yesprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; connection default; select current_user; current_user @@ -1423,8 +1426,10 @@ show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT USAGE ON *.* TO `test_noprivs`@`localhost` IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT SELECT, UPDATE ON `priv_db`.* TO `test_noprivs`@`localhost` -connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection yes_privs; +connect no_privs,localhost,test_noprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection no_privs; update only on column: ---------------------- diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_0407.result b/mysql-test/suite/funcs_1/r/myisam_trig_0407.result index ceae360946c0e..c9a15b46aba07 100644 --- a/mysql-test/suite/funcs_1/r/myisam_trig_0407.result +++ b/mysql-test/suite/funcs_1/r/myisam_trig_0407.result @@ -69,8 +69,10 @@ revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost; create User test_super@localhost; set password for test_super@localhost = password('PWD'); grant ALL on *.* to test_super@localhost with grant OPTION; -connect con1_general,localhost,test_general,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect con1_super,localhost,test_super,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; +connect con1_general,localhost,test_general,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection con1_general; +connect con1_super,localhost,test_super,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK; +connection con1_super; connection default; Testcase 3.5.4: diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_08.result b/mysql-test/suite/funcs_1/r/myisam_trig_08.result index c9d6454dc5b2c..c37266bb40c91 100644 --- a/mysql-test/suite/funcs_1/r/myisam_trig_08.result +++ b/mysql-test/suite/funcs_1/r/myisam_trig_08.result @@ -66,6 +66,7 @@ Testcase: 3.5: create User test_general@localhost; set password for test_general@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost; +grant SELECT,UPDATE,DELETE,INSERT on test.* to test_general@localhost; create User test_super@localhost; set password for test_super@localhost = password('PWD'); grant ALL on *.* to test_super@localhost with grant OPTION; diff --git a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result index 126bf44f7ebb0..2bba1c0616276 100644 --- a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result +++ b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result @@ -10,6 +10,8 @@ DROP USER ddicttestuser1@'localhost'; DROP USER ddicttestuser2@'localhost'; CREATE USER ddicttestuser1@'localhost'; CREATE USER ddicttestuser2@'localhost'; +GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,CREATE TEMPORARY TABLES,CREATE VIEW,DROP on test.* to ddicttestuser1@'localhost'; +GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,CREATE TEMPORARY TABLES,CREATE VIEW,DROP on test.* to ddicttestuser2@'localhost'; SET PASSWORD FOR ddicttestuser1@'localhost' = PASSWORD('ddictpass'); SET PASSWORD FOR ddicttestuser2@'localhost' = PASSWORD('ddictpass'); #################################################################################### @@ -152,6 +154,7 @@ ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'in SHOW GRANTS; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` CREATE INDEX i_processlist ON processlist (user); ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema' DROP TABLE processlist; @@ -188,6 +191,7 @@ connection con100; SHOW GRANTS; Grants for ddicttestuser1@localhost GRANT PROCESS ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Query TIME starting SHOW processlist TIME_MS @@ -202,6 +206,7 @@ connect con101,localhost,ddicttestuser1,ddictpass,information_schema; SHOW GRANTS; Grants for ddicttestuser1@localhost GRANT PROCESS ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -255,6 +260,7 @@ ddicttestuser1 are visible. SHOW GRANTS; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -298,6 +304,7 @@ Only the processes of ddicttestuser1 user are visible. SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT SUPER ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -325,6 +332,7 @@ Only the processes of ddicttestuser1 are visible. SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -353,6 +361,7 @@ Try to grant PROCESS privilege to user ddicttestuser2 without having it. SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT SUPER ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' WITH GRANT OPTION +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; ERROR 28000: Access denied for user 'ddicttestuser1'@'localhost' (using password: YES) #################################################################################### @@ -369,6 +378,7 @@ Grant PROCESS privilege to user ddicttestuser2 SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT PROCESS, SUPER ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' WITH GRANT OPTION +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; #################################################################################### 10.4 New connection con200 (ddicttestuser2 with PROCESS privilege) @@ -378,6 +388,7 @@ ddicttestuser2 has now the PROCESS privilege and sees all connections SHOW GRANTS FOR 'ddicttestuser2'@'localhost'; Grants for ddicttestuser2@localhost GRANT PROCESS ON *.* TO `ddicttestuser2`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser2`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -418,6 +429,7 @@ ddicttestuser2 has no more the PROCESS privilege and can only see own connects SHOW GRANTS; Grants for ddicttestuser2@localhost GRANT USAGE ON *.* TO `ddicttestuser2`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser2`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser2 HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -441,6 +453,7 @@ He is also unable to GRANT the PROCESS privilege to ddicttestuser2 SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; ERROR 28000: Access denied for user 'ddicttestuser1'@'localhost' (using password: YES) SHOW processlist; @@ -480,6 +493,7 @@ Therefore the missing SELECT privilege does not affect SELECTs on PROCESSLIST. SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS diff --git a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result index 95c706b3f2552..94bc1544c071b 100644 --- a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result +++ b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result @@ -10,6 +10,8 @@ DROP USER ddicttestuser1@'localhost'; DROP USER ddicttestuser2@'localhost'; CREATE USER ddicttestuser1@'localhost'; CREATE USER ddicttestuser2@'localhost'; +GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,CREATE TEMPORARY TABLES,CREATE VIEW,DROP on test.* to ddicttestuser1@'localhost'; +GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,CREATE TEMPORARY TABLES,CREATE VIEW,DROP on test.* to ddicttestuser2@'localhost'; SET PASSWORD FOR ddicttestuser1@'localhost' = PASSWORD('ddictpass'); SET PASSWORD FOR ddicttestuser2@'localhost' = PASSWORD('ddictpass'); #################################################################################### @@ -152,6 +154,7 @@ ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'in SHOW GRANTS; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` CREATE INDEX i_processlist ON processlist (user); ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema' DROP TABLE processlist; @@ -188,6 +191,7 @@ connection con100; SHOW GRANTS; Grants for ddicttestuser1@localhost GRANT PROCESS ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Query TIME starting SHOW processlist TIME_MS @@ -202,6 +206,7 @@ connect con101,localhost,ddicttestuser1,ddictpass,information_schema; SHOW GRANTS; Grants for ddicttestuser1@localhost GRANT PROCESS ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -255,6 +260,7 @@ ddicttestuser1 are visible. SHOW GRANTS; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -298,6 +304,7 @@ Only the processes of ddicttestuser1 user are visible. SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT SUPER ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -325,6 +332,7 @@ Only the processes of ddicttestuser1 are visible. SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -353,6 +361,7 @@ Try to grant PROCESS privilege to user ddicttestuser2 without having it. SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT SUPER ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' WITH GRANT OPTION +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; ERROR 28000: Access denied for user 'ddicttestuser1'@'localhost' (using password: YES) #################################################################################### @@ -369,6 +378,7 @@ Grant PROCESS privilege to user ddicttestuser2 SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT PROCESS, SUPER ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' WITH GRANT OPTION +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; #################################################################################### 10.4 New connection con200 (ddicttestuser2 with PROCESS privilege) @@ -378,6 +388,7 @@ ddicttestuser2 has now the PROCESS privilege and sees all connections SHOW GRANTS FOR 'ddicttestuser2'@'localhost'; Grants for ddicttestuser2@localhost GRANT PROCESS ON *.* TO `ddicttestuser2`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser2`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -418,6 +429,7 @@ ddicttestuser2 has no more the PROCESS privilege and can only see own connects SHOW GRANTS; Grants for ddicttestuser2@localhost GRANT USAGE ON *.* TO `ddicttestuser2`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser2`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser2 HOST_NAME information_schema Sleep TIME NULL TIME_MS @@ -441,6 +453,7 @@ He is also unable to GRANT the PROCESS privilege to ddicttestuser2 SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; ERROR 28000: Access denied for user 'ddicttestuser1'@'localhost' (using password: YES) SHOW processlist; @@ -480,6 +493,7 @@ Therefore the missing SELECT privilege does not affect SELECTs on PROCESSLIST. SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; Grants for ddicttestuser1@localhost GRANT USAGE ON *.* TO `ddicttestuser1`@`localhost` IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, CREATE TEMPORARY TABLES, CREATE VIEW ON `test`.* TO `ddicttestuser1`@`localhost` SHOW processlist; Id User Host db Command Time State Info Progress ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS diff --git a/mysql-test/suite/funcs_1/t/is_basics_mixed.test b/mysql-test/suite/funcs_1/t/is_basics_mixed.test index bed3f63321249..0fea9dd351cbc 100644 --- a/mysql-test/suite/funcs_1/t/is_basics_mixed.test +++ b/mysql-test/suite/funcs_1/t/is_basics_mixed.test @@ -52,6 +52,7 @@ SELECT DATABASE(); --error 0,ER_CANNOT_USER DROP USER 'testuser1'@'localhost'; CREATE USER 'testuser1'@'localhost'; +GRANT SELECT ON test.* TO 'testuser1'@'localhost'; # Low privileged user --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , test); diff --git a/mysql-test/suite/funcs_1/t/is_check_constraints.test b/mysql-test/suite/funcs_1/t/is_check_constraints.test index 0881b4bdf7724..3ae45e23cb87e 100644 --- a/mysql-test/suite/funcs_1/t/is_check_constraints.test +++ b/mysql-test/suite/funcs_1/t/is_check_constraints.test @@ -77,7 +77,7 @@ CONSTRAINT b1 check (b<123456789012345678901234567890123456789012345678901234567 SELECT * from information_schema.check_constraints; DISCONNECT con1; -CONNECT(con2, localhost, boo2,, test); +CONNECT(con2, localhost, boo2,,"*NO-ONE*"); --sorted_result SELECT * from information_schema.check_constraints; diff --git a/mysql-test/suite/funcs_1/t/is_schema_privileges.test b/mysql-test/suite/funcs_1/t/is_schema_privileges.test index fdf09a6f94bcf..8d0ec916f6f19 100644 --- a/mysql-test/suite/funcs_1/t/is_schema_privileges.test +++ b/mysql-test/suite/funcs_1/t/is_schema_privileges.test @@ -116,7 +116,7 @@ let $show_testuser1 = SHOW GRANTS FOR 'testuser1'@'localhost'; let $show_testuser2 = SHOW GRANTS FOR 'testuser2'@'localhost'; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -connect (testuser1, localhost, testuser1, , test); +connect (testuser1, localhost, testuser1, ,"*NO-ONE*"); GRANT SELECT ON db_datadict_4.* TO 'testuser2'@'localhost'; --echo # Root granted INSERT db_datadict_1 to me -> visible --echo # Root granted SELECT db_datadict_1 to testuser2 -> invisible @@ -132,7 +132,7 @@ eval $show_testuser1; eval $show_testuser2; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -connect (testuser2, localhost, testuser2, , test); +connect (testuser2, localhost, testuser2, ,"*NO-ONE*"); --echo # Root granted SELECT db_datadict_1 to me -> visible --echo # Root granted INSERT db_datadict_1 to testuser1 -> invisible --echo # Root granted INSERT db_datadict_2.t1 but not db_datadict_1 to testuser1 -> invisible diff --git a/mysql-test/suite/funcs_1/t/is_statistics.test b/mysql-test/suite/funcs_1/t/is_statistics.test index 3d7f23a7b2c7a..9f317eee55c4b 100644 --- a/mysql-test/suite/funcs_1/t/is_statistics.test +++ b/mysql-test/suite/funcs_1/t/is_statistics.test @@ -109,6 +109,8 @@ CREATE USER 'testuser1'@'localhost'; --error 0,ER_CANNOT_USER DROP USER 'testuser2'@'localhost'; CREATE USER 'testuser2'@'localhost'; +GRANT ALL ON test.* TO 'testuser1'@'localhost'; +GRANT ALL ON test.* TO 'testuser2'@'localhost'; --replace_result $engine_type eval diff --git a/mysql-test/suite/funcs_1/t/is_user_privileges.test b/mysql-test/suite/funcs_1/t/is_user_privileges.test index 3af56ad2533a6..814e4db97fb10 100644 --- a/mysql-test/suite/funcs_1/t/is_user_privileges.test +++ b/mysql-test/suite/funcs_1/t/is_user_privileges.test @@ -170,7 +170,7 @@ eval $my_select2; eval $my_show; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK -connect (testuser3, localhost, testuser3, , test); +connect (testuser3, localhost, testuser3, ,"*NO-ONE*"); --vertical_results eval $my_select1; --error ER_TABLEACCESS_DENIED_ERROR diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03.inc b/mysql-test/suite/funcs_1/triggers/triggers_03.inc index f48d1979f77f5..c16737afab3c4 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03.inc @@ -205,7 +205,7 @@ let $message= Testcase 3.5.3.7b:; grant UPDATE on priv_db.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; - connect (no_privs_424b,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (no_privs_424b,localhost,test_noprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK); connect (yes_privs_424b,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); connection default; diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_columns.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_columns.inc index 2f0ad2c1cccb5..3b2ffc57aa3ec 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_columns.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_columns.inc @@ -36,9 +36,13 @@ let $message= ####### Testcase for column privileges of triggers: #######; grant SELECT,UPDATE on priv_db.* to test_noprivs@localhost; show grants for test_noprivs@localhost; - connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection yes_privs; - connect (no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (no_privs,localhost,test_noprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection no_privs; # grant TRIGGER and UPDATE on column -> succeed diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_db_level.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_db_level.inc index 9e6d8598e6fd2..1170bb7811df9 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_db_level.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_db_level.inc @@ -37,7 +37,9 @@ let $message= Testcase for db level:; show grants for test_noprivs@localhost; # no trigger privilege->create trigger must fail: - connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (yes_privs,localhost,test_yesprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection yes_privs; let $message= no trigger privilege on db level for create:; --source include/show_msg.inc use priv_db; @@ -46,8 +48,9 @@ let $message= no trigger privilege on db level for create:; set new.f1 = 'trig 1_1-no'; # user with minimum privs on t1->no trigger executed; - connect (no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); - use priv_db; + connect (no_privs,localhost,test_noprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection no_privs; insert into t1 (f1) values ('insert-yes'); select f1 from t1 order by f1; diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_db_table_mix.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_db_table_mix.inc index e56a5972ce611..6566cd6fd4e6a 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_db_table_mix.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_db_table_mix.inc @@ -41,10 +41,8 @@ let $message= ####### Testcase for mix of db and table level: #######; grant SELECT,INSERT on priv2_db.* to test_noprivs@localhost; show grants for test_noprivs@localhost; - connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); - use priv1_db; - connect (no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); - use priv1_db; + connect (yes_privs,localhost,test_yesprivs,PWD,priv1_db,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (no_privs,localhost,test_noprivs,PWD,priv1_db,$MASTER_MYPORT,$MASTER_MYSOCK); # trigger priv on db level->create trigger for all tables successful diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_definer.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_definer.inc index 9988e1cafc2e3..8e3dff9b01893 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_definer.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_definer.inc @@ -27,7 +27,9 @@ let $message= ######### Testcase for definer: ########; revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; - connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection yes_privs; # create trigger with not existing definer shall deliver a warning: connection default; diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_prepare.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_prepare.inc index e2efa5774fa7a..6479439467a58 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_prepare.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_prepare.inc @@ -32,7 +32,9 @@ let $message= #### Testcase for trigger privilege on execution time ########; revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; revoke ALL PRIVILEGES, GRANT OPTION FROM test_useprivs@localhost; - connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection yes_privs; connection default; select current_user; @@ -56,9 +58,10 @@ let $message= #### Testcase for trigger privilege on execution time ########; select f1 from t1 order by f1; prepare ins1 from 'insert into t1 (f1) values (''insert2-no'')'; - connect (use_privs,localhost,test_useprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (use_privs,localhost,test_useprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection use_privs; select current_user; - use priv_db; prepare ins1 from 'insert into t1 (f1) values (''insert3-no'')'; execute ins1; select f1 from t1 order by f1; diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_table_level.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_table_level.inc index bd6bee9bcf200..bc73511a2ea4d 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_table_level.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_table_level.inc @@ -30,9 +30,13 @@ let $message= ######### Testcase for table level: ########; set password for test_noprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost; - connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (yes_privs,localhost,test_yesprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection yes_privs; - connect (no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (no_privs,localhost,test_noprivs,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection no_privs; ################ Section 3.5.3 ############ # Check for the table level of Triggers # diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_transaction.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_transaction.inc index 2f72ba64bfd1c..35c0ec76eba9e 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_transaction.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_transaction.inc @@ -27,7 +27,6 @@ let $message= ######### Testcase for transactions: ########; revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; - connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); connection default; select current_user; @@ -35,9 +34,9 @@ let $message= ######### Testcase for transactions: ########; on priv_db.t1 to test_yesprivs@localhost; show grants for test_yesprivs@localhost; + connect (yes_privs,localhost,test_yesprivs,PWD,priv_db,$MASTER_MYPORT,$MASTER_MYSOCK); connection yes_privs; select current_user; - use priv_db; set autocommit=0; create definer=current_user trigger trg1_1 before INSERT on t1 for each row diff --git a/mysql-test/suite/funcs_1/triggers/triggers_0407.inc b/mysql-test/suite/funcs_1/triggers/triggers_0407.inc index 71471696761aa..812811561504d 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_0407.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_0407.inc @@ -23,8 +23,12 @@ let $message= Testcase: 3.5:; create User test_super@localhost; set password for test_super@localhost = password('PWD'); grant ALL on *.* to test_super@localhost with grant OPTION; - connect (con1_general,localhost,test_general,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); - connect (con1_super,localhost,test_super,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); + connect (con1_general,localhost,test_general,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection con1_general; + connect (con1_super,localhost,test_super,PWD,"*NO-ONE*",$MASTER_MYPORT,$MASTER_MYSOCK); +# next is to check that we connected above + connection con1_super; connection default; #################################### diff --git a/mysql-test/suite/funcs_1/triggers/triggers_08.inc b/mysql-test/suite/funcs_1/triggers/triggers_08.inc index 0aeb46896a64d..7169f160fb855 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_08.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_08.inc @@ -20,6 +20,7 @@ let $message= Testcase: 3.5:; create User test_general@localhost; set password for test_general@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_general@localhost; + grant SELECT,UPDATE,DELETE,INSERT on test.* to test_general@localhost; create User test_super@localhost; set password for test_super@localhost = password('PWD'); diff --git a/mysql-test/suite/galera/r/galera_create_procedure.result b/mysql-test/suite/galera/r/galera_create_procedure.result index 24a0bd66b3971..27bdf19f25643 100644 --- a/mysql-test/suite/galera/r/galera_create_procedure.result +++ b/mysql-test/suite/galera/r/galera_create_procedure.result @@ -2,6 +2,7 @@ connection node_2; connection node_1; connection node_1; CREATE USER 'user1'; +GRANT ALL ON test.* to 'user1'; CREATE TABLE t1 (f1 INTEGER); CREATE DEFINER = 'user1' diff --git a/mysql-test/suite/galera/r/galera_create_trigger.result b/mysql-test/suite/galera/r/galera_create_trigger.result index 56b35150d877f..4244e4c85adff 100644 --- a/mysql-test/suite/galera/r/galera_create_trigger.result +++ b/mysql-test/suite/galera/r/galera_create_trigger.result @@ -5,6 +5,7 @@ CREATE TABLE definer_user (f1 INTEGER, trigger_user VARCHAR(100)) ENGINE=InnoDB; CREATE TABLE definer_current_user (f1 INTEGER, trigger_user VARCHAR(100)) ENGINE=InnoDB; CREATE TABLE definer_default (f1 INTEGER, trigger_user VARCHAR(100)) ENGINE=InnoDB; CREATE USER 'user1'; +GRANT ALL ON test.* to 'user1'; CREATE DEFINER=root@localhost TRIGGER definer_root BEFORE INSERT ON definer_root FOR EACH ROW SET NEW.trigger_user = CURRENT_USER(); CREATE DEFINER=user1 TRIGGER definer_user BEFORE INSERT ON definer_user FOR EACH ROW SET NEW.trigger_user = CURRENT_USER(); CREATE DEFINER=current_user TRIGGER definer_current_user BEFORE INSERT ON definer_current_user FOR EACH ROW SET NEW.trigger_user = CURRENT_USER(); diff --git a/mysql-test/suite/galera/r/galera_read_only.result b/mysql-test/suite/galera/r/galera_read_only.result index e7e18ca814594..0928c62f23b39 100644 --- a/mysql-test/suite/galera/r/galera_read_only.result +++ b/mysql-test/suite/galera/r/galera_read_only.result @@ -10,6 +10,7 @@ SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 CREATE USER foo@localhost; +GRANT ALL ON test.* to foo@localhost; # Open connection to node 2 using 'foo' user. connect foo_node_2,127.0.0.1,foo,,test,$port_2,; diff --git a/mysql-test/suite/galera/r/galera_roles.result b/mysql-test/suite/galera/r/galera_roles.result index 19bc9be62b068..fccef1637f657 100644 --- a/mysql-test/suite/galera/r/galera_roles.result +++ b/mysql-test/suite/galera/r/galera_roles.result @@ -21,8 +21,8 @@ GRANT EXECUTE ON PROCEDURE test1.pr1 TO role1; GRANT SELECT ON test1.t1 TO role1; GRANT SELECT (a) ON test1.t2 TO role1; # Open connections to the 2 nodes using 'foo' user. -connect foo_node_1,127.0.0.1,foo,,test,$port_1,; -connect foo_node_2,127.0.0.1,foo,,test,$port_2,; +connect foo_node_1,127.0.0.1,foo,,"*NO-ONE*",$port_1,; +connect foo_node_2,127.0.0.1,foo,,"*NO-ONE*",$port_2,; # Connect with foo_node_1 connection foo_node_1; diff --git a/mysql-test/suite/galera/t/galera_create_procedure.test b/mysql-test/suite/galera/t/galera_create_procedure.test index 30bc85fcea0bd..4947a446e9eb9 100644 --- a/mysql-test/suite/galera/t/galera_create_procedure.test +++ b/mysql-test/suite/galera/t/galera_create_procedure.test @@ -7,6 +7,7 @@ --connection node_1 CREATE USER 'user1'; +GRANT ALL ON test.* to 'user1'; CREATE TABLE t1 (f1 INTEGER); CREATE diff --git a/mysql-test/suite/galera/t/galera_create_trigger.test b/mysql-test/suite/galera/t/galera_create_trigger.test index 6708e30bf0f3d..c76981aae2937 100644 --- a/mysql-test/suite/galera/t/galera_create_trigger.test +++ b/mysql-test/suite/galera/t/galera_create_trigger.test @@ -11,6 +11,7 @@ CREATE TABLE definer_current_user (f1 INTEGER, trigger_user VARCHAR(100)) ENGINE CREATE TABLE definer_default (f1 INTEGER, trigger_user VARCHAR(100)) ENGINE=InnoDB; CREATE USER 'user1'; +GRANT ALL ON test.* to 'user1'; CREATE DEFINER=root@localhost TRIGGER definer_root BEFORE INSERT ON definer_root FOR EACH ROW SET NEW.trigger_user = CURRENT_USER(); CREATE DEFINER=user1 TRIGGER definer_user BEFORE INSERT ON definer_user FOR EACH ROW SET NEW.trigger_user = CURRENT_USER(); CREATE DEFINER=current_user TRIGGER definer_current_user BEFORE INSERT ON definer_current_user FOR EACH ROW SET NEW.trigger_user = CURRENT_USER(); diff --git a/mysql-test/suite/galera/t/galera_read_only.test b/mysql-test/suite/galera/t/galera_read_only.test index 56fe2fdd91001..8d8a8cf88aa03 100644 --- a/mysql-test/suite/galera/t/galera_read_only.test +++ b/mysql-test/suite/galera/t/galera_read_only.test @@ -18,6 +18,7 @@ INSERT INTO t1 VALUES (1); SELECT COUNT(*) = 1 FROM t1; CREATE USER foo@localhost; +GRANT ALL ON test.* to foo@localhost; --echo # Open connection to node 2 using 'foo' user. --let $port_2= \$NODE_MYPORT_2 diff --git a/mysql-test/suite/galera/t/galera_roles.test b/mysql-test/suite/galera/t/galera_roles.test index 3005562db9c7e..e71ca42f2d8ba 100644 --- a/mysql-test/suite/galera/t/galera_roles.test +++ b/mysql-test/suite/galera/t/galera_roles.test @@ -33,11 +33,11 @@ GRANT SELECT (a) ON test1.t2 TO role1; --echo # Open connections to the 2 nodes using 'foo' user. --let $port_1= \$NODE_MYPORT_1 ---connect(foo_node_1,127.0.0.1,foo,,test,$port_1,) +--connect(foo_node_1,127.0.0.1,foo,,"*NO-ONE*",$port_1,) --let $port_2= \$NODE_MYPORT_2 --sleep 1 ---connect(foo_node_2,127.0.0.1,foo,,test,$port_2,) +--connect(foo_node_2,127.0.0.1,foo,,"*NO-ONE*",$port_2,) --echo --echo # Connect with foo_node_1 diff --git a/mysql-test/suite/innodb/r/partition_locking.result b/mysql-test/suite/innodb/r/partition_locking.result index 56bfe3885171f..f25b8a15a2484 100644 --- a/mysql-test/suite/innodb/r/partition_locking.result +++ b/mysql-test/suite/innodb/r/partition_locking.result @@ -3,7 +3,7 @@ set @start_autocommit= @@global.autocommit; set default_storage_engine= innodb; set @@global.autocommit= 0; CREATE USER test@localhost; -grant CREATE, SELECT, UPDATE on *.* to test@localhost; +grant CREATE, SELECT, UPDATE, INSERT on *.* to test@localhost; CREATE USER test2@localhost; grant CREATE, SELECT, UPDATE on *.* to test2@localhost; CREATE TABLE t1 ( diff --git a/mysql-test/suite/innodb/t/partition_locking.test b/mysql-test/suite/innodb/t/partition_locking.test index e33df934a2813..13457c1d9be15 100644 --- a/mysql-test/suite/innodb/t/partition_locking.test +++ b/mysql-test/suite/innodb/t/partition_locking.test @@ -9,7 +9,7 @@ set default_storage_engine= innodb; set @@global.autocommit= 0; CREATE USER test@localhost; -grant CREATE, SELECT, UPDATE on *.* to test@localhost; +grant CREATE, SELECT, UPDATE, INSERT on *.* to test@localhost; CREATE USER test2@localhost; grant CREATE, SELECT, UPDATE on *.* to test2@localhost; diff --git a/mysql-test/suite/parts/inc/part_exch_qa_7.inc b/mysql-test/suite/parts/inc/part_exch_qa_7.inc index e6276fe3ca249..117077675942e 100644 --- a/mysql-test/suite/parts/inc/part_exch_qa_7.inc +++ b/mysql-test/suite/parts/inc/part_exch_qa_7.inc @@ -1,4 +1,5 @@ CREATE USER test_2@localhost; +GRANT SELECT,INSERT,CREATE,ALTER,DROP on test.* to test_2@localhost; --source include/not_embedded.inc --disable_result_log diff --git a/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result index 0913bbaa55b7a..4613a2fd06468 100644 --- a/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result +++ b/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result @@ -1,4 +1,5 @@ CREATE USER test_2@localhost; +GRANT SELECT,INSERT,CREATE,ALTER,DROP on test.* to test_2@localhost; send ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10; connect test_2,localhost,test_2,,test,$MASTER_MYPORT,$MASTER_MYSOCK; diff --git a/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result index 0913bbaa55b7a..4613a2fd06468 100644 --- a/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result +++ b/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result @@ -1,4 +1,5 @@ CREATE USER test_2@localhost; +GRANT SELECT,INSERT,CREATE,ALTER,DROP on test.* to test_2@localhost; send ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10; connect test_2,localhost,test_2,,test,$MASTER_MYPORT,$MASTER_MYSOCK; diff --git a/mysql-test/suite/perfschema/r/connect_attrs.result b/mysql-test/suite/perfschema/r/connect_attrs.result index aa61eb306a2db..6db8f3585d074 100644 --- a/mysql-test/suite/perfschema/r/connect_attrs.result +++ b/mysql-test/suite/perfschema/r/connect_attrs.result @@ -25,7 +25,7 @@ FROM performance_schema.session_account_connect_attrs; COUNT(DISTINCT PROCESSLIST_ID) 1 CREATE USER wl5924@localhost; -connect non_privileged_user,localhost,wl5924,,test; +connect non_privileged_user,localhost,wl5924,,"*NO-ONE*"; connection default; # must return 1 SELECT COUNT(DISTINCT PROCESSLIST_ID) diff --git a/mysql-test/suite/perfschema/r/global_read_lock.result b/mysql-test/suite/perfschema/r/global_read_lock.result index df98b9bd1bb21..31e1751d7b91b 100644 --- a/mysql-test/suite/perfschema/r/global_read_lock.result +++ b/mysql-test/suite/perfschema/r/global_read_lock.result @@ -3,7 +3,7 @@ update performance_schema.setup_instruments set enabled='YES'; create user pfsuser@localhost; grant SELECT, UPDATE, LOCK TABLES on performance_schema.* to pfsuser@localhost; flush privileges; -connect con1, localhost, pfsuser, , test; +connect con1, localhost, pfsuser, ,"*NO-ONE*"; lock tables performance_schema.setup_instruments read; select * from performance_schema.setup_instruments; unlock tables; diff --git a/mysql-test/suite/perfschema/r/privilege.result b/mysql-test/suite/perfschema/r/privilege.result index 79d69b87ca735..75b018426bcc1 100644 --- a/mysql-test/suite/perfschema/r/privilege.result +++ b/mysql-test/suite/perfschema/r/privilege.result @@ -5,6 +5,9 @@ GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION create user 'pfs_user_1'@localhost; create user 'pfs_user_2'@localhost; create user 'pfs_user_3'@localhost; +grant SELECT,INSERT,UPDATE,DELETE,DROP,CREATE on test.* to 'pfs_user_1'@localhost; +grant SELECT,INSERT,UPDATE,DELETE,DROP,CREATE on test.* to 'pfs_user_2'@localhost; +grant SELECT,INSERT,UPDATE,DELETE,DROP,CREATE on test.* to 'pfs_user_3'@localhost; grant ALL on *.* to 'pfs_user_1'@localhost with GRANT OPTION; grant ALL on performance_schema.* to 'pfs_user_2'@localhost with GRANT OPTION; @@ -521,7 +524,7 @@ flush privileges; # Test cases from WL#4818 # Setup user CREATE user pfs_user_4; -connect pfs_user_4, localhost, pfs_user_4, , ; +connect pfs_user_4, localhost, pfs_user_4, ,"*NO-ONE*"; # # WL#4818, NFS4: Normal user does not have access to view data # without grants diff --git a/mysql-test/suite/perfschema/r/privilege_table_io.result b/mysql-test/suite/perfschema/r/privilege_table_io.result index 94cc2b33b49ef..6dd885281b3a1 100644 --- a/mysql-test/suite/perfschema/r/privilege_table_io.result +++ b/mysql-test/suite/perfschema/r/privilege_table_io.result @@ -119,8 +119,6 @@ wait/io/table/sql/handler TABLE mysql global_priv fetch 1 wait/io/table/sql/handler TABLE mysql global_priv fetch 1 wait/io/table/sql/handler TABLE mysql global_priv fetch 1 wait/io/table/sql/handler TABLE mysql db fetch 1 -wait/io/table/sql/handler TABLE mysql db fetch 1 -wait/io/table/sql/handler TABLE mysql db fetch 1 wait/io/table/sql/handler TABLE mysql proxies_priv fetch 1 wait/io/table/sql/handler TABLE mysql proxies_priv fetch 1 wait/io/table/sql/handler TABLE mysql proxies_priv fetch 1 diff --git a/mysql-test/suite/perfschema/r/read_only.result b/mysql-test/suite/perfschema/r/read_only.result index 344526bbd6314..aa18efc928fdf 100644 --- a/mysql-test/suite/perfschema/r/read_only.result +++ b/mysql-test/suite/perfschema/r/read_only.result @@ -3,7 +3,7 @@ set @start_read_only= @@global.read_only; create user pfsuser@localhost; grant SELECT, UPDATE on performance_schema.* to pfsuser@localhost; flush privileges; -connect con1, localhost, pfsuser, , test; +connect con1, localhost, pfsuser, ,"*NO-ONE*"; connection default; set global read_only=0; connection con1; @@ -35,7 +35,7 @@ connection default; grant READ_ONLY ADMIN on *.* to pfsuser@localhost; flush privileges; disconnect con1; -connect con1, localhost, pfsuser, , test; +connect con1, localhost, pfsuser, ,"*NO-ONE*"; select @@global.read_only; @@global.read_only 1 diff --git a/mysql-test/suite/perfschema/t/connect_attrs.test b/mysql-test/suite/perfschema/t/connect_attrs.test index c703badef8518..2d2c2ce266e1b 100644 --- a/mysql-test/suite/perfschema/t/connect_attrs.test +++ b/mysql-test/suite/perfschema/t/connect_attrs.test @@ -45,7 +45,7 @@ SELECT COUNT(DISTINCT PROCESSLIST_ID) CREATE USER wl5924@localhost; -connect(non_privileged_user,localhost,wl5924,,test); +connect(non_privileged_user,localhost,wl5924,,"*NO-ONE*"); connection default; --echo # must return 1 diff --git a/mysql-test/suite/perfschema/t/global_read_lock.test b/mysql-test/suite/perfschema/t/global_read_lock.test index 4217de0d72302..430d6eed5dc34 100644 --- a/mysql-test/suite/perfschema/t/global_read_lock.test +++ b/mysql-test/suite/perfschema/t/global_read_lock.test @@ -15,7 +15,7 @@ create user pfsuser@localhost; grant SELECT, UPDATE, LOCK TABLES on performance_schema.* to pfsuser@localhost; flush privileges; -connect (con1, localhost, pfsuser, , test); +connect (con1, localhost, pfsuser, ,"*NO-ONE*"); lock tables performance_schema.setup_instruments read; --disable_result_log diff --git a/mysql-test/suite/perfschema/t/privilege.test b/mysql-test/suite/perfschema/t/privilege.test index a0af41e0372dd..06e7cdf0cae24 100644 --- a/mysql-test/suite/perfschema/t/privilege.test +++ b/mysql-test/suite/perfschema/t/privilege.test @@ -8,6 +8,9 @@ show grants; create user 'pfs_user_1'@localhost; create user 'pfs_user_2'@localhost; create user 'pfs_user_3'@localhost; +grant SELECT,INSERT,UPDATE,DELETE,DROP,CREATE on test.* to 'pfs_user_1'@localhost; +grant SELECT,INSERT,UPDATE,DELETE,DROP,CREATE on test.* to 'pfs_user_2'@localhost; +grant SELECT,INSERT,UPDATE,DELETE,DROP,CREATE on test.* to 'pfs_user_3'@localhost; grant ALL on *.* to 'pfs_user_1'@localhost with GRANT OPTION; # Test denied privileges on performance_schema.* @@ -228,7 +231,7 @@ flush privileges; --echo # Setup user CREATE user pfs_user_4; ---connect (pfs_user_4, localhost, pfs_user_4, , ) +--connect (pfs_user_4, localhost, pfs_user_4, ,"*NO-ONE*") --echo # --echo # WL#4818, NFS4: Normal user does not have access to view data diff --git a/mysql-test/suite/perfschema/t/read_only.test b/mysql-test/suite/perfschema/t/read_only.test index 2d8e41595d121..4cbaad0de6b8f 100644 --- a/mysql-test/suite/perfschema/t/read_only.test +++ b/mysql-test/suite/perfschema/t/read_only.test @@ -16,7 +16,7 @@ create user pfsuser@localhost; grant SELECT, UPDATE on performance_schema.* to pfsuser@localhost; flush privileges; -connect (con1, localhost, pfsuser, , test); +connect (con1, localhost, pfsuser, ,"*NO-ONE*"); connection default; @@ -55,7 +55,7 @@ grant READ_ONLY ADMIN on *.* to pfsuser@localhost; flush privileges; disconnect con1; -connect (con1, localhost, pfsuser, , test); +connect (con1, localhost, pfsuser, ,"*NO-ONE*"); select @@global.read_only; show grants; diff --git a/mysql-test/suite/plugins/r/dialog.result b/mysql-test/suite/plugins/r/dialog.result index 0fcbb41ebe026..b0acc311843e3 100644 --- a/mysql-test/suite/plugins/r/dialog.result +++ b/mysql-test/suite/plugins/r/dialog.result @@ -1,5 +1,6 @@ install plugin three_attempts soname 'dialog_examples.so'; create user test_dialog identified via three_attempts using 'SECRET'; +GRANT SELECT ON test.* TO test_dialog; # # -pSECRET is picked up, no questions asked. # diff --git a/mysql-test/suite/plugins/r/multiauth.result b/mysql-test/suite/plugins/r/multiauth.result index 73241619008eb..a3a9d238a00c6 100644 --- a/mysql-test/suite/plugins/r/multiauth.result +++ b/mysql-test/suite/plugins/r/multiauth.result @@ -1,6 +1,8 @@ install soname 'auth_ed25519'; create user 'USER' identified via unix_socket OR mysql_native_password as password("GOOD"); +grant select on test.* to 'USER' ; create user mysqltest1 identified via unix_socket OR mysql_native_password as password("good"); +grant select on test.* to mysqltest1; show create user mysqltest1; CREATE USER for mysqltest1@% CREATE USER `mysqltest1`@`%` IDENTIFIED VIA unix_socket OR mysql_native_password USING '*8409037B3E362D6DAE24C8E667F4D3B66716144E' @@ -16,7 +18,9 @@ mysqltest1@localhost mysqltest1@% test mysqltest: Could not open connection 'default': 1045 Access denied for user 'mysqltest1'@'localhost' (using password: YES) drop user 'USER', mysqltest1; create user 'USER' identified via mysql_native_password as password("GOOD") OR unix_socket; +grant select on test.* to 'USER' ; create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket; +grant select on test.* to mysqltest1; show create user mysqltest1; CREATE USER for mysqltest1@% CREATE USER `mysqltest1`@`%` IDENTIFIED VIA mysql_native_password USING '*8409037B3E362D6DAE24C8E667F4D3B66716144E' OR unix_socket @@ -32,7 +36,9 @@ mysqltest1@localhost mysqltest1@% test mysqltest: Could not open connection 'default': 1698 Access denied for user 'mysqltest1'@'localhost' drop user 'USER', mysqltest1; create user 'USER' identified via unix_socket OR ed25519 as password("GOOD"); +grant select on test.* to 'USER' ; create user mysqltest1 identified via unix_socket OR ed25519 as password("good"); +grant select on test.* to mysqltest1; show create user mysqltest1; CREATE USER for mysqltest1@% CREATE USER `mysqltest1`@`%` IDENTIFIED VIA unix_socket OR ed25519 USING 'F4aF8bw7130VaRbdLCl4f/P/wkjDmgJXwWvpJ5gmsZc' @@ -48,7 +54,9 @@ mysqltest1@localhost mysqltest1@% test mysqltest: Could not open connection 'default': 1045 Access denied for user 'mysqltest1'@'localhost' (using password: YES) drop user 'USER', mysqltest1; create user 'USER' identified via ed25519 as password("GOOD") OR unix_socket; +grant select on test.* to 'USER' ; create user mysqltest1 identified via ed25519 as password("good") OR unix_socket; +grant select on test.* to mysqltest1; show create user mysqltest1; CREATE USER for mysqltest1@% CREATE USER `mysqltest1`@`%` IDENTIFIED VIA ed25519 USING 'F4aF8bw7130VaRbdLCl4f/P/wkjDmgJXwWvpJ5gmsZc' OR unix_socket @@ -64,7 +72,9 @@ mysqltest1@localhost mysqltest1@% test mysqltest: Could not open connection 'default': 1698 Access denied for user 'mysqltest1'@'localhost' drop user 'USER', mysqltest1; create user 'USER' identified via ed25519 as password("GOOD") OR unix_socket OR mysql_native_password as password("works"); +grant select on test.* to 'USER' ; create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); +grant select on test.* to mysqltest1; show create user mysqltest1; CREATE USER for mysqltest1@% CREATE USER `mysqltest1`@`%` IDENTIFIED VIA ed25519 USING 'F4aF8bw7130VaRbdLCl4f/P/wkjDmgJXwWvpJ5gmsZc' OR unix_socket OR mysql_native_password USING '*7D8C3DF236D9163B6C274A9D47704BC496988460' @@ -84,6 +94,7 @@ mysqltest1@localhost mysqltest1@% test mysqltest: Could not open connection 'default': 1045 Access denied for user 'mysqltest1'@'localhost' (using password: YES) drop user 'USER', mysqltest1; create user mysqltest1 identified via mysql_native_password as password("good") OR mysql_native_password as password("works"); +grant select on test.* to mysqltest1; show create user mysqltest1; CREATE USER for mysqltest1@% CREATE USER `mysqltest1`@`%` IDENTIFIED VIA mysql_native_password USING '*8409037B3E362D6DAE24C8E667F4D3B66716144E' OR mysql_native_password USING '*7D8C3DF236D9163B6C274A9D47704BC496988460' @@ -158,7 +169,9 @@ create user mysqltest1 identified via ed25519 as password("good") OR unix_socket ERROR HY000: Column count of mysql.user is wrong. Expected 3, found 47. Created with MariaDB XX.YY.ZZ, now running XX.YY.ZZ. Please use mariadb-upgrade to fix this error # switching back from mysql.user to mysql.global_priv create user 'USER' identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; +grant select on test.* to 'USER' ; create user mysqltest1 identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; +grant select on test.* to mysqltest1; update mysql.global_priv set priv=replace(priv, '1234567890123456789012345678901234567890a', 'invalid password'); flush privileges; show create user mysqltest1; @@ -177,6 +190,7 @@ user() current_user() database() mysqltest1@localhost mysqltest1@% test drop user 'USER', mysqltest1; create user mysqltest1 identified via ed25519 as password("good"); +grant select on test.* to mysqltest1; show create user mysqltest1; CREATE USER for mysqltest1@% CREATE USER `mysqltest1`@`%` IDENTIFIED VIA ed25519 USING 'F4aF8bw7130VaRbdLCl4f/P/wkjDmgJXwWvpJ5gmsZc' diff --git a/mysql-test/suite/plugins/r/pam.result b/mysql-test/suite/plugins/r/pam.result index b858891616923..ceb81690cd87a 100644 --- a/mysql-test/suite/plugins/r/pam.result +++ b/mysql-test/suite/plugins/r/pam.result @@ -1,6 +1,8 @@ install plugin pam soname 'auth_pam.so'; create user test_pam identified via pam using 'mariadb_mtr'; +grant all on test.* to test_pam; create user pam_test; +grant all on test.* to pam_test; grant proxy on pam_test to test_pam; # # athentication is successful, challenge/pin are ok @@ -72,6 +74,7 @@ select user(), current_user(), database(); drop user test_pam; drop user pam_test; create user PAM_TEST identified via pam using 'mariadb_mtr'; +grant all on test.* to PAM_TEST; # # athentication is unsuccessful # @@ -95,6 +98,7 @@ drop user PAM_TEST; # MDEV-27341 Use SET PASSWORD to change PAM service # create user pam_test identified via pam using 'mariadb_mtr'; +grant all on test.* to pam_test; Challenge input first. Enter: ************************* Now, the magic number! diff --git a/mysql-test/suite/plugins/r/pam_cleartext.result b/mysql-test/suite/plugins/r/pam_cleartext.result index 07c379a4b7fd1..6a4d21edbf271 100644 --- a/mysql-test/suite/plugins/r/pam_cleartext.result +++ b/mysql-test/suite/plugins/r/pam_cleartext.result @@ -1,6 +1,8 @@ install plugin pam soname 'auth_pam.so'; create user test_pam identified via pam using 'mariadb_mtr'; +grant all on test.* to test_pam; create user pam_test; +grant all on test.* to pam_test; grant proxy on pam_test to test_pam; show variables like 'pam_use_%'; Variable_name Value diff --git a/mysql-test/suite/plugins/r/pam_v1.result b/mysql-test/suite/plugins/r/pam_v1.result index 66776e3bca7ee..c90d17188d61a 100644 --- a/mysql-test/suite/plugins/r/pam_v1.result +++ b/mysql-test/suite/plugins/r/pam_v1.result @@ -1,6 +1,8 @@ install plugin pam soname 'auth_pam_v1.so'; create user test_pam identified via pam using 'mariadb_mtr'; +grant all on test.* to test_pam; create user pam_test; +grant all on test.* to pam_test; grant proxy on pam_test to test_pam; # # athentication is successful, challenge/pin are ok diff --git a/mysql-test/suite/plugins/r/qc_info_priv.result b/mysql-test/suite/plugins/r/qc_info_priv.result index 9aa15885563ab..ea866d510303b 100644 --- a/mysql-test/suite/plugins/r/qc_info_priv.result +++ b/mysql-test/suite/plugins/r/qc_info_priv.result @@ -31,6 +31,7 @@ STATEMENT_SCHEMA STATEMENT_TEXT RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BL test select * from t1 1 512 # -1 1011 513 binary utf32 utf32_bin Europe/Moscow 4 7 STRICT_ALL_TABLES ar_SD 1 1 1 # 0 0 0 # 0 test select * from t1 1 512 # -1 1024 1048576 latin1 latin1 latin1_swedish_ci SYSTEM 0 4 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION en_US 1 1 1 # 0 0 1 # 0 create user mysqltest; +grant select on test.* to mysqltest; connect conn1,localhost,mysqltest,,; connection conn1; select a from t1; diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result index c676c671a8701..ae40d54e8df90 100644 --- a/mysql-test/suite/plugins/r/server_audit.result +++ b/mysql-test/suite/plugins/r/server_audit.result @@ -247,7 +247,7 @@ connect(localhost,plug,plug_dest,test,MYSQL_PORT,MYSQL_SOCK); connect plug_con,localhost,plug,plug_dest; ERROR 28000: Access denied for user 'plug'@'localhost' (using password: YES) GRANT PROXY ON plug_dest TO plug; -connect plug_con,localhost,plug,plug_dest; +connect plug_con,localhost,plug,plug_dest,"*NO-ONE*"; connection plug_con; select USER(),CURRENT_USER(); USER() CURRENT_USER() @@ -478,8 +478,8 @@ TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,global_priv, TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'GRANT PROXY ON plug_dest TO plug',0 TIME,HOSTNAME,plug,localhost,ID,0,CONNECT,,,0 TIME,HOSTNAME,plug,localhost,ID,0,PROXY_CONNECT,,`plug_dest`@`%`,0 -TIME,HOSTNAME,plug,localhost,ID,ID,QUERY,test,'select USER(),CURRENT_USER()',0 -TIME,HOSTNAME,plug,localhost,ID,0,DISCONNECT,test,,0 +TIME,HOSTNAME,plug,localhost,ID,ID,QUERY,,'select USER(),CURRENT_USER()',0 +TIME,HOSTNAME,plug,localhost,ID,0,DISCONNECT,,,0 TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,db, TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,tables_priv, TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,columns_priv, diff --git a/mysql-test/suite/plugins/r/unix_socket.result b/mysql-test/suite/plugins/r/unix_socket.result index b663d3412215c..81fef9f7c96b3 100644 --- a/mysql-test/suite/plugins/r/unix_socket.result +++ b/mysql-test/suite/plugins/r/unix_socket.result @@ -2,6 +2,7 @@ # with named user # create user 'USER' identified via unix_socket; +grant select on test.* to 'USER'; # # name match = ok # @@ -27,3 +28,4 @@ USER@localhost @% test # delete from mysql.user where user=''; FLUSH PRIVILEGES; +delete from mysql.db; diff --git a/mysql-test/suite/plugins/t/dialog.test b/mysql-test/suite/plugins/t/dialog.test index 1dd52cfde34e9..efababa96b949 100644 --- a/mysql-test/suite/plugins/t/dialog.test +++ b/mysql-test/suite/plugins/t/dialog.test @@ -14,6 +14,7 @@ if (!$DIALOG_EXAMPLES_SO) { --replace_result .dll .so eval install plugin three_attempts soname '$DIALOG_EXAMPLES_SO'; create user test_dialog identified via three_attempts using 'SECRET'; +GRANT SELECT ON test.* TO test_dialog; --write_file $MYSQLTEST_VARDIR/tmp/dialog_good.txt foo diff --git a/mysql-test/suite/plugins/t/multiauth.test b/mysql-test/suite/plugins/t/multiauth.test index 86c98a5d5c328..d2a93cf100694 100644 --- a/mysql-test/suite/plugins/t/multiauth.test +++ b/mysql-test/suite/plugins/t/multiauth.test @@ -28,6 +28,7 @@ select user(), current_user(), database(); EOF --let $creplace=create user '$USER' +--let $greplace=grant select on test.* to '$USER' --let $dreplace=drop user '$USER' # @@ -35,7 +36,10 @@ EOF # --replace_result $creplace "create user 'USER'" eval $creplace identified via unix_socket OR mysql_native_password as password("GOOD"); +--replace_result $greplace "grant select on test.* to 'USER'" +eval $greplace ; create user mysqltest1 identified via unix_socket OR mysql_native_password as password("good"); +grant select on test.* to mysqltest1; show create user mysqltest1; --echo # name match = ok --exec $try_auth -u $USER @@ -52,7 +56,10 @@ eval $dreplace, mysqltest1; # --replace_result $creplace "create user 'USER'" eval $creplace identified via mysql_native_password as password("GOOD") OR unix_socket; +--replace_result $greplace "grant select on test.* to 'USER'" +eval $greplace ; create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket; +grant select on test.* to mysqltest1; show create user mysqltest1; --echo # name match = ok --exec $try_auth -u $USER @@ -69,7 +76,10 @@ eval $dreplace, mysqltest1; # --replace_result $creplace "create user 'USER'" eval $creplace identified via unix_socket OR ed25519 as password("GOOD"); +--replace_result $greplace "grant select on test.* to 'USER'" +eval $greplace ; create user mysqltest1 identified via unix_socket OR ed25519 as password("good"); +grant select on test.* to mysqltest1; show create user mysqltest1; --echo # name match = ok --exec $try_auth -u $USER @@ -86,7 +96,10 @@ eval $dreplace, mysqltest1; # --replace_result $creplace "create user 'USER'" eval $creplace identified via ed25519 as password("GOOD") OR unix_socket; +--replace_result $greplace "grant select on test.* to 'USER'" +eval $greplace ; create user mysqltest1 identified via ed25519 as password("good") OR unix_socket; +grant select on test.* to mysqltest1; show create user mysqltest1; --echo # name match = ok --exec $try_auth -u $USER @@ -103,7 +116,10 @@ eval $dreplace, mysqltest1; # --replace_result $creplace "create user 'USER'" eval $creplace identified via ed25519 as password("GOOD") OR unix_socket OR mysql_native_password as password("works"); +--replace_result $greplace "grant select on test.* to 'USER'" +eval $greplace ; create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); +grant select on test.* to mysqltest1; show create user mysqltest1; --echo # name match = ok --exec $try_auth -u $USER @@ -121,6 +137,7 @@ eval $dreplace, mysqltest1; # password,password # create user mysqltest1 identified via mysql_native_password as password("good") OR mysql_native_password as password("works"); +grant select on test.* to mysqltest1; show create user mysqltest1; --echo # password good = ok --exec $try_auth -u mysqltest1 -pgood @@ -165,7 +182,10 @@ create user mysqltest1 identified via ed25519 as password("good") OR unix_socket # --replace_result $creplace "create user 'USER'" eval $creplace identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; +--replace_result $greplace "grant select on test.* to 'USER'" +eval $greplace ; create user mysqltest1 identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; +grant select on test.* to mysqltest1; update mysql.global_priv set priv=replace(priv, '1234567890123456789012345678901234567890a', 'invalid password'); flush privileges; show create user mysqltest1; @@ -184,6 +204,7 @@ eval $dreplace, mysqltest1; # missing client-side plugin # create user mysqltest1 identified via ed25519 as password("good"); +grant select on test.* to mysqltest1; show create user mysqltest1; --echo # no plugin = failure # covers Linux (1st re), FreeBSD (2nd), AIX (3rd and 4th) diff --git a/mysql-test/suite/plugins/t/pam.test b/mysql-test/suite/plugins/t/pam.test index dbe108d1efaf9..c953e05fa684c 100644 --- a/mysql-test/suite/plugins/t/pam.test +++ b/mysql-test/suite/plugins/t/pam.test @@ -86,6 +86,7 @@ alter user test_pam password expire; drop user test_pam; drop user pam_test; create user PAM_TEST identified via pam using 'mariadb_mtr'; +grant all on test.* to PAM_TEST; --echo # --echo # athentication is unsuccessful @@ -109,6 +110,7 @@ drop user PAM_TEST; --echo # MDEV-27341 Use SET PASSWORD to change PAM service --echo # create user pam_test identified via pam using 'mariadb_mtr'; +grant all on test.* to pam_test; --write_file $MYSQLTEST_VARDIR/tmp/setpwd.txt not very secret challenge 9225 diff --git a/mysql-test/suite/plugins/t/pam_init.inc b/mysql-test/suite/plugins/t/pam_init.inc index 131b787f6b927..f3a948421ed91 100644 --- a/mysql-test/suite/plugins/t/pam_init.inc +++ b/mysql-test/suite/plugins/t/pam_init.inc @@ -7,7 +7,9 @@ if (!$PAM_PLUGIN_VERSION) { eval install plugin pam soname '$PAM_PLUGIN_VERSION'; create user test_pam identified via pam using 'mariadb_mtr'; +grant all on test.* to test_pam; create user pam_test; +grant all on test.* to pam_test; grant proxy on pam_test to test_pam; let $plugindir=`SELECT @@global.plugin_dir`; diff --git a/mysql-test/suite/plugins/t/qc_info_priv.test b/mysql-test/suite/plugins/t/qc_info_priv.test index 59258731508e4..f5052702768d9 100644 --- a/mysql-test/suite/plugins/t/qc_info_priv.test +++ b/mysql-test/suite/plugins/t/qc_info_priv.test @@ -4,6 +4,7 @@ set @save_query_cache_size=@@global.query_cache_size; # try an unprivileged user create user mysqltest; +grant select on test.* to mysqltest; connect (conn1,localhost,mysqltest,,); connection conn1; select a from t1; diff --git a/mysql-test/suite/plugins/t/server_audit.test b/mysql-test/suite/plugins/t/server_audit.test index d8f8b9d01651f..3a78a4049e8dc 100644 --- a/mysql-test/suite/plugins/t/server_audit.test +++ b/mysql-test/suite/plugins/t/server_audit.test @@ -200,7 +200,7 @@ connect(plug_con,localhost,plug,plug_dest); --sleep 2 GRANT PROXY ON plug_dest TO plug; --sleep 2 -connect(plug_con,localhost,plug,plug_dest); +connect(plug_con,localhost,plug,plug_dest,"*NO-ONE*"); connection plug_con; select USER(),CURRENT_USER(); connection default; diff --git a/mysql-test/suite/plugins/t/unix_socket.test b/mysql-test/suite/plugins/t/unix_socket.test index be2afb0ca6656..892b6f7516197 100644 --- a/mysql-test/suite/plugins/t/unix_socket.test +++ b/mysql-test/suite/plugins/t/unix_socket.test @@ -5,8 +5,11 @@ --echo # --let $replace=create user '$USER' +--let $greplace=grant select on test.* to '$USER' --replace_result $replace "create user 'USER'" eval create user '$USER' identified via unix_socket; +--replace_result $greplace "grant select on test.* to 'USER'" +eval grant select on test.* to '$USER'; --write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt --let $replace1=$USER@localhost @@ -49,3 +52,5 @@ grant SELECT ON test.* TO '' identified via unix_socket; delete from mysql.user where user=''; FLUSH PRIVILEGES; --remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt + +delete from mysql.db; diff --git a/mysql-test/suite/roles/acl_statistics.result b/mysql-test/suite/roles/acl_statistics.result index f43f692cc4891..c60e0297af362 100644 --- a/mysql-test/suite/roles/acl_statistics.result +++ b/mysql-test/suite/roles/acl_statistics.result @@ -1,7 +1,7 @@ SHOW STATUS LIKE 'Acl%'; Variable_name Value Acl_column_grants 0 -Acl_database_grants 2 +Acl_database_grants 0 Acl_function_grants 0 Acl_procedure_grants 0 Acl_package_spec_grants 0 @@ -16,7 +16,7 @@ COLUMN_GRANTS 0 SELECT count(*) DATABASE_GRANTS from mysql.db; DATABASE_GRANTS -2 +0 SELECT count(*) FUNCTION_GRANTS from mysql.procs_priv where routine_type='FUNCTION'; FUNCTION_GRANTS 0 @@ -66,7 +66,7 @@ GRANT EXECUTE ON FUNCTION mysql.test_func TO r2; SHOW STATUS LIKE 'Acl%'; Variable_name Value Acl_column_grants 2 -Acl_database_grants 4 +Acl_database_grants 2 Acl_function_grants 3 Acl_procedure_grants 2 Acl_package_spec_grants 0 @@ -81,7 +81,7 @@ COLUMN_GRANTS 2 SELECT count(*) DATABASE_GRANTS from mysql.db; DATABASE_GRANTS -4 +2 SELECT count(*) FUNCTION_GRANTS from mysql.procs_priv where routine_type='FUNCTION'; FUNCTION_GRANTS 3 diff --git a/mysql-test/suite/roles/definer.result b/mysql-test/suite/roles/definer.result index 8b5e36d8b3c87..091ba255bc60f 100644 --- a/mysql-test/suite/roles/definer.result +++ b/mysql-test/suite/roles/definer.result @@ -5,15 +5,19 @@ insert t1 values (1,10,100),(2,20,200); create role role1; grant select (a) on mysqltest1.t1 to role1; grant event,execute,trigger on mysqltest1.* to role1; +grant select on test.* to role1; grant role1 to current_user; create role role2; grant insert,select on mysqltest1.t1 to role2; grant event,execute,trigger on mysqltest1.* to role2; +grant select on test.* to role2; create user foo@localhost; grant create view on mysqltest1.* to foo@localhost; +grant select, create view on test.* to foo@localhost; create role role4; grant select on mysqltest1.t1 to role4; grant role4 to foo@localhost; +grant select on test.* to role4; create definer=current_role view test.v1 as select a+b,c from t1; ERROR 0L000: Invalid definer set role role1; @@ -41,6 +45,7 @@ Grants for foo@localhost GRANT `role4` TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT CREATE VIEW ON `mysqltest1`.* TO `foo`@`localhost` +GRANT SELECT, CREATE VIEW ON `test`.* TO `foo`@`localhost` select * from test.v1; ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them select * from test.v2; @@ -642,7 +647,7 @@ grant r1 to user1; grant r1 to r2; grant r2 to user1; grant r3 to user1; -connect user1, localhost,user1,,,,,; +connect user1, localhost,user1,,"*NO-ONE*",,,; set role r2; use rtest; CREATE DEFINER=current_role() PROCEDURE user1_proc() SQL SECURITY INVOKER @@ -717,7 +722,7 @@ CREATE DEFINER=`user_like_role`@`%` PROCEDURE sensitive_proc() SQL SECURITY INVO BEGIN SELECT NOW(), VERSION(); END;// -connect user_like_role, localhost, user_like_role,,,,,; +connect user_like_role, localhost, user_like_role,,"*NO-ONE*",,,; use rtest; show create procedure sensitive_proc; Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation @@ -726,7 +731,7 @@ sensitive_proc STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USE BEGIN SELECT NOW(), VERSION(); END latin1 latin1_swedish_ci latin1_swedish_ci -connect foo, localhost, foo,,,,,; +connect foo, localhost, foo,,"*NO-ONE*",,,; set role user_like_role; use rtest; # diff --git a/mysql-test/suite/roles/definer.test b/mysql-test/suite/roles/definer.test index c1e56f3f94b2b..4cd42d59b2476 100644 --- a/mysql-test/suite/roles/definer.test +++ b/mysql-test/suite/roles/definer.test @@ -19,6 +19,7 @@ insert t1 values (1,10,100),(2,20,200); create role role1; grant select (a) on mysqltest1.t1 to role1; grant event,execute,trigger on mysqltest1.* to role1; +grant select on test.* to role1; grant role1 to current_user; @@ -26,13 +27,16 @@ grant role1 to current_user; create role role2; grant insert,select on mysqltest1.t1 to role2; grant event,execute,trigger on mysqltest1.* to role2; +grant select on test.* to role2; # create a non-priv user and a priv role granted to him create user foo@localhost; grant create view on mysqltest1.* to foo@localhost; +grant select, create view on test.* to foo@localhost; create role role4; grant select on mysqltest1.t1 to role4; grant role4 to foo@localhost; +grant select on test.* to role4; ################################################## # views @@ -355,7 +359,7 @@ grant r1 to r2; grant r2 to user1; grant r3 to user1; -connect (user1, localhost,user1,,,,,); +connect (user1, localhost,user1,,"*NO-ONE*",,,); set role r2; use rtest; @@ -433,11 +437,11 @@ CREATE DEFINER=`user_like_role`@`%` PROCEDURE sensitive_proc() SQL SECURITY INVO END;// DELIMITER ;// -connect (user_like_role, localhost, user_like_role,,,,,); +connect (user_like_role, localhost, user_like_role,,"*NO-ONE*",,,); use rtest; show create procedure sensitive_proc; -connect (foo, localhost, foo,,,,,); +connect (foo, localhost, foo,,"*NO-ONE*",,,); set role user_like_role; use rtest; diff --git a/mysql-test/suite/roles/flush_roles-12366.result b/mysql-test/suite/roles/flush_roles-12366.result index f65c97e0ee39a..043f79f8f7f5f 100644 --- a/mysql-test/suite/roles/flush_roles-12366.result +++ b/mysql-test/suite/roles/flush_roles-12366.result @@ -240,7 +240,6 @@ connect con1,localhost,u,,; SHOW DATABASES; Database information_schema -test SET ROLE operations_cluster; SHOW DATABASES; Database @@ -261,7 +260,6 @@ oms_live_sg oms_live_th oms_live_tw oms_live_vn -test SELECT COUNT(1) FROM oms_live_sg.a; COUNT(1) 0 @@ -364,7 +362,6 @@ connect con3,localhost,u,,; SHOW DATABASES; Database information_schema -test SET ROLE operations_cluster; SHOW DATABASES; Database @@ -385,7 +382,6 @@ oms_live_sg oms_live_th oms_live_tw oms_live_vn -test SELECT COUNT(1) FROM oms_live_sg.a; COUNT(1) 0 diff --git a/mysql-test/suite/roles/recursive.inc b/mysql-test/suite/roles/recursive.inc index 940a3c9e0db90..7642f2d69bfe2 100644 --- a/mysql-test/suite/roles/recursive.inc +++ b/mysql-test/suite/roles/recursive.inc @@ -17,6 +17,7 @@ source include/not_embedded.inc; create user foo@localhost; +grant select on test.* to foo@localhost; create role role1; create role role2; create role role3; diff --git a/mysql-test/suite/roles/recursive.result b/mysql-test/suite/roles/recursive.result index 05f28745f02c3..77dade466eb53 100644 --- a/mysql-test/suite/roles/recursive.result +++ b/mysql-test/suite/roles/recursive.result @@ -1,4 +1,5 @@ create user foo@localhost; +grant select on test.* to foo@localhost; create role role1; create role role2; create role role3; @@ -26,6 +27,7 @@ ERROR HY000: Cannot grant role 'role10' to: 'role2' connect foo, localhost, foo; show grants; Grants for foo@localhost +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT `role10` TO `foo`@`localhost` select * from information_schema.applicable_roles; @@ -57,6 +59,7 @@ count(*) show grants; Grants for foo@localhost GRANT SELECT ON *.* TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role2` @@ -115,6 +118,7 @@ count(*) show grants; Grants for foo@localhost GRANT SELECT ON `mysql`.* TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role1` @@ -158,6 +162,7 @@ count(*) show grants; Grants for foo@localhost GRANT SELECT ON `mysql`.`roles_mapping` TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role1` @@ -203,6 +208,7 @@ count(concat(User)) show grants; Grants for foo@localhost GRANT SELECT (User) ON `mysql`.`roles_mapping` TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role1` @@ -238,6 +244,7 @@ show grants; Grants for foo@localhost GRANT SELECT (Host) ON `mysql`.`roles_mapping` TO `role3` GRANT SELECT (User) ON `mysql`.`roles_mapping` TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role1` diff --git a/mysql-test/suite/roles/recursive_dbug.result b/mysql-test/suite/roles/recursive_dbug.result index 55bbad51c0935..053307804d8cb 100644 --- a/mysql-test/suite/roles/recursive_dbug.result +++ b/mysql-test/suite/roles/recursive_dbug.result @@ -3,6 +3,7 @@ Variable_name Value set @old_dbug=@@global.debug_dbug; set global debug_dbug="+d,role_merge_stats"; create user foo@localhost; +grant select on test.* to foo@localhost; create role role1; create role role2; create role role3; @@ -30,6 +31,7 @@ ERROR HY000: Cannot grant role 'role10' to: 'role2' connect foo, localhost, foo; show grants; Grants for foo@localhost +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT `role10` TO `foo`@`localhost` select * from information_schema.applicable_roles; @@ -71,6 +73,7 @@ count(*) show grants; Grants for foo@localhost GRANT SELECT ON *.* TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role2` @@ -139,6 +142,7 @@ count(*) show grants; Grants for foo@localhost GRANT SELECT ON `mysql`.* TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role1` @@ -192,6 +196,7 @@ count(*) show grants; Grants for foo@localhost GRANT SELECT ON `mysql`.`roles_mapping` TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role1` @@ -247,6 +252,7 @@ count(concat(User)) show grants; Grants for foo@localhost GRANT SELECT (User) ON `mysql`.`roles_mapping` TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role1` @@ -287,6 +293,7 @@ show grants; Grants for foo@localhost GRANT SELECT (Host) ON `mysql`.`roles_mapping` TO `role3` GRANT SELECT (User) ON `mysql`.`roles_mapping` TO `role1` +GRANT SELECT ON `test`.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `foo`@`localhost` GRANT USAGE ON *.* TO `role10` GRANT USAGE ON *.* TO `role1` diff --git a/mysql-test/suite/roles/set_role-9614.result b/mysql-test/suite/roles/set_role-9614.result index 318d9ced73e00..d4d689b87e470 100644 --- a/mysql-test/suite/roles/set_role-9614.result +++ b/mysql-test/suite/roles/set_role-9614.result @@ -61,13 +61,11 @@ connect john, localhost, john,,information_schema; show databases; Database information_schema -test set role client; show databases; Database bug_db information_schema -test use bug_db; # # Try using the database as usertestjohn. @@ -76,13 +74,11 @@ connect usertestjohn, localhost, usertestjohn,,information_schema; show databases; Database information_schema -test set role client; show databases; Database bug_db information_schema -test show grants; Grants for usertestjohn@% GRANT `client` TO `usertestjohn`@`%` diff --git a/mysql-test/suite/roles/set_role-database-recursive.result b/mysql-test/suite/roles/set_role-database-recursive.result index be31e645362e7..594ea059988dc 100644 --- a/mysql-test/suite/roles/set_role-database-recursive.result +++ b/mysql-test/suite/roles/set_role-database-recursive.result @@ -19,8 +19,6 @@ localhost test_user test_role1 N localhost test_user test_role2 N select user, host from mysql.db; user host - % - % grant select on mysql.* to test_role2; flush privileges; select * from mysql.roles_mapping; diff --git a/mysql-test/suite/roles/show_create_database-10463.result b/mysql-test/suite/roles/show_create_database-10463.result index 121aab4fe1da6..94f7d7e95baaf 100644 --- a/mysql-test/suite/roles/show_create_database-10463.result +++ b/mysql-test/suite/roles/show_create_database-10463.result @@ -12,7 +12,6 @@ connect con1,localhost,beep,,; show databases; Database information_schema -test show create database db; ERROR 42000: Access denied for user 'beep'@'localhost' to database 'db' select table_schema, table_name from information_schema.tables @@ -23,7 +22,6 @@ show databases; Database db information_schema -test show create database db; Database Create Database db CREATE DATABASE `db` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci */ @@ -41,7 +39,6 @@ connect con2,localhost,beep2,,; show databases; Database information_schema -test show create database db; ERROR 42000: Access denied for user 'beep2'@'localhost' to database 'db' select table_schema, table_name from information_schema.tables @@ -52,7 +49,6 @@ show databases; Database db information_schema -test show create database db; Database Create Database db CREATE DATABASE `db` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci */ diff --git a/mysql-test/suite/roles/show_grants.result b/mysql-test/suite/roles/show_grants.result index 7ae499a9cfca1..21c5a74efe45a 100644 --- a/mysql-test/suite/roles/show_grants.result +++ b/mysql-test/suite/roles/show_grants.result @@ -19,8 +19,6 @@ localhost test_user test_role1 N localhost test_user test_role2 N select user, host from mysql.db; user host - % - % grant select on mysql.* to test_role2; flush privileges; select * from information_schema.applicable_roles; diff --git a/mysql-test/suite/rpl/r/rpl_read_only.result b/mysql-test/suite/rpl/r/rpl_read_only.result index dbcd58a224f81..647918889641f 100644 --- a/mysql-test/suite/rpl/r/rpl_read_only.result +++ b/mysql-test/suite/rpl/r/rpl_read_only.result @@ -3,6 +3,7 @@ include/master-slave.inc call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); connection master; create user test; +grant all on test.* to test; connection slave; connect master2,127.0.0.1,test,,test,$MASTER_MYPORT,; connect slave2,127.0.0.1,test,,test,$SLAVE_MYPORT,; diff --git a/mysql-test/suite/rpl/r/rpl_temporary.result b/mysql-test/suite/rpl/r/rpl_temporary.result index 650fe1db9e034..492e9ac3ac3d5 100644 --- a/mysql-test/suite/rpl/r/rpl_temporary.result +++ b/mysql-test/suite/rpl/r/rpl_temporary.result @@ -34,6 +34,8 @@ connection master; DROP TABLE t1; connection slave; connection master; +create user zedjzlcsjhd@localhost; +GRANT ALL on test.* to zedjzlcsjhd@localhost; connect con1,localhost,root,,; connect con2,localhost,root,,; connect con3,localhost,zedjzlcsjhd,,; @@ -83,6 +85,7 @@ f 5 7 drop table t1, t2; +drop user zedjzlcsjhd@localhost; use test; SET TIMESTAMP=1040323920; create table t1(f int); @@ -174,7 +177,7 @@ FLUSH PRIVILEGES; GRANT USAGE ON *.* TO user43748@127.0.0.1 IDENTIFIED BY 'meow'; GRANT PROCESS ON *.* TO user43748@127.0.0.1; -- try to KILL system-thread as that non-privileged user (on slave). -connect cont43748,127.0.0.1,user43748,meow,test,$SLAVE_MYPORT,; +connect cont43748,127.0.0.1,user43748,meow,"*NO-ONE*",$SLAVE_MYPORT,; connection cont43748; SELECT id INTO @id FROM information_schema.processlist WHERE user='system user' LIMIT 1; KILL @id; diff --git a/mysql-test/suite/rpl/t/rpl_read_only.test b/mysql-test/suite/rpl/t/rpl_read_only.test index c4781bbbb3bea..15d5f74fb6d8b 100644 --- a/mysql-test/suite/rpl/t/rpl_read_only.test +++ b/mysql-test/suite/rpl/t/rpl_read_only.test @@ -7,6 +7,7 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state # Create a test and replicate it to slave connection master; create user test; +grant all on test.* to test; sync_slave_with_master; # Setting the master readonly : diff --git a/mysql-test/suite/rpl/t/rpl_temporary.test b/mysql-test/suite/rpl/t/rpl_temporary.test index 729f275bb0d2f..0ec57715f798e 100644 --- a/mysql-test/suite/rpl/t/rpl_temporary.test +++ b/mysql-test/suite/rpl/t/rpl_temporary.test @@ -99,6 +99,9 @@ sync_slave_with_master; connection master; +create user zedjzlcsjhd@localhost; +GRANT ALL on test.* to zedjzlcsjhd@localhost; + connect (con1,localhost,root,,); connect (con2,localhost,root,,); # We want to connect as an unprivileged user. But if we use user="" then this @@ -182,6 +185,7 @@ select * from t2 ORDER BY f; #show binlog events; drop table t1, t2; +drop user zedjzlcsjhd@localhost; use test; SET TIMESTAMP=1040323920; @@ -339,7 +343,7 @@ GRANT USAGE ON *.* TO user43748@127.0.0.1 IDENTIFIED BY 'meow'; GRANT PROCESS ON *.* TO user43748@127.0.0.1; --echo -- try to KILL system-thread as that non-privileged user (on slave). -connect (cont43748,127.0.0.1,user43748,meow,test,$SLAVE_MYPORT,); +connect (cont43748,127.0.0.1,user43748,meow,"*NO-ONE*",$SLAVE_MYPORT,); connection cont43748; SELECT id INTO @id FROM information_schema.processlist WHERE user='system user' LIMIT 1; diff --git a/mysql-test/suite/sys_vars/inc/secure_timestamp_func.inc b/mysql-test/suite/sys_vars/inc/secure_timestamp_func.inc index 4ea7a2aff4664..e097938f3c8f1 100644 --- a/mysql-test/suite/sys_vars/inc/secure_timestamp_func.inc +++ b/mysql-test/suite/sys_vars/inc/secure_timestamp_func.inc @@ -17,7 +17,7 @@ set timestamp=default; --echo ### SUPER create user foo@127.0.0.1; grant super on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; disable_abort_on_error; set timestamp=1234567890.101112; enable_abort_on_error; @@ -30,7 +30,7 @@ set timestamp=default; --echo ### BINLOG REPLAY create user foo@127.0.0.1; grant binlog replay on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; disable_abort_on_error; set timestamp=1234567890.101112; enable_abort_on_error; @@ -42,7 +42,7 @@ set timestamp=default; --echo ### non-privileged user create user foo@127.0.0.1; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; disable_abort_on_error; set timestamp=1234567890.101112; enable_abort_on_error; diff --git a/mysql-test/suite/sys_vars/r/automatic_sp_privileges_func.result b/mysql-test/suite/sys_vars/r/automatic_sp_privileges_func.result index d4d582b92d5d4..421ea1446785e 100644 --- a/mysql-test/suite/sys_vars/r/automatic_sp_privileges_func.result +++ b/mysql-test/suite/sys_vars/r/automatic_sp_privileges_func.result @@ -3,7 +3,9 @@ SET @global_automatic_sp_privileges = @@GLOBAL.automatic_sp_privileges; CREATE TABLE t1 (a varchar(200)); INSERT INTO t1 VALUES('Procedure Executed.'); CREATE USER 'userTest'@'localhost'; +GRANT CREATE ROUTINE, SELECT ON test.* to 'userTest'@'localhost'; CREATE USER 'userTest1'@'localhost'; +GRANT CREATE ROUTINE, SELECT ON test.* to 'userTest1'@'localhost'; connection default; SET GLOBAL automatic_sp_privileges = TRUE; connect conUser,localhost,userTest,,; diff --git a/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_func.result b/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_func.result index 0bec3eb2b2915..8291800afa3ea 100644 --- a/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_func.result +++ b/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_func.result @@ -3,6 +3,7 @@ drop table if exists t1; SET @start_value= @@global.log_bin_trust_function_creators; ## Creating new user tt ## CREATE USER tt@localhost; +GRANT ALL ON test.* TO tt@localhost; ## Setting value of variable to 0 ## SET @@global.log_bin_trust_function_creators = 0; ## Creating new table t2 ## diff --git a/mysql-test/suite/sys_vars/r/read_only_func.result b/mysql-test/suite/sys_vars/r/read_only_func.result index 88a7b33420467..f9ac41293ab68 100644 --- a/mysql-test/suite/sys_vars/r/read_only_func.result +++ b/mysql-test/suite/sys_vars/r/read_only_func.result @@ -18,6 +18,7 @@ id name '#--------------------FN_DYNVARS_140_02-------------------------#' ** Creating new user with out super privilege** CREATE user sameea; +grant all on test.* to sameea; CONNECT connn,localhost,sameea,,; SET Global read_ONLY=ON; ERROR 42000: Access denied; you need (at least one of) the READ_ONLY ADMIN privilege(s) for this operation diff --git a/mysql-test/suite/sys_vars/r/secure_timestamp_no.result b/mysql-test/suite/sys_vars/r/secure_timestamp_no.result index fcf04f944762c..14d16d9fc997a 100644 --- a/mysql-test/suite/sys_vars/r/secure_timestamp_no.result +++ b/mysql-test/suite/sys_vars/r/secure_timestamp_no.result @@ -13,7 +13,7 @@ set timestamp=default; ### SUPER create user foo@127.0.0.1; grant super on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'SUPER'; SUPER @@ -25,7 +25,7 @@ set timestamp=default; ### BINLOG REPLAY create user foo@127.0.0.1; grant binlog replay on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'BINLOG REPLAY'; BINLOG REPLAY @@ -36,7 +36,7 @@ drop user foo@127.0.0.1; set timestamp=default; ### non-privileged user create user foo@127.0.0.1; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'non-privileged'; non-privileged diff --git a/mysql-test/suite/sys_vars/r/secure_timestamp_rpl.result b/mysql-test/suite/sys_vars/r/secure_timestamp_rpl.result index d4b25257da32c..43c7a402cd550 100644 --- a/mysql-test/suite/sys_vars/r/secure_timestamp_rpl.result +++ b/mysql-test/suite/sys_vars/r/secure_timestamp_rpl.result @@ -13,7 +13,7 @@ set timestamp=default; ### SUPER create user foo@127.0.0.1; grant super on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; ERROR 42000: Access denied; you need (at least one of) the BINLOG REPLAY privilege(s) for this operation select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'SUPER'; @@ -26,7 +26,7 @@ set timestamp=default; ### BINLOG REPLAY create user foo@127.0.0.1; grant binlog replay on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'BINLOG REPLAY'; BINLOG REPLAY @@ -37,7 +37,7 @@ drop user foo@127.0.0.1; set timestamp=default; ### non-privileged user create user foo@127.0.0.1; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; ERROR 42000: Access denied; you need (at least one of) the BINLOG REPLAY privilege(s) for this operation select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'non-privileged'; diff --git a/mysql-test/suite/sys_vars/r/secure_timestamp_super.result b/mysql-test/suite/sys_vars/r/secure_timestamp_super.result index e005fdabf8ac6..b1aec21fea72d 100644 --- a/mysql-test/suite/sys_vars/r/secure_timestamp_super.result +++ b/mysql-test/suite/sys_vars/r/secure_timestamp_super.result @@ -13,7 +13,7 @@ set timestamp=default; ### SUPER create user foo@127.0.0.1; grant super on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'SUPER'; SUPER @@ -25,7 +25,7 @@ set timestamp=default; ### BINLOG REPLAY create user foo@127.0.0.1; grant binlog replay on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'BINLOG REPLAY'; BINLOG REPLAY @@ -36,7 +36,7 @@ drop user foo@127.0.0.1; set timestamp=default; ### non-privileged user create user foo@127.0.0.1; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG REPLAY privilege(s) for this operation select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'non-privileged'; diff --git a/mysql-test/suite/sys_vars/r/secure_timestamp_yes.result b/mysql-test/suite/sys_vars/r/secure_timestamp_yes.result index 44b310809f6d7..c6c1dea66578e 100644 --- a/mysql-test/suite/sys_vars/r/secure_timestamp_yes.result +++ b/mysql-test/suite/sys_vars/r/secure_timestamp_yes.result @@ -14,7 +14,7 @@ set timestamp=default; ### SUPER create user foo@127.0.0.1; grant super on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; ERROR HY000: The MariaDB server is running with the --secure-timestamp=YES option so it cannot execute this statement select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'SUPER'; @@ -27,7 +27,7 @@ set timestamp=default; ### BINLOG REPLAY create user foo@127.0.0.1; grant binlog replay on *.* TO `foo`@`127.0.0.1`; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; ERROR HY000: The MariaDB server is running with the --secure-timestamp=YES option so it cannot execute this statement select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'BINLOG REPLAY'; @@ -39,7 +39,7 @@ drop user foo@127.0.0.1; set timestamp=default; ### non-privileged user create user foo@127.0.0.1; -connect con2,127.0.0.1,foo,,test,$SLAVE_MYPORT; +connect con2,127.0.0.1,foo,,"*NO-ONE*",$SLAVE_MYPORT; set timestamp=1234567890.101112; ERROR HY000: The MariaDB server is running with the --secure-timestamp=YES option so it cannot execute this statement select if(now(6) > 20100101, 'READONLY', 'EDITABLE') as 'non-privileged'; diff --git a/mysql-test/suite/sys_vars/t/automatic_sp_privileges_func.test b/mysql-test/suite/sys_vars/t/automatic_sp_privileges_func.test index fd2dbefe7f608..25fda7d664a9a 100644 --- a/mysql-test/suite/sys_vars/t/automatic_sp_privileges_func.test +++ b/mysql-test/suite/sys_vars/t/automatic_sp_privileges_func.test @@ -38,7 +38,9 @@ INSERT INTO t1 VALUES('Procedure Executed.'); # CREATE USER 'userTest'@'localhost'; +GRANT CREATE ROUTINE, SELECT ON test.* to 'userTest'@'localhost'; CREATE USER 'userTest1'@'localhost'; +GRANT CREATE ROUTINE, SELECT ON test.* to 'userTest1'@'localhost'; # # Value TRUE diff --git a/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_func.test b/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_func.test index 41911d82ac50c..958ae5d6c7a6b 100644 --- a/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_func.test +++ b/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_func.test @@ -36,6 +36,7 @@ SET @start_value= @@global.log_bin_trust_function_creators; --echo ## Creating new user tt ## CREATE USER tt@localhost; +GRANT ALL ON test.* TO tt@localhost; --echo ## Setting value of variable to 0 ## SET @@global.log_bin_trust_function_creators = 0; diff --git a/mysql-test/suite/sys_vars/t/read_only_func.test b/mysql-test/suite/sys_vars/t/read_only_func.test index bc3991aee7c13..64141e3f91d0d 100644 --- a/mysql-test/suite/sys_vars/t/read_only_func.test +++ b/mysql-test/suite/sys_vars/t/read_only_func.test @@ -81,6 +81,7 @@ select * from t1 where id=1; --echo ** Creating new user with out super privilege** CREATE user sameea; +grant all on test.* to sameea; CONNECT (connn,localhost,sameea,,); --Error ER_SPECIFIC_ACCESS_DENIED_ERROR diff --git a/mysql-test/suite/versioning/r/not_embedded.result b/mysql-test/suite/versioning/r/not_embedded.result index 23574f34da9dd..5d8380e096962 100644 --- a/mysql-test/suite/versioning/r/not_embedded.result +++ b/mysql-test/suite/versioning/r/not_embedded.result @@ -38,7 +38,7 @@ connect root,localhost,root,,test; connection root; create database mysqltest; create user mysqltest_1@localhost; -connect user1,localhost,mysqltest_1,,test; +connect user1,localhost,mysqltest_1,,"*NO-ONE*"; connection user1; connection root; create table mysqltest.t (a int) with system versioning; diff --git a/mysql-test/suite/versioning/t/not_embedded.test b/mysql-test/suite/versioning/t/not_embedded.test index 80e936b02f364..38f42a44587c1 100644 --- a/mysql-test/suite/versioning/t/not_embedded.test +++ b/mysql-test/suite/versioning/t/not_embedded.test @@ -50,7 +50,7 @@ create database mysqltest; --enable_warnings create user mysqltest_1@localhost; -connect (user1,localhost,mysqltest_1,,test); +connect (user1,localhost,mysqltest_1,,"*NO-ONE*"); connection user1; connection root; diff --git a/scripts/mysql_test_db.sql b/scripts/mysql_test_db.sql index 9f8a0cf604c06..ea9fa95bd61b6 100644 --- a/scripts/mysql_test_db.sql +++ b/scripts/mysql_test_db.sql @@ -15,14 +15,6 @@ CREATE DATABASE IF NOT EXISTS test CHARACTER SET latin1 COLLATE latin1_swedish_ci; --- Fill "db" table with default grants for anyone to --- access database 'test' and 'test_%' if "db" table didn't exist -CREATE TEMPORARY TABLE tmp_db LIKE db; -INSERT INTO tmp_db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','Y'); -INSERT INTO tmp_db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','Y'); -INSERT INTO db SELECT * FROM tmp_db WHERE @had_db_table=0; -DROP TABLE tmp_db; - -- Anonymous user with no privileges. CREATE TEMPORARY TABLE tmp_user_anonymous LIKE global_priv; INSERT INTO tmp_user_anonymous (host,user) VALUES ('localhost',''); From b0325bd6d6afa2a904163e683174457fde18c895 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Mon, 13 Dec 2021 16:15:21 +0100 Subject: [PATCH 080/113] MDEV-5215 Granted to PUBLIC --- mysql-test/main/public_basic.result | 138 +++++++ mysql-test/main/public_basic.test | 130 +++++++ mysql-test/main/public_privileges.result | 346 ++++++++++++++++++ mysql-test/main/public_privileges.test | 411 +++++++++++++++++++++ mysql-test/suite/roles/none_public.result | 13 +- mysql-test/suite/roles/none_public.test | 21 +- sql/sql_acl.cc | 418 ++++++++++++++-------- sql/sql_acl.h | 4 +- sql/sql_db.cc | 11 +- sql/sql_parse.cc | 14 +- sql/sql_show.cc | 12 +- sql/sql_yacc.yy | 1 + sql/structs.h | 1 + sql/table.h | 9 + 14 files changed, 1325 insertions(+), 204 deletions(-) create mode 100644 mysql-test/main/public_basic.result create mode 100644 mysql-test/main/public_basic.test create mode 100644 mysql-test/main/public_privileges.result create mode 100644 mysql-test/main/public_privileges.test diff --git a/mysql-test/main/public_basic.result b/mysql-test/main/public_basic.result new file mode 100644 index 0000000000000..5832180d2cf56 --- /dev/null +++ b/mysql-test/main/public_basic.result @@ -0,0 +1,138 @@ +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +# it is not PUBLIC but an user +# (this should work as it allowed for roles for example) +create user PUBLIC; +create user PUBLIC@localhost; +GRANT SELECT on test.* to PUBLIC@localhost; +drop user PUBLIC@localhost; +drop user PUBLIC; +# preinstalled PUBLIC +GRANT SELECT on test.* to PUBLIC; +GRANT SELECT on mysql.db to PUBLIC; +select * from mysql.global_priv where user="PUBLIC" ; +Host User Priv + PUBLIC {"access":0,"version_id":VERSION,"is_role":true} +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +GRANT SELECT ON `test`.* TO `PUBLIC` +GRANT SELECT ON `mysql`.`db` TO `PUBLIC` +GRANT UPDATE on test.* to PUBLIC; +GRANT UPDATE on mysql.db to PUBLIC; +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +GRANT SELECT, UPDATE ON `test`.* TO `PUBLIC` +GRANT SELECT, UPDATE ON `mysql`.`db` TO `PUBLIC` +REVOKE SELECT on test.* from PUBLIC; +REVOKE SELECT on mysql.db from PUBLIC; +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +GRANT UPDATE ON `test`.* TO `PUBLIC` +GRANT UPDATE ON `mysql`.`db` TO `PUBLIC` +REVOKE UPDATE on test.* from PUBLIC; +REVOKE UPDATE on mysql.db from PUBLIC; +REVOKE UPDATE on test.* from PUBLIC; +ERROR 42000: There is no such grant defined for user 'PUBLIC' on host '' +REVOKE UPDATE on mysql.db from PUBLIC; +ERROR 42000: There is no such grant defined for user 'PUBLIC' on host '' on table 'db' +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +# automaticly added PUBLIC +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +select * from mysql.global_priv where user="PUBLIC" ; +Host User Priv +GRANT SELECT on test.* to PUBLIC; +GRANT SELECT on mysql.db to PUBLIC; +select * from mysql.global_priv where user="PUBLIC" ; +Host User Priv + PUBLIC {"access":0,"version_id":VERSION,"is_role":true} +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +GRANT SELECT ON `test`.* TO `PUBLIC` +GRANT SELECT ON `mysql`.`db` TO `PUBLIC` +GRANT UPDATE on test.* to PUBLIC; +GRANT UPDATE on mysql.db to PUBLIC; +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +GRANT SELECT, UPDATE ON `test`.* TO `PUBLIC` +GRANT SELECT, UPDATE ON `mysql`.`db` TO `PUBLIC` +REVOKE SELECT on test.* from PUBLIC; +REVOKE SELECT on mysql.db from PUBLIC; +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +GRANT UPDATE ON `test`.* TO `PUBLIC` +GRANT UPDATE ON `mysql`.`db` TO `PUBLIC` +REVOKE UPDATE on test.* from PUBLIC; +REVOKE UPDATE on mysql.db from PUBLIC; +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +GRANT XXXXXX TO CURRENT_USER; +ERROR OP000: Invalid role specification `XXXXXX` +# following should fail with the same error as above +GRANT PUBLIC TO CURRENT_USER; +ERROR OP000: Invalid role specification `PUBLIC` +REVOKE XXXXXX FROM CURRENT_USER; +ERROR OP000: Invalid role specification `XXXXXX` +# following should fail with the same error as above +REVOKE PUBLIC FROM CURRENT_USER; +ERROR OP000: Invalid role specification `PUBLIC` +drop role XXXXXX; +ERROR HY000: Operation DROP ROLE failed for 'XXXXXX' +# following should fail with the same error as above +drop role PUBLIC; +ERROR HY000: Operation DROP ROLE failed for PUBLIC +SET ROLE XXXXXX; +ERROR OP000: Invalid role specification `XXXXXX` +# following should fail with the same error as above +SET ROLE PUBLIC; +ERROR OP000: Invalid role specification `PUBLIC` +SET DEFAULT ROLE XXXXXX; +ERROR OP000: Invalid role specification `XXXXXX` +# following should fail with the same error as above +SET DEFAULT ROLE PUBLIC; +ERROR OP000: Invalid role specification `PUBLIC` +# +# check prohibition of change security context to PUBLIC +# +# be sure that we have PUBLIC +GRANT SELECT on test.* to PUBLIC; +# try with a view +create table t1( a int); +create definer = PUBLIC view v1 as select * from t1; +Warnings: +Note 1449 The user specified as a definer ('PUBLIC'@'') does not exist +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`PUBLIC` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci +Warnings: +Note 1449 The user specified as a definer ('PUBLIC'@'') does not exist +select * from v1; +ERROR HY000: The user specified as a definer ('PUBLIC'@'') does not exist +drop view v1; +drop table t1; +# try with a view +create definer='PUBLIC' PROCEDURE p1() SELECT 1; +Warnings: +Note 1449 The user specified as a definer ('PUBLIC'@'') does not exist +show create procedure p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`PUBLIC` PROCEDURE `p1`() +SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci +call p1(); +ERROR HY000: The user specified as a definer ('PUBLIC'@'') does not exist +drop procedure p1; +# this test cleanup +REVOKE SELECT on test.* from PUBLIC; +# +# check autocreation of PUBLIC on GRAND role TO PUBLIC +# +# make sure that the privilege will be added automatically +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +create role roletest; +GRANT roletest TO PUBLIC; +drop role roletest; +# clean up +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; diff --git a/mysql-test/main/public_basic.test b/mysql-test/main/public_basic.test new file mode 100644 index 0000000000000..ddb4e040fce59 --- /dev/null +++ b/mysql-test/main/public_basic.test @@ -0,0 +1,130 @@ +SHOW GRANTS FOR PUBLIC; + +--echo # it is not PUBLIC but an user +--echo # (this should work as it allowed for roles for example) +create user PUBLIC; +create user PUBLIC@localhost; +GRANT SELECT on test.* to PUBLIC@localhost; +drop user PUBLIC@localhost; +drop user PUBLIC; + +--echo # preinstalled PUBLIC +GRANT SELECT on test.* to PUBLIC; +GRANT SELECT on mysql.db to PUBLIC; +--replace_regex /"version_id"\:[0-9]+/"version_id":VERSION/ +select * from mysql.global_priv where user="PUBLIC" ; + +SHOW GRANTS FOR PUBLIC; + +GRANT UPDATE on test.* to PUBLIC; +GRANT UPDATE on mysql.db to PUBLIC; + +SHOW GRANTS FOR PUBLIC; + +REVOKE SELECT on test.* from PUBLIC; +REVOKE SELECT on mysql.db from PUBLIC; + +SHOW GRANTS FOR PUBLIC; + +REVOKE UPDATE on test.* from PUBLIC; +REVOKE UPDATE on mysql.db from PUBLIC; + +--error ER_NONEXISTING_GRANT +REVOKE UPDATE on test.* from PUBLIC; +--error ER_NONEXISTING_TABLE_GRANT +REVOKE UPDATE on mysql.db from PUBLIC; + +SHOW GRANTS FOR PUBLIC; + +--echo # automaticly added PUBLIC +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +select * from mysql.global_priv where user="PUBLIC" ; +GRANT SELECT on test.* to PUBLIC; +GRANT SELECT on mysql.db to PUBLIC; +--replace_regex /"version_id"\:[0-9]+/"version_id":VERSION/ +select * from mysql.global_priv where user="PUBLIC" ; + +SHOW GRANTS FOR PUBLIC; + +GRANT UPDATE on test.* to PUBLIC; +GRANT UPDATE on mysql.db to PUBLIC; + +SHOW GRANTS FOR PUBLIC; + +REVOKE SELECT on test.* from PUBLIC; +REVOKE SELECT on mysql.db from PUBLIC; + +SHOW GRANTS FOR PUBLIC; + +REVOKE UPDATE on test.* from PUBLIC; +REVOKE UPDATE on mysql.db from PUBLIC; + +SHOW GRANTS FOR PUBLIC; + +--error ER_INVALID_ROLE +GRANT XXXXXX TO CURRENT_USER; +--echo # following should fail with the same error as above +--error ER_INVALID_ROLE +GRANT PUBLIC TO CURRENT_USER; + +--error ER_INVALID_ROLE +REVOKE XXXXXX FROM CURRENT_USER; +--echo # following should fail with the same error as above +--error ER_INVALID_ROLE +REVOKE PUBLIC FROM CURRENT_USER; +--error ER_CANNOT_USER + +drop role XXXXXX; +--echo # following should fail with the same error as above +--error ER_CANNOT_USER +drop role PUBLIC; + +--error ER_INVALID_ROLE +SET ROLE XXXXXX; +--echo # following should fail with the same error as above +--error ER_INVALID_ROLE +SET ROLE PUBLIC; + +--error ER_INVALID_ROLE +SET DEFAULT ROLE XXXXXX; +--echo # following should fail with the same error as above +--error ER_INVALID_ROLE +SET DEFAULT ROLE PUBLIC; + +--echo # +--echo # check prohibition of change security context to PUBLIC +--echo # +--echo # be sure that we have PUBLIC +GRANT SELECT on test.* to PUBLIC; +--echo # try with a view +create table t1( a int); +create definer = PUBLIC view v1 as select * from t1; +show create view v1; +--error ER_NO_SUCH_USER +select * from v1; +drop view v1; +drop table t1; +--echo # try with a view +create definer='PUBLIC' PROCEDURE p1() SELECT 1; +show create procedure p1; +--error ER_NO_SUCH_USER +call p1(); +drop procedure p1; +--echo # this test cleanup +REVOKE SELECT on test.* from PUBLIC; + +--echo # +--echo # check autocreation of PUBLIC on GRAND role TO PUBLIC +--echo # +--echo # make sure that the privilege will be added automatically +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +create role roletest; +GRANT roletest TO PUBLIC; +drop role roletest; + + +-- echo # clean up +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; diff --git a/mysql-test/main/public_privileges.result b/mysql-test/main/public_privileges.result new file mode 100644 index 0000000000000..ae50ab78553a6 --- /dev/null +++ b/mysql-test/main/public_privileges.result @@ -0,0 +1,346 @@ +# +# Test DB/TABLE/COLUMN privileges in queries +# +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +create user testuser; +create database testdb1; +use testdb1; +create table t1 (a int, b int); +insert into t1 values (1,2); +create database testdb2; +use testdb2; +create table t2 (a int, b int); +insert into t2 values (1,2); +create table t3 (a int, b int); +insert into t3 values (1,2); +connect testuser,localhost,testuser,,; +connection testuser; +select * from testdb1.t1; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb1`.`t1` +select * from testdb2.t2; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb2`.`t2` +select b from testdb2.t3; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb2`.`t3` +select a from testdb2.t3; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb2`.`t3` +connection default; +GRANT SELECT ON testdb1.* to PUBLIC; +GRANT SELECT ON testdb2.t2 to PUBLIC; +GRANT SELECT (b) ON testdb2.t3 to PUBLIC; +disconnect testuser; +connect testuser,localhost,testuser,,; +connection testuser; +select * from testdb1.t1; +a b +1 2 +select * from testdb2.t2; +a b +1 2 +select b from testdb2.t3; +b +2 +select a from testdb2.t3; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'a' in table 't3' +connection default; +disconnect testuser; +# check that the privilegas correctly read by acl_load +flush privileges; +connect testuser,localhost,testuser,,; +connection testuser; +select * from testdb1.t1; +a b +1 2 +select * from testdb2.t2; +a b +1 2 +select b from testdb2.t3; +b +2 +select a from testdb2.t3; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'a' in table 't3' +connection default; +use test; +disconnect testuser; +REVOKE SELECT ON testdb1.* from PUBLIC; +REVOKE SELECT ON testdb2.t2 from PUBLIC; +REVOKE SELECT (b) ON testdb2.t3 from PUBLIC; +drop user testuser; +drop database testdb1; +drop database testdb2; +# +# test global process list privilege and EXECUTE db level +# +create user testuser; +create database testdb; +use testdb; +create procedure p1 () select 1; +connect testuser,localhost,testuser,,; +connection testuser; +SHOW PROCESSLIST; +Id User Host db Command Time State Info Progress +# testuser # NULL Query # # SHOW PROCESSLIST 0.000 +call testdb.p1(); +ERROR 42000: execute command denied to user 'testuser'@'%' for routine 'testdb.p1' +connection default; +GRANT PROCESS ON *.* to PUBLIC; +GRANT EXECUTE ON testdb.* to PUBLIC; +disconnect testuser; +connect testuser,localhost,testuser,,; +connection testuser; +SHOW PROCESSLIST; +Id User Host db Command Time State Info Progress +# root # testdb Sleep # # NULL 0.000 +# testuser # NULL Query # # SHOW PROCESSLIST 0.000 +call testdb.p1(); +1 +1 +connection default; +disconnect testuser; +# check that the privilegas correctly read by acl_load +flush privileges; +connect testuser,localhost,testuser,,; +connection testuser; +SHOW PROCESSLIST; +Id User Host db Command Time State Info Progress +# root # testdb Sleep # # NULL 0.000 +# testuser # NULL Query # # SHOW PROCESSLIST 0.000 +call testdb.p1(); +1 +1 +connection default; +SHOW PROCESSLIST; +Id User Host db Command Time State Info Progress +# root # testdb Query # # SHOW PROCESSLIST 0.000 +# testuser # NULL Sleep # # NULL 0.000 +connection default; +use test; +disconnect testuser; +REVOKE PROCESS ON *.* from PUBLIC; +REVOKE EXECUTE ON testdb.* from PUBLIC; +drop user testuser; +drop database testdb; +# +# test DB privilege to allow USE statement +# +create user testuser; +create database testdb; +connect testuser,localhost,testuser,,; +connection testuser; +use testdb; +ERROR 42000: Access denied for user 'testuser'@'%' to database 'testdb' +connection default; +GRANT LOCK TABLES ON testdb.* to PUBLIC; +disconnect testuser; +connect testuser,localhost,testuser,,; +connection testuser; +use testdb; +connection default; +disconnect testuser; +# check that the privilegas correctly read by acl_load +flush privileges; +connect testuser,localhost,testuser,,; +connection testuser; +use testdb; +connection default; +use test; +disconnect testuser; +REVOKE LOCK TABLES ON testdb.* from PUBLIC; +drop user testuser; +drop database testdb; +# +# test DB privilege to allow USE statement (as above) +# test current db privileges +# +create user testuser; +create database testdb; +use testdb; +create table t1 (a int); +insert into t1 values (1); +GRANT LOCK TABLES ON testdb.* to PUBLIC; +connect testuser,localhost,testuser,,; +connection testuser; +use testdb; +update t1 set a=a+1; +ERROR 42000: UPDATE command denied to user 'testuser'@'localhost' for table `testdb`.`t1` +connection default; +GRANT UPDATE,SELECT ON testdb.* to PUBLIC; +disconnect testuser; +connect testuser,localhost,testuser,,; +connection testuser; +use testdb; +update t1 set a=a+1; +connection default; +select * from testdb.t1; +a +2 +use test; +disconnect testuser; +REVOKE LOCK TABLES ON testdb.* from PUBLIC; +REVOKE UPDATE,SELECT ON testdb.* from PUBLIC; +drop user testuser; +drop database testdb; +# +# test DB privilege to allow USE statement (as above) +# test table/column privileges in current DB +# +create user testuser; +create database testdb; +use testdb; +create table t1 (a int); +insert into t1 values (1); +create table t2 (a int, b int); +insert into t2 values (1,2); +GRANT LOCK TABLES ON testdb.* to PUBLIC; +connect testuser,localhost,testuser,,; +connection testuser; +use testdb; +delete from t1; +ERROR 42000: DELETE command denied to user 'testuser'@'localhost' for table `testdb`.`t1` +select b from t2; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb`.`t2` +select a from t2; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb`.`t2` +connection default; +GRANT DELETE ON testdb.t1 to PUBLIC; +GRANT SELECT (a) ON testdb.t2 to PUBLIC; +disconnect testuser; +connect testuser,localhost,testuser,,; +connection testuser; +use testdb; +delete from t1; +select a from t2; +a +1 +select b from t2; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't2' +connection default; +select * from testdb.t1; +a +insert into t1 values (1); +disconnect testuser; +# check that the privilegas correctly read by acl_load +flush privileges; +connect testuser,localhost,testuser,,; +connection testuser; +use testdb; +delete from t1; +select a from t2; +a +1 +select b from t2; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't2' +connection default; +select * from testdb.t1; +a +use test; +disconnect testuser; +REVOKE ALL PRIVILEGES, GRANT OPTION from `PUBLIC`; +SHOW GRANTS FOR PUBLIC; +Grants for PUBLIC +drop user testuser; +drop database testdb; +# +# test function privilege +# +create user testuser; +create database testdb; +use testdb; +create function f1() returns int return 2; +connect testuser,localhost,testuser,,; +connection testuser; +alter function testdb.f1 comment "A stupid function"; +ERROR 42000: alter routine command denied to user 'testuser'@'%' for routine 'testdb.f1' +select testdb.f1(); +ERROR 42000: execute command denied to user 'testuser'@'%' for routine 'testdb.f1' +connection default; +GRANT ALTER ROUTINE ON testdb.* to PUBLIC; +disconnect testuser; +connect testuser,localhost,testuser,,; +connection testuser; +alter function testdb.f1 comment "A stupid function"; +select testdb.f1(); +ERROR 42000: execute command denied to user 'testuser'@'%' for routine 'testdb.f1' +connection default; +disconnect testuser; +# check that the privilegas correctly read by acl_load +flush privileges; +connect testuser,localhost,testuser,,; +connection testuser; +alter function testdb.f1 comment "A stupid function"; +select testdb.f1(); +ERROR 42000: execute command denied to user 'testuser'@'%' for routine 'testdb.f1' +connection default; +use test; +disconnect testuser; +REVOKE ALTER ROUTINE ON testdb.* from PUBLIC; +drop function testdb.f1; +drop user testuser; +drop database testdb; +# +# bug with automatically added PUBLIC role +# +# automaticly added PUBLIC +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +GRANT SELECT on test.* to PUBLIC; +REVOKE SELECT on test.* from PUBLIC; +create user testuser; +create database testdb1; +use testdb1; +create table t1 (a int, b int); +insert into t1 values (1,2); +connect testuser,localhost,testuser,,; +connection testuser; +select * from testdb1.t1; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb1`.`t1` +connection default; +disconnect testuser; +drop user testuser; +drop database testdb1; +# +# check assigning privileges via GRAND role TO PUBLIC +# +create user testuser; +create database testdb1; +use testdb1; +create table t1 (a int, b int); +# check that user do not have rights +connect testuser,localhost,testuser,,*NO-ONE*; +connection testuser; +select * from testdb1.t1; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb1`.`t1` +connection default; +disconnect testuser; +give rights to everyone via assigning the role to public +create role roletest; +GRANT SELECT ON testdb1.* TO roletest; +GRANT roletest TO PUBLIC; +connect testuser,localhost,testuser,,*NO-ONE*; +connection testuser; +select * from testdb1.t1; +a b +connection default; +disconnect testuser; +# check that the privilegas correctly read by acl_load +flush privileges; +connect testuser,localhost,testuser,,*NO-ONE*; +connection testuser; +select * from testdb1.t1; +a b +connection default; +disconnect testuser; +# drop role... +drop role roletest; +# ... and check that user do not have rights again +connect testuser,localhost,testuser,,*NO-ONE*; +connection testuser; +select * from testdb1.t1; +ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb1`.`t1` +connection default; +disconnect testuser; +drop user testuser; +drop database testdb1; +# clean up +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; diff --git a/mysql-test/main/public_privileges.test b/mysql-test/main/public_privileges.test new file mode 100644 index 0000000000000..2de23b5c81adf --- /dev/null +++ b/mysql-test/main/public_privileges.test @@ -0,0 +1,411 @@ +--echo # +--echo # Test DB/TABLE/COLUMN privileges in queries +--echo # + +SHOW GRANTS FOR PUBLIC; + +create user testuser; +create database testdb1; +use testdb1; +create table t1 (a int, b int); +insert into t1 values (1,2); +create database testdb2; +use testdb2; +create table t2 (a int, b int); +insert into t2 values (1,2); +create table t3 (a int, b int); +insert into t3 values (1,2); + +connect (testuser,localhost,testuser,,); +connection testuser; +--error ER_TABLEACCESS_DENIED_ERROR +select * from testdb1.t1; +--error ER_TABLEACCESS_DENIED_ERROR +select * from testdb2.t2; +--error ER_TABLEACCESS_DENIED_ERROR +select b from testdb2.t3; +--error ER_TABLEACCESS_DENIED_ERROR +select a from testdb2.t3; + +connection default; + +GRANT SELECT ON testdb1.* to PUBLIC; +GRANT SELECT ON testdb2.t2 to PUBLIC; +GRANT SELECT (b) ON testdb2.t3 to PUBLIC; + +disconnect testuser; +connect (testuser,localhost,testuser,,); +connection testuser; +select * from testdb1.t1; +select * from testdb2.t2; +select b from testdb2.t3; +--error ER_COLUMNACCESS_DENIED_ERROR +select a from testdb2.t3; + +connection default; +disconnect testuser; + +--echo # check that the privilegas correctly read by acl_load +flush privileges; + +connect (testuser,localhost,testuser,,); +connection testuser; +select * from testdb1.t1; +select * from testdb2.t2; +select b from testdb2.t3; +--error ER_COLUMNACCESS_DENIED_ERROR +select a from testdb2.t3; + +connection default; +use test; +disconnect testuser; +REVOKE SELECT ON testdb1.* from PUBLIC; +REVOKE SELECT ON testdb2.t2 from PUBLIC; +REVOKE SELECT (b) ON testdb2.t3 from PUBLIC; +drop user testuser; +drop database testdb1; +drop database testdb2; + +--echo # +--echo # test global process list privilege and EXECUTE db level +--echo # + +create user testuser; +create database testdb; +use testdb; +create procedure p1 () select 1; + +connect (testuser,localhost,testuser,,); +connection testuser; + +--replace_column 1 # 3 # 6 # 7 # +SHOW PROCESSLIST; +--error ER_PROCACCESS_DENIED_ERROR +call testdb.p1(); + +connection default; + +GRANT PROCESS ON *.* to PUBLIC; +GRANT EXECUTE ON testdb.* to PUBLIC; + +disconnect testuser; +connect (testuser,localhost,testuser,,); +connection testuser; + +--replace_column 1 # 3 # 6 # 7 # +SHOW PROCESSLIST; +call testdb.p1(); + +connection default; +disconnect testuser; + +--echo # check that the privilegas correctly read by acl_load +flush privileges; + +connect (testuser,localhost,testuser,,); +connection testuser; + +--replace_column 1 # 3 # 6 # 7 # +SHOW PROCESSLIST; +call testdb.p1(); + +connection default; + +--replace_column 1 # 3 # 6 # 7 # +SHOW PROCESSLIST; + +connection default; + +use test; +disconnect testuser; +REVOKE PROCESS ON *.* from PUBLIC; +REVOKE EXECUTE ON testdb.* from PUBLIC; +drop user testuser; +drop database testdb; + +--echo # +--echo # test DB privilege to allow USE statement +--echo # + +create user testuser; +create database testdb; + +connect (testuser,localhost,testuser,,); +connection testuser; + +--error ER_DBACCESS_DENIED_ERROR +use testdb; + +connection default; + +GRANT LOCK TABLES ON testdb.* to PUBLIC; + +disconnect testuser; +connect (testuser,localhost,testuser,,); +connection testuser; + +use testdb; + +connection default; +disconnect testuser; + +--echo # check that the privilegas correctly read by acl_load +flush privileges; + +connect (testuser,localhost,testuser,,); +connection testuser; + +use testdb; + +connection default; + +use test; +disconnect testuser; +REVOKE LOCK TABLES ON testdb.* from PUBLIC; +drop user testuser; +drop database testdb; + + +--echo # +--echo # test DB privilege to allow USE statement (as above) +--echo # test current db privileges +--echo # + +create user testuser; +create database testdb; +use testdb; +create table t1 (a int); +insert into t1 values (1); +GRANT LOCK TABLES ON testdb.* to PUBLIC; + +connect (testuser,localhost,testuser,,); +connection testuser; + +use testdb; +--error ER_TABLEACCESS_DENIED_ERROR +update t1 set a=a+1; + +connection default; + +GRANT UPDATE,SELECT ON testdb.* to PUBLIC; + +disconnect testuser; +connect (testuser,localhost,testuser,,); +connection testuser; + +use testdb; +update t1 set a=a+1; + +connection default; +select * from testdb.t1; + +use test; +disconnect testuser; +REVOKE LOCK TABLES ON testdb.* from PUBLIC; +REVOKE UPDATE,SELECT ON testdb.* from PUBLIC; +drop user testuser; +drop database testdb; + + +--echo # +--echo # test DB privilege to allow USE statement (as above) +--echo # test table/column privileges in current DB +--echo # + +create user testuser; +create database testdb; +use testdb; +create table t1 (a int); +insert into t1 values (1); +create table t2 (a int, b int); +insert into t2 values (1,2); +GRANT LOCK TABLES ON testdb.* to PUBLIC; + +connect (testuser,localhost,testuser,,); +connection testuser; + +use testdb; +--error ER_TABLEACCESS_DENIED_ERROR +delete from t1; +--error ER_TABLEACCESS_DENIED_ERROR +select b from t2; +--error ER_TABLEACCESS_DENIED_ERROR +select a from t2; + +connection default; + +GRANT DELETE ON testdb.t1 to PUBLIC; +GRANT SELECT (a) ON testdb.t2 to PUBLIC; + +disconnect testuser; +connect (testuser,localhost,testuser,,); +connection testuser; + +use testdb; +delete from t1; +select a from t2; +--error ER_COLUMNACCESS_DENIED_ERROR +select b from t2; + +connection default; +select * from testdb.t1; +insert into t1 values (1); +disconnect testuser; + +--echo # check that the privilegas correctly read by acl_load +flush privileges; + +connect (testuser,localhost,testuser,,); +connection testuser; + +use testdb; +delete from t1; +select a from t2; +--error ER_COLUMNACCESS_DENIED_ERROR +select b from t2; + +connection default; +select * from testdb.t1; + + +use test; +disconnect testuser; +REVOKE ALL PRIVILEGES, GRANT OPTION from `PUBLIC`; +SHOW GRANTS FOR PUBLIC; + +drop user testuser; +drop database testdb; + +--echo # +--echo # test function privilege +--echo # + +create user testuser; +create database testdb; +use testdb; +create function f1() returns int return 2; + +connect (testuser,localhost,testuser,,); +connection testuser; + +--error ER_PROCACCESS_DENIED_ERROR +alter function testdb.f1 comment "A stupid function"; +--error ER_PROCACCESS_DENIED_ERROR +select testdb.f1(); + +connection default; + +GRANT ALTER ROUTINE ON testdb.* to PUBLIC; + +disconnect testuser; +connect (testuser,localhost,testuser,,); +connection testuser; + +alter function testdb.f1 comment "A stupid function"; +--error ER_PROCACCESS_DENIED_ERROR +select testdb.f1(); + +connection default; +disconnect testuser; + +--echo # check that the privilegas correctly read by acl_load +flush privileges; + +connect (testuser,localhost,testuser,,); +connection testuser; + +alter function testdb.f1 comment "A stupid function"; +--error ER_PROCACCESS_DENIED_ERROR +select testdb.f1(); + +connection default; + +use test; +disconnect testuser; +REVOKE ALTER ROUTINE ON testdb.* from PUBLIC; +drop function testdb.f1; +drop user testuser; +drop database testdb; + +--echo # +--echo # bug with automatically added PUBLIC role +--echo # + +--echo # automaticly added PUBLIC +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +GRANT SELECT on test.* to PUBLIC; + +REVOKE SELECT on test.* from PUBLIC; + +create user testuser; +create database testdb1; +use testdb1; +create table t1 (a int, b int); +insert into t1 values (1,2); + +connect (testuser,localhost,testuser,,); +connection testuser; +--error ER_TABLEACCESS_DENIED_ERROR +select * from testdb1.t1; + +connection default; + +disconnect testuser; +drop user testuser; +drop database testdb1; + +--echo # +--echo # check assigning privileges via GRAND role TO PUBLIC +--echo # +create user testuser; +create database testdb1; +use testdb1; +create table t1 (a int, b int); + +--echo # check that user do not have rights +connect (testuser,localhost,testuser,,*NO-ONE*); +connection testuser; +--error ER_TABLEACCESS_DENIED_ERROR +select * from testdb1.t1; +connection default; +disconnect testuser; + +--echo give rights to everyone via assigning the role to public +create role roletest; +GRANT SELECT ON testdb1.* TO roletest; +GRANT roletest TO PUBLIC; + +connect (testuser,localhost,testuser,,*NO-ONE*); +connection testuser; +select * from testdb1.t1; +connection default; +disconnect testuser; + +--echo # check that the privilegas correctly read by acl_load +flush privileges; + +connect (testuser,localhost,testuser,,*NO-ONE*); +connection testuser; +select * from testdb1.t1; +connection default; +disconnect testuser; + + +--echo # drop role... +drop role roletest; + +--echo # ... and check that user do not have rights again +connect (testuser,localhost,testuser,,*NO-ONE*); +connection testuser; +--error ER_TABLEACCESS_DENIED_ERROR +select * from testdb1.t1; +connection default; +disconnect testuser; + +drop user testuser; +drop database testdb1; + +-- echo # clean up +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; diff --git a/mysql-test/suite/roles/none_public.result b/mysql-test/suite/roles/none_public.result index c253ae1478b68..4acba8bd13345 100644 --- a/mysql-test/suite/roles/none_public.result +++ b/mysql-test/suite/roles/none_public.result @@ -14,9 +14,6 @@ ERROR OP000: Invalid role specification `none` grant public to role1; ERROR OP000: Invalid role specification `public` grant role1 to public; -ERROR OP000: Invalid role specification `public` -grant select on *.* to public; -ERROR OP000: Invalid role specification `public` grant role1 to current_role; ERROR OP000: Invalid role specification `NONE` revoke none from role1; @@ -28,21 +25,15 @@ ERROR OP000: Invalid role specification `none` revoke public from role1; ERROR OP000: Invalid role specification `public` revoke role1 from public; -ERROR OP000: Invalid role specification `public` +ERROR HY000: Cannot revoke role 'role1' from: 'public'@'%' revoke select on *.* from public; -ERROR OP000: Invalid role specification `public` show grants for none; ERROR OP000: Invalid role specification `none` -show grants for public; -ERROR OP000: Invalid role specification `public` create definer=none view test.v1 as select 1; ERROR OP000: Invalid role specification `none` -create definer=public view test.v1 as select 1; -ERROR OP000: Invalid role specification `public` drop role role1; -insert mysql.global_priv values ('', 'none', '{"is_role":true}'), ('', 'public', '{"is_role":true}'); +insert mysql.global_priv values ('', 'none', '{"is_role":true}'); flush privileges; Warnings: Error 1959 Invalid role specification `none` -Error 1959 Invalid role specification `public` delete from mysql.global_priv where host=''; diff --git a/mysql-test/suite/roles/none_public.test b/mysql-test/suite/roles/none_public.test index a0ec2315cfc80..21e9dacf16653 100644 --- a/mysql-test/suite/roles/none_public.test +++ b/mysql-test/suite/roles/none_public.test @@ -17,10 +17,10 @@ grant role1 to none; grant select on *.* to none; --error ER_INVALID_ROLE grant public to role1; ---error ER_INVALID_ROLE grant role1 to public; ---error ER_INVALID_ROLE -grant select on *.* to public; +# PUBLIC is legal role +#--error ER_INVALID_ROLE +#grant select on *.* to public; --error ER_INVALID_ROLE grant role1 to current_role; @@ -33,23 +33,24 @@ revoke role1 from none; revoke select on *.* from none; --error ER_INVALID_ROLE revoke public from role1; ---error ER_INVALID_ROLE +--error ER_CANNOT_REVOKE_ROLE revoke role1 from public; ---error ER_INVALID_ROLE revoke select on *.* from public; --error ER_INVALID_ROLE show grants for none; ---error ER_INVALID_ROLE -show grants for public; +# PUBLIC is legal role +#--error ER_INVALID_ROLE +#show grants for public; --error ER_INVALID_ROLE create definer=none view test.v1 as select 1; ---error ER_INVALID_ROLE -create definer=public view test.v1 as select 1; +# PUBLIC is legal role +#--error ER_INVALID_ROLE +#create definer=public view test.v1 as select 1; drop role role1; -insert mysql.global_priv values ('', 'none', '{"is_role":true}'), ('', 'public', '{"is_role":true}'); +insert mysql.global_priv values ('', 'none', '{"is_role":true}'); flush privileges; delete from mysql.global_priv where host=''; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 20293c613f200..4713787ade858 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -103,7 +103,9 @@ LEX_CSTRING host_not_specified= { STRING_WITH_LEN("%") }; */ LEX_CSTRING current_user= { STRING_WITH_LEN("*current_user") }; LEX_CSTRING current_role= { STRING_WITH_LEN("*current_role") }; -LEX_CSTRING current_user_and_current_role= { STRING_WITH_LEN("*current_user_and_current_role") }; +LEX_CSTRING current_user_and_current_role= + { STRING_WITH_LEN("*current_user_and_current_role") }; +LEX_CSTRING public_name= {STRING_WITH_LEN("PUBLIC") }; static plugin_ref old_password_plugin; @@ -317,6 +319,13 @@ static bool show_table_and_column_privileges(THD *, const char *, const char *, static int show_routine_grants(THD *, const char *, const char *, const Sp_handler *sph, char *, int); +static ACL_ROLE *acl_public= NULL; + +inline privilege_t public_access() +{ + return (acl_public ? acl_public->access : NO_ACL); +} + class Grant_tables; class User_table; class Proxies_priv_table; @@ -685,7 +694,7 @@ static void rebuild_check_host(void); static void rebuild_role_grants(void); static ACL_USER *find_user_exact(const char *host, const char *user); static ACL_USER *find_user_wild(const char *host, const char *user, const char *ip= 0); -static ACL_ROLE *find_acl_role(const char *user); +static ACL_ROLE *find_acl_role(const char *user, bool allow_public); static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_CSTRING *u, const LEX_CSTRING *h, const LEX_CSTRING *r); static ACL_USER_BASE *find_acl_user_base(const char *user, const char *host); static bool update_user_table_password(THD *, const User_table&, const ACL_USER&); @@ -2196,14 +2205,32 @@ ACL_ROLE::ACL_ROLE(const char * rolename, privilege_t privileges, flags= IS_ROLE; } +enum role_name_check_result +{ + ROLE_NAME_OK= 0, + ROLE_NAME_PUBLIC, + ROLE_NAME_INVALID +}; -static bool is_invalid_role_name(const char *str) +static role_name_check_result check_role_name(const char *str, + bool public_is_ok) { - if (*str && strcasecmp(str, "PUBLIC") && strcasecmp(str, "NONE")) - return false; + if (*str) + { + if (strcasecmp(str, public_name.str) == 0) + { + if (public_is_ok) + return ROLE_NAME_PUBLIC; + else + goto error; + } + if (strcasecmp(str, "NONE") != 0) + return ROLE_NAME_OK; + } +error: my_error(ER_INVALID_ROLE, MYF(0), str); - return true; + return ROLE_NAME_INVALID; } @@ -2632,7 +2659,8 @@ static bool acl_load(THD *thd, const Grant_tables& tables) if (is_role) { - if (is_invalid_role_name(username)) + role_name_check_result result= check_role_name(username, true); + if (result == ROLE_NAME_INVALID) { thd->clear_error(); // the warning is still issued continue; @@ -2642,6 +2670,9 @@ static bool acl_load(THD *thd, const Grant_tables& tables) entry->role_grants = user.role_grants; my_init_dynamic_array(key_memory_acl_mem, &entry->parent_grantee, sizeof(ACL_USER_BASE *), 0, 8, MYF(0)); + if (result == ROLE_NAME_PUBLIC) + acl_public= entry; + my_hash_insert(&acl_roles, (uchar *)entry); continue; @@ -2697,7 +2728,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables) char *db_name; db.user=safe_str(get_field(&acl_memroot, db_table.user())); const char *hostname= get_field(&acl_memroot, db_table.host()); - if (!hostname && find_acl_role(db.user)) + if (!hostname && find_acl_role(db.user, true)) hostname= ""; update_hostname(&db.host, hostname); db.db= db_name= get_field(&acl_memroot, db_table.db()); @@ -2827,6 +2858,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables) void acl_free(bool end) { my_hash_free(&acl_roles); + acl_public= NULL; free_root(&acl_memroot,MYF(0)); delete_dynamic(&acl_hosts); delete_dynamic_with_callback(&acl_users, (FREE_FUNC) free_acl_user); @@ -2871,10 +2903,13 @@ bool acl_reload(THD *thd) DYNAMIC_ARRAY old_acl_hosts, old_acl_users, old_acl_proxy_users; Dynamic_array old_acl_dbs(PSI_INSTRUMENT_MEM, 0, 0); HASH old_acl_roles, old_acl_roles_mappings; + ACL_ROLE *old_acl_public; MEM_ROOT old_mem; int result; DBUG_ENTER("acl_reload"); + acl_public= NULL; + Grant_tables tables; /* To avoid deadlocks we should obtain table locks before @@ -2901,6 +2936,7 @@ bool acl_reload(THD *thd) old_acl_hosts= acl_hosts; old_acl_users= acl_users; old_acl_roles= acl_roles; + old_acl_public= acl_public; old_acl_roles_mappings= acl_roles_mappings; old_acl_proxy_users= acl_proxy_users; old_acl_dbs= acl_dbs; @@ -2925,6 +2961,7 @@ bool acl_reload(THD *thd) acl_hosts= old_acl_hosts; acl_users= old_acl_users; acl_roles= old_acl_roles; + acl_public= old_acl_public; acl_roles_mappings= old_acl_roles_mappings; acl_proxy_users= old_acl_proxy_users; acl_dbs= old_acl_dbs; @@ -3209,7 +3246,7 @@ bool acl_getroot(Security_context *sctx, const char *user, const char *host, } else // Role, not User { - ACL_ROLE *acl_role= find_acl_role(user); + ACL_ROLE *acl_role= find_acl_role(user, false); if (acl_role) { res= 0; @@ -3222,6 +3259,14 @@ bool acl_getroot(Security_context *sctx, const char *user, const char *host, } } + if (acl_public) + { + if (ACL_DB *acl_db= acl_db_find(db, public_name.str, "", "", FALSE)) + sctx->db_access|= acl_db->access; + + sctx->master_access|= acl_public->access; + } + mysql_mutex_unlock(&acl_cache->lock); DBUG_RETURN(res); } @@ -3276,7 +3321,7 @@ static int check_user_can_set_role(THD *thd, const char *user, goto end; } - role= find_acl_role(rolename); + role= find_acl_role(rolename, false); /* According to SQL standard, the same error message must be presented */ if (role == NULL) @@ -3381,20 +3426,22 @@ int acl_setrole(THD *thd, const char *rolename, privilege_t access) /* merge the privileges */ Security_context *sctx= thd->security_ctx; sctx->master_access= access; - if (thd->db.str) - sctx->db_access= acl_get(sctx->host, sctx->ip, sctx->user, thd->db.str, FALSE); - if (!strcasecmp(rolename, "NONE")) { thd->security_ctx->priv_role[0]= 0; } else { - if (thd->db.str) - sctx->db_access|= acl_get("", "", rolename, thd->db.str, FALSE); /* mark the current role */ strmake_buf(thd->security_ctx->priv_role, rolename); } + if (thd->db.str) + sctx->db_access= acl_get_all3(sctx, thd->db.str, FALSE); + + // PUBLIC magic + if (acl_public) + sctx->master_access|= acl_public->access; + return 0; } @@ -3408,9 +3455,13 @@ static uchar* check_get_key(ACL_USER *buff, size_t *length, static void acl_update_role(const char *rolename, const privilege_t privileges) { - ACL_ROLE *role= find_acl_role(rolename); + ACL_ROLE *role= find_acl_role(rolename, true); if (role) + { role->initial_role_access= role->access= privileges; + if (strcasecmp(rolename, public_name.str) == 0) + acl_public= role; + } } @@ -3532,6 +3583,8 @@ static int acl_user_update(THD *thd, ACL_USER *acl_user, uint nauth, static void acl_insert_role(const char *rolename, privilege_t privileges) { ACL_ROLE *entry; + DBUG_ENTER("acl_insert_role"); + DBUG_PRINT("enter", ("Role: '%s'", rolename)); mysql_mutex_assert_owner(&acl_cache->lock); entry= new (&acl_memroot) ACL_ROLE(rolename, privileges, &acl_memroot); @@ -3541,6 +3594,10 @@ static void acl_insert_role(const char *rolename, privilege_t privileges) sizeof(ACL_ROLE *), 0, 8, MYF(0)); my_hash_insert(&acl_roles, (uchar *)entry); + if (strcasecmp(rolename, public_name.str) == 0) + acl_public= entry; + + DBUG_VOID_RETURN; } @@ -3659,7 +3716,9 @@ privilege_t acl_get(const char *host, const char *ip, if (acl_db->host.hostname) goto exit; // Fully specified. Take it /* the host table is not used for roles */ - if ((!host || !host[0]) && !acl_db->host.hostname && find_acl_role(user)) + if ((!host || !host[0]) && + !acl_db->host.hostname && + find_acl_role(user, false)) goto exit; } @@ -3699,6 +3758,23 @@ privilege_t acl_get(const char *host, const char *ip, DBUG_RETURN(db_access & host_access); } +/* + Check if there is access for the host/user, role, public on the database +*/ + +privilege_t acl_get_all3(Security_context *sctx, const char *db, + bool db_is_patern) +{ + privilege_t access= acl_get(sctx->host, sctx->ip, + sctx->priv_user, db, db_is_patern); + if (sctx->priv_role[0]) + access|= acl_get("", "", sctx->priv_role, db, db_is_patern); + if (acl_public) + access|= acl_get("", "", public_name.str, db, db_is_patern); + return access; +} + + /* Check if there are any possible matching entries for this host @@ -3820,7 +3896,7 @@ static bool add_role_user_mapping(const char *uname, const char *hname, const char *rname) { ACL_USER_BASE *grantee= find_acl_user_base(uname, hname); - ACL_ROLE *role= find_acl_role(rname); + ACL_ROLE *role= find_acl_role(rname, false); if (grantee == NULL || role == NULL) return 1; @@ -4319,7 +4395,7 @@ bool is_acl_user(const char *host, const char *user) if (*host) // User res= find_user_exact(host, user) != NULL; else // Role - res= find_acl_role(user) != NULL; + res= find_acl_role(user, false) != NULL; mysql_mutex_unlock(&acl_cache->lock); return res; @@ -4369,7 +4445,7 @@ static ACL_USER * find_user_wild(const char *host, const char *user, const char /* Find a role with the specified name */ -static ACL_ROLE *find_acl_role(const char *role) +static ACL_ROLE *find_acl_role(const char *role, bool allow_public) { size_t length= strlen(role); DBUG_ENTER("find_acl_role"); @@ -4378,7 +4454,9 @@ static ACL_ROLE *find_acl_role(const char *role) mysql_mutex_assert_owner(&acl_cache->lock); - if (!length) + if (!length || (!allow_public && + length == public_name.length && + strcasecmp(role, public_name.str) == 0)) DBUG_RETURN(NULL); ACL_ROLE *r= (ACL_ROLE *)my_hash_search(&acl_roles, (uchar *)role, @@ -4392,7 +4470,7 @@ static ACL_USER_BASE *find_acl_user_base(const char *user, const char *host) if (*host) return find_user_exact(host, user); - return find_acl_role(user); + return find_acl_role(user, true); } @@ -4608,10 +4686,7 @@ static bool test_if_create_new_users(THD *thd) NULL, TL_WRITE); create_new_users= 1; - db_access=acl_get(sctx->host, sctx->ip, - sctx->priv_user, tl.db.str, 0); - if (sctx->priv_role[0]) - db_access|= acl_get("", "", sctx->priv_role, tl.db.str, 0); + db_access= acl_get_all3(sctx, tl.db.str, FALSE); if (!(db_access & INSERT_ACL)) { if (check_grant(thd, INSERT_ACL, &tl, FALSE, UINT_MAX, TRUE)) @@ -4903,7 +4978,7 @@ static int replace_db_table(TABLE *table, const char *db, if (!find_user_wild(combo.host.str,combo.user.str)) { /* The user could be a role, check if the user is registered as a role */ - if (!combo.host.length && !find_acl_role(combo.user.str)) + if (!combo.host.length && !find_acl_role(combo.user.str, true)) { my_message(ER_PASSWORD_NO_MATCH, ER_THD(table->in_use, ER_PASSWORD_NO_MATCH), MYF(0)); @@ -5415,7 +5490,7 @@ GRANT_NAME::GRANT_NAME(TABLE *form, bool is_routine) const char *hostname= get_field(&grant_memroot, form->field[0]); mysql_mutex_lock(&acl_cache->lock); - if (!hostname && find_acl_role(user)) + if (!hostname && find_acl_role(user, true)) hostname= ""; mysql_mutex_unlock(&acl_cache->lock); update_hostname(&host, hostname); @@ -5874,6 +5949,10 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, privilege_t store_table_rights(NO_ACL), store_col_rights(NO_ACL); uchar user_key[MAX_KEY_LENGTH]; DBUG_ENTER("replace_table_table"); + DBUG_PRINT("enter", ("User: '%s' Host: '%s' Revoke:'%d'", + (combo.user.length ? combo.user.str : ""), + (combo.host.length ? combo.host.str : ""), + (int) revoke_grant)); get_grantor(thd, grantor); /* @@ -5882,7 +5961,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, */ if (!find_user_wild(combo.host.str,combo.user.str)) { - if (!combo.host.length && !find_acl_role(combo.user.str)) + if (!combo.host.length && !find_acl_role(combo.user.str, true)) { my_message(ER_PASSWORD_NO_MATCH, ER_THD(thd, ER_PASSWORD_NO_MATCH), MYF(0)); /* purecov: deadcode */ @@ -7196,8 +7275,9 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, error= copy_and_check_auth(Str, tmp_Str, thd) || replace_user_table(thd, tables.user_table(), Str, NO_ACL, revoke_grant, create_new_users, - MY_TEST(thd->variables.sql_mode & - MODE_NO_AUTO_CREATE_USER)); + MY_TEST(tmp_Str->is_public || + (thd->variables.sql_mode & + MODE_NO_AUTO_CREATE_USER))); if (unlikely(error)) { result= TRUE; // Remember error @@ -7293,7 +7373,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, } } if (Str->is_role()) - propagate_role_grants(find_acl_role(Str->user.str), + propagate_role_grants(find_acl_role(Str->user.str, true), PRIVS_TO_MERGE::TABLE_COLUMN, db_name, table_name); } @@ -7420,7 +7500,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, continue; } if (Str->is_role()) - propagate_role_grants(find_acl_role(Str->user.str), + propagate_role_grants(find_acl_role(Str->user.str, true), sp_privs_to_merge(sph->type()), db_name, table_name); } @@ -7558,7 +7638,7 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) mysql_rwlock_wrlock(&LOCK_grant); mysql_mutex_lock(&acl_cache->lock); - if (!(role= find_acl_role(rolename.str))) + if (!(role= find_acl_role(rolename.str, false))) { mysql_mutex_unlock(&acl_cache->lock); mysql_rwlock_unlock(&LOCK_grant); @@ -7589,7 +7669,8 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) result= 1; continue; } - if (!(role_as_user= find_acl_role(thd->security_ctx->priv_role))) + if (!(role_as_user= find_acl_role(thd->security_ctx->priv_role, + true))) { LEX_CSTRING ls= { thd->security_ctx->priv_role, strlen(thd->security_ctx->priv_role) }; @@ -7622,11 +7703,11 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) if (user->host.str) hostname= user->host; else - if ((role_as_user= find_acl_role(user->user.str))) + if ((role_as_user= find_acl_role(user->user.str, false))) hostname= empty_clex_str; else { - if (is_invalid_role_name(username.str)) + if (check_role_name(username.str, true) == ROLE_NAME_INVALID) { append_user(thd, &wrong_users, &username, &empty_clex_str); result= 1; @@ -7648,19 +7729,31 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) if (!grantee && !revoke) { LEX_USER user_combo = *user; - user_combo.host = hostname; user_combo.user = username; + user_combo.is_public= (user->host.length == 0 && + // it is also can be that + // hostname.length= 1 && hostname.str[0] == '%' + // if the PUBLIC was absent + username.length == public_name.length && + (strcasecmp(username.str, public_name.str) == 0)); + if (user_combo.is_public) + user_combo.host= hostname= empty_clex_str; + else + user_combo.host = hostname; if (copy_and_check_auth(&user_combo, &user_combo, thd) || replace_user_table(thd, tables.user_table(), &user_combo, NO_ACL, false, create_new_user, - no_auto_create_user)) + (!user_combo.is_public && no_auto_create_user))) { append_user(thd, &wrong_users, &username, &hostname); result= 1; continue; } - grantee= find_user_exact(hostname.str, username.str); + if (!user_combo.is_public) + grantee= find_user_exact(hostname.str, username.str); + else + grantee= role_as_user= acl_public; /* either replace_user_table failed, or we've added the user */ DBUG_ASSERT(grantee); @@ -7826,8 +7919,9 @@ bool mysql_grant(THD *thd, const char *db, List &list, replace_user_table(thd, tables.user_table(), Str, (!db ? rights : NO_ACL), revoke_grant, create_new_users, - MY_TEST(thd->variables.sql_mode & - MODE_NO_AUTO_CREATE_USER))) + MY_TEST(!Str->is_public && + (thd->variables.sql_mode & + MODE_NO_AUTO_CREATE_USER)))) result= true; else if (db) { @@ -7851,7 +7945,7 @@ bool mysql_grant(THD *thd, const char *db, List &list, result= true; } if (Str->is_role()) - propagate_role_grants(find_acl_role(Str->user.str), + propagate_role_grants(find_acl_role(Str->user.str, true), db ? PRIVS_TO_MERGE::DB : PRIVS_TO_MERGE::GLOBAL, db); } @@ -8218,8 +8312,6 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables, uint i; privilege_t original_want_access(want_access); bool locked= 0; - GRANT_TABLE *grant_table; - GRANT_TABLE *grant_table_role= NULL; DBUG_ENTER("check_grant"); DBUG_ASSERT(number > 0); @@ -8341,18 +8433,11 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables, mysql_rwlock_rdlock(&LOCK_grant); } - grant_table= table_hash_search(sctx->host, sctx->ip, - t_ref->get_db_name(), - sctx->priv_user, - t_ref->get_table_name(), - FALSE); - if (sctx->priv_role[0]) - grant_table_role= table_hash_search("", NULL, t_ref->get_db_name(), - sctx->priv_role, - t_ref->get_table_name(), - TRUE); + t_ref->grant.read(sctx, t_ref->get_db_name(), t_ref->get_table_name()); - if (!grant_table && !grant_table_role) + if (!t_ref->grant.grant_table_user && + !t_ref->grant.grant_table_role && + !t_ref->grant.grant_public) { want_access&= ~t_ref->grant.privilege; goto err; // No grants @@ -8365,19 +8450,14 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables, if (any_combination_will_do) continue; - t_ref->grant.grant_table_user= grant_table; // Remember for column test - t_ref->grant.grant_table_role= grant_table_role; - t_ref->grant.version= grant_version; - t_ref->grant.privilege|= grant_table ? grant_table->privs : NO_ACL; - t_ref->grant.privilege|= grant_table_role ? grant_table_role->privs : NO_ACL; + t_ref->grant.privilege|= t_ref->grant.aggregate_privs(); t_ref->grant.want_privilege= ((want_access & COL_ACLS) & ~t_ref->grant.privilege); if (!(~t_ref->grant.privilege & want_access)) continue; - if ((want_access&= ~((grant_table ? grant_table->cols : NO_ACL) | - (grant_table_role ? grant_table_role->cols : NO_ACL) | - t_ref->grant.privilege))) + if ((want_access&= ~(t_ref->grant.aggregate_cols() | + t_ref->grant.privilege))) { goto err; // impossible } @@ -8420,6 +8500,49 @@ static void check_grant_column_int(GRANT_TABLE *grant_table, const char *name, } } +inline privilege_t GRANT_INFO::aggregate_privs() +{ + return (grant_table_user ? grant_table_user->privs : NO_ACL) | + (grant_table_role ? grant_table_role->privs : NO_ACL) | + (grant_public ? grant_public->privs : NO_ACL); +} + +inline privilege_t GRANT_INFO::aggregate_cols() +{ + return (grant_table_user ? grant_table_user->cols : NO_ACL) | + (grant_table_role ? grant_table_role->cols : NO_ACL) | + (grant_public ? grant_public->cols : NO_ACL); +} + +void GRANT_INFO::refresh(const Security_context *sctx, + const char *db, const char *table) +{ + if (version != grant_version) + read(sctx, db, table); +} + +void GRANT_INFO::read(const Security_context *sctx, + const char *db, const char *table) +{ +#ifdef EMBEDDED_LIBRARY + grant_table_user= grant_table_role= grant_public= NULL; +#else + grant_table_user= + table_hash_search(sctx->host, sctx->ip, db, + sctx->priv_user, + table, FALSE); /* purecov: inspected */ + grant_table_role= + sctx->priv_role[0] ? table_hash_search("", NULL, db, + sctx->priv_role, + table, TRUE) : NULL; + grant_public= + acl_public ? table_hash_search("", NULL, db, + public_name.str, + table, TRUE) : NULL; +#endif + version= grant_version; /* purecov: inspected */ +} + /* Check column rights in given security context @@ -8453,24 +8576,14 @@ bool check_grant_column(THD *thd, GRANT_INFO *grant, mysql_rwlock_rdlock(&LOCK_grant); /* reload table if someone has modified any grants */ - - if (grant->version != grant_version) - { - grant->grant_table_user= - table_hash_search(sctx->host, sctx->ip, db_name, - sctx->priv_user, - table_name, 0); /* purecov: inspected */ - grant->grant_table_role= - sctx->priv_role[0] ? table_hash_search("", NULL, db_name, - sctx->priv_role, - table_name, TRUE) : NULL; - grant->version= grant_version; /* purecov: inspected */ - } + grant->refresh(sctx, db_name, table_name); check_grant_column_int(grant->grant_table_user, name, (uint)length, &want_access); check_grant_column_int(grant->grant_table_role, name, (uint)length, &want_access); + check_grant_column_int(grant->grant_public, name, (uint)length, + &want_access); mysql_rwlock_unlock(&LOCK_grant); if (!want_access) @@ -8586,6 +8699,7 @@ bool check_grant_all_columns(THD *thd, privilege_t want_access_arg, GRANT_INFO *grant; GRANT_TABLE *UNINIT_VAR(grant_table); GRANT_TABLE *UNINIT_VAR(grant_table_role); + GRANT_TABLE *UNINIT_VAR(grant_public); /* Flag that gets set if privilege checking has to be performed on column level. @@ -8611,22 +8725,12 @@ bool check_grant_all_columns(THD *thd, privilege_t want_access_arg, if (want_access) { /* reload table if someone has modified any grants */ - if (grant->version != grant_version) - { - grant->grant_table_user= - table_hash_search(sctx->host, sctx->ip, db_name, - sctx->priv_user, - table_name, 0); /* purecov: inspected */ - grant->grant_table_role= - sctx->priv_role[0] ? table_hash_search("", NULL, db_name, - sctx->priv_role, - table_name, TRUE) : NULL; - grant->version= grant_version; /* purecov: inspected */ - } + grant->refresh(sctx, db_name, table_name); grant_table= grant->grant_table_user; grant_table_role= grant->grant_table_role; - if (!grant_table && !grant_table_role) + grant_public= grant->grant_public; + if (!grant_table && !grant_table_role && !grant_public) goto err; } } @@ -8649,6 +8753,15 @@ bool check_grant_all_columns(THD *thd, privilege_t want_access_arg, if (grant_column) have_access|= grant_column->rights; } + if (grant_public) + { + GRANT_COLUMN *grant_column= + column_hash_search(grant_public, field_name->str, + field_name->length); + if (grant_column) + have_access|= grant_column->rights; + + } if (have_access) using_column_privileges= TRUE; @@ -8828,6 +8941,13 @@ bool check_grant_routine(THD *thd, privilege_t want_access, table->table_name.str, sph, 0))) table->grant.privilege|= grant_proc->privs; } + if (acl_public) + { + if ((grant_proc= routine_hash_search("", NULL, table->db.str, + public_name.str, + table->table_name.str, sph, 0))) + table->grant.privilege|= grant_proc->privs; + } if (want_access & ~table->grant.privilege) { @@ -8907,27 +9027,10 @@ privilege_t get_table_grant(THD *thd, TABLE_LIST *table) { Security_context *sctx= thd->security_ctx; const char *db = table->db.str ? table->db.str : thd->db.str; - GRANT_TABLE *grant_table; - GRANT_TABLE *grant_table_role= NULL; mysql_rwlock_rdlock(&LOCK_grant); -#ifdef EMBEDDED_LIBRARY - grant_table= NULL; - grant_table_role= NULL; -#else - grant_table= table_hash_search(sctx->host, sctx->ip, db, sctx->priv_user, - table->table_name.str, 0); - if (sctx->priv_role[0]) - grant_table_role= table_hash_search("", "", db, sctx->priv_role, - table->table_name.str, 0); -#endif - table->grant.grant_table_user= grant_table; // Remember for column test - table->grant.grant_table_role= grant_table_role; - table->grant.version=grant_version; - if (grant_table) - table->grant.privilege|= grant_table->privs; - if (grant_table_role) - table->grant.privilege|= grant_table_role->privs; + table->grant.read(sctx, db, table->table_name.str); + table->grant.privilege|= table->grant.aggregate_privs(); privilege_t privilege(table->grant.privilege); mysql_rwlock_unlock(&LOCK_grant); return privilege; @@ -8958,29 +9061,19 @@ privilege_t get_column_grant(THD *thd, GRANT_INFO *grant, { GRANT_TABLE *grant_table; GRANT_TABLE *grant_table_role; + GRANT_TABLE *grant_public; GRANT_COLUMN *grant_column; privilege_t priv(NO_ACL); mysql_rwlock_rdlock(&LOCK_grant); /* reload table if someone has modified any grants */ - if (grant->version != grant_version) - { - Security_context *sctx= thd->security_ctx; - grant->grant_table_user= - table_hash_search(sctx->host, sctx->ip, - db_name, sctx->priv_user, - table_name, 0); /* purecov: inspected */ - grant->grant_table_role= - sctx->priv_role[0] ? table_hash_search("", "", db_name, - sctx->priv_role, - table_name, TRUE) : NULL; - grant->version= grant_version; /* purecov: inspected */ - } + grant->refresh(thd->security_ctx, db_name, table_name); grant_table= grant->grant_table_user; grant_table_role= grant->grant_table_role; + grant_public= grant->grant_public; - if (!grant_table && !grant_table_role) + if (!grant_table && !grant_table_role && !grant_public) priv= grant->privilege; else { @@ -9004,6 +9097,16 @@ privilege_t get_column_grant(THD *thd, GRANT_INFO *grant, priv|= (grant->privilege | grant_table_role->privs | grant_column->rights); } + if (grant_public) + { + grant_column= column_hash_search(grant_public, field_name, + (uint) strlen(field_name)); + if (!grant_column) + priv|= (grant->privilege | grant_public->privs); + else + priv|= (grant->privilege | grant_public->privs | + grant_column->rights); + } } mysql_rwlock_unlock(&LOCK_grant); return priv; @@ -9479,7 +9582,7 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user) if (rolename) { - acl_role= find_acl_role(rolename); + acl_role= find_acl_role(rolename, true); if (acl_role) { /* get a list of all inherited roles */ @@ -9618,6 +9721,13 @@ static bool show_global_privileges(THD *thd, ACL_USER_BASE *acl_entry, want_access= ((ACL_ROLE *)acl_entry)->initial_role_access; else want_access= acl_entry->access; + + // suppress "GRANT USAGE ON *.* TO `PUBLIC`" + if (!(want_access & ~GRANT_ACL) && + acl_entry->user.length == public_name.length && + strcasecmp(acl_entry->user.str, public_name.str) == 0) + return FALSE; + if (test_all_bits(want_access, (GLOBAL_ACLS & ~ GRANT_ACL))) global.append(STRING_WITH_LEN("ALL PRIVILEGES")); else if (!(want_access & ~GRANT_ACL)) @@ -10354,7 +10464,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop, if (struct_no == ROLE_ACL) //no need to scan the structures in this case { - acl_role= find_acl_role(user_from->user.str); + acl_role= find_acl_role(user_from->user.str, true); if (!acl_role) DBUG_RETURN(0); @@ -10712,7 +10822,7 @@ static int handle_grant_data(THD *thd, Grant_tables& tables, bool drop, if (search_only) { /* quickly search in-memory structures first */ - if (handle_as_role && find_acl_role(user_from->user.str)) + if (handle_as_role && find_acl_role(user_from->user.str, true)) DBUG_RETURN(1); // found if (!handle_as_role && find_user_exact(user_from->host.str, user_from->user.str)) @@ -10943,7 +11053,8 @@ bool mysql_create_user(THD *thd, List &list, bool handle_as_role) continue; } - if (handle_as_role && is_invalid_role_name(user_name->user.str)) + if (handle_as_role && + (check_role_name(user_name->user.str, false) == ROLE_NAME_INVALID)) { append_user(thd, &wrong_users, user_name); result= TRUE; @@ -11011,7 +11122,7 @@ bool mysql_create_user(THD *thd, List &list, bool handle_as_role) { ACL_USER_BASE *grantee= find_acl_user_base(thd->lex->definer->user.str, thd->lex->definer->host.str); - ACL_ROLE *role= find_acl_role(user_name->user.str); + ACL_ROLE *role= find_acl_role(user_name->user.str, false); /* just like with routines, views, triggers, and events we allow @@ -11103,10 +11214,15 @@ bool mysql_drop_user(THD *thd, List &list, bool handle_as_role) { int rc; user_name= get_current_user(thd, tmp_user_name, false); - if (!user_name) + if (!user_name || (handle_as_role && + (strcasecmp(user_name->user.str, + public_name.str) == 0))) { thd->clear_error(); - append_str(&wrong_users, STRING_WITH_LEN("CURRENT_ROLE")); + if (!user_name) + append_str(&wrong_users, STRING_WITH_LEN("CURRENT_ROLE")); + else + append_str(&wrong_users, public_name.str, public_name.length); result= TRUE; continue; } @@ -11535,7 +11651,7 @@ bool mysql_revoke_all(THD *thd, List &list) if (lex_user->is_role()) { /* this can not fail due to get_current_user already having searched for it */ - user_or_role= find_acl_role(lex_user->user.str); + user_or_role= find_acl_role(lex_user->user.str, true); } else { @@ -12056,6 +12172,8 @@ static bool set_user_salt_if_needed(ACL_USER *, int, plugin_ref) { return 0; } bool check_grant(THD *, privilege_t, TABLE_LIST *, bool, uint, bool) { return 0; } +inline privilege_t public_access() +{ return NO_ACL; } #endif /*NO_EMBEDDED_ACCESS_CHECKS */ @@ -12314,7 +12432,7 @@ bool check_role_is_granted(const char *username, if (hostname) root= find_user_exact(hostname, username); else - root= find_acl_role(username); + root= find_acl_role(username, false); LEX_CSTRING role_lex; role_lex.str= rolename; @@ -12342,7 +12460,7 @@ int fill_schema_enabled_roles(THD *thd, TABLE_LIST *tables, COND *cond) { mysql_rwlock_rdlock(&LOCK_grant); mysql_mutex_lock(&acl_cache->lock); - ACL_ROLE *acl_role= find_acl_role(thd->security_ctx->priv_role); + ACL_ROLE *acl_role= find_acl_role(thd->security_ctx->priv_role, false); if (acl_role) traverse_role_graph_down(acl_role, table, enabled_roles_insert, NULL); mysql_mutex_unlock(&acl_cache->lock); @@ -12816,11 +12934,7 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, if (!thd->db.str || strcmp(db, thd->db.str)) { - /* db privileges */ - grant->privilege|= acl_get(sctx->host, sctx->ip, sctx->priv_user, db, 0); - /* db privileges for role */ - if (sctx->priv_role[0]) - grant->privilege|= acl_get("", "", sctx->priv_role, db, 0); + grant->privilege|= acl_get_all3(sctx, db, FALSE); } else { @@ -12829,18 +12943,8 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, /* table privileges */ mysql_rwlock_rdlock(&LOCK_grant); - if (grant->version != grant_version) - { - grant->grant_table_user= - table_hash_search(sctx->host, sctx->ip, db, - sctx->priv_user, - table, 0); /* purecov: inspected */ - grant->grant_table_role= - sctx->priv_role[0] ? table_hash_search("", "", db, - sctx->priv_role, - table, TRUE) : NULL; - grant->version= grant_version; /* purecov: inspected */ - } + grant->refresh(sctx, db, table); + if (grant->grant_table_user != 0) { grant->privilege|= grant->grant_table_user->privs; @@ -12849,6 +12953,10 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, { grant->privilege|= grant->grant_table_role->privs; } + if (grant->grant_public != 0) + { + grant->privilege|= grant->grant_public->privs; + } mysql_rwlock_unlock(&LOCK_grant); DBUG_PRINT("info", ("privilege 0x%llx", (longlong) grant->privilege)); @@ -12904,12 +13012,16 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) return dup; } - if (is_invalid_role_name(user->user.str)) + role_name_check_result result= check_role_name(user->user.str, + user->host.length == 0); + if (result == ROLE_NAME_INVALID) return 0; + if (result == ROLE_NAME_PUBLIC) + dup->is_public= true; if (lock) mysql_mutex_lock(&acl_cache->lock); - if (find_acl_role(dup->user.str)) + if (find_acl_role(dup->user.str, false) || dup->is_public) dup->host= empty_clex_str; else dup->host= host_not_specified; @@ -14518,7 +14630,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len) } #endif - sctx->master_access= acl_user->access; + sctx->master_access= (acl_user->access | public_access()); strmake_buf(sctx->priv_user, acl_user->user.str); if (acl_user->host.hostname) diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 570da144b46e5..d1597ca9f5a7c 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -76,8 +76,8 @@ bool hostname_requires_resolving(const char *hostname); bool acl_init(bool dont_read_acl_tables); bool acl_reload(THD *thd); void acl_free(bool end=0); -privilege_t acl_get(const char *host, const char *ip, - const char *user, const char *db, my_bool db_is_pattern); +privilege_t acl_get_all3(Security_context *sctx, const char *db, + bool db_is_patern); bool acl_authenticate(THD *thd, uint com_change_user_pkt_len); bool acl_getroot(Security_context *sctx, const char *user, const char *host, const char *ip, const char *db); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 7be4ba00b8618..452a01773e552 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1778,16 +1778,13 @@ uint mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, #ifndef NO_EMBEDDED_ACCESS_CHECKS if (test_all_bits(sctx->master_access, DB_ACLS)) + { db_access= DB_ACLS; + } else { - db_access= acl_get(sctx->host, sctx->ip, sctx->priv_user, - new_db_file_name.str, FALSE) | sctx->master_access; - if (sctx->priv_role[0]) - { - /* include a possible currently set role for access */ - db_access|= acl_get("", "", sctx->priv_role, new_db_file_name.str, FALSE); - } + db_access= acl_get_all3(sctx, new_db_file_name.str, FALSE); + db_access|= sctx->master_access; } if (!force_switch && diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 69803242fc109..7025b7214b3fe 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6760,10 +6760,7 @@ check_access(THD *thd, privilege_t want_access, { if (db && (!thd->db.str || db_is_pattern || strcmp(db, thd->db.str))) { - db_access= acl_get(sctx->host, sctx->ip, sctx->priv_user, db, - db_is_pattern); - if (sctx->priv_role[0]) - db_access|= acl_get("", "", sctx->priv_role, db, db_is_pattern); + db_access= acl_get_all3(sctx, db, db_is_pattern); } else { @@ -6808,14 +6805,7 @@ check_access(THD *thd, privilege_t want_access, } if (db && (!thd->db.str || db_is_pattern || strcmp(db, thd->db.str))) - { - db_access= acl_get(sctx->host, sctx->ip, sctx->priv_user, db, - db_is_pattern); - if (sctx->priv_role[0]) - { - db_access|= acl_get("", "", sctx->priv_role, db, db_is_pattern); - } - } + db_access= acl_get_all3(sctx, db, db_is_pattern); else db_access= sctx->db_access; DBUG_PRINT("info",("db_access: %llx want_access: %llx", diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b47b9f4b89bc7..87f697c5ae91d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1406,12 +1406,8 @@ bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname, if (test_all_bits(sctx->master_access, DB_ACLS)) db_access=DB_ACLS; else - { - db_access= acl_get(sctx->host, sctx->ip, sctx->priv_user, dbname->str, 0) | + db_access= acl_get_all3(sctx, dbname->str, FALSE) | sctx->master_access; - if (sctx->priv_role[0]) - db_access|= acl_get("", "", sctx->priv_role, dbname->str, 0); - } if (!(db_access & DB_ACLS) && check_grant_db(thd,dbname->str)) { @@ -5302,7 +5298,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) &thd->col_access, NULL, 0, 1) || (!thd->col_access && check_grant_db(thd, db_name->str))) || sctx->master_access & (DB_ACLS | SHOW_DB_ACL) || - acl_get(sctx->host, sctx->ip, sctx->priv_user, db_name->str, 0)) + acl_get_all3(sctx, db_name->str, 0)) #endif { Dynamic_array table_names(PSI_INSTRUMENT_MEM); @@ -5502,9 +5498,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond) } #ifndef NO_EMBEDDED_ACCESS_CHECKS if (sctx->master_access & (DB_ACLS | SHOW_DB_ACL) || - acl_get(sctx->host, sctx->ip, sctx->priv_user, db_name->str, false) || - (sctx->priv_role[0] ? - acl_get("", "", sctx->priv_role, db_name->str, false) : NO_ACL) || + acl_get_all3(sctx, db_name->str, false) || !check_grant_db(thd, db_name->str)) #endif { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 774f92197f9ec..2c36ee5ab2dd4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -17156,6 +17156,7 @@ grant_role: $$->user= $1; $$->host= empty_clex_str; $$->auth= NULL; + $$->is_public= false; if (unlikely(check_string_char_length(&$$->user, ER_USERNAME, username_char_length, diff --git a/sql/structs.h b/sql/structs.h index b36f8e6a1a01a..edecbf0888b51 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -254,6 +254,7 @@ struct AUTHID struct LEX_USER: public AUTHID { USER_AUTH *auth; + bool is_public; bool has_auth() { return auth && (auth->plugin.length || auth->auth_str.length || auth->pwtext.length); diff --git a/sql/table.h b/sql/table.h index 3aabee9a087bc..97b469e41cb29 100644 --- a/sql/table.h +++ b/sql/table.h @@ -301,6 +301,7 @@ typedef struct st_grant_info */ GRANT_TABLE *grant_table_user; GRANT_TABLE *grant_table_role; + GRANT_TABLE *grant_public; /** @brief Used for cache invalidation when caching privilege information. @@ -347,6 +348,14 @@ typedef struct st_grant_info want_privilege(NO_ACL), orig_want_privilege(NO_ACL) { } + + void read(const Security_context *sctx, const char *db, + const char *table); + + inline void refresh(const Security_context *sctx, const char *db, + const char *table); + inline privilege_t aggregate_privs(); + inline privilege_t aggregate_cols(); } GRANT_INFO; enum tmp_table_type From b4e7803a6f4c734fc5f06a0b0d78285510ae0f48 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 1 Nov 2022 21:52:23 +0100 Subject: [PATCH 081/113] MDEV-5215 post-review fixes * "public" should work in any letter case * PUBLIC is not a valid definer * granting to public should auto-create an entry in mysql.global_priv * SHOW GRANTS should show privileges obtained via PUBLIC * LEX_USER::is_public was often uninitialized * comments, whitespaces, typos, etc --- mysql-test/main/public_basic.result | 95 ++++++------------- mysql-test/main/public_basic.test | 84 +++++++--------- mysql-test/main/public_privileges.result | 79 ++++++--------- mysql-test/main/public_privileges.test | 67 ++++--------- .../perfschema/r/connection_type_win.result | 3 +- mysql-test/suite/roles/none_public.result | 35 ++++++- mysql-test/suite/roles/none_public.test | 39 ++++++-- sql/sql_acl.cc | 93 +++++++++--------- sql/sql_class.cc | 1 + sql/sql_parse.cc | 21 ++-- sql/sql_yacc.yy | 9 +- 11 files changed, 238 insertions(+), 288 deletions(-) diff --git a/mysql-test/main/public_basic.result b/mysql-test/main/public_basic.result index 5832180d2cf56..9506fdfff00c8 100644 --- a/mysql-test/main/public_basic.result +++ b/mysql-test/main/public_basic.result @@ -1,3 +1,6 @@ +# +# MDEV-5215 Granted to PUBLIC +# SHOW GRANTS FOR PUBLIC; Grants for PUBLIC # it is not PUBLIC but an user @@ -7,39 +10,6 @@ create user PUBLIC@localhost; GRANT SELECT on test.* to PUBLIC@localhost; drop user PUBLIC@localhost; drop user PUBLIC; -# preinstalled PUBLIC -GRANT SELECT on test.* to PUBLIC; -GRANT SELECT on mysql.db to PUBLIC; -select * from mysql.global_priv where user="PUBLIC" ; -Host User Priv - PUBLIC {"access":0,"version_id":VERSION,"is_role":true} -SHOW GRANTS FOR PUBLIC; -Grants for PUBLIC -GRANT SELECT ON `test`.* TO `PUBLIC` -GRANT SELECT ON `mysql`.`db` TO `PUBLIC` -GRANT UPDATE on test.* to PUBLIC; -GRANT UPDATE on mysql.db to PUBLIC; -SHOW GRANTS FOR PUBLIC; -Grants for PUBLIC -GRANT SELECT, UPDATE ON `test`.* TO `PUBLIC` -GRANT SELECT, UPDATE ON `mysql`.`db` TO `PUBLIC` -REVOKE SELECT on test.* from PUBLIC; -REVOKE SELECT on mysql.db from PUBLIC; -SHOW GRANTS FOR PUBLIC; -Grants for PUBLIC -GRANT UPDATE ON `test`.* TO `PUBLIC` -GRANT UPDATE ON `mysql`.`db` TO `PUBLIC` -REVOKE UPDATE on test.* from PUBLIC; -REVOKE UPDATE on mysql.db from PUBLIC; -REVOKE UPDATE on test.* from PUBLIC; -ERROR 42000: There is no such grant defined for user 'PUBLIC' on host '' -REVOKE UPDATE on mysql.db from PUBLIC; -ERROR 42000: There is no such grant defined for user 'PUBLIC' on host '' on table 'db' -SHOW GRANTS FOR PUBLIC; -Grants for PUBLIC -# automaticly added PUBLIC -delete from mysql.global_priv where user="PUBLIC"; -flush privileges; select * from mysql.global_priv where user="PUBLIC" ; Host User Priv GRANT SELECT on test.* to PUBLIC; @@ -52,12 +22,12 @@ Grants for PUBLIC GRANT SELECT ON `test`.* TO `PUBLIC` GRANT SELECT ON `mysql`.`db` TO `PUBLIC` GRANT UPDATE on test.* to PUBLIC; -GRANT UPDATE on mysql.db to PUBLIC; -SHOW GRANTS FOR PUBLIC; +grant update on mysql.db to public; +show grants for public; Grants for PUBLIC GRANT SELECT, UPDATE ON `test`.* TO `PUBLIC` GRANT SELECT, UPDATE ON `mysql`.`db` TO `PUBLIC` -REVOKE SELECT on test.* from PUBLIC; +revoke select on test.* from public; REVOKE SELECT on mysql.db from PUBLIC; SHOW GRANTS FOR PUBLIC; Grants for PUBLIC @@ -72,15 +42,15 @@ ERROR OP000: Invalid role specification `XXXXXX` # following should fail with the same error as above GRANT PUBLIC TO CURRENT_USER; ERROR OP000: Invalid role specification `PUBLIC` -REVOKE XXXXXX FROM CURRENT_USER; -ERROR OP000: Invalid role specification `XXXXXX` +revoke xxxxxx from current_user; +ERROR OP000: Invalid role specification `xxxxxx` # following should fail with the same error as above -REVOKE PUBLIC FROM CURRENT_USER; -ERROR OP000: Invalid role specification `PUBLIC` +revoke public from current_user; +ERROR OP000: Invalid role specification `public` drop role XXXXXX; ERROR HY000: Operation DROP ROLE failed for 'XXXXXX' # following should fail with the same error as above -drop role PUBLIC; +drop role public; ERROR HY000: Operation DROP ROLE failed for PUBLIC SET ROLE XXXXXX; ERROR OP000: Invalid role specification `XXXXXX` @@ -92,6 +62,8 @@ ERROR OP000: Invalid role specification `XXXXXX` # following should fail with the same error as above SET DEFAULT ROLE PUBLIC; ERROR OP000: Invalid role specification `PUBLIC` +set default role public; +ERROR OP000: Invalid role specification `public` # # check prohibition of change security context to PUBLIC # @@ -100,39 +72,34 @@ GRANT SELECT on test.* to PUBLIC; # try with a view create table t1( a int); create definer = PUBLIC view v1 as select * from t1; -Warnings: -Note 1449 The user specified as a definer ('PUBLIC'@'') does not exist -show create view v1; -View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`PUBLIC` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci -Warnings: -Note 1449 The user specified as a definer ('PUBLIC'@'') does not exist -select * from v1; -ERROR HY000: The user specified as a definer ('PUBLIC'@'') does not exist -drop view v1; +ERROR OP000: Invalid role specification `PUBLIC` drop table t1; -# try with a view +# try with a stored procedure create definer='PUBLIC' PROCEDURE p1() SELECT 1; -Warnings: -Note 1449 The user specified as a definer ('PUBLIC'@'') does not exist -show create procedure p1; -Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation -p1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`PUBLIC` PROCEDURE `p1`() -SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci -call p1(); -ERROR HY000: The user specified as a definer ('PUBLIC'@'') does not exist -drop procedure p1; +ERROR OP000: Invalid role specification `PUBLIC` # this test cleanup -REVOKE SELECT on test.* from PUBLIC; +revoke select on test.* from public; # -# check autocreation of PUBLIC on GRAND role TO PUBLIC +# check autocreation of PUBLIC on GRANT role TO PUBLIC # # make sure that the privilege will be added automatically delete from mysql.global_priv where user="PUBLIC"; flush privileges; create role roletest; -GRANT roletest TO PUBLIC; +grant roletest to public; drop role roletest; +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +grant select on mysql.global_priv to public; +revoke select on mysql.global_priv from public; +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +grant select (user) on mysql.global_priv to public; +revoke select (user) on mysql.global_priv from public; +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +grant execute on procedure mtr.add_suppression to public; +revoke execute on procedure mtr.add_suppression from public; # clean up delete from mysql.global_priv where user="PUBLIC"; flush privileges; diff --git a/mysql-test/main/public_basic.test b/mysql-test/main/public_basic.test index ddb4e040fce59..99952c54e943e 100644 --- a/mysql-test/main/public_basic.test +++ b/mysql-test/main/public_basic.test @@ -1,3 +1,8 @@ +--source include/not_embedded.inc +--echo # +--echo # MDEV-5215 Granted to PUBLIC +--echo # + SHOW GRANTS FOR PUBLIC; --echo # it is not PUBLIC but an user @@ -8,37 +13,6 @@ GRANT SELECT on test.* to PUBLIC@localhost; drop user PUBLIC@localhost; drop user PUBLIC; ---echo # preinstalled PUBLIC -GRANT SELECT on test.* to PUBLIC; -GRANT SELECT on mysql.db to PUBLIC; ---replace_regex /"version_id"\:[0-9]+/"version_id":VERSION/ -select * from mysql.global_priv where user="PUBLIC" ; - -SHOW GRANTS FOR PUBLIC; - -GRANT UPDATE on test.* to PUBLIC; -GRANT UPDATE on mysql.db to PUBLIC; - -SHOW GRANTS FOR PUBLIC; - -REVOKE SELECT on test.* from PUBLIC; -REVOKE SELECT on mysql.db from PUBLIC; - -SHOW GRANTS FOR PUBLIC; - -REVOKE UPDATE on test.* from PUBLIC; -REVOKE UPDATE on mysql.db from PUBLIC; - ---error ER_NONEXISTING_GRANT -REVOKE UPDATE on test.* from PUBLIC; ---error ER_NONEXISTING_TABLE_GRANT -REVOKE UPDATE on mysql.db from PUBLIC; - -SHOW GRANTS FOR PUBLIC; - ---echo # automaticly added PUBLIC -delete from mysql.global_priv where user="PUBLIC"; -flush privileges; select * from mysql.global_priv where user="PUBLIC" ; GRANT SELECT on test.* to PUBLIC; GRANT SELECT on mysql.db to PUBLIC; @@ -48,11 +22,11 @@ select * from mysql.global_priv where user="PUBLIC" ; SHOW GRANTS FOR PUBLIC; GRANT UPDATE on test.* to PUBLIC; -GRANT UPDATE on mysql.db to PUBLIC; +grant update on mysql.db to public; -SHOW GRANTS FOR PUBLIC; +show grants for public; -REVOKE SELECT on test.* from PUBLIC; +revoke select on test.* from public; REVOKE SELECT on mysql.db from PUBLIC; SHOW GRANTS FOR PUBLIC; @@ -69,16 +43,16 @@ GRANT XXXXXX TO CURRENT_USER; GRANT PUBLIC TO CURRENT_USER; --error ER_INVALID_ROLE -REVOKE XXXXXX FROM CURRENT_USER; +revoke xxxxxx from current_user; --echo # following should fail with the same error as above --error ER_INVALID_ROLE -REVOKE PUBLIC FROM CURRENT_USER; ---error ER_CANNOT_USER +revoke public from current_user; +--error ER_CANNOT_USER drop role XXXXXX; --echo # following should fail with the same error as above --error ER_CANNOT_USER -drop role PUBLIC; +drop role public; --error ER_INVALID_ROLE SET ROLE XXXXXX; @@ -91,6 +65,8 @@ SET DEFAULT ROLE XXXXXX; --echo # following should fail with the same error as above --error ER_INVALID_ROLE SET DEFAULT ROLE PUBLIC; +--error ER_INVALID_ROLE +set default role public; --echo # --echo # check prohibition of change security context to PUBLIC @@ -99,31 +75,39 @@ SET DEFAULT ROLE PUBLIC; GRANT SELECT on test.* to PUBLIC; --echo # try with a view create table t1( a int); +--error ER_INVALID_ROLE create definer = PUBLIC view v1 as select * from t1; -show create view v1; ---error ER_NO_SUCH_USER -select * from v1; -drop view v1; drop table t1; ---echo # try with a view +--echo # try with a stored procedure +--error ER_INVALID_ROLE create definer='PUBLIC' PROCEDURE p1() SELECT 1; -show create procedure p1; ---error ER_NO_SUCH_USER -call p1(); -drop procedure p1; --echo # this test cleanup -REVOKE SELECT on test.* from PUBLIC; +revoke select on test.* from public; --echo # ---echo # check autocreation of PUBLIC on GRAND role TO PUBLIC +--echo # check autocreation of PUBLIC on GRANT role TO PUBLIC --echo # --echo # make sure that the privilege will be added automatically delete from mysql.global_priv where user="PUBLIC"; flush privileges; create role roletest; -GRANT roletest TO PUBLIC; +grant roletest to public; drop role roletest; +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +grant select on mysql.global_priv to public; +revoke select on mysql.global_priv from public; + +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +grant select (user) on mysql.global_priv to public; +revoke select (user) on mysql.global_priv from public; + +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; +grant execute on procedure mtr.add_suppression to public; +revoke execute on procedure mtr.add_suppression from public; -- echo # clean up delete from mysql.global_priv where user="PUBLIC"; diff --git a/mysql-test/main/public_privileges.result b/mysql-test/main/public_privileges.result index ae50ab78553a6..5f48297e00978 100644 --- a/mysql-test/main/public_privileges.result +++ b/mysql-test/main/public_privileges.result @@ -1,4 +1,7 @@ # +# MDEV-5215 Granted to PUBLIC +# +# # Test DB/TABLE/COLUMN privileges in queries # SHOW GRANTS FOR PUBLIC; @@ -15,7 +18,6 @@ insert into t2 values (1,2); create table t3 (a int, b int); insert into t3 values (1,2); connect testuser,localhost,testuser,,; -connection testuser; select * from testdb1.t1; ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb1`.`t1` select * from testdb2.t2; @@ -28,8 +30,6 @@ connection default; GRANT SELECT ON testdb1.* to PUBLIC; GRANT SELECT ON testdb2.t2 to PUBLIC; GRANT SELECT (b) ON testdb2.t3 to PUBLIC; -disconnect testuser; -connect testuser,localhost,testuser,,; connection testuser; select * from testdb1.t1; a b @@ -42,12 +42,20 @@ b 2 select a from testdb2.t3; ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'a' in table 't3' +show grants; +Grants for testuser@% +GRANT USAGE ON *.* TO `testuser`@`%` +GRANT SELECT ON `testdb1`.* TO `PUBLIC` +GRANT SELECT ON `testdb2`.`t2` TO `PUBLIC` +GRANT SELECT (b) ON `testdb2`.`t3` TO `PUBLIC` +show grants for testuser@'%'; +Grants for testuser@% +GRANT USAGE ON *.* TO `testuser`@`%` connection default; disconnect testuser; -# check that the privilegas correctly read by acl_load +# check that the privileges are correctly read by acl_load flush privileges; connect testuser,localhost,testuser,,; -connection testuser; select * from testdb1.t1; a b 1 2 @@ -76,10 +84,8 @@ create database testdb; use testdb; create procedure p1 () select 1; connect testuser,localhost,testuser,,; -connection testuser; -SHOW PROCESSLIST; -Id User Host db Command Time State Info Progress -# testuser # NULL Query # # SHOW PROCESSLIST 0.000 +select user,db from information_schema.processlist where user='root'; +user db call testdb.p1(); ERROR 42000: execute command denied to user 'testuser'@'%' for routine 'testdb.p1' connection default; @@ -87,33 +93,24 @@ GRANT PROCESS ON *.* to PUBLIC; GRANT EXECUTE ON testdb.* to PUBLIC; disconnect testuser; connect testuser,localhost,testuser,,; -connection testuser; -SHOW PROCESSLIST; -Id User Host db Command Time State Info Progress -# root # testdb Sleep # # NULL 0.000 -# testuser # NULL Query # # SHOW PROCESSLIST 0.000 +select user,db from information_schema.processlist where user='root'; +user db +root testdb call testdb.p1(); 1 1 connection default; disconnect testuser; -# check that the privilegas correctly read by acl_load +# check that the privileges are correctly read by acl_load flush privileges; connect testuser,localhost,testuser,,; -connection testuser; -SHOW PROCESSLIST; -Id User Host db Command Time State Info Progress -# root # testdb Sleep # # NULL 0.000 -# testuser # NULL Query # # SHOW PROCESSLIST 0.000 +select user,db from information_schema.processlist where user='root'; +user db +root testdb call testdb.p1(); 1 1 connection default; -SHOW PROCESSLIST; -Id User Host db Command Time State Info Progress -# root # testdb Query # # SHOW PROCESSLIST 0.000 -# testuser # NULL Sleep # # NULL 0.000 -connection default; use test; disconnect testuser; REVOKE PROCESS ON *.* from PUBLIC; @@ -126,21 +123,17 @@ drop database testdb; create user testuser; create database testdb; connect testuser,localhost,testuser,,; -connection testuser; use testdb; ERROR 42000: Access denied for user 'testuser'@'%' to database 'testdb' connection default; GRANT LOCK TABLES ON testdb.* to PUBLIC; -disconnect testuser; -connect testuser,localhost,testuser,,; connection testuser; use testdb; connection default; disconnect testuser; -# check that the privilegas correctly read by acl_load +# check that the privileges are correctly read by acl_load flush privileges; connect testuser,localhost,testuser,,; -connection testuser; use testdb; connection default; use test; @@ -159,14 +152,11 @@ create table t1 (a int); insert into t1 values (1); GRANT LOCK TABLES ON testdb.* to PUBLIC; connect testuser,localhost,testuser,,; -connection testuser; use testdb; update t1 set a=a+1; ERROR 42000: UPDATE command denied to user 'testuser'@'localhost' for table `testdb`.`t1` connection default; GRANT UPDATE,SELECT ON testdb.* to PUBLIC; -disconnect testuser; -connect testuser,localhost,testuser,,; connection testuser; use testdb; update t1 set a=a+1; @@ -193,7 +183,6 @@ create table t2 (a int, b int); insert into t2 values (1,2); GRANT LOCK TABLES ON testdb.* to PUBLIC; connect testuser,localhost,testuser,,; -connection testuser; use testdb; delete from t1; ERROR 42000: DELETE command denied to user 'testuser'@'localhost' for table `testdb`.`t1` @@ -204,8 +193,6 @@ ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `tes connection default; GRANT DELETE ON testdb.t1 to PUBLIC; GRANT SELECT (a) ON testdb.t2 to PUBLIC; -disconnect testuser; -connect testuser,localhost,testuser,,; connection testuser; use testdb; delete from t1; @@ -219,10 +206,9 @@ select * from testdb.t1; a insert into t1 values (1); disconnect testuser; -# check that the privilegas correctly read by acl_load +# check that the privileges are correctly read by acl_load flush privileges; connect testuser,localhost,testuser,,; -connection testuser; use testdb; delete from t1; select a from t2; @@ -248,25 +234,21 @@ create database testdb; use testdb; create function f1() returns int return 2; connect testuser,localhost,testuser,,; -connection testuser; alter function testdb.f1 comment "A stupid function"; ERROR 42000: alter routine command denied to user 'testuser'@'%' for routine 'testdb.f1' select testdb.f1(); ERROR 42000: execute command denied to user 'testuser'@'%' for routine 'testdb.f1' connection default; GRANT ALTER ROUTINE ON testdb.* to PUBLIC; -disconnect testuser; -connect testuser,localhost,testuser,,; connection testuser; alter function testdb.f1 comment "A stupid function"; select testdb.f1(); ERROR 42000: execute command denied to user 'testuser'@'%' for routine 'testdb.f1' connection default; disconnect testuser; -# check that the privilegas correctly read by acl_load +# check that the privileges are correctly read by acl_load flush privileges; connect testuser,localhost,testuser,,; -connection testuser; alter function testdb.f1 comment "A stupid function"; select testdb.f1(); ERROR 42000: execute command denied to user 'testuser'@'%' for routine 'testdb.f1' @@ -291,7 +273,6 @@ use testdb1; create table t1 (a int, b int); insert into t1 values (1,2); connect testuser,localhost,testuser,,; -connection testuser; select * from testdb1.t1; ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb1`.`t1` connection default; @@ -307,33 +288,27 @@ use testdb1; create table t1 (a int, b int); # check that user do not have rights connect testuser,localhost,testuser,,*NO-ONE*; -connection testuser; select * from testdb1.t1; ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb1`.`t1` connection default; -disconnect testuser; give rights to everyone via assigning the role to public create role roletest; GRANT SELECT ON testdb1.* TO roletest; GRANT roletest TO PUBLIC; -connect testuser,localhost,testuser,,*NO-ONE*; connection testuser; select * from testdb1.t1; a b connection default; disconnect testuser; -# check that the privilegas correctly read by acl_load +# check that the privileges are correctly read by acl_load flush privileges; connect testuser,localhost,testuser,,*NO-ONE*; -connection testuser; select * from testdb1.t1; a b connection default; -disconnect testuser; # drop role... drop role roletest; -# ... and check that user do not have rights again -connect testuser,localhost,testuser,,*NO-ONE*; +# ... and check that user does not have rights again connection testuser; select * from testdb1.t1; ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table `testdb1`.`t1` diff --git a/mysql-test/main/public_privileges.test b/mysql-test/main/public_privileges.test index 2de23b5c81adf..e6f803f1038e6 100644 --- a/mysql-test/main/public_privileges.test +++ b/mysql-test/main/public_privileges.test @@ -1,3 +1,8 @@ +--source include/not_embedded.inc +--echo # +--echo # MDEV-5215 Granted to PUBLIC +--echo # + --echo # --echo # Test DB/TABLE/COLUMN privileges in queries --echo # @@ -17,7 +22,6 @@ create table t3 (a int, b int); insert into t3 values (1,2); connect (testuser,localhost,testuser,,); -connection testuser; --error ER_TABLEACCESS_DENIED_ERROR select * from testdb1.t1; --error ER_TABLEACCESS_DENIED_ERROR @@ -33,8 +37,6 @@ GRANT SELECT ON testdb1.* to PUBLIC; GRANT SELECT ON testdb2.t2 to PUBLIC; GRANT SELECT (b) ON testdb2.t3 to PUBLIC; -disconnect testuser; -connect (testuser,localhost,testuser,,); connection testuser; select * from testdb1.t1; select * from testdb2.t2; @@ -42,14 +44,16 @@ select b from testdb2.t3; --error ER_COLUMNACCESS_DENIED_ERROR select a from testdb2.t3; +show grants; +show grants for testuser@'%'; + connection default; disconnect testuser; ---echo # check that the privilegas correctly read by acl_load +--echo # check that the privileges are correctly read by acl_load flush privileges; connect (testuser,localhost,testuser,,); -connection testuser; select * from testdb1.t1; select * from testdb2.t2; select b from testdb2.t3; @@ -76,10 +80,8 @@ use testdb; create procedure p1 () select 1; connect (testuser,localhost,testuser,,); -connection testuser; ---replace_column 1 # 3 # 6 # 7 # -SHOW PROCESSLIST; +select user,db from information_schema.processlist where user='root'; --error ER_PROCACCESS_DENIED_ERROR call testdb.p1(); @@ -88,34 +90,25 @@ connection default; GRANT PROCESS ON *.* to PUBLIC; GRANT EXECUTE ON testdb.* to PUBLIC; +# need to reconnect because of PROCESS disconnect testuser; connect (testuser,localhost,testuser,,); -connection testuser; ---replace_column 1 # 3 # 6 # 7 # -SHOW PROCESSLIST; +select user,db from information_schema.processlist where user='root'; call testdb.p1(); connection default; disconnect testuser; ---echo # check that the privilegas correctly read by acl_load +--echo # check that the privileges are correctly read by acl_load flush privileges; connect (testuser,localhost,testuser,,); -connection testuser; ---replace_column 1 # 3 # 6 # 7 # -SHOW PROCESSLIST; +select user,db from information_schema.processlist where user='root'; call testdb.p1(); connection default; - ---replace_column 1 # 3 # 6 # 7 # -SHOW PROCESSLIST; - -connection default; - use test; disconnect testuser; REVOKE PROCESS ON *.* from PUBLIC; @@ -131,7 +124,6 @@ create user testuser; create database testdb; connect (testuser,localhost,testuser,,); -connection testuser; --error ER_DBACCESS_DENIED_ERROR use testdb; @@ -140,8 +132,6 @@ connection default; GRANT LOCK TABLES ON testdb.* to PUBLIC; -disconnect testuser; -connect (testuser,localhost,testuser,,); connection testuser; use testdb; @@ -149,11 +139,10 @@ use testdb; connection default; disconnect testuser; ---echo # check that the privilegas correctly read by acl_load +--echo # check that the privileges are correctly read by acl_load flush privileges; connect (testuser,localhost,testuser,,); -connection testuser; use testdb; @@ -179,7 +168,6 @@ insert into t1 values (1); GRANT LOCK TABLES ON testdb.* to PUBLIC; connect (testuser,localhost,testuser,,); -connection testuser; use testdb; --error ER_TABLEACCESS_DENIED_ERROR @@ -189,8 +177,6 @@ connection default; GRANT UPDATE,SELECT ON testdb.* to PUBLIC; -disconnect testuser; -connect (testuser,localhost,testuser,,); connection testuser; use testdb; @@ -222,7 +208,6 @@ insert into t2 values (1,2); GRANT LOCK TABLES ON testdb.* to PUBLIC; connect (testuser,localhost,testuser,,); -connection testuser; use testdb; --error ER_TABLEACCESS_DENIED_ERROR @@ -237,8 +222,6 @@ connection default; GRANT DELETE ON testdb.t1 to PUBLIC; GRANT SELECT (a) ON testdb.t2 to PUBLIC; -disconnect testuser; -connect (testuser,localhost,testuser,,); connection testuser; use testdb; @@ -252,11 +235,10 @@ select * from testdb.t1; insert into t1 values (1); disconnect testuser; ---echo # check that the privilegas correctly read by acl_load +--echo # check that the privileges are correctly read by acl_load flush privileges; connect (testuser,localhost,testuser,,); -connection testuser; use testdb; delete from t1; @@ -286,7 +268,6 @@ use testdb; create function f1() returns int return 2; connect (testuser,localhost,testuser,,); -connection testuser; --error ER_PROCACCESS_DENIED_ERROR alter function testdb.f1 comment "A stupid function"; @@ -297,8 +278,6 @@ connection default; GRANT ALTER ROUTINE ON testdb.* to PUBLIC; -disconnect testuser; -connect (testuser,localhost,testuser,,); connection testuser; alter function testdb.f1 comment "A stupid function"; @@ -308,11 +287,10 @@ select testdb.f1(); connection default; disconnect testuser; ---echo # check that the privilegas correctly read by acl_load +--echo # check that the privileges are correctly read by acl_load flush privileges; connect (testuser,localhost,testuser,,); -connection testuser; alter function testdb.f1 comment "A stupid function"; --error ER_PROCACCESS_DENIED_ERROR @@ -345,7 +323,6 @@ create table t1 (a int, b int); insert into t1 values (1,2); connect (testuser,localhost,testuser,,); -connection testuser; --error ER_TABLEACCESS_DENIED_ERROR select * from testdb1.t1; @@ -365,38 +342,32 @@ create table t1 (a int, b int); --echo # check that user do not have rights connect (testuser,localhost,testuser,,*NO-ONE*); -connection testuser; --error ER_TABLEACCESS_DENIED_ERROR select * from testdb1.t1; connection default; -disconnect testuser; --echo give rights to everyone via assigning the role to public create role roletest; GRANT SELECT ON testdb1.* TO roletest; GRANT roletest TO PUBLIC; -connect (testuser,localhost,testuser,,*NO-ONE*); connection testuser; select * from testdb1.t1; connection default; disconnect testuser; ---echo # check that the privilegas correctly read by acl_load +--echo # check that the privileges are correctly read by acl_load flush privileges; connect (testuser,localhost,testuser,,*NO-ONE*); -connection testuser; select * from testdb1.t1; connection default; -disconnect testuser; --echo # drop role... drop role roletest; ---echo # ... and check that user do not have rights again -connect (testuser,localhost,testuser,,*NO-ONE*); +--echo # ... and check that user does not have rights again connection testuser; --error ER_TABLEACCESS_DENIED_ERROR select * from testdb1.t1; diff --git a/mysql-test/suite/perfschema/r/connection_type_win.result b/mysql-test/suite/perfschema/r/connection_type_win.result index 8dc064babff73..c6c8b6cc77b31 100644 --- a/mysql-test/suite/perfschema/r/connection_type_win.result +++ b/mysql-test/suite/perfschema/r/connection_type_win.result @@ -55,7 +55,7 @@ select user_host, command_type, argument from mysql.general_log where command_type = "Connect"; user_host [root] @ santa.claus.ipv4.example.com [192.0.2.4] command_type Connect -argument root@santa.claus.ipv4.example.com on test using TCP/IP +argument root@santa.claus.ipv4.example.com on using TCP/IP user_host [root] @ santa.claus.ipv4.example.com [192.0.2.4] command_type Connect argument root@santa.claus.ipv4.example.com on test using TCP/IP @@ -65,7 +65,6 @@ argument rootssl@santa.claus.ipv4.example.com on test using SSL/TLS select substring(argument, locate("Connect", argument)) from test_log where argument like "%Connect%on test%"; substring(argument, locate("Connect", argument)) Connect root@santa.claus.ipv4.example.com on test using TCP/IP -substring(argument, locate("Connect", argument)) Connect root@santa.claus.ipv4.example.com on test using TCP/IP substring(argument, locate("Connect", argument)) Connect rootssl@santa.claus.ipv4.example.com on test using SSL/TLS DROP TABLE test_log; SET GLOBAL general_log_file= @old_general_log_file; diff --git a/mysql-test/suite/roles/none_public.result b/mysql-test/suite/roles/none_public.result index 4acba8bd13345..bb8e3c0782a6d 100644 --- a/mysql-test/suite/roles/none_public.result +++ b/mysql-test/suite/roles/none_public.result @@ -5,6 +5,8 @@ create role public; ERROR OP000: Invalid role specification `public` drop role none; ERROR HY000: Operation DROP ROLE failed for 'none' +drop role public; +ERROR HY000: Operation DROP ROLE failed for PUBLIC grant none to role1; ERROR OP000: Invalid role specification `none` grant role1 to none; @@ -14,6 +16,7 @@ ERROR OP000: Invalid role specification `none` grant public to role1; ERROR OP000: Invalid role specification `public` grant role1 to public; +grant select on *.* to public; grant role1 to current_role; ERROR OP000: Invalid role specification `NONE` revoke none from role1; @@ -25,13 +28,43 @@ ERROR OP000: Invalid role specification `none` revoke public from role1; ERROR OP000: Invalid role specification `public` revoke role1 from public; -ERROR HY000: Cannot revoke role 'role1' from: 'public'@'%' revoke select on *.* from public; show grants for none; ERROR OP000: Invalid role specification `none` +show grants for public; +Grants for PUBLIC create definer=none view test.v1 as select 1; ERROR OP000: Invalid role specification `none` +create definer=public view test.v1 as select 1; +ERROR OP000: Invalid role specification `public` drop role role1; +create user foo@localhost; +connect foo,localhost,foo; +set default role public; +ERROR OP000: Invalid role specification `public` +disconnect foo; +connection default; +update mysql.global_priv set priv=json_insert(priv, '$.default_role', 'none') where user='foo'; +connect foo,localhost,foo; +show grants; +Grants for foo@localhost +GRANT USAGE ON *.* TO `foo`@`localhost` +select * from information_schema.enabled_roles; +ROLE_NAME +NULL +disconnect foo; +connection default; +update mysql.global_priv set priv=json_insert(priv, '$.default_role', 'public') where user='foo'; +connect foo,localhost,foo; +show grants; +Grants for foo@localhost +GRANT USAGE ON *.* TO `foo`@`localhost` +select * from information_schema.enabled_roles; +ROLE_NAME +NULL +disconnect foo; +connection default; +drop user foo@localhost; insert mysql.global_priv values ('', 'none', '{"is_role":true}'); flush privileges; Warnings: diff --git a/mysql-test/suite/roles/none_public.test b/mysql-test/suite/roles/none_public.test index 21e9dacf16653..e88ed45c492aa 100644 --- a/mysql-test/suite/roles/none_public.test +++ b/mysql-test/suite/roles/none_public.test @@ -8,6 +8,8 @@ create role none; create role public; --error ER_CANNOT_USER drop role none; +--error ER_CANNOT_USER +drop role public; --error ER_INVALID_ROLE grant none to role1; @@ -18,9 +20,7 @@ grant select on *.* to none; --error ER_INVALID_ROLE grant public to role1; grant role1 to public; -# PUBLIC is legal role -#--error ER_INVALID_ROLE -#grant select on *.* to public; +grant select on *.* to public; --error ER_INVALID_ROLE grant role1 to current_role; @@ -33,24 +33,43 @@ revoke role1 from none; revoke select on *.* from none; --error ER_INVALID_ROLE revoke public from role1; ---error ER_CANNOT_REVOKE_ROLE revoke role1 from public; revoke select on *.* from public; --error ER_INVALID_ROLE show grants for none; -# PUBLIC is legal role -#--error ER_INVALID_ROLE -#show grants for public; +show grants for public; --error ER_INVALID_ROLE create definer=none view test.v1 as select 1; -# PUBLIC is legal role -#--error ER_INVALID_ROLE -#create definer=public view test.v1 as select 1; +--error ER_INVALID_ROLE +create definer=public view test.v1 as select 1; drop role role1; +create user foo@localhost; +connect foo,localhost,foo; +--error ER_INVALID_ROLE +set default role public; +disconnect foo; + +connection default; +update mysql.global_priv set priv=json_insert(priv, '$.default_role', 'none') where user='foo'; +connect foo,localhost,foo; +show grants; +select * from information_schema.enabled_roles; +disconnect foo; + +connection default; +update mysql.global_priv set priv=json_insert(priv, '$.default_role', 'public') where user='foo'; +connect foo,localhost,foo; +show grants; +select * from information_schema.enabled_roles; +disconnect foo; + +connection default; +drop user foo@localhost; + insert mysql.global_priv values ('', 'none', '{"is_role":true}'); flush privileges; delete from mysql.global_priv where host=''; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 4713787ade858..487f4c5d3dc40 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3352,11 +3352,12 @@ static int check_user_can_set_role(THD *thd, const char *user, } if (access) - { *access = acl_user->access | role->access; - } end: + if (acl_public && access) + *access|= acl_public->access; + mysql_mutex_unlock(&acl_cache->lock); /* We present different error messages depending if the user has sufficient @@ -3438,10 +3439,6 @@ int acl_setrole(THD *thd, const char *rolename, privilege_t access) if (thd->db.str) sctx->db_access= acl_get_all3(sctx, thd->db.str, FALSE); - // PUBLIC magic - if (acl_public) - sctx->master_access|= acl_public->access; - return 0; } @@ -3459,8 +3456,7 @@ static void acl_update_role(const char *rolename, const privilege_t privileges) if (role) { role->initial_role_access= role->access= privileges; - if (strcasecmp(rolename, public_name.str) == 0) - acl_public= role; + DBUG_ASSERT(strcasecmp(rolename, public_name.str) || acl_public == role); } } @@ -3716,8 +3712,7 @@ privilege_t acl_get(const char *host, const char *ip, if (acl_db->host.hostname) goto exit; // Fully specified. Take it /* the host table is not used for roles */ - if ((!host || !host[0]) && - !acl_db->host.hostname && + if ((!host || !host[0]) && !acl_db->host.hostname && find_acl_role(user, false)) goto exit; } @@ -4370,7 +4365,7 @@ int acl_set_default_role(THD *thd, const char *host, const char *user, /* - Find user in ACL + Find user in ACL. Uses to check a definer SYNOPSIS is_acl_user() @@ -4378,8 +4373,8 @@ int acl_set_default_role(THD *thd, const char *host, const char *user, user user name RETURN - FALSE user not fond - TRUE there is such user + FALSE definer not fond + TRUE there is such definer */ bool is_acl_user(const char *host, const char *user) @@ -4454,17 +4449,17 @@ static ACL_ROLE *find_acl_role(const char *role, bool allow_public) mysql_mutex_assert_owner(&acl_cache->lock); - if (!length || (!allow_public && - length == public_name.length && + if (!length || (!allow_public && length == public_name.length && strcasecmp(role, public_name.str) == 0)) DBUG_RETURN(NULL); - ACL_ROLE *r= (ACL_ROLE *)my_hash_search(&acl_roles, (uchar *)role, - length); + ACL_ROLE *r= (ACL_ROLE *)my_hash_search(&acl_roles, (uchar *)role, length); DBUG_RETURN(r); } - +/* + Finds a grantee - something that privileges or roles can be granted to. +*/ static ACL_USER_BASE *find_acl_user_base(const char *user, const char *host) { if (*host) @@ -5950,9 +5945,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, uchar user_key[MAX_KEY_LENGTH]; DBUG_ENTER("replace_table_table"); DBUG_PRINT("enter", ("User: '%s' Host: '%s' Revoke:'%d'", - (combo.user.length ? combo.user.str : ""), - (combo.host.length ? combo.host.str : ""), - (int) revoke_grant)); + combo.user.str, combo.host.str, (int) revoke_grant)); get_grantor(thd, grantor); /* @@ -7272,10 +7265,10 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, continue; } /* Create user if needed */ - error= copy_and_check_auth(Str, tmp_Str, thd) || + error= copy_and_check_auth(Str, Str, thd) || replace_user_table(thd, tables.user_table(), Str, NO_ACL, revoke_grant, create_new_users, - MY_TEST(tmp_Str->is_public || + MY_TEST(!Str->is_public && (thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER))); if (unlikely(error)) @@ -7461,7 +7454,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, if (copy_and_check_auth(Str, tmp_Str, thd) || replace_user_table(thd, tables.user_table(), Str, NO_ACL, revoke_grant, create_new_users, - MY_TEST(thd->variables.sql_mode & + !Str->is_public && (thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER))) { result= TRUE; @@ -7629,8 +7622,7 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) rolename= granted_role->user; create_new_user= test_if_create_new_users(thd); - no_auto_create_user= MY_TEST(thd->variables.sql_mode & - MODE_NO_AUTO_CREATE_USER); + no_auto_create_user= thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER; Grant_tables tables; if ((result= tables.open_and_lock(thd, Table_user | Table_roles_mapping, TL_WRITE))) @@ -7669,8 +7661,7 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) result= 1; continue; } - if (!(role_as_user= find_acl_role(thd->security_ctx->priv_role, - true))) + if (!(role_as_user= find_acl_role(thd->security_ctx->priv_role, true))) { LEX_CSTRING ls= { thd->security_ctx->priv_role, strlen(thd->security_ctx->priv_role) }; @@ -7707,13 +7698,21 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) hostname= empty_clex_str; else { - if (check_role_name(username.str, true) == ROLE_NAME_INVALID) - { + switch (check_role_name(username.str, true)) { + case ROLE_NAME_INVALID: append_user(thd, &wrong_users, &username, &empty_clex_str); result= 1; continue; + case ROLE_NAME_PUBLIC: + user->user= username= public_name; // fix the letter case + user->host= hostname= empty_clex_str; + user->is_public= true; + role_as_user= acl_public; + break; + case ROLE_NAME_OK: + hostname= host_not_specified; + break; } - hostname= host_not_specified; } } @@ -7730,16 +7729,7 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) { LEX_USER user_combo = *user; user_combo.user = username; - user_combo.is_public= (user->host.length == 0 && - // it is also can be that - // hostname.length= 1 && hostname.str[0] == '%' - // if the PUBLIC was absent - username.length == public_name.length && - (strcasecmp(username.str, public_name.str) == 0)); - if (user_combo.is_public) - user_combo.host= hostname= empty_clex_str; - else - user_combo.host = hostname; + user_combo.host = hostname; if (copy_and_check_auth(&user_combo, &user_combo, thd) || replace_user_table(thd, tables.user_table(), &user_combo, NO_ACL, @@ -9602,6 +9592,12 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user) } } + if (username && rolename) // show everything, incl. PUBLIC + { + if (acl_public) + traverse_role_graph_down(acl_public, thd, show_grants_callback, NULL); + } + if (username) { /* Show default role to acl_user */ @@ -11908,6 +11904,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, thd->make_lex_string(&combo->host, combo->host.str, strlen(combo->host.str)); combo->auth= NULL; + combo->is_public= false; if (user_list.push_back(combo, thd->mem_root)) DBUG_RETURN(TRUE); @@ -12420,8 +12417,7 @@ SHOW_VAR acl_statistics[] = { hostname == NULL means we are looking for a role as a starting point, otherwise a user. */ -bool check_role_is_granted(const char *username, - const char *hostname, +bool check_role_is_granted(const char *username, const char *hostname, const char *rolename) { DBUG_ENTER("check_role_is_granted"); @@ -13005,6 +13001,8 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) if (!dup) return 0; + dup->is_public= false; + #ifndef NO_EMBEDDED_ACCESS_CHECKS if (has_auth(user, thd->lex)) { @@ -13017,11 +13015,16 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) if (result == ROLE_NAME_INVALID) return 0; if (result == ROLE_NAME_PUBLIC) + { dup->is_public= true; + dup->user= public_name; // fix the letter case + dup->host= empty_clex_str; + return dup; + } if (lock) mysql_mutex_lock(&acl_cache->lock); - if (find_acl_role(dup->user.str, false) || dup->is_public) + if (find_acl_role(dup->user.str, false)) dup->host= empty_clex_str; else dup->host= host_not_specified; @@ -15088,5 +15091,3 @@ extern "C" void maria_update_hostname( *ip_mask= h.ip_mask; #endif } - - diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 68dfa249449c1..78c2e682af0d0 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6033,6 +6033,7 @@ void THD::get_definer(LEX_USER *definer, bool role) definer->user= invoker.user; definer->host= invoker.host; definer->auth= NULL; + definer->is_public= false; } else #endif diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7025b7214b3fe..d3101bf0c13ad 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2798,9 +2798,15 @@ bool sp_process_definer(THD *thd) } else { - LEX_USER *d= lex->definer= get_current_user(thd, lex->definer); + LEX_USER *d= get_current_user(thd, lex->definer); if (!d) DBUG_RETURN(TRUE); + if (d->is_public) + { + my_error(ER_INVALID_ROLE, MYF(0), lex->definer->user.str); + DBUG_RETURN(TRUE); + } + lex->definer= d; /* If the specified definer differs from the current user or role, we @@ -2823,12 +2829,9 @@ bool sp_process_definer(THD *thd) #ifndef NO_EMBEDDED_ACCESS_CHECKS if (!is_acl_user(lex->definer->host.str, lex->definer->user.str)) { - push_warning_printf(thd, - Sql_condition::WARN_LEVEL_NOTE, - ER_NO_SUCH_USER, - ER_THD(thd, ER_NO_SUCH_USER), - lex->definer->user.str, - lex->definer->host.str); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_NO_SUCH_USER, ER_THD(thd, ER_NO_SUCH_USER), + lex->definer->user.str, lex->definer->host.str); } #endif /* NO_EMBEDDED_ACCESS_CHECKS */ @@ -3120,8 +3123,7 @@ mysql_create_routine(THD *thd, LEX *lex) */ if (thd->slave_thread && is_acl_user(definer->host.str, definer->user.str)) { - security_context.change_security_context(thd, - &thd->lex->definer->user, + security_context.change_security_context(thd, &thd->lex->definer->user, &thd->lex->definer->host, &thd->lex->sphead->m_db, &backup); @@ -10062,6 +10064,7 @@ void get_default_definer(THD *thd, LEX_USER *definer, bool role) } definer->user.length= strlen(definer->user.str); definer->auth= NULL; + definer->is_public= false; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2c36ee5ab2dd4..5d0a2455228ee 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -13814,7 +13814,7 @@ show_param: { Lex->sql_command= SQLCOM_SHOW_GRANTS; if (unlikely(!(Lex->grant_user= - (LEX_USER*)thd->alloc(sizeof(LEX_USER))))) + (LEX_USER*)thd->calloc(sizeof(LEX_USER))))) MYSQL_YYABORT; Lex->grant_user->user= current_user_and_current_role; } @@ -13923,7 +13923,7 @@ show_param: { Lex->sql_command= SQLCOM_SHOW_CREATE_USER; if (unlikely(!(Lex->grant_user= - (LEX_USER*)thd->alloc(sizeof(LEX_USER))))) + (LEX_USER*)thd->calloc(sizeof(LEX_USER))))) MYSQL_YYABORT; Lex->grant_user->user= current_user; } @@ -17138,7 +17138,6 @@ current_role: if (unlikely(!($$=(LEX_USER*) thd->calloc(sizeof(LEX_USER))))) MYSQL_YYABORT; $$->user= current_role; - $$->auth= NULL; } ; @@ -17151,12 +17150,10 @@ grant_role: ((char*) $1.str)[$1.length] = '\0'; if (unlikely($1.length == 0)) my_yyabort_error((ER_INVALID_ROLE, MYF(0), "")); - if (unlikely(!($$=(LEX_USER*) thd->alloc(sizeof(LEX_USER))))) + if (unlikely(!($$=(LEX_USER*) thd->calloc(sizeof(LEX_USER))))) MYSQL_YYABORT; $$->user= $1; $$->host= empty_clex_str; - $$->auth= NULL; - $$->is_public= false; if (unlikely(check_string_char_length(&$$->user, ER_USERNAME, username_char_length, From 0b519a40751e1830b9a23016f398cd70b4dcd175 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 24 Sep 2022 11:26:08 +0200 Subject: [PATCH 082/113] cleanup --- sql/sql_acl.cc | 28 +++++++++++----------------- sql/sql_class.cc | 6 +----- sql/sql_yacc.yy | 3 +-- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 487f4c5d3dc40..b8bb8343eba91 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -281,8 +281,8 @@ class ACL_ROLE :public ACL_USER_BASE uint counter; DYNAMIC_ARRAY parent_grantee; // array of backlinks to elements granted - ACL_ROLE(ACL_USER * user, MEM_ROOT *mem); - ACL_ROLE(const char * rolename, privilege_t privileges, MEM_ROOT *mem); + ACL_ROLE(ACL_USER *user); + ACL_ROLE(const char *rolename, privilege_t privileges, MEM_ROOT *mem); }; @@ -2182,7 +2182,7 @@ enum enum_acl_lists ROLES_MAPPINGS_HASH }; -ACL_ROLE::ACL_ROLE(ACL_USER *user, MEM_ROOT *root) +ACL_ROLE::ACL_ROLE(ACL_USER *user) : /* set initial role access the same as the table row privileges */ initial_role_access(user->access), @@ -2194,9 +2194,8 @@ ACL_ROLE::ACL_ROLE(ACL_USER *user, MEM_ROOT *root) flags= IS_ROLE; } -ACL_ROLE::ACL_ROLE(const char * rolename, privilege_t privileges, - MEM_ROOT *root) : - initial_role_access(privileges), counter(0) +ACL_ROLE::ACL_ROLE(const char *rolename, privilege_t privileges, MEM_ROOT *root) + : initial_role_access(privileges), counter(0) { this->access= initial_role_access; this->user.str= safe_strdup_root(root, rolename); @@ -2666,7 +2665,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables) continue; } - ACL_ROLE *entry= new (&acl_memroot) ACL_ROLE(&user, &acl_memroot); + ACL_ROLE *entry= new (&acl_memroot) ACL_ROLE(&user); entry->role_grants = user.role_grants; my_init_dynamic_array(key_memory_acl_mem, &entry->parent_grantee, sizeof(ACL_USER_BASE *), 0, 8, MYF(0)); @@ -8518,16 +8517,13 @@ void GRANT_INFO::read(const Security_context *sctx, grant_table_user= grant_table_role= grant_public= NULL; #else grant_table_user= - table_hash_search(sctx->host, sctx->ip, db, - sctx->priv_user, + table_hash_search(sctx->host, sctx->ip, db, sctx->priv_user, table, FALSE); /* purecov: inspected */ grant_table_role= - sctx->priv_role[0] ? table_hash_search("", NULL, db, - sctx->priv_role, + sctx->priv_role[0] ? table_hash_search("", NULL, db, sctx->priv_role, table, TRUE) : NULL; grant_public= - acl_public ? table_hash_search("", NULL, db, - public_name.str, + acl_public ? table_hash_search("", NULL, db, public_name.str, table, TRUE) : NULL; #endif version= grant_version; /* purecov: inspected */ @@ -11211,8 +11207,7 @@ bool mysql_drop_user(THD *thd, List &list, bool handle_as_role) int rc; user_name= get_current_user(thd, tmp_user_name, false); if (!user_name || (handle_as_role && - (strcasecmp(user_name->user.str, - public_name.str) == 0))) + (strcasecmp(user_name->user.str, public_name.str) == 0))) { thd->clear_error(); if (!user_name) @@ -13010,8 +13005,7 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) return dup; } - role_name_check_result result= check_role_name(user->user.str, - user->host.length == 0); + role_name_check_result result= check_role_name(user->user.str, true); if (result == ROLE_NAME_INVALID) return 0; if (result == ROLE_NAME_PUBLIC) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 78c2e682af0d0..5d51ed00ebc2f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6024,11 +6024,7 @@ void THD::get_definer(LEX_USER *definer, bool role) { binlog_invoker(role); #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) -#ifdef WITH_WSREP - if ((wsrep_applier || slave_thread) && has_invoker()) -#else - if (slave_thread && has_invoker()) -#endif + if ((IF_WSREP(wsrep_applier, 0) || slave_thread) && has_invoker()) { definer->user= invoker.user; definer->host= invoker.host; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 5d0a2455228ee..d064576e48aad 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -17156,8 +17156,7 @@ grant_role: $$->host= empty_clex_str; if (unlikely(check_string_char_length(&$$->user, ER_USERNAME, - username_char_length, - cs, 0))) + username_char_length, cs, 0))) MYSQL_YYABORT; } | current_role From 00c56e1c7c6cac21c583a57f40b87b9113adeffd Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 24 Sep 2022 22:38:12 +0200 Subject: [PATCH 083/113] compare public_name by pointer print PUBLIC not quoted in SHOW GRANTS, PUBLIC is not a role --- mysql-test/main/public_basic.result | 16 ++-- mysql-test/main/public_privileges.result | 6 +- mysql-test/suite/roles/none_public.result | 16 ++-- sql/sql_acl.cc | 107 ++++++++++++---------- sql/sql_acl.h | 2 + sql/sql_yacc.yy | 50 +++++----- 6 files changed, 107 insertions(+), 90 deletions(-) diff --git a/mysql-test/main/public_basic.result b/mysql-test/main/public_basic.result index 9506fdfff00c8..e7eb26ff68ee5 100644 --- a/mysql-test/main/public_basic.result +++ b/mysql-test/main/public_basic.result @@ -19,20 +19,20 @@ Host User Priv PUBLIC {"access":0,"version_id":VERSION,"is_role":true} SHOW GRANTS FOR PUBLIC; Grants for PUBLIC -GRANT SELECT ON `test`.* TO `PUBLIC` -GRANT SELECT ON `mysql`.`db` TO `PUBLIC` +GRANT SELECT ON `test`.* TO PUBLIC +GRANT SELECT ON `mysql`.`db` TO PUBLIC GRANT UPDATE on test.* to PUBLIC; grant update on mysql.db to public; show grants for public; Grants for PUBLIC -GRANT SELECT, UPDATE ON `test`.* TO `PUBLIC` -GRANT SELECT, UPDATE ON `mysql`.`db` TO `PUBLIC` +GRANT SELECT, UPDATE ON `test`.* TO PUBLIC +GRANT SELECT, UPDATE ON `mysql`.`db` TO PUBLIC revoke select on test.* from public; REVOKE SELECT on mysql.db from PUBLIC; SHOW GRANTS FOR PUBLIC; Grants for PUBLIC -GRANT UPDATE ON `test`.* TO `PUBLIC` -GRANT UPDATE ON `mysql`.`db` TO `PUBLIC` +GRANT UPDATE ON `test`.* TO PUBLIC +GRANT UPDATE ON `mysql`.`db` TO PUBLIC REVOKE UPDATE on test.* from PUBLIC; REVOKE UPDATE on mysql.db from PUBLIC; SHOW GRANTS FOR PUBLIC; @@ -46,7 +46,7 @@ revoke xxxxxx from current_user; ERROR OP000: Invalid role specification `xxxxxx` # following should fail with the same error as above revoke public from current_user; -ERROR OP000: Invalid role specification `public` +ERROR OP000: Invalid role specification `PUBLIC` drop role XXXXXX; ERROR HY000: Operation DROP ROLE failed for 'XXXXXX' # following should fail with the same error as above @@ -63,7 +63,7 @@ ERROR OP000: Invalid role specification `XXXXXX` SET DEFAULT ROLE PUBLIC; ERROR OP000: Invalid role specification `PUBLIC` set default role public; -ERROR OP000: Invalid role specification `public` +ERROR OP000: Invalid role specification `PUBLIC` # # check prohibition of change security context to PUBLIC # diff --git a/mysql-test/main/public_privileges.result b/mysql-test/main/public_privileges.result index 5f48297e00978..2ecb3872a5a44 100644 --- a/mysql-test/main/public_privileges.result +++ b/mysql-test/main/public_privileges.result @@ -45,9 +45,9 @@ ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'a' show grants; Grants for testuser@% GRANT USAGE ON *.* TO `testuser`@`%` -GRANT SELECT ON `testdb1`.* TO `PUBLIC` -GRANT SELECT ON `testdb2`.`t2` TO `PUBLIC` -GRANT SELECT (b) ON `testdb2`.`t3` TO `PUBLIC` +GRANT SELECT ON `testdb1`.* TO PUBLIC +GRANT SELECT ON `testdb2`.`t2` TO PUBLIC +GRANT SELECT (b) ON `testdb2`.`t3` TO PUBLIC show grants for testuser@'%'; Grants for testuser@% GRANT USAGE ON *.* TO `testuser`@`%` diff --git a/mysql-test/suite/roles/none_public.result b/mysql-test/suite/roles/none_public.result index bb8e3c0782a6d..a6c896c9d2daf 100644 --- a/mysql-test/suite/roles/none_public.result +++ b/mysql-test/suite/roles/none_public.result @@ -1,32 +1,32 @@ create role role1; create role none; -ERROR OP000: Invalid role specification `none` +ERROR OP000: Invalid role specification `NONE` create role public; -ERROR OP000: Invalid role specification `public` +ERROR OP000: Invalid role specification `PUBLIC` drop role none; -ERROR HY000: Operation DROP ROLE failed for 'none' +ERROR HY000: Operation DROP ROLE failed for 'NONE' drop role public; ERROR HY000: Operation DROP ROLE failed for PUBLIC grant none to role1; -ERROR OP000: Invalid role specification `none` +ERROR OP000: Invalid role specification `NONE` grant role1 to none; ERROR OP000: Invalid role specification `none` grant select on *.* to none; ERROR OP000: Invalid role specification `none` grant public to role1; -ERROR OP000: Invalid role specification `public` +ERROR OP000: Invalid role specification `PUBLIC` grant role1 to public; grant select on *.* to public; grant role1 to current_role; ERROR OP000: Invalid role specification `NONE` revoke none from role1; -ERROR OP000: Invalid role specification `none` +ERROR OP000: Invalid role specification `NONE` revoke role1 from none; ERROR OP000: Invalid role specification `none` revoke select on *.* from none; ERROR OP000: Invalid role specification `none` revoke public from role1; -ERROR OP000: Invalid role specification `public` +ERROR OP000: Invalid role specification `PUBLIC` revoke role1 from public; revoke select on *.* from public; show grants for none; @@ -41,7 +41,7 @@ drop role role1; create user foo@localhost; connect foo,localhost,foo; set default role public; -ERROR OP000: Invalid role specification `public` +ERROR OP000: Invalid role specification `PUBLIC` disconnect foo; connection default; update mysql.global_priv set priv=json_insert(priv, '$.default_role', 'none') where user='foo'; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b8bb8343eba91..1bb58383654fe 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -105,6 +105,7 @@ LEX_CSTRING current_user= { STRING_WITH_LEN("*current_user") }; LEX_CSTRING current_role= { STRING_WITH_LEN("*current_role") }; LEX_CSTRING current_user_and_current_role= { STRING_WITH_LEN("*current_user_and_current_role") }; +LEX_CSTRING none= {STRING_WITH_LEN("NONE") }; LEX_CSTRING public_name= {STRING_WITH_LEN("PUBLIC") }; @@ -2198,8 +2199,13 @@ ACL_ROLE::ACL_ROLE(const char *rolename, privilege_t privileges, MEM_ROOT *root) : initial_role_access(privileges), counter(0) { this->access= initial_role_access; - this->user.str= safe_strdup_root(root, rolename); - this->user.length= strlen(rolename); + if (rolename == public_name.str) + this->user= public_name; + else + { + this->user.str= safe_strdup_root(root, rolename); + this->user.length= strlen(rolename); + } bzero(&parent_grantee, sizeof(parent_grantee)); flags= IS_ROLE; } @@ -2211,24 +2217,26 @@ enum role_name_check_result ROLE_NAME_INVALID }; -static role_name_check_result check_role_name(const char *str, +static role_name_check_result check_role_name(LEX_CSTRING *str, bool public_is_ok) { - if (*str) + if (str->length) { - if (strcasecmp(str, public_name.str) == 0) + if (str->length == public_name.length && + strcasecmp(str->str, public_name.str) == 0) { + *str= public_name; if (public_is_ok) return ROLE_NAME_PUBLIC; else goto error; } - if (strcasecmp(str, "NONE") != 0) + if (str->length != none.length || strcasecmp(str->str, none.str) != 0) return ROLE_NAME_OK; } error: - my_error(ER_INVALID_ROLE, MYF(0), str); + my_error(ER_INVALID_ROLE, MYF(0), str->str); return ROLE_NAME_INVALID; } @@ -2658,7 +2666,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables) if (is_role) { - role_name_check_result result= check_role_name(username, true); + role_name_check_result result= check_role_name(&user.user, true); if (result == ROLE_NAME_INVALID) { thd->clear_error(); // the warning is still issued @@ -3307,7 +3315,7 @@ static int check_user_can_set_role(THD *thd, const char *user, /* clear role privileges */ mysql_mutex_lock(&acl_cache->lock); - if (!strcasecmp(rolename, "NONE")) + if (!strcasecmp(rolename, none.str)) { /* have to clear the privileges */ /* get the current user */ @@ -3426,7 +3434,7 @@ int acl_setrole(THD *thd, const char *rolename, privilege_t access) /* merge the privileges */ Security_context *sctx= thd->security_ctx; sctx->master_access= access; - if (!strcasecmp(rolename, "NONE")) + if (!strcasecmp(rolename, none.str)) { thd->security_ctx->priv_role[0]= 0; } @@ -3589,7 +3597,8 @@ static void acl_insert_role(const char *rolename, privilege_t privileges) sizeof(ACL_ROLE *), 0, 8, MYF(0)); my_hash_insert(&acl_roles, (uchar *)entry); - if (strcasecmp(rolename, public_name.str) == 0) + DBUG_ASSERT(strcasecmp(rolename, public_name.str) || rolename == public_name.str); + if (rolename == public_name.str) acl_public= entry; DBUG_VOID_RETURN; @@ -4243,7 +4252,7 @@ int acl_set_default_role(THD *thd, const char *host, const char *user, DBUG_PRINT("enter",("host: '%s' user: '%s' rolename: '%s'", user, safe_str(host), safe_str(rolename))); - if (!strcasecmp(rolename, "NONE")) + if (!strcasecmp(rolename, none.str)) clear_role= TRUE; if (mysql_bin_log.is_open() || @@ -4448,8 +4457,7 @@ static ACL_ROLE *find_acl_role(const char *role, bool allow_public) mysql_mutex_assert_owner(&acl_cache->lock); - if (!length || (!allow_public && length == public_name.length && - strcasecmp(role, public_name.str) == 0)) + if (!length || (!allow_public && strcasecmp(role, public_name.str) == 0)) DBUG_RETURN(NULL); ACL_ROLE *r= (ACL_ROLE *)my_hash_search(&acl_roles, (uchar *)role, length); @@ -7655,8 +7663,8 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) /* current_role is NONE */ if (!thd->security_ctx->priv_role[0]) { - my_error(ER_INVALID_ROLE, MYF(0), "NONE"); - append_str(&wrong_users, STRING_WITH_LEN("NONE")); + my_error(ER_INVALID_ROLE, MYF(0), none.str); + append_str(&wrong_users, none.str, none.length); result= 1; continue; } @@ -7689,30 +7697,27 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) } else { - username= user->user; if (user->host.str) hostname= user->host; else - if ((role_as_user= find_acl_role(user->user.str, false))) - hostname= empty_clex_str; - else - { - switch (check_role_name(username.str, true)) { - case ROLE_NAME_INVALID: - append_user(thd, &wrong_users, &username, &empty_clex_str); - result= 1; - continue; - case ROLE_NAME_PUBLIC: - user->user= username= public_name; // fix the letter case - user->host= hostname= empty_clex_str; - user->is_public= true; - role_as_user= acl_public; - break; - case ROLE_NAME_OK: + switch (check_role_name(&user->user, true)) { + case ROLE_NAME_INVALID: + append_user(thd, &wrong_users, &user->user, &empty_clex_str); + result= 1; + continue; + case ROLE_NAME_PUBLIC: + user->host= hostname= empty_clex_str; + user->is_public= true; + role_as_user= acl_public; + break; + case ROLE_NAME_OK: + if ((role_as_user= find_acl_role(user->user.str, false))) + hostname= empty_clex_str; + else hostname= host_not_specified; - break; - } + break; } + username= user->user; } ROLE_GRANT_PAIR *hash_entry= find_role_grant_pair(&username, &hostname, @@ -9673,7 +9678,10 @@ static bool show_role_grants(THD *thd, const char *hostname, ACL_ROLE**)); append_identifier(thd, &grant, acl_role->user.str, acl_role->user.length); grant.append(STRING_WITH_LEN(" TO ")); - append_identifier(thd, &grant, acl_entry->user.str, acl_entry->user.length); + if (acl_entry == acl_public) + grant.append(public_name); + else + append_identifier(thd, &grant, acl_entry->user.str, acl_entry->user.length); if (!(acl_entry->flags & IS_ROLE)) { grant.append('@'); @@ -9715,9 +9723,7 @@ static bool show_global_privileges(THD *thd, ACL_USER_BASE *acl_entry, want_access= acl_entry->access; // suppress "GRANT USAGE ON *.* TO `PUBLIC`" - if (!(want_access & ~GRANT_ACL) && - acl_entry->user.length == public_name.length && - strcasecmp(acl_entry->user.str, public_name.str) == 0) + if (!(want_access & ~GRANT_ACL) && acl_entry == acl_public) return FALSE; if (test_all_bits(want_access, (GLOBAL_ACLS & ~ GRANT_ACL))) @@ -9741,7 +9747,10 @@ static bool show_global_privileges(THD *thd, ACL_USER_BASE *acl_entry, } } global.append (STRING_WITH_LEN(" ON *.* TO ")); - append_identifier(thd, &global, acl_entry->user.str, acl_entry->user.length); + if (acl_entry == acl_public) + global.append(public_name); + else + append_identifier(thd, &global, acl_entry->user.str, acl_entry->user.length); if (!handle_as_role) add_user_parameters(thd, &global, (ACL_USER *)acl_entry, @@ -9763,7 +9772,10 @@ static void add_to_user(THD *thd, String *result, const char *user, bool is_user, const char *host) { result->append(STRING_WITH_LEN(" TO ")); - append_identifier(thd, result, user, strlen(user)); + if (user == public_name.str) + result->append(public_name); + else + append_identifier(thd, result, user, strlen(user)); if (is_user) { result->append('@'); @@ -9982,9 +9994,8 @@ static bool show_table_and_column_privileges(THD *thd, const char *username, } -static int show_routine_grants(THD* thd, - const char *username, const char *hostname, - const Sp_handler *sph, +static int show_routine_grants(THD* thd, const char *username, + const char *hostname, const Sp_handler *sph, char *buff, int buffsize) { uint counter, index; @@ -11046,7 +11057,7 @@ bool mysql_create_user(THD *thd, List &list, bool handle_as_role) } if (handle_as_role && - (check_role_name(user_name->user.str, false) == ROLE_NAME_INVALID)) + (check_role_name(&user_name->user, false) == ROLE_NAME_INVALID)) { append_user(thd, &wrong_users, user_name); result= TRUE; @@ -11206,8 +11217,7 @@ bool mysql_drop_user(THD *thd, List &list, bool handle_as_role) { int rc; user_name= get_current_user(thd, tmp_user_name, false); - if (!user_name || (handle_as_role && - (strcasecmp(user_name->user.str, public_name.str) == 0))) + if (!user_name || (handle_as_role && user_name->is_public)) { thd->clear_error(); if (!user_name) @@ -13005,13 +13015,12 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) return dup; } - role_name_check_result result= check_role_name(user->user.str, true); + role_name_check_result result= check_role_name(&dup->user, true); if (result == ROLE_NAME_INVALID) return 0; if (result == ROLE_NAME_PUBLIC) { dup->is_public= true; - dup->user= public_name; // fix the letter case dup->host= empty_clex_str; return dup; } diff --git a/sql/sql_acl.h b/sql/sql_acl.h index d1597ca9f5a7c..ab98cfff36426 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -58,6 +58,8 @@ extern LEX_CSTRING host_not_specified; extern LEX_CSTRING current_user; extern LEX_CSTRING current_role; extern LEX_CSTRING current_user_and_current_role; +extern LEX_CSTRING none; +extern LEX_CSTRING public_name; static inline int access_denied_error_code(int passwd_used) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d064576e48aad..e789df01bf148 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1580,7 +1580,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); field_scale opt_field_scale %type user grant_user grant_role user_or_role current_role - admin_option_for_role user_maybe_role + admin_option_for_role user_maybe_role role_name %type opt_auth_str auth_expression auth_token text_or_password @@ -16686,12 +16686,12 @@ option_value_no_option_type: if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY))) MYSQL_YYABORT; } - | ROLE_SYM ident_or_text + | ROLE_SYM role_name { if (sp_create_assignment_lex(thd, $1.pos())) MYSQL_YYABORT; LEX *lex = Lex; - set_var_role *var= new (thd->mem_root) set_var_role($2); + set_var_role *var= new (thd->mem_root) set_var_role($2->user); if (unlikely(var == NULL) || unlikely(lex->var_list.push_back(var, thd->mem_root)) || unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY))) @@ -17141,26 +17141,32 @@ current_role: } ; -grant_role: - ident_or_text - { - CHARSET_INFO *cs= system_charset_info; - /* trim end spaces (as they'll be lost in mysql.user anyway) */ - $1.length= cs->lengthsp($1.str, $1.length); - ((char*) $1.str)[$1.length] = '\0'; - if (unlikely($1.length == 0)) - my_yyabort_error((ER_INVALID_ROLE, MYF(0), "")); - if (unlikely(!($$=(LEX_USER*) thd->calloc(sizeof(LEX_USER))))) - MYSQL_YYABORT; - $$->user= $1; - $$->host= empty_clex_str; - if (unlikely(check_string_char_length(&$$->user, ER_USERNAME, - username_char_length, cs, 0))) - MYSQL_YYABORT; - } - | current_role - ; +role_name: ident_or_text + { + CHARSET_INFO *cs= system_charset_info; + /* trim end spaces (as they'll be lost in mysql.user anyway) */ + $1.length= cs->lengthsp($1.str, $1.length); + ((char*) $1.str)[$1.length] = '\0'; + if (unlikely($1.length == 0)) + my_yyabort_error((ER_INVALID_ROLE, MYF(0), "")); + if (unlikely(!($$=(LEX_USER*) thd->calloc(sizeof(LEX_USER))))) + MYSQL_YYABORT; + if (lex_string_eq(&$1, &none)) + $$->user= none; + else if (lex_string_eq(&$1, &public_name)) + { + $$->user= public_name; + $$->is_public= true; + } + else if (check_string_char_length(&($$->user= $1), ER_USERNAME, + username_char_length, cs, 0)) + MYSQL_YYABORT; + $$->host= empty_clex_str; + } + ; + +grant_role: role_name | current_role ; opt_table: /* Empty */ From 5dc804c3bb30d6a629036f57a1dfcac8df041fef Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 1 Nov 2022 22:22:23 +0100 Subject: [PATCH 084/113] MDEV-29752 SHOW GRANTS for PUBLIC should work for all users --- mysql-test/main/public_privileges.result | 23 ++++++++++++++++++++ mysql-test/main/public_privileges.test | 27 ++++++++++++++++++++++++ sql/sql_acl.cc | 4 ++-- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/public_privileges.result b/mysql-test/main/public_privileges.result index 2ecb3872a5a44..dd5a9c796530c 100644 --- a/mysql-test/main/public_privileges.result +++ b/mysql-test/main/public_privileges.result @@ -319,3 +319,26 @@ drop database testdb1; # clean up delete from mysql.global_priv where user="PUBLIC"; flush privileges; +# +# MDEV-29752 SHOW GRANTS FOR PUBLIC should work for all users +# +create database dbtest; +create user `testuser`@`%`; +GRANT USAGE ON *.* TO `testuser`@`%`; +GRANT ALL PRIVILEGES ON `dbtest`.* TO `PUBLIC`; +connect testuser,localhost,testuser,,; +show grants for public; +Grants for PUBLIC +GRANT ALL PRIVILEGES ON `dbtest`.* TO PUBLIC +show grants for testuser; +Grants for testuser@% +GRANT USAGE ON *.* TO `testuser`@`%` +connection default; +disconnect testuser; +REVOKE ALL PRIVILEGES ON `dbtest`.* FROM `PUBLIC`; +REVOKE USAGE ON *.* FROM `testuser`@`%`; +drop user `testuser`@`%`; +drop database dbtest; +# clean up +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; diff --git a/mysql-test/main/public_privileges.test b/mysql-test/main/public_privileges.test index e6f803f1038e6..9465cc9bfaddf 100644 --- a/mysql-test/main/public_privileges.test +++ b/mysql-test/main/public_privileges.test @@ -380,3 +380,30 @@ drop database testdb1; -- echo # clean up delete from mysql.global_priv where user="PUBLIC"; flush privileges; + +--echo # +--echo # MDEV-29752 SHOW GRANTS FOR PUBLIC should work for all users +--echo # + +create database dbtest; +create user `testuser`@`%`; + +GRANT USAGE ON *.* TO `testuser`@`%`; +GRANT ALL PRIVILEGES ON `dbtest`.* TO `PUBLIC`; + +connect (testuser,localhost,testuser,,); + +show grants for public; +show grants for testuser; + +connection default; +disconnect testuser; + +REVOKE ALL PRIVILEGES ON `dbtest`.* FROM `PUBLIC`; +REVOKE USAGE ON *.* FROM `testuser`@`%`; +drop user `testuser`@`%`; +drop database dbtest; + +-- echo # clean up +delete from mysql.global_priv where user="PUBLIC"; +flush privileges; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1bb58383654fe..65cdd63f2ef35 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -7726,7 +7726,7 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) if (has_auth(user, thd->lex)) DBUG_ASSERT(!grantee); - else if (!grantee) + else if (!grantee && !user->is_public) grantee= find_user_exact(hostname.str, username.str); if (!grantee && !revoke) @@ -9464,7 +9464,7 @@ bool get_show_user(THD *thd, LEX_USER *lex_user, const char **username, if (lex_user->is_role()) { *rolename= lex_user->user.str; - do_check_access= strcmp(*rolename, sctx->priv_role); + do_check_access= !lex_user->is_public && strcmp(*rolename, sctx->priv_role); } else { From 0537ce4e9fab393c5941ddfc636b9022f106e36e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 24 Sep 2022 23:12:00 +0200 Subject: [PATCH 085/113] remove LEX_USER->is_public it's now redundant --- sql/sql_acl.cc | 32 +++++++++++++++----------------- sql/sql_class.cc | 1 - sql/sql_parse.cc | 3 +-- sql/sql_yacc.yy | 3 --- sql/structs.h | 1 - 5 files changed, 16 insertions(+), 24 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 65cdd63f2ef35..f6f7fb387a8fb 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -108,6 +108,9 @@ LEX_CSTRING current_user_and_current_role= LEX_CSTRING none= {STRING_WITH_LEN("NONE") }; LEX_CSTRING public_name= {STRING_WITH_LEN("PUBLIC") }; +static inline bool is_public(const char *l) { return l == public_name.str; } +static inline bool is_public(const LEX_CSTRING *l) { return is_public(l->str); } +static inline bool is_public(const LEX_USER *l) { return is_public(&l->user); } static plugin_ref old_password_plugin; static plugin_ref native_password_plugin; @@ -2199,7 +2202,7 @@ ACL_ROLE::ACL_ROLE(const char *rolename, privilege_t privileges, MEM_ROOT *root) : initial_role_access(privileges), counter(0) { this->access= initial_role_access; - if (rolename == public_name.str) + if (is_public(rolename)) this->user= public_name; else { @@ -3597,8 +3600,8 @@ static void acl_insert_role(const char *rolename, privilege_t privileges) sizeof(ACL_ROLE *), 0, 8, MYF(0)); my_hash_insert(&acl_roles, (uchar *)entry); - DBUG_ASSERT(strcasecmp(rolename, public_name.str) || rolename == public_name.str); - if (rolename == public_name.str) + DBUG_ASSERT(strcasecmp(rolename, public_name.str) || is_public(rolename)); + if (is_public(rolename)) acl_public= entry; DBUG_VOID_RETURN; @@ -7275,7 +7278,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, error= copy_and_check_auth(Str, Str, thd) || replace_user_table(thd, tables.user_table(), Str, NO_ACL, revoke_grant, create_new_users, - MY_TEST(!Str->is_public && + MY_TEST(!is_public(Str) && (thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER))); if (unlikely(error)) @@ -7461,7 +7464,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, if (copy_and_check_auth(Str, tmp_Str, thd) || replace_user_table(thd, tables.user_table(), Str, NO_ACL, revoke_grant, create_new_users, - !Str->is_public && (thd->variables.sql_mode & + !is_public(Str) && (thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER))) { result= TRUE; @@ -7707,7 +7710,6 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) continue; case ROLE_NAME_PUBLIC: user->host= hostname= empty_clex_str; - user->is_public= true; role_as_user= acl_public; break; case ROLE_NAME_OK: @@ -7726,7 +7728,7 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) if (has_auth(user, thd->lex)) DBUG_ASSERT(!grantee); - else if (!grantee && !user->is_public) + else if (!grantee && !is_public(user)) grantee= find_user_exact(hostname.str, username.str); if (!grantee && !revoke) @@ -7738,13 +7740,13 @@ bool mysql_grant_role(THD *thd, List &list, bool revoke) if (copy_and_check_auth(&user_combo, &user_combo, thd) || replace_user_table(thd, tables.user_table(), &user_combo, NO_ACL, false, create_new_user, - (!user_combo.is_public && no_auto_create_user))) + (!is_public(&user_combo) && no_auto_create_user))) { append_user(thd, &wrong_users, &username, &hostname); result= 1; continue; } - if (!user_combo.is_public) + if (!is_public(&user_combo)) grantee= find_user_exact(hostname.str, username.str); else grantee= role_as_user= acl_public; @@ -7913,7 +7915,7 @@ bool mysql_grant(THD *thd, const char *db, List &list, replace_user_table(thd, tables.user_table(), Str, (!db ? rights : NO_ACL), revoke_grant, create_new_users, - MY_TEST(!Str->is_public && + MY_TEST(!is_public(Str) && (thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER)))) result= true; @@ -9464,7 +9466,7 @@ bool get_show_user(THD *thd, LEX_USER *lex_user, const char **username, if (lex_user->is_role()) { *rolename= lex_user->user.str; - do_check_access= !lex_user->is_public && strcmp(*rolename, sctx->priv_role); + do_check_access= !is_public(lex_user) && strcmp(*rolename, sctx->priv_role); } else { @@ -9772,7 +9774,7 @@ static void add_to_user(THD *thd, String *result, const char *user, bool is_user, const char *host) { result->append(STRING_WITH_LEN(" TO ")); - if (user == public_name.str) + if (is_public(user)) result->append(public_name); else append_identifier(thd, result, user, strlen(user)); @@ -11217,7 +11219,7 @@ bool mysql_drop_user(THD *thd, List &list, bool handle_as_role) { int rc; user_name= get_current_user(thd, tmp_user_name, false); - if (!user_name || (handle_as_role && user_name->is_public)) + if (!user_name || (handle_as_role && is_public(user_name))) { thd->clear_error(); if (!user_name) @@ -11909,7 +11911,6 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, thd->make_lex_string(&combo->host, combo->host.str, strlen(combo->host.str)); combo->auth= NULL; - combo->is_public= false; if (user_list.push_back(combo, thd->mem_root)) DBUG_RETURN(TRUE); @@ -13006,8 +13007,6 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) if (!dup) return 0; - dup->is_public= false; - #ifndef NO_EMBEDDED_ACCESS_CHECKS if (has_auth(user, thd->lex)) { @@ -13020,7 +13019,6 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) return 0; if (result == ROLE_NAME_PUBLIC) { - dup->is_public= true; dup->host= empty_clex_str; return dup; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5d51ed00ebc2f..0c2ed1bf30241 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6029,7 +6029,6 @@ void THD::get_definer(LEX_USER *definer, bool role) definer->user= invoker.user; definer->host= invoker.host; definer->auth= NULL; - definer->is_public= false; } else #endif diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d3101bf0c13ad..7851e775c3544 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2801,7 +2801,7 @@ bool sp_process_definer(THD *thd) LEX_USER *d= get_current_user(thd, lex->definer); if (!d) DBUG_RETURN(TRUE); - if (d->is_public) + if (d->user.str == public_name.str) { my_error(ER_INVALID_ROLE, MYF(0), lex->definer->user.str); DBUG_RETURN(TRUE); @@ -10064,7 +10064,6 @@ void get_default_definer(THD *thd, LEX_USER *definer, bool role) } definer->user.length= strlen(definer->user.str); definer->auth= NULL; - definer->is_public= false; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e789df01bf148..0b09d52e21753 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -17155,10 +17155,7 @@ role_name: ident_or_text if (lex_string_eq(&$1, &none)) $$->user= none; else if (lex_string_eq(&$1, &public_name)) - { $$->user= public_name; - $$->is_public= true; - } else if (check_string_char_length(&($$->user= $1), ER_USERNAME, username_char_length, cs, 0)) MYSQL_YYABORT; diff --git a/sql/structs.h b/sql/structs.h index edecbf0888b51..b36f8e6a1a01a 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -254,7 +254,6 @@ struct AUTHID struct LEX_USER: public AUTHID { USER_AUTH *auth; - bool is_public; bool has_auth() { return auth && (auth->plugin.length || auth->auth_str.length || auth->pwtext.length); From 093ec49b6b6948ee8d5a560cd2f862e38844c223 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 21 Oct 2022 16:50:55 +0200 Subject: [PATCH 086/113] Add magic database access to test and test_% and removing the script from mysql-test-run. --- mysql-test/mariadb-test-run.pl | 5 ++--- scripts/mysql_test_db.sql | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index 16f4164061eb0..ff02689dfb022 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -3132,9 +3132,8 @@ sub mysql_install_db { # Append sys schema mtr_appendfile_to_file("$gis_sp_path/mysql_sys_schema.sql", $bootstrap_sql_file); - # Create test database - mtr_appendfile_to_file("$sql_dir/mysql_test_db.sql", - $bootstrap_sql_file); + + mtr_tofile($bootstrap_sql_file, "CREATE DATABASE IF NOT EXISTS test CHARACTER SET latin1 COLLATE latin1_swedish_ci;\n"); # mysql.gtid_slave_pos was created in InnoDB, but many tests # run without InnoDB. Alter it to Aria now diff --git a/scripts/mysql_test_db.sql b/scripts/mysql_test_db.sql index ea9fa95bd61b6..c83f2c44a4fae 100644 --- a/scripts/mysql_test_db.sql +++ b/scripts/mysql_test_db.sql @@ -15,6 +15,15 @@ CREATE DATABASE IF NOT EXISTS test CHARACTER SET latin1 COLLATE latin1_swedish_ci; +--- Fill "db" table with default grants for anyone to +--- access database 'test' and 'test_%' if "db" table didn't exist +INSERT INTO mysql.global_priv VALUES ('', 'PUBLIC', '{"access":0,"is_role":true}'); +CREATE TEMPORARY TABLE tmp_db LIKE db; +INSERT INTO tmp_db VALUES ('','test','PUBLIC','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','Y'); +INSERT INTO tmp_db VALUES ('','test\_%','PUBLIC','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','Y'); +INSERT INTO db SELECT * FROM tmp_db WHERE @had_db_table=0; +DROP TABLE tmp_db; + -- Anonymous user with no privileges. CREATE TEMPORARY TABLE tmp_user_anonymous LIKE global_priv; INSERT INTO tmp_user_anonymous (host,user) VALUES ('localhost',''); From 125e172a2bdfbf4e8c9700db4a353e67424b1352 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 20 May 2022 16:32:35 +0200 Subject: [PATCH 087/113] MDEV-26715 Windows/installer - allow passwordless login for root Allow passwordless login in addition to usual login with password, when creating 'root' user during install. The effect of that change is that "local administrators" group are allowed to connect as root user. This is done via gssapi authentication plugin. Clients that are not aware of gssapi client plugin, can still login with password credentials. --- .../main/mysql_install_db_win_admin.result | 12 +++++++++++ .../main/mysql_install_db_win_admin.test | 21 +++++++++++++++++++ mysql-test/main/mysqld--help.test | 2 +- mysql-test/mariadb-test-run.pl | 3 ++- plugin/auth_gssapi/CMakeLists.txt | 12 +++++++---- .../mysql-test/auth_gssapi/basic.result | 4 ---- .../mysql-test/auth_gssapi/basic.test | 5 ----- .../mysql-test/auth_gssapi/groups.result | 4 ---- .../mysql-test/auth_gssapi/groups.test | 7 ++----- .../mysql-test/auth_gssapi/multiauth.result | 4 ---- .../mysql-test/auth_gssapi/multiauth.test | 4 ---- .../mysql-test/auth_gssapi/suite.opt | 2 +- .../mysql-test/auth_gssapi/suite.pm | 3 ++- plugin/auth_gssapi/server_plugin.cc | 2 +- sql/mysql_install_db.cc | 5 ++++- 15 files changed, 54 insertions(+), 36 deletions(-) create mode 100644 mysql-test/main/mysql_install_db_win_admin.result create mode 100644 mysql-test/main/mysql_install_db_win_admin.test diff --git a/mysql-test/main/mysql_install_db_win_admin.result b/mysql-test/main/mysql_install_db_win_admin.result new file mode 100644 index 0000000000000..06d3d6779774e --- /dev/null +++ b/mysql-test/main/mysql_install_db_win_admin.result @@ -0,0 +1,12 @@ +use mysql; +Running bootstrap +Creating my.ini file +Removing default user +Allowing remote access for user root +Setting root password +Creation of the database was successful +# Kill the server +# restart: --datadir=MYSQLTEST_VARDIR/tmp/ddir +connect root,localhost,root,wrongpass,mysql; +# Kill the server +# restart diff --git a/mysql-test/main/mysql_install_db_win_admin.test b/mysql-test/main/mysql_install_db_win_admin.test new file mode 100644 index 0000000000000..a6b98f9705837 --- /dev/null +++ b/mysql-test/main/mysql_install_db_win_admin.test @@ -0,0 +1,21 @@ +--source include/windows.inc +--source include/check_windows_admin.inc +--source include/have_innodb.inc + +# Create database in tmp directory using mysql_install_db.exe, +# and start server from this directory. +let $ddir= $MYSQLTEST_VARDIR/tmp/ddir; +use mysql; +exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R; +--source include/kill_mysqld.inc +let $restart_parameters=--datadir=$ddir; +--source include/start_mysqld.inc + +# Check that connect with wrong password succeeds +connect (root,localhost,root,wrongpass,mysql); + +--source include/kill_mysqld.inc +let $restart_parameters=; +rmdir $ddir; +--source include/start_mysqld.inc + diff --git a/mysql-test/main/mysqld--help.test b/mysql-test/main/mysqld--help.test index 35b3363e8d89a..a73562e424916 100644 --- a/mysql-test/main/mysqld--help.test +++ b/mysql-test/main/mysqld--help.test @@ -41,7 +41,7 @@ perl; wsrep file-key-management cracklib-password-check user-variables provider-bzip2 provider-lzma provider-lzo thread-pool-groups thread-pool-queues thread-pool-stats - thread-pool-waits hashicorp provider/; + thread-pool-waits hashicorp provider gssapi/; # And substitute the content some environment variables with their # names: diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index 491779dd61316..5d84f73cc5813 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -1769,7 +1769,8 @@ sub collect_mysqld_features { and $1 ne "innodb-buffer-page" and $1 ne "innodb-lock-waits" and $1 ne "innodb-locks" - and $1 ne "innodb-trx"; + and $1 ne "innodb-trx" + and $1 ne "gssapi"; next; } diff --git a/plugin/auth_gssapi/CMakeLists.txt b/plugin/auth_gssapi/CMakeLists.txt index 8c82d335ab2cc..f84f0aafb65bf 100644 --- a/plugin/auth_gssapi/CMakeLists.txt +++ b/plugin/auth_gssapi/CMakeLists.txt @@ -46,11 +46,15 @@ ELSE() ENDIF() ENDIF () - +IF(WIN32) + SET(AUTH_GSSAPI_DEFAULT DEFAULT) +ELSE() + SET(AUTH_GSSAPI_DEFAULT) +ENDIF() MYSQL_ADD_PLUGIN(auth_gssapi server_plugin.cc ${GSSAPI_SERVER} ${GSSAPI_ERRMSG} - LINK_LIBRARIES ${GSSAPI_LIBS} - COMPONENT gssapi-server - MODULE_ONLY) + LINK_LIBRARIES ${GSSAPI_LIBS} + ${AUTH_GSSAPI_DEFAULT} + COMPONENT gssapi-server) # disabled in favor of libmariadb/plugins/auth/auth_gssapi_client.c # diff --git a/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.result b/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.result index b7cf3d8e488ab..09be092d879ad 100644 --- a/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.result +++ b/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.result @@ -1,6 +1,3 @@ -INSTALL SONAME 'auth_gssapi'; -Warnings: -Note 1105 SSPI: using principal name 'localhost', mech 'Negotiate' CREATE USER 'GSSAPI_SHORTNAME' IDENTIFIED WITH gssapi; connect con1,localhost,$GSSAPI_SHORTNAME,,; SELECT USER(),CURRENT_USER(); @@ -23,4 +20,3 @@ DROP USER usr1; CREATE USER nosuchuser IDENTIFIED WITH gssapi AS 'nosuchuser@EXAMPLE.COM'; ERROR 28000: GSSAPI name mismatch, requested 'nosuchuser@EXAMPLE.COM', actual name 'GSSAPI_FULLNAME' DROP USER nosuchuser; -UNINSTALL SONAME 'auth_gssapi'; diff --git a/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.test b/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.test index 2307aa3934a3e..dc242e3a9cb56 100644 --- a/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.test +++ b/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.test @@ -1,6 +1,3 @@ ---replace_regex /name '[^']+'/name 'localhost'/ -INSTALL SONAME 'auth_gssapi'; - # # CREATE USER without 'AS' clause # @@ -42,5 +39,3 @@ CREATE USER nosuchuser IDENTIFIED WITH gssapi AS 'nosuchuser@EXAMPLE.COM'; connect (con1,localhost,nosuchuser,,); --enable_query_log DROP USER nosuchuser; - -UNINSTALL SONAME 'auth_gssapi'; \ No newline at end of file diff --git a/plugin/auth_gssapi/mysql-test/auth_gssapi/groups.result b/plugin/auth_gssapi/mysql-test/auth_gssapi/groups.result index 10b3eb3e9d64b..38244eca35b25 100644 --- a/plugin/auth_gssapi/mysql-test/auth_gssapi/groups.result +++ b/plugin/auth_gssapi/mysql-test/auth_gssapi/groups.result @@ -1,6 +1,3 @@ -INSTALL SONAME 'auth_gssapi'; -Warnings: -Note 1105 SSPI: using principal name 'localhost', mech 'Negotiate' CREATE USER 'nosuchgroup' IDENTIFIED WITH gssapi AS 'GROUP:nosuchgroup'; connect(localhost,nosuchuser,,test,MASTER_MYPORT,MASTER_MYSOCK); connect con1,localhost,nosuchuser,,; @@ -41,4 +38,3 @@ connect con1,localhost,me_sid,,; disconnect con1; connection default; DROP USER me_sid; -UNINSTALL SONAME 'auth_gssapi'; diff --git a/plugin/auth_gssapi/mysql-test/auth_gssapi/groups.test b/plugin/auth_gssapi/mysql-test/auth_gssapi/groups.test index 1c72ad9cc23ae..647e02043f290 100644 --- a/plugin/auth_gssapi/mysql-test/auth_gssapi/groups.test +++ b/plugin/auth_gssapi/mysql-test/auth_gssapi/groups.test @@ -1,6 +1,6 @@ source include/windows.inc; --replace_regex /name '[^']+'/name 'localhost'/ -INSTALL SONAME 'auth_gssapi'; + # Invalid group name @@ -67,7 +67,4 @@ replace_result $MASTER_MYSOCK MASTER_MYSOCK $MASTER_MYPORT MASTER_MYPORT; connect (con1,localhost,me_sid,,); disconnect con1; connection default; -DROP USER me_sid; - - -UNINSTALL SONAME 'auth_gssapi'; \ No newline at end of file +DROP USER me_sid; \ No newline at end of file diff --git a/plugin/auth_gssapi/mysql-test/auth_gssapi/multiauth.result b/plugin/auth_gssapi/mysql-test/auth_gssapi/multiauth.result index c65eb7a86342b..41d2707398b9f 100644 --- a/plugin/auth_gssapi/mysql-test/auth_gssapi/multiauth.result +++ b/plugin/auth_gssapi/mysql-test/auth_gssapi/multiauth.result @@ -1,6 +1,3 @@ -INSTALL SONAME 'auth_gssapi'; -Warnings: -Note 1105 SSPI: using principal name 'localhost', mech 'Negotiate' CREATE USER 'nosuchuser' IDENTIFIED WITH gssapi OR mysql_native_password as password("good"); connect(localhost,nosuchuser,,test,MASTER_MYPORT,MASTER_MYSOCK); connect con1,localhost,nosuchuser,,; @@ -31,4 +28,3 @@ GSSAPI_SHORTNAME@localhost GSSAPI_SHORTNAME@% disconnect con1; connection default; DROP USER 'GSSAPI_SHORTNAME'; -UNINSTALL SONAME 'auth_gssapi'; diff --git a/plugin/auth_gssapi/mysql-test/auth_gssapi/multiauth.test b/plugin/auth_gssapi/mysql-test/auth_gssapi/multiauth.test index 10e1e80907ea9..0257946b786db 100644 --- a/plugin/auth_gssapi/mysql-test/auth_gssapi/multiauth.test +++ b/plugin/auth_gssapi/mysql-test/auth_gssapi/multiauth.test @@ -1,6 +1,3 @@ ---replace_regex /name '[^']+'/name 'localhost'/ -INSTALL SONAME 'auth_gssapi'; - # gssapi,password CREATE USER 'nosuchuser' IDENTIFIED WITH gssapi OR mysql_native_password as password("good"); replace_result $MASTER_MYSOCK MASTER_MYSOCK $MASTER_MYPORT MASTER_MYPORT; @@ -33,4 +30,3 @@ connection default; replace_result $GSSAPI_SHORTNAME GSSAPI_SHORTNAME; eval DROP USER '$GSSAPI_SHORTNAME'; -UNINSTALL SONAME 'auth_gssapi'; diff --git a/plugin/auth_gssapi/mysql-test/auth_gssapi/suite.opt b/plugin/auth_gssapi/mysql-test/auth_gssapi/suite.opt index 3077d70c9c367..c9a5d52260013 100644 --- a/plugin/auth_gssapi/mysql-test/auth_gssapi/suite.opt +++ b/plugin/auth_gssapi/mysql-test/auth_gssapi/suite.opt @@ -1 +1 @@ ---loose-gssapi-keytab-path=$GSSAPI_KEYTAB_PATH --loose-gssapi-principal-name=$GSSAPI_PRINCIPAL_NAME +--loose-gssapi=ON --loose-gssapi-keytab-path=$GSSAPI_KEYTAB_PATH --loose-gssapi-principal-name=$GSSAPI_PRINCIPAL_NAME --plugin-load-add=$AUTH_GSSAPI_SO diff --git a/plugin/auth_gssapi/mysql-test/auth_gssapi/suite.pm b/plugin/auth_gssapi/mysql-test/auth_gssapi/suite.pm index e77ba05cb5cf5..af13b76e74c5a 100644 --- a/plugin/auth_gssapi/mysql-test/auth_gssapi/suite.pm +++ b/plugin/auth_gssapi/mysql-test/auth_gssapi/suite.pm @@ -1,8 +1,9 @@ + package My::Suite::AuthGSSAPI; @ISA = qw(My::Suite); -return "No AUTH_GSSAPI plugin" unless $ENV{AUTH_GSSAPI_SO}; +return "No AUTH_GSSAPI plugin" unless ($ENV{AUTH_GSSAPI_SO} or $::mysqld_variables{gssapi} eq "ON"); return "Not run for embedded server" if $::opt_embedded_server; diff --git a/plugin/auth_gssapi/server_plugin.cc b/plugin/auth_gssapi/server_plugin.cc index eeca4607ece01..c45452cee8ec6 100644 --- a/plugin/auth_gssapi/server_plugin.cc +++ b/plugin/auth_gssapi/server_plugin.cc @@ -141,7 +141,7 @@ static struct st_mysql_auth server_handler= { gssapi_auth, NULL, NULL }; -maria_declare_plugin(gssapi_server) +maria_declare_plugin(auth_gssapi) { MYSQL_AUTHENTICATION_PLUGIN, &server_handler, diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 934226685a925..100b4c250967a 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -438,7 +438,10 @@ static constexpr const char* update_root_passwd= "UPDATE mysql.global_priv SET priv=json_set(priv," "'$.password_last_changed', UNIX_TIMESTAMP()," "'$.plugin','mysql_native_password'," - "'$.authentication_string','%s') where User='root';\n"; + "'$.authentication_string','%s'," + "'$.auth_or', json_array(json_object(), json_object('plugin', 'gssapi','authentication_string','SID:BA'))" + ") where User= 'root';\n "; + static constexpr char remove_default_user_cmd[]= "DELETE FROM mysql.user where User='';\n"; static constexpr char allow_remote_root_access_cmd[]= From f97c8f7ececd083f046714a3106b5a6e6293bb05 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 26 Aug 2022 00:38:00 +0200 Subject: [PATCH 088/113] MDEV-26715 Fix mysql_install_db_win tests. It looks like C/C reconnect retains the database. It is correct behavior However there is a problem that mysql_install_db.exe does not create 'test' database, thus using mysql_install_db to create datadir, then restarting server and reconnecting does not succeed, if 'test' was current db before reconnect. The problem became apparent with MDEV-26715. Why it worked before, with a simpler 'root' definition is a mystery. Fix is to switch current connection to 'mysql' database, prior to reconnect to the instance created via mysql_install_db.exe --- mysql-test/main/mysql_install_db_win.result | 5 +++++ mysql-test/main/mysql_install_db_win.test | 3 +++ mysql-test/main/mysql_install_db_win_utf8.result | 2 ++ mysql-test/main/mysql_install_db_win_utf8.test | 3 ++- mysql-test/main/winservice.inc | 3 +-- mysql-test/main/winservice_basic.result | 1 + mysql-test/main/winservice_i18n.result | 1 + 7 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/mysql_install_db_win.result b/mysql-test/main/mysql_install_db_win.result index 2440ff351eac6..511be75e131c1 100644 --- a/mysql-test/main/mysql_install_db_win.result +++ b/mysql-test/main/mysql_install_db_win.result @@ -1,3 +1,7 @@ +select database(); +database() +test +use mysql; Running bootstrap Creating my.ini file Removing default user @@ -29,3 +33,4 @@ skip-name-resolve [client] port=3307 # restart +use test; diff --git a/mysql-test/main/mysql_install_db_win.test b/mysql-test/main/mysql_install_db_win.test index c400dbf3fb9fd..fd3bf6d24b0dd 100644 --- a/mysql-test/main/mysql_install_db_win.test +++ b/mysql-test/main/mysql_install_db_win.test @@ -1,4 +1,6 @@ --source include/windows.inc +select database(); +use mysql; # Create database in tmp directory using mysql_install_db.exe, # and start server from this directory. @@ -87,4 +89,5 @@ perl; EOF rmdir $_BASEDIR; --source include/start_mysqld.inc +use test; diff --git a/mysql-test/main/mysql_install_db_win_utf8.result b/mysql-test/main/mysql_install_db_win_utf8.result index 744c982b2917e..edcc69aaeb718 100644 --- a/mysql-test/main/mysql_install_db_win_utf8.result +++ b/mysql-test/main/mysql_install_db_win_utf8.result @@ -1,3 +1,4 @@ +use mysql; Running bootstrap Creating my.ini file Removing default user @@ -12,3 +13,4 @@ DATADIR/ # Kill the server connection default; # restart +use test; diff --git a/mysql-test/main/mysql_install_db_win_utf8.test b/mysql-test/main/mysql_install_db_win_utf8.test index fc67b66d3caa5..0dc75af39145d 100644 --- a/mysql-test/main/mysql_install_db_win_utf8.test +++ b/mysql-test/main/mysql_install_db_win_utf8.test @@ -1,6 +1,6 @@ --source include/windows.inc --source include/check_utf8_cli.inc - +use mysql; # Create database in tmp directory using mysql_install_db.exe, # and start server from this directory. let $ddir= $MYSQLTEST_VARDIR/tmp/датадир; @@ -32,4 +32,5 @@ rmdir $ddir; connection default; --source include/start_mysqld.inc +use test; diff --git a/mysql-test/main/winservice.inc b/mysql-test/main/winservice.inc index 2d8f6ccae1e33..d77856f6b5b9b 100644 --- a/mysql-test/main/winservice.inc +++ b/mysql-test/main/winservice.inc @@ -9,7 +9,7 @@ let $sc_exe= C:\Windows\System32\sc.exe; let $ddir= $MYSQLTEST_VARDIR/tmp/$datadir_name; let $service_name=$service_name_prefix$MASTER_MYPORT; - +use mysql; error 0,1; rmdir $ddir; @@ -72,4 +72,3 @@ rmdir $ddir; #restart original server connection default; source include/start_mysqld.inc; - diff --git a/mysql-test/main/winservice_basic.result b/mysql-test/main/winservice_basic.result index 0a5e8693b6bc1..da03a15d8b705 100644 --- a/mysql-test/main/winservice_basic.result +++ b/mysql-test/main/winservice_basic.result @@ -1,3 +1,4 @@ +use mysql; # run mysql_install_db with --service parameter # Start service # Connect with root user password=password diff --git a/mysql-test/main/winservice_i18n.result b/mysql-test/main/winservice_i18n.result index 8d5eba3df38ec..a3ee1137e9805 100644 --- a/mysql-test/main/winservice_i18n.result +++ b/mysql-test/main/winservice_i18n.result @@ -1,3 +1,4 @@ +use mysql; # run mysql_install_db with --service parameter # Start service # Connect with root user password=パスワード From d186cb180e424fb4e166959145b3bccb5e7f5164 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 8 Nov 2022 14:35:16 +0100 Subject: [PATCH 089/113] MDEV-26715 Windows/installer - gssapi support update libmariadb --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 72b40bfaa869f..d9af4fcbc6a7c 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 72b40bfaa869f3fe84242471dda989d13983d84c +Subproject commit d9af4fcbc6a7c0ab72b38bb47e0d4fa1f1f83316 From 8283948846740a22f96bbe7bccf250708406d5d9 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Wed, 16 Nov 2022 10:27:25 -0500 Subject: [PATCH 090/113] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7594fbe488f99..8cd63dc39bd6e 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=11 -MYSQL_VERSION_PATCH=1 +MYSQL_VERSION_PATCH=2 SERVER_MATURITY=gamma From b18241e059c17d4ad533dac3729302aa0ef60345 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 29 Nov 2022 16:23:46 +0530 Subject: [PATCH 091/113] MDEV-30122 mariabackup.skip_innodb crashes when innodb_undo_tablespaces > 0 - Assign srv_undo_space_id_start when InnoDB opens extra unused InnoDB undo tablespaces in srv_all_undo_tablespaces_open(). Mariabackup can detect the undo tablespaces using srv_undo_space_id_start variable --- mysql-test/suite/mariabackup/skip_innodb.test | 3 ++- storage/innobase/srv/srv0start.cc | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/mariabackup/skip_innodb.test b/mysql-test/suite/mariabackup/skip_innodb.test index 14e4bc007f664..25495b308b029 100644 --- a/mysql-test/suite/mariabackup/skip_innodb.test +++ b/mysql-test/suite/mariabackup/skip_innodb.test @@ -1,3 +1,4 @@ +--source include/innodb_undo_tablespaces.inc let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; CREATE TABLE t(i int); INSERT INTO t VALUES(1); @@ -9,4 +10,4 @@ exec $XTRABACKUP --prepare --target-dir=$targetdir; SELECT * from t; DROP TABLE t; -rmdir $targetdir; \ No newline at end of file +rmdir $targetdir; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 364775207e025..60b1a06e9ca5e 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -817,9 +817,11 @@ static dberr_t srv_all_undo_tablespaces_open(bool create_new_undo, { char name[OS_FILE_MAX_PATH]; snprintf(name, sizeof name, "%s/undo%03u", srv_undo_dir, i); - if (!srv_undo_tablespace_open(create_new_undo, name, i)) + uint32_t space_id= srv_undo_tablespace_open(create_new_undo, name, i); + if (!space_id) break; - ++srv_undo_tablespaces_open; + if (0 == srv_undo_tablespaces_open++) + srv_undo_space_id_start= space_id; } return DB_SUCCESS; From 922f7ba75c864a9ae4d0e55fa66860dae306136f Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 5 Dec 2022 16:25:27 +0530 Subject: [PATCH 092/113] MDEV-30158 InnoDB fails to start ther server 10.11 when innodb_undo_tablespaces mismatch - InnoDB should throw the warning when user specified undo tablespaces doesn't match with the number of opened undo tablespaces and should reflect the value in innodb_undo_tablespaces variable --- storage/innobase/srv/srv0start.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index c839356bdb774..34532bf792e69 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -570,19 +570,13 @@ static dberr_t srv_undo_tablespaces_reinitialize() tolerate that discrepancy but not the inverse. Because there could be unused undo tablespaces for future use. */ - if (srv_undo_tablespaces > srv_undo_tablespaces_open) + if (srv_undo_tablespaces != srv_undo_tablespaces_open) { - ib::error() << "Expected to open innodb_undo_tablespaces=" - << srv_undo_tablespaces - << " but was able to find only " - << srv_undo_tablespaces_open; - - return DB_ERROR; - } - else if (srv_undo_tablespaces < srv_undo_tablespaces_open) sql_print_warning("InnoDB: Cannot change innodb_undo_tablespaces=%u " "because previous shutdown was not with " "innodb_fast_shutdown=0", srv_undo_tablespaces); + srv_undo_tablespaces= srv_undo_tablespaces_open; + } else if (srv_undo_tablespaces_open > 0) sql_print_information("InnoDB: Opened " UINT32PF " undo tablespaces", srv_undo_tablespaces_open); From c1fd082e9c7369f4511eb5a52e58cb15489caa74 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 14 Dec 2022 13:34:11 +0100 Subject: [PATCH 093/113] MDEV-25341 post-fix. Don't use DiscardVirtualMemory on Windows. This turns out to be a too expensive call to use for every freed page, especially under global buffer pool mutex protection. Also, the usefulness of proactive shrinking of the buffer pool on Windows this is seems questionable - there is no OOM killer, and the OS will shrink working sets itself. --- storage/innobase/include/buf0buf.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 2dd6935241e32..eb84aff8354e9 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -662,8 +662,6 @@ class buf_page_t MEM_NOACCESS(frame, srv_page_size); #ifdef MADV_FREE madvise(frame, srv_page_size, MADV_FREE); -#elif defined(_WIN32) - DiscardVirtualMemory(frame, srv_page_size); #endif } From 71a72dd7701f6a4951f4cd4073163ea03ee80241 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 19 Dec 2022 19:01:42 +0100 Subject: [PATCH 094/113] 11.0 branch --- VERSION | 8 ++++---- client/mysqlbinlog.cc | 1 + debian/additions/mariadb.conf.d/50-server.cnf | 4 ++-- debian/changelog | 2 +- debian/control | 4 ---- debian/source/lintian-overrides | 17 ----------------- mysql-test/main/comments.result | 4 ++-- mysql-test/main/comments.test | 4 ++-- mysql-test/main/mysql_upgrade.test | 4 +--- ...create_and_drop_role_invalid_user_table.test | 2 +- mysql-test/suite/sys_vars/r/sysvars_star.result | 2 +- 11 files changed, 15 insertions(+), 37 deletions(-) diff --git a/VERSION b/VERSION index 8cd63dc39bd6e..03af4aaf27f43 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ -MYSQL_VERSION_MAJOR=10 -MYSQL_VERSION_MINOR=11 -MYSQL_VERSION_PATCH=2 -SERVER_MATURITY=gamma +MYSQL_VERSION_MAJOR=11 +MYSQL_VERSION_MINOR=0 +MYSQL_VERSION_PATCH=0 +SERVER_MATURITY=beta diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 75fc7268b0d84..82b9ff20731ba 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -2822,6 +2822,7 @@ static Exit_status check_master_version() break; case 5: case 10: + case 11: /* The server is soon going to send us its Format_description log event, unless it is a 5.0 server with 3.23 or 4.0 binlogs. diff --git a/debian/additions/mariadb.conf.d/50-server.cnf b/debian/additions/mariadb.conf.d/50-server.cnf index 5e958e9e697b5..fac3ce54c5ced 100644 --- a/debian/additions/mariadb.conf.d/50-server.cnf +++ b/debian/additions/mariadb.conf.d/50-server.cnf @@ -108,7 +108,7 @@ collation-server = utf8mb4_general_ci # you can put MariaDB-only options here [mariadb] -# This group is only read by MariaDB-10.11 servers. +# This group is only read by MariaDB-11.0 servers. # If you use the same .cnf file for MariaDB of different versions, # use this group for options that older servers don't understand -[mariadb-10.11] +[mariadb-11.0] diff --git a/debian/changelog b/debian/changelog index af6536d9be9a0..60ef886f6dd98 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -mariadb (1:10.11.0) unstable; urgency=medium +mariadb (1:11.0.0) unstable; urgency=medium * Initial Release diff --git a/debian/control b/debian/control index 81418c1365626..f5b6c3b762aa1 100644 --- a/debian/control +++ b/debian/control @@ -384,7 +384,6 @@ Replaces: mariadb-client (<< ${source:Version}), percona-xtradb-cluster-server-5.7, virtual-mysql-client-core Provides: default-mysql-client-core, - mariadb-client-core-10.11, virtual-mysql-client-core Description: MariaDB database core client binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database @@ -544,7 +543,6 @@ Replaces: mariadb-client (<< ${source:Version}), percona-xtradb-cluster-server-5.7, virtual-mysql-client Provides: default-mysql-client, - mariadb-client-10.11, virtual-mysql-client Recommends: libdbd-mariadb-perl | libdbd-mysql-perl, libdbi-perl, @@ -658,7 +656,6 @@ Replaces: mariadb-client (<< ${source:Version}), percona-xtradb-cluster-server-5.7, virtual-mysql-server-core Provides: default-mysql-server-core, - mariadb-server-core-10.11, virtual-mysql-server-core Description: MariaDB database core server files MariaDB is a fast, stable and true multi-user, multi-threaded SQL database @@ -771,7 +768,6 @@ Replaces: handlersocket-mysql-5.5, percona-xtradb-cluster-server-5.7, virtual-mysql-server Provides: default-mysql-server, - mariadb-server-10.11, virtual-mysql-server Description: MariaDB database server binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides index 1deb9f8c4e9a6..76506dd03aa4d 100644 --- a/debian/source/lintian-overrides +++ b/debian/source/lintian-overrides @@ -9,23 +9,6 @@ version-substvar-for-external-package mariadb-server-10.9 -> mysql-client-8.* version-substvar-for-external-package mariadb-client-10.9 -> mysql-client-core-5.* version-substvar-for-external-package mariadb-client-10.9 -> mysql-client-core-8.* version-substvar-for-external-package libmariadbd-dev -> libmariadbclient-dev -# Intentional version-substvar-for-external-package as long as mariadb-server -# provides mariadb-server-10.11 and mariadb-client provides mariadb-client-10.11 -version-substvar-for-external-package Conflicts (line 408) ${source:Version} mariadb-client -> mariadb-client-10.11 -version-substvar-for-external-package Conflicts (line 575) ${source:Version} mariadb-server-core -> mariadb-server-core-10.11 -version-substvar-for-external-package Conflicts (line 711) ${source:Version} mariadb-server -> mariadb-server-10.11 -version-substvar-for-external-package Conflicts (line 95) ${source:Version} libmariadb-dev-compat -> libmariadbclient-dev -version-substvar-for-external-package Replaces (line 109) ${source:Version} libmariadb-dev-compat -> libmariadbclient-dev -version-substvar-for-external-package Replaces (line 330) ${source:Version} mariadb-client-core -> mariadb-client-10.11 -version-substvar-for-external-package Replaces (line 330) ${source:Version} mariadb-client-core -> mariadb-server-core-10.11 -version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-client-10.11 -version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-client-core-10.11 -version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-server-10.11 -version-substvar-for-external-package Replaces (line 481) ${source:Version} mariadb-client -> mariadb-server-core-10.11 -version-substvar-for-external-package Replaces (line 626) ${source:Version} mariadb-server-core -> mariadb-client-10.11 -version-substvar-for-external-package Replaces (line 626) ${source:Version} mariadb-server-core -> mariadb-server-10.11 -version-substvar-for-external-package Replaces (line 748) ${source:Version} mariadb-server -> mariadb-client-10.11 -version-substvar-for-external-package Replaces (line 748) ${source:Version} mariadb-server -> mariadb-server-10.11 # ColumnStore not used in Debian, safe to ignore. Reported upstream in https://jira.mariadb.org/browse/MDEV-24124 source-is-missing storage/columnstore/columnstore/utils/jemalloc/libjemalloc.so.2 source-is-missing [storage/columnstore/columnstore/utils/jemalloc/libjemalloc.so.2] diff --git a/mysql-test/main/comments.result b/mysql-test/main/comments.result index c13eb510326b3..8b3f9fba38241 100644 --- a/mysql-test/main/comments.result +++ b/mysql-test/main/comments.result @@ -64,7 +64,7 @@ SELECT 1 /*!99999 +1*/; SELECT 1 /*!100000 +1*/; 1 +1 2 -SELECT 1 /*!110000 +1*/; +SELECT 1 /*!210000 +1*/; 1 1 # @@ -86,7 +86,7 @@ SELECT 1 /*M!99999 +1*/; SELECT 1 /*M!100000 +1*/; 1 +1 2 -SELECT 1 /*M!110000 +1*/; +SELECT 1 /*M!210000 +1*/; 1 1 select 1/*!2*/; diff --git a/mysql-test/main/comments.test b/mysql-test/main/comments.test index 6cf69635d1e74..871258907801f 100644 --- a/mysql-test/main/comments.test +++ b/mysql-test/main/comments.test @@ -41,7 +41,7 @@ SELECT 1 /*!50700 +1*/; SELECT 1 /*!50999 +1*/; SELECT 1 /*!99999 +1*/; SELECT 1 /*!100000 +1*/; -SELECT 1 /*!110000 +1*/; +SELECT 1 /*!210000 +1*/; --echo # --echo # Tesing that versions >= 5.7.x and < 10.0.0 are not ignored @@ -52,7 +52,7 @@ SELECT 1 /*M!50700 +1*/; SELECT 1 /*M!50999 +1*/; SELECT 1 /*M!99999 +1*/; SELECT 1 /*M!100000 +1*/; -SELECT 1 /*M!110000 +1*/; +SELECT 1 /*M!210000 +1*/; # # Bug#25411 (trigger code truncated) diff --git a/mysql-test/main/mysql_upgrade.test b/mysql-test/main/mysql_upgrade.test index b9ff05401f712..b149038067d66 100644 --- a/mysql-test/main/mysql_upgrade.test +++ b/mysql-test/main/mysql_upgrade.test @@ -337,14 +337,12 @@ EOF --echo # MDEV-27279: mariadb_upgrade check-if-upgrade with major version change --echo # -# take 2rd number of version and change to 0 - let DATADIR= $MYSQLD_DATADIR; perl; my $ver= $ENV{'MYSQL_SERVER_VERSION'} or die "MYSQL_SERVER_VERSION not set"; my $file= $ENV{'DATADIR'} or die "MYSQLD_DATADIR not set"; - $ver =~ s/^(\d*)\.(\d*).(\d*)(.*)/$1.0.$3$4/; + $ver =~ s/^(\d*)\.(\d*).(\d*)(.*)/10.11.2$4/; open(FILE, ">$file/mysql_upgrade_info") or die "Failed to open $file"; print FILE "$ver\n"; close(FILE); diff --git a/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test b/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test index dac6eab21e998..e86e93f7a3b1b 100644 --- a/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test +++ b/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test @@ -17,7 +17,7 @@ alter table user drop column max_statement_time; flush privileges; ---replace_regex /10\d\d\d\d/MYSQL_VERSION_ID/ +--replace_regex /1\d\d\d\d\d/MYSQL_VERSION_ID/ --error ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE create role test_role; --error ER_CANNOT_USER diff --git a/mysql-test/suite/sys_vars/r/sysvars_star.result b/mysql-test/suite/sys_vars/r/sysvars_star.result index b3357fda3afab..b4c0ea875811a 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_star.result +++ b/mysql-test/suite/sys_vars/r/sysvars_star.result @@ -60,7 +60,7 @@ VARIABLE_NAME PLUGIN_MATURITY SESSION_VALUE NULL GLOBAL_VALUE alpha GLOBAL_VALUE_ORIGIN CONFIG -DEFAULT_VALUE beta +DEFAULT_VALUE alpha VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded From 681976ed14a3d8d75ff1e4ae54746d081f4ed8d9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 19 Dec 2022 21:14:05 +0100 Subject: [PATCH 095/113] spider fixes for 11.0+ spider_rewrite plugin is not in 11.0. spider initialization code used "11.0" for "in the distant future", but suddenly it's now spider tests didn't expect anything beyond 10.x --- .../spider/bugfix/include/sql_mode_init.inc | 16 +--------------- storage/spider/spd_init_query.h | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/storage/spider/mysql-test/spider/bugfix/include/sql_mode_init.inc b/storage/spider/mysql-test/spider/bugfix/include/sql_mode_init.inc index 09ab2934aea4d..337979a4f3d49 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/sql_mode_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/sql_mode_init.inc @@ -5,21 +5,7 @@ --enable_result_log --enable_query_log --enable_warnings ---let $SQL_MODES= real_as_float,pipes_as_concat,ansi_quotes,ignore_space,ignore_bad_table_options,only_full_group_by,no_unsigned_subtraction,no_dir_in_create,postgresql,oracle,mssql,db2,maxdb,no_key_options,no_table_options,no_field_options,mysql323,mysql40,ansi,no_auto_value_on_zero,no_backslash_escapes,strict_trans_tables,strict_all_tables,no_zero_in_date,no_zero_date,allow_invalid_dates,error_for_division_by_zero,traditional,no_auto_create_user,high_not_precedence,no_engine_substitution,pad_char_to_full_length -if (`SELECT IF(STRCMP('$SERVER_NAME', 'MariaDB') = 0, 1, 0)`) -{ - if (`SELECT IF($SERVER_MAJOR_VERSION = 10, 1, 0)`) - { - if (`SELECT IF($SERVER_MINOR_VERSION >= 3, 1, 0)`) - { - --let $SQL_MODES= $SQL_MODES,empty_string_is_null,simultaneous_assignment - } - if (`SELECT IF($SERVER_MINOR_VERSION >= 4, 1, 0)`) - { - --let $SQL_MODES= $SQL_MODES,time_round_fractional - } - } -} +--let $SQL_MODES= real_as_float,pipes_as_concat,ansi_quotes,ignore_space,ignore_bad_table_options,only_full_group_by,no_unsigned_subtraction,no_dir_in_create,postgresql,oracle,mssql,db2,maxdb,no_key_options,no_table_options,no_field_options,mysql323,mysql40,ansi,no_auto_value_on_zero,no_backslash_escapes,strict_trans_tables,strict_all_tables,no_zero_in_date,no_zero_date,allow_invalid_dates,error_for_division_by_zero,traditional,no_auto_create_user,high_not_precedence,no_engine_substitution,pad_char_to_full_length,empty_string_is_null,simultaneous_assignment,time_round_fractional --connection master_1 set @old_sql_mode= @@sql_mode; eval set session sql_mode= '$SQL_MODES'; diff --git a/storage/spider/spd_init_query.h b/storage/spider/spd_init_query.h index e66e94d837319..0aba850ce0fa4 100644 --- a/storage/spider/spd_init_query.h +++ b/storage/spider/spd_init_query.h @@ -538,6 +538,10 @@ static LEX_STRING spider_init_queries[] = { " engine=Aria transactional=1;" " end if;" " end if;" +/* + tables for ddl pushdown +*/ +/* " if @server_name = 'MariaDB' and" " (" " @server_major_version > 10 or" @@ -547,7 +551,6 @@ static LEX_STRING spider_init_queries[] = { " )" " )" " then" - " /* table for ddl pushdown */" " create table if not exists mysql.spider_rewrite_tables(" " table_id bigint unsigned not null auto_increment," " db_name char(64) not null default ''," @@ -602,6 +605,7 @@ static LEX_STRING spider_init_queries[] = { " primary key (db_name, table_name, table_id, partition_id)" " ) engine=Aria transactional=1 default charset=utf8 collate=utf8_bin;" " end if;" +*/ /* Fix for version 3.4 */ @@ -798,6 +802,10 @@ static LEX_STRING spider_init_queries[] = { " soname 'ha_spider.dll';" " end if;" " end if;" +/* + Install spider_rewrite plugin +*/ +/* " if @server_name = 'MariaDB' and" " (" " @server_major_version > 10 or" @@ -807,9 +815,6 @@ static LEX_STRING spider_init_queries[] = { " )" " )" " then" -/* - Install spider_rewrite plugin -*/ " set @have_spider_i_s_rewrite_plugin := 0;" " select @have_spider_i_s_rewrite_plugin := 1" " from INFORMATION_SCHEMA.plugins" @@ -819,11 +824,6 @@ static LEX_STRING spider_init_queries[] = { " where name = 'spider_rewrite';" " if @have_spider_i_s_rewrite_plugin = 0 then" " if @have_spider_rewrite_plugin = 1 then" - " /*" - " spider_rewrite plugin is present in mysql.plugin but not in" - " information_schema.plugins. Remove spider_rewrite plugin entry" - " in mysql.plugin first." - " */" " delete from mysql.plugin where name = 'spider_rewrite';" " end if;" " if @win_plugin = 0 then " @@ -845,6 +845,7 @@ static LEX_STRING spider_init_queries[] = { " end if;" " end if;" " end if;" +*/ "end;" )}, {C_STRING_WITH_LEN( From b1856aff37557e82b0e53ddbd89fc41f86df07e6 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 10 Dec 2022 12:05:36 +0100 Subject: [PATCH 096/113] mark an unused error message --- sql/share/errmsg-utf8.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index b76401a50e78a..65a7e613b7244 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6304,11 +6304,8 @@ ER_VIEW_FRM_NO_USER eng "View '%-.192s'.'%-.192s' has no definer information (old table format). Current user is used as definer. Please recreate the view!" ger "View '%-.192s'.'%-.192s' hat keine Definierer-Information (altes Tabellenformat). Der aktuelle Benutzer wird als Definierer verwendet. Bitte erstellen Sie den View neu" spa "La vista '%-.192s'.'%-.192s' no tiene información de definidor (formato viejo de tabla). Se usa el usuario actual como definidor. Por favor, ¡recrea la vista!" -ER_VIEW_OTHER_USER - chi "您需要使用'%-.192s'@'%-.192s'的创建视图的超级特权" - eng "You need the SUPER privilege for creation view with '%-.192s'@'%-.192s' definer" - ger "Sie brauchen die SUPER-Berechtigung, um einen View mit dem Definierer '%-.192s'@'%-.192s' zu erzeugen" - spa "Vd necesita el privilegio SUPER para la creación de la vista con definidor '%-.192s'@'%-.192s'" +ER_UNUSED_30 + eng "You should never see it" ER_NO_SUCH_USER chi "指定为定义的用户('%-.64s'@'%-.64s')不存在" eng "The user specified as a definer ('%-.64s'@'%-.64s') does not exist" From 9c05c840b4e05f307651daa032bafaaed569a519 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 29 Nov 2022 16:46:53 +1100 Subject: [PATCH 097/113] MDEV-28891 Spider: remove #ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR unifdef -DSPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR -m storage/spider/*.{cc,h} and removing the definition manually. Signed-off-by: Yuchen Pei Reviewed-by: Nayuta Yanagisawa --- storage/spider/spd_include.h | 1 - storage/spider/spd_sys_table.cc | 44 --------------------------------- 2 files changed, 45 deletions(-) diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 26acaaa86ec18..4d567e0a760f4 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -85,7 +85,6 @@ #define SPIDER_TEST(A) MY_TEST(A) -#define SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR #define SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON #define SPIDER_Item_args_arg_count_IS_PROTECTED diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index a0cf104d46e61..df95336cc191d 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -3572,24 +3572,13 @@ TABLE *spider_mk_sys_tmp_table( TABLE *tmp_table; DBUG_ENTER("spider_mk_sys_tmp_table"); -#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(field = new (thd->mem_root) Field_blob( 4294967295U, FALSE, field_name, cs, TRUE))) goto error_alloc_field; -#else - if (!(field = new Field_blob( - 4294967295U, FALSE, field_name, cs, TRUE))) - goto error_alloc_field; -#endif field->init(table); -#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(i_field = new (thd->mem_root) Item_field(thd, (Field *) field))) goto error_alloc_item_field; -#else - if (!(i_field = new Item_field((Field *) field))) - goto error_alloc_item_field; -#endif if (i_list.push_back(i_field)) goto error_push_item; @@ -3650,68 +3639,35 @@ TABLE *spider_mk_sys_tmp_table_for_result( TABLE *tmp_table; DBUG_ENTER("spider_mk_sys_tmp_table_for_result"); -#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(field1 = new (thd->mem_root) Field_blob( 4294967295U, FALSE, field_name1, cs, TRUE))) goto error_alloc_field1; -#else - if (!(field1 = new Field_blob( - 4294967295U, FALSE, field_name1, cs, TRUE))) - goto error_alloc_field1; -#endif field1->init(table); -#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(i_field1 = new (thd->mem_root) Item_field(thd, (Field *) field1))) goto error_alloc_item_field1; -#else - if (!(i_field1 = new Item_field((Field *) field1))) - goto error_alloc_item_field1; -#endif if (i_list.push_back(i_field1)) goto error_push_item1; -#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(field2 = new (thd->mem_root) Field_blob( 4294967295U, FALSE, field_name2, cs, TRUE))) goto error_alloc_field2; -#else - if (!(field2 = new Field_blob( - 4294967295U, FALSE, field_name2, cs, TRUE))) - goto error_alloc_field2; -#endif field2->init(table); -#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(i_field2 = new (thd->mem_root) Item_field(thd, (Field *) field2))) goto error_alloc_item_field2; -#else - if (!(i_field2 = new Item_field((Field *) field2))) - goto error_alloc_item_field2; -#endif if (i_list.push_back(i_field2)) goto error_push_item2; -#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(field3 = new (thd->mem_root) Field_blob( 4294967295U, FALSE, field_name3, cs, TRUE))) goto error_alloc_field3; -#else - if (!(field3 = new Field_blob( - 4294967295U, FALSE, field_name3, cs, TRUE))) - goto error_alloc_field3; -#endif field3->init(table); -#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(i_field3 = new (thd->mem_root) Item_field(thd, (Field *) field3))) goto error_alloc_item_field3; -#else - if (!(i_field3 = new Item_field((Field *) field3))) - goto error_alloc_item_field3; -#endif if (i_list.push_back(i_field3)) goto error_push_item3; From 1128b54aa4577da7e31c739ad9601bb11d476c72 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 29 Nov 2022 12:08:27 +1100 Subject: [PATCH 098/113] MDEV-29269 Spider: remove #ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC Produced using the following command unifdef -UITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC -m storage/spider/spd_* Signed-off-by: Yuchen Pei Reviewed-by: nayuta.yanagisawa@mariadb.com --- storage/spider/spd_db_mysql.cc | 81 ---------------------------------- 1 file changed, 81 deletions(-) diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 78236243bf209..bd34a9e035505 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -5839,88 +5839,7 @@ int spider_db_mbase_util::open_item_func( alias, alias_length, dbton_id, use_fields, fields)); } else if (!strncasecmp("timestampdiff", func_name, func_name_length)) { -#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC - Item_func_timestamp_diff *item_func_timestamp_diff = - (Item_func_timestamp_diff *) item_func; - if (str) - { - const char *interval_str; - uint interval_len; - switch (item_func_timestamp_diff->int_type) - { - case INTERVAL_YEAR: - interval_str = SPIDER_SQL_YEAR_STR; - interval_len = SPIDER_SQL_YEAR_LEN; - break; - case INTERVAL_QUARTER: - interval_str = SPIDER_SQL_QUARTER_STR; - interval_len = SPIDER_SQL_QUARTER_LEN; - break; - case INTERVAL_MONTH: - interval_str = SPIDER_SQL_MONTH_STR; - interval_len = SPIDER_SQL_MONTH_LEN; - break; - case INTERVAL_WEEK: - interval_str = SPIDER_SQL_WEEK_STR; - interval_len = SPIDER_SQL_WEEK_LEN; - break; - case INTERVAL_DAY: - interval_str = SPIDER_SQL_DAY_STR; - interval_len = SPIDER_SQL_DAY_LEN; - break; - case INTERVAL_HOUR: - interval_str = SPIDER_SQL_HOUR_STR; - interval_len = SPIDER_SQL_HOUR_LEN; - break; - case INTERVAL_MINUTE: - interval_str = SPIDER_SQL_MINUTE_STR; - interval_len = SPIDER_SQL_MINUTE_LEN; - break; - case INTERVAL_SECOND: - interval_str = SPIDER_SQL_SECOND_STR; - interval_len = SPIDER_SQL_SECOND_LEN; - break; - case INTERVAL_MICROSECOND: - interval_str = SPIDER_SQL_MICROSECOND_STR; - interval_len = SPIDER_SQL_MICROSECOND_LEN; - break; - default: - interval_str = ""; - interval_len = 0; - break; - } - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN + - interval_len + SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - str->q_append(interval_str, interval_len); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, - SPIDER_SQL_CLOSE_PAREN_LEN); - } - DBUG_RETURN(0); -#else DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); -#endif } } else if (func_name_length == 14) { From 1be861c5820b76970551b7f51016c033e2c676b9 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 1 Dec 2022 17:30:10 +1100 Subject: [PATCH 099/113] MDEV-28526 Spider: remove conn_kind member variables The conn_kind, which stands for "connection kind", is no longer useful because the HandlerSocket support is deleted and Spider now has only one connection kind, SPIDER_CONN_KIND_MYSQL. Remove conn_kind and related code. Signed-off-by: Yuchen Pei Reviewed-by: Nayuta Yanagisawa --- storage/spider/ha_spider.cc | 31 ++++------------------ storage/spider/ha_spider.h | 2 -- storage/spider/spd_conn.cc | 41 ++++++++++++----------------- storage/spider/spd_conn.h | 3 --- storage/spider/spd_copy_tables.cc | 9 +++---- storage/spider/spd_db_conn.cc | 3 +-- storage/spider/spd_db_include.h | 2 -- storage/spider/spd_db_mysql.cc | 8 +++--- storage/spider/spd_direct_sql.cc | 2 -- storage/spider/spd_include.h | 1 - storage/spider/spd_ping_table.cc | 8 +++--- storage/spider/spd_table.cc | 32 +++++++---------------- storage/spider/spd_trx.cc | 43 ++++++++++--------------------- storage/spider/spd_trx.h | 6 +---- 14 files changed, 58 insertions(+), 133 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 09c73b46d25e9..b12813dd81906 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -238,7 +238,6 @@ int ha_spider::open( DBUG_PRINT("info",("spider this=%p", this)); dup_key_idx = (uint) -1; - conn_kinds = SPIDER_CONN_KIND_MYSQL; table->file->get_no_parts("", &part_num); if (part_num) { @@ -590,22 +589,7 @@ int ha_spider::check_access_kind_for_connection( int error_num, roop_count; DBUG_ENTER("ha_spider::check_access_kind_for_connection"); DBUG_PRINT("info",("spider this=%p", this)); - conn_kinds = 0; - switch (wide_handler->sql_command) - { - case SQLCOM_UPDATE: - case SQLCOM_UPDATE_MULTI: - case SQLCOM_DELETE: - case SQLCOM_DELETE_MULTI: - default: - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - break; - } - if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE))) + if ((error_num= spider_check_trx_and_get_conn(thd, this))) { DBUG_RETURN(error_num); } @@ -1037,8 +1021,6 @@ int ha_spider::reset() for (roop_count = share->link_count - 1; roop_count >= 0; roop_count--) { result_list.update_sqls[roop_count].length(0); - - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; } result_list.bulk_update_mode = 0; result_list.bulk_update_size = 0; @@ -1064,7 +1046,6 @@ int ha_spider::reset() result_list.use_union = FALSE; result_list.use_both_key = FALSE; pt_clone_last_searcher = NULL; - conn_kinds = SPIDER_CONN_KIND_MYSQL; use_index_merge = FALSE; init_rnd_handler = FALSE; if (multi_range_keys) @@ -6682,8 +6663,7 @@ int ha_spider::info( pthread_mutex_lock(&share->sts_mutex); if (difftime(tmp_time, share->sts_get_time) >= sts_interval) { - if ((error_num = spider_check_trx_and_get_conn(ha_thd(), this, - FALSE))) + if ((error_num= spider_check_trx_and_get_conn(ha_thd(), this))) { pthread_mutex_unlock(&share->sts_mutex); if (!share->sts_init) @@ -7268,7 +7248,7 @@ int ha_spider::check_crd() } if (crd_mode == 3) crd_mode = 1; - if ((error_num = spider_check_trx_and_get_conn(ha_thd(), this, FALSE))) + if ((error_num= spider_check_trx_and_get_conn(ha_thd(), this))) { DBUG_RETURN(check_error_mode(error_num)); } @@ -8482,7 +8462,7 @@ int ha_spider::truncate() DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } wide_handler->sql_command = SQLCOM_TRUNCATE; - if ((error_num = spider_check_trx_and_get_conn(thd, this, FALSE))) + if ((error_num= spider_check_trx_and_get_conn(thd, this))) { DBUG_RETURN(error_num); } @@ -12057,8 +12037,7 @@ int ha_spider::append_lock_tables_list() DBUG_PRINT("info",("spider lock_table_type=%u", wide_handler->lock_table_type)); - if ((error_num = spider_check_trx_and_get_conn(wide_handler->trx->thd, this, - FALSE))) + if ((error_num= spider_check_trx_and_get_conn(wide_handler->trx->thd, this))) { DBUG_RETURN(error_num); } diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 4dffdf7855390..f6efc62dfe673 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -60,8 +60,6 @@ class ha_spider final : public handler const char *mem_calc_file_name; ulong mem_calc_line_no; ulonglong *connection_ids; - uint conn_kinds; - uint *conn_kind; char *conn_keys_first_ptr; char **conn_keys; SPIDER_CONN **conns; diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index a1d80ae8670fc..4941c2890f552 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -108,7 +108,6 @@ uchar *spider_conn_get_key( ) { DBUG_ENTER("spider_conn_get_key"); *length = conn->conn_key_length; - DBUG_PRINT("info",("spider conn_kind=%u", conn->conn_kind)); #ifdef DBUG_TRACE spider_print_keys(conn->conn_key, conn->conn_key_length); #endif @@ -382,7 +381,6 @@ SPIDER_CONN *spider_create_conn( ha_spider *spider, int link_idx, int base_link_idx, - uint conn_kind, int *error_num ) { int *need_mon; @@ -595,7 +593,6 @@ SPIDER_CONN *spider_create_conn( conn->semi_trx_isolation_chk = FALSE; conn->semi_trx_chk = FALSE; conn->link_idx = base_link_idx; - conn->conn_kind = conn_kind; conn->conn_need_mon = need_mon; if (spider) conn->need_mon = &spider->need_mons[base_link_idx]; @@ -682,13 +679,11 @@ SPIDER_CONN *spider_get_conn( ha_spider *spider, bool another, bool thd_chg, - uint conn_kind, int *error_num ) { SPIDER_CONN *conn = NULL; int base_link_idx = link_idx; DBUG_ENTER("spider_get_conn"); - DBUG_PRINT("info",("spider conn_kind=%u", conn_kind)); if (spider) link_idx = spider->conn_link_idx[base_link_idx]; @@ -727,7 +722,8 @@ SPIDER_CONN *spider_get_conn( pthread_mutex_unlock(&spider_conn_mutex); if (spider_param_max_connections()) { /* enable connection pool */ - conn = spider_get_conn_from_idle_connection(share, link_idx, conn_key, spider, conn_kind, base_link_idx, error_num); + conn= spider_get_conn_from_idle_connection( + share, link_idx, conn_key, spider, base_link_idx, error_num); /* failed get conn, goto error */ if (!conn) goto error; @@ -736,8 +732,8 @@ SPIDER_CONN *spider_get_conn( else { /* did not enable conncetion pool , create_conn */ DBUG_PRINT("info",("spider create new conn")); - if (!(conn = spider_create_conn(share, spider, link_idx, - base_link_idx, conn_kind, error_num))) + if (!(conn= spider_create_conn(share, spider, link_idx, + base_link_idx, error_num))) goto error; *conn->conn_key = *conn_key; if (spider) @@ -761,8 +757,8 @@ SPIDER_CONN *spider_get_conn( } else { DBUG_PRINT("info",("spider create new conn")); /* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */ - if (!(conn = spider_create_conn(share, spider, link_idx, base_link_idx, - conn_kind, error_num))) + if (!(conn= spider_create_conn(share, spider, link_idx, base_link_idx, + error_num))) goto error; *conn->conn_key = *conn_key; if (spider) @@ -885,13 +881,10 @@ int spider_check_and_get_casual_read_conn( char first_byte_bak = *spider->conn_keys[link_idx]; *spider->conn_keys[link_idx] = '0' + spider->result_list.casual_read[link_idx]; - if ( - !(spider->conns[link_idx] = - spider_get_conn(spider->share, link_idx, - spider->conn_keys[link_idx], spider->wide_handler->trx, - spider, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL, - &error_num)) - ) { + if (!(spider->conns[link_idx]= spider_get_conn( + spider->share, link_idx, spider->conn_keys[link_idx], + spider->wide_handler->trx, spider, FALSE, TRUE, &error_num))) + { *spider->conn_keys[link_idx] = first_byte_bak; DBUG_RETURN(error_num); } @@ -3010,9 +3003,8 @@ void *spider_bg_sts_action( if (!conns[spider.search_link_idx]) { spider_get_conn(share, spider.search_link_idx, - share->conn_keys[spider.search_link_idx], - trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, - &error_num); + share->conn_keys[spider.search_link_idx], trx, + &spider, FALSE, FALSE, &error_num); conns[spider.search_link_idx]->error_mode = 0; /* if ( @@ -3335,9 +3327,8 @@ void *spider_bg_crd_action( if (!conns[spider.search_link_idx]) { spider_get_conn(share, spider.search_link_idx, - share->conn_keys[spider.search_link_idx], - trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, - &error_num); + share->conn_keys[spider.search_link_idx], trx, + &spider, FALSE, FALSE, &error_num); conns[spider.search_link_idx]->error_mode = 0; /* if ( @@ -3904,7 +3895,6 @@ SPIDER_CONN* spider_get_conn_from_idle_connection( int link_idx, char *conn_key, ha_spider *spider, - uint conn_kind, int base_link_idx, int *error_num ) @@ -3992,7 +3982,8 @@ SPIDER_CONN* spider_get_conn_from_idle_connection( if (ip_port_conn) pthread_mutex_unlock(&ip_port_conn->mutex); DBUG_PRINT("info",("spider create new conn")); - if (!(conn = spider_create_conn(share, spider, link_idx, base_link_idx, conn_kind, error_num))) + if (!(conn= spider_create_conn(share, spider, link_idx, base_link_idx, + error_num))) DBUG_RETURN(conn); *conn->conn_key = *conn_key; if (spider) diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h index 807e1474ed2c4..1759f06baa67c 100644 --- a/storage/spider/spd_conn.h +++ b/storage/spider/spd_conn.h @@ -84,7 +84,6 @@ SPIDER_CONN *spider_create_conn( ha_spider *spider, int link_id, int base_link_id, - uint conn_kind, int *error_num ); @@ -96,7 +95,6 @@ SPIDER_CONN *spider_get_conn( ha_spider *spider, bool another, bool thd_chg, - uint conn_kind, int *error_num ); @@ -397,7 +395,6 @@ SPIDER_CONN* spider_get_conn_from_idle_connection int link_idx, char *conn_key, ha_spider *spider, - uint conn_kind, int base_link_idx, int *error_num ); diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index eb2454b2f298a..5e28b5903092a 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -593,11 +593,10 @@ int spider_udf_get_copy_tgt_conns( while (table_conn) { share = table_conn->share; - if ( - !(table_conn->conn = spider_get_conn( - share, 0, share->conn_keys[0], trx, NULL, FALSE, FALSE, - SPIDER_CONN_KIND_MYSQL, &error_num)) - ) { + if (!(table_conn->conn= + spider_get_conn(share, 0, share->conn_keys[0], trx, NULL, + FALSE, FALSE, &error_num))) + { my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), share->server_names[0]); DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); } diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 0f54709d2dbb4..634451680fd92 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -80,7 +80,7 @@ int spider_db_connect( THD* thd = current_thd; longlong connect_retry_interval; DBUG_ENTER("spider_db_connect"); - DBUG_ASSERT(conn->conn_kind != SPIDER_CONN_KIND_MYSQL || conn->need_mon); + DBUG_ASSERT(conn->need_mon); DBUG_PRINT("info",("spider link_idx=%d", link_idx)); DBUG_PRINT("info",("spider conn=%p", conn)); @@ -240,7 +240,6 @@ void spider_db_disconnect( ) { DBUG_ENTER("spider_db_disconnect"); DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->conn_kind=%u", conn->conn_kind)); if (conn->db_conn->is_connected()) { conn->db_conn->disconnect(); diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 02d0c38951571..8f8cf6c97bcc1 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -168,8 +168,6 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_LOP_CHK_PRM_PRF_STR "spider_lc_" #define SPIDER_SQL_LOP_CHK_PRM_PRF_LEN (sizeof(SPIDER_SQL_LOP_CHK_PRM_PRF_STR) - 1) -#define SPIDER_CONN_KIND_MYSQL (1 << 0) - #define SPIDER_SQL_TYPE_SELECT_SQL (1 << 0) #define SPIDER_SQL_TYPE_INSERT_SQL (1 << 1) #define SPIDER_SQL_TYPE_UPDATE_SQL (1 << 2) diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index bd34a9e035505..21c2e6bb4342a 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -8217,10 +8217,10 @@ int spider_mbase_share::discover_table_structure( SPIDER_CONN *conn; int need_mon; - if (!(conn = spider_get_conn( - spider_share, 0, spider_share->conn_keys[roop_count], trx, NULL, FALSE, - FALSE, SPIDER_CONN_KIND_MYSQL, &error_num)) - ) { + if (!(conn= spider_get_conn(spider_share, 0, + spider_share->conn_keys[roop_count], trx, NULL, + FALSE, FALSE, &error_num))) + { DBUG_RETURN(error_num); } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 429c8fa9ae793..4048607373038 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -551,7 +551,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( conn->semi_trx_isolation = -2; conn->semi_trx_isolation_chk = FALSE; conn->semi_trx_chk = FALSE; - conn->conn_kind = SPIDER_CONN_KIND_MYSQL; if (mysql_mutex_init(spd_key_mutex_mta_conn, &conn->mta_conn_mutex, MY_MUTEX_INIT_FAST)) @@ -697,7 +696,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( conn->queued_ping = FALSE; DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->conn_kind=%u", conn->conn_kind)); DBUG_RETURN(conn); error: diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 4d567e0a760f4..e6d4c2dca879b 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -327,7 +327,6 @@ typedef struct st_spider_conn_loop_check SPIDER_CONN_LOOP_CHECK; /* database connection */ typedef struct st_spider_conn { - uint conn_kind; char *conn_key; uint conn_key_length; my_hash_value_type conn_key_hash_value; diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index b331a9fec0d67..e82a5925265e6 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -594,11 +594,9 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn( ) { SPIDER_CONN *conn; DBUG_ENTER("spider_get_ping_table_tgt_conn"); - if ( - !(conn = spider_get_conn( - share, 0, share->conn_keys[0], trx, NULL, FALSE, FALSE, - SPIDER_CONN_KIND_MYSQL, error_num)) - ) { + if (!(conn= spider_get_conn(share, 0, share->conn_keys[0], trx, NULL, FALSE, + FALSE, error_num))) + { my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), share->server_names[0]); *error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index f3761c62556fc..e6ecf96de1c34 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -4842,7 +4842,6 @@ SPIDER_SHARE *spider_get_share( &spider->conn_link_idx, sizeof(uint) * share->link_count, &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size, &spider->connection_ids, sizeof(ulonglong) * share->link_count, - &spider->conn_kind, sizeof(uint) * share->link_count, &spider->db_request_id, sizeof(ulonglong) * share->link_count, &spider->db_request_phase, sizeof(uchar) * share->link_bitmap_size, &spider->need_mons, sizeof(int) * share->link_count, @@ -4875,7 +4874,6 @@ SPIDER_SHARE *spider_get_share( tmp_name += share->conn_keys_lengths[roop_count] + 1; result_list->upd_tmp_tbl_prms[roop_count].init(); result_list->upd_tmp_tbl_prms[roop_count].field_count = 1; - spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; } spider_trx_set_link_idx_for_all(spider); @@ -4930,7 +4928,6 @@ SPIDER_SHARE *spider_get_share( !(spider->conns[roop_count] = spider_get_conn(share, roop_count, spider->conn_keys[roop_count], spider->wide_handler->trx, spider, FALSE, TRUE, - SPIDER_CONN_KIND_MYSQL, error_num)) ) { if ( @@ -5297,7 +5294,6 @@ SPIDER_SHARE *spider_get_share( &spider->conn_link_idx, sizeof(uint) * share->link_count, &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size, &spider->connection_ids, sizeof(ulonglong) * share->link_count, - &spider->conn_kind, sizeof(uint) * share->link_count, &spider->db_request_id, sizeof(ulonglong) * share->link_count, &spider->db_request_phase, sizeof(uchar) * share->link_bitmap_size, &spider->need_mons, sizeof(int) * share->link_count, @@ -5327,7 +5323,6 @@ SPIDER_SHARE *spider_get_share( tmp_name += share->conn_keys_lengths[roop_count] + 1; result_list->upd_tmp_tbl_prms[roop_count].init(); result_list->upd_tmp_tbl_prms[roop_count].field_count = 1; - spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; } spider_trx_set_link_idx_for_all(spider); @@ -5379,7 +5374,6 @@ SPIDER_SHARE *spider_get_share( !(spider->conns[roop_count] = spider_get_conn(share, roop_count, spider->conn_keys[roop_count], spider->wide_handler->trx, spider, FALSE, TRUE, - SPIDER_CONN_KIND_MYSQL, error_num)) ) { if ( @@ -6034,11 +6028,9 @@ int spider_open_all_tables( } /* create conn */ - if ( - !(conn = spider_get_conn( - &tmp_share, 0, tmp_share.conn_keys[0], trx, NULL, FALSE, FALSE, - SPIDER_CONN_KIND_MYSQL, &error_num)) - ) { + if (!(conn= spider_get_conn(&tmp_share, 0, tmp_share.conn_keys[0], trx, + NULL, FALSE, FALSE, &error_num))) + { spider_sys_index_end(table_tables); spider_close_sys_table(thd, table_tables, &open_tables_backup, TRUE); @@ -6149,11 +6141,9 @@ int spider_open_all_tables( } /* create another conn */ - if ( - (!(conn = spider_get_conn( - &tmp_share, 0, tmp_share.conn_keys[0], trx, spider, TRUE, FALSE, - SPIDER_CONN_KIND_MYSQL, &error_num))) - ) { + if ((!(conn= spider_get_conn(&tmp_share, 0, tmp_share.conn_keys[0], trx, + spider, TRUE, FALSE, &error_num)))) + { spider_free_tmp_dbton_handler(spider); spider_free(trx, share, MYF(0)); delete spider; @@ -9176,9 +9166,8 @@ void *spider_table_bg_sts_action( if (!conns[spider->search_link_idx]) { spider_get_conn(share, spider->search_link_idx, - share->conn_keys[spider->search_link_idx], - trx, spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, - &error_num); + share->conn_keys[spider->search_link_idx], trx, + spider, FALSE, FALSE, &error_num); if (conns[spider->search_link_idx]) { conns[spider->search_link_idx]->error_mode = 0; @@ -9322,9 +9311,8 @@ void *spider_table_bg_crd_action( if (!conns[spider->search_link_idx]) { spider_get_conn(share, spider->search_link_idx, - share->conn_keys[spider->search_link_idx], - trx, spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, - &error_num); + share->conn_keys[spider->search_link_idx], trx, + spider, FALSE, FALSE, &error_num); if (conns[spider->search_link_idx]) { conns[spider->search_link_idx]->error_mode = 0; diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index c61aeaf502805..85b2cdb8a2717 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -2716,13 +2716,11 @@ int spider_internal_xa_commit_by_xid( goto error; } - if ( - !(conn = spider_get_conn( - &tmp_share, 0, tmp_share.conn_keys[0], trx, NULL, FALSE, FALSE, - SPIDER_CONN_KIND_MYSQL, &error_num)) && - (force_commit == 0 || - (force_commit == 1 && error_num != ER_XAER_NOTA)) - ) { + if (!(conn= spider_get_conn(&tmp_share, 0, tmp_share.conn_keys[0], trx, + NULL, FALSE, FALSE, &error_num)) && + (force_commit == 0 || + (force_commit == 1 && error_num != ER_XAER_NOTA))) + { spider_sys_index_end(table_xa_member); spider_free_tmp_share_alloc(&tmp_share); free_root(&mem_root, MYF(0)); @@ -2945,13 +2943,11 @@ int spider_internal_xa_rollback_by_xid( goto error; } - if ( - !(conn = spider_get_conn( - &tmp_share, 0, tmp_share.conn_keys[0], trx, NULL, FALSE, FALSE, - SPIDER_CONN_KIND_MYSQL, &error_num)) && - (force_commit == 0 || - (force_commit == 1 && error_num != ER_XAER_NOTA)) - ) { + if (!(conn= spider_get_conn(&tmp_share, 0, tmp_share.conn_keys[0], trx, + NULL, FALSE, FALSE, &error_num)) && + (force_commit == 0 || + (force_commit == 1 && error_num != ER_XAER_NOTA))) + { spider_sys_index_end(table_xa_member); spider_free_tmp_share_alloc(&tmp_share); free_root(&mem_root, MYF(0)); @@ -3441,11 +3437,8 @@ int spider_end_trx( DBUG_RETURN(error_num); } -int spider_check_trx_and_get_conn( - THD *thd, - ha_spider *spider, - bool use_conn_kind -) { +int spider_check_trx_and_get_conn(THD *thd, ha_spider *spider) +{ int error_num, roop_count, search_link_idx; SPIDER_TRX *trx; SPIDER_SHARE *share = spider->share; @@ -3545,22 +3538,16 @@ int spider_check_trx_and_get_conn( spider->conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { - uint tgt_conn_kind = (use_conn_kind ? spider->conn_kind[roop_count] : - SPIDER_CONN_KIND_MYSQL); if (roop_count == spider->search_link_idx) search_link_idx_is_checked = TRUE; - if ( - tgt_conn_kind == SPIDER_CONN_KIND_MYSQL && - !spider->conns[roop_count] - ) { + if (!spider->conns[roop_count]) + { *spider->conn_keys[roop_count] = first_byte; if ( !(conn = spider_get_conn(share, roop_count, spider->conn_keys[roop_count], trx, spider, FALSE, TRUE, - use_conn_kind ? spider->conn_kind[roop_count] : - SPIDER_CONN_KIND_MYSQL, &error_num)) ) { if ( @@ -3640,8 +3627,6 @@ int spider_check_trx_and_get_conn( spider_get_conn(share, roop_count, spider->conn_keys[roop_count], trx, spider, FALSE, TRUE, - use_conn_kind ? spider->conn_kind[roop_count] : - SPIDER_CONN_KIND_MYSQL, &error_num)) ) { if ( diff --git a/storage/spider/spd_trx.h b/storage/spider/spd_trx.h index 2055a49717efe..93b03fcec21f0 100644 --- a/storage/spider/spd_trx.h +++ b/storage/spider/spd_trx.h @@ -227,11 +227,7 @@ int spider_end_trx( SPIDER_CONN *conn ); -int spider_check_trx_and_get_conn( - THD *thd, - ha_spider *spider, - bool use_conn_kind -); +int spider_check_trx_and_get_conn(THD *thd, ha_spider *spider); THD *spider_create_tmp_thd(); From a5be6c91cbf3c2f9104703c0ee13e386ecb3224a Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 27 Oct 2022 09:09:39 +1100 Subject: [PATCH 100/113] MDEV-29889 mariadb-dump --tab --header is slow --header applied an ORDER BY to ensure that the header row was the first row in the output given UNION ALL doesn't in the standard enforce the order. We change that now only add the ORDER BY if --order-by-primary is used. An assumption that if UNION ALL change to a different behaviour the resulting mysqldump-header test may also change. --- client/mysqldump.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 72f3a8abfcf0d..842b13e899767 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -4230,9 +4230,13 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, if (opt_header) { - dynstr_append_checked(&query_string, " FROM (SELECT 0 AS `_$is_data_row$_`,"); + dynstr_append_checked(&query_string, " FROM ( SELECT "); + if (order_by) + dynstr_append_checked(&query_string, " 0 AS `_$is_data_row$_`,"); dynstr_append_checked(&query_string, select_field_names_for_header.str); - dynstr_append_checked(&query_string, " UNION ALL SELECT 1 AS `_$is_data_row$_`,"); + dynstr_append_checked(&query_string, " UNION ALL SELECT "); + if (order_by) + dynstr_append_checked(&query_string, "1 AS `_$is_data_row$_`,"); dynstr_append_checked(&query_string, select_field_names.str); } dynstr_append_checked(&query_string, " FROM "); @@ -4247,12 +4251,12 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, dynstr_append_checked(&query_string, where); } if (opt_header) - dynstr_append_checked(&query_string, ") s ORDER BY `_$is_data_row$_`"); + dynstr_append_checked(&query_string, ") s"); if (order_by) { if (opt_header) - dynstr_append_checked(&query_string, ","); + dynstr_append_checked(&query_string, " ORDER BY `_$is_data_row$_`,"); else dynstr_append_checked(&query_string, " ORDER BY "); dynstr_append_checked(&query_string, order_by); From 22491e627aad3ff9c9c8b076c0a1f9cb9f2ae4aa Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 7 Dec 2022 14:59:06 +0100 Subject: [PATCH 101/113] MDEV-30154: Assertion `strcasecmp(rolename, public_name.str) || acl_public == role' failed in acl_update_role on GRANT ... TO PUBLIC Reset of acl_public was made too early (before saving it to restore in case of error). --- mysql-test/main/public_basic.result | 17 +++++++++++++++++ mysql-test/main/public_basic.test | 20 ++++++++++++++++++++ sql/sql_acl.cc | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/public_basic.result b/mysql-test/main/public_basic.result index e7eb26ff68ee5..380e07a7b7e33 100644 --- a/mysql-test/main/public_basic.result +++ b/mysql-test/main/public_basic.result @@ -100,6 +100,23 @@ delete from mysql.global_priv where user="PUBLIC"; flush privileges; grant execute on procedure mtr.add_suppression to public; revoke execute on procedure mtr.add_suppression from public; +# +# MDEV-30154: Assertion `strcasecmp(rolename, public_name.str) || +# acl_public == role' failed in acl_update_role on GRANT ... TO PUBLIC +# +call mtr.add_suppression("Can't open and lock privilege tables"); +USE test; +GRANT SELECT ON *.* TO PUBLIC; +LOCK TABLES mysql.time_zone WRITE,mysql.proc WRITE; +FLUSH PRIVILEGES; +ERROR HY000: Table 'db' was not locked with LOCK TABLES +LOCK TABLE nonexisting WRITE; +ERROR 42S02: Table 'test.nonexisting' doesn't exist +GRANT SELECT ON *.* TO PUBLIC; +REVOKE SELECT ON *.* FROM PUBLIC; +# +# End of 10.11 test +# # clean up delete from mysql.global_priv where user="PUBLIC"; flush privileges; diff --git a/mysql-test/main/public_basic.test b/mysql-test/main/public_basic.test index 99952c54e943e..fb175820ee0d5 100644 --- a/mysql-test/main/public_basic.test +++ b/mysql-test/main/public_basic.test @@ -109,6 +109,26 @@ flush privileges; grant execute on procedure mtr.add_suppression to public; revoke execute on procedure mtr.add_suppression from public; +--echo # +--echo # MDEV-30154: Assertion `strcasecmp(rolename, public_name.str) || +--echo # acl_public == role' failed in acl_update_role on GRANT ... TO PUBLIC +--echo # +call mtr.add_suppression("Can't open and lock privilege tables"); +USE test; +GRANT SELECT ON *.* TO PUBLIC; +LOCK TABLES mysql.time_zone WRITE,mysql.proc WRITE; +--error 1100 +FLUSH PRIVILEGES; +--error 1146 +LOCK TABLE nonexisting WRITE; +GRANT SELECT ON *.* TO PUBLIC; + +REVOKE SELECT ON *.* FROM PUBLIC; + +--echo # +--echo # End of 10.11 test +--echo # + -- echo # clean up delete from mysql.global_priv where user="PUBLIC"; flush privileges; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index e91770c8686fd..8cf9c7b6df2ce 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2918,7 +2918,6 @@ bool acl_reload(THD *thd) int result; DBUG_ENTER("acl_reload"); - acl_public= NULL; Grant_tables tables; /* @@ -2963,6 +2962,7 @@ bool acl_reload(THD *thd) old_mem= acl_memroot; delete_dynamic(&acl_wild_hosts); my_hash_free(&acl_check_hosts); + acl_public= NULL; if ((result= acl_load(thd, tables))) { // Error. Revert to old list From c6e0ab74f02cb502bda0a6cce6901a5fd19c6b02 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 3 Jan 2023 10:43:51 +0100 Subject: [PATCH 102/113] bump the VERSION --- VERSION | 4 ++-- mysql-test/suite/sys_vars/r/sysvars_star.result | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 03af4aaf27f43..2b0eac3dbce9c 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=11 MYSQL_VERSION_MINOR=0 -MYSQL_VERSION_PATCH=0 -SERVER_MATURITY=beta +MYSQL_VERSION_PATCH=1 +SERVER_MATURITY=gamma diff --git a/mysql-test/suite/sys_vars/r/sysvars_star.result b/mysql-test/suite/sys_vars/r/sysvars_star.result index b4c0ea875811a..b3357fda3afab 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_star.result +++ b/mysql-test/suite/sys_vars/r/sysvars_star.result @@ -60,7 +60,7 @@ VARIABLE_NAME PLUGIN_MATURITY SESSION_VALUE NULL GLOBAL_VALUE alpha GLOBAL_VALUE_ORIGIN CONFIG -DEFAULT_VALUE alpha +DEFAULT_VALUE beta VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded From cfaf47a4d4d740bbf561898a4c96670e7df4d428 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 3 Jan 2023 13:38:55 +1100 Subject: [PATCH 103/113] acl - is_public - avoid embedded warning Using clang generates the unused-function warning on embedded like: FAILED: libmysqld/CMakeFiles/sql_embedded.dir/__/sql/sql_acl.cc.o /usr/lib64/ccache/clang++ .... libmysqld/CMakeFiles/sql_embedded.dir/__/sql/sql_acl.cc.o -MF libmysqld/CMakeFiles/sql_embedded.dir/__/sql/sql_acl.cc.o.d -o libmysqld/CMakeFiles/sql_embedded.dir/__/sql/sql_acl.cc.o -c /home/dan/repos/mariadb-server-10.11/sql/sql_acl.cc sql_acl.cc:113:20: error: unused function 'is_public' [-Werror,-Wunused-function] static inline bool is_public(const LEX_USER *l) { return is_public(&l->user); } --- sql/sql_acl.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 8cf9c7b6df2ce..038b1d56acaeb 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -108,10 +108,6 @@ LEX_CSTRING current_user_and_current_role= LEX_CSTRING none= {STRING_WITH_LEN("NONE") }; LEX_CSTRING public_name= {STRING_WITH_LEN("PUBLIC") }; -static inline bool is_public(const char *l) { return l == public_name.str; } -static inline bool is_public(const LEX_CSTRING *l) { return is_public(l->str); } -static inline bool is_public(const LEX_USER *l) { return is_public(&l->user); } - static plugin_ref old_password_plugin; static plugin_ref native_password_plugin; @@ -135,6 +131,10 @@ struct acl_host_and_ip #ifndef NO_EMBEDDED_ACCESS_CHECKS static bool compare_hostname(const acl_host_and_ip *, const char *, const char *); +static inline bool is_public(const char *l) { return l == public_name.str; } +static inline bool is_public(const LEX_CSTRING *l) { return is_public(l->str); } +static inline bool is_public(const LEX_USER *l) { return is_public(&l->user); } + #else #define compare_hostname(X,Y,Z) 0 #endif From b075191ba8598af6aff5549e6e19f6255aef258a Mon Sep 17 00:00:00 2001 From: Rex Date: Fri, 6 Jan 2023 15:03:54 +1200 Subject: [PATCH 104/113] MDEV-30353 Debian additions version fix fix up version detection in debian/additions/innotop after 10->11 --- debian/additions/innotop/innotop | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/additions/innotop/innotop b/debian/additions/innotop/innotop index 5d81980341dec..1602c21e8066e 100644 --- a/debian/additions/innotop/innotop +++ b/debian/additions/innotop/innotop @@ -466,7 +466,7 @@ sub parse_status_text { # too many locks to print, the output might be truncated) my $time_text; - if ( ($mysqlversion =~ /^5\.[67]\./) || ($mysqlversion =~ /^10\.[0-9]\./) ) { + if ( ($mysqlversion =~ /^5\.[67]\./) || ($mysqlversion =~ /^10|11\.[0-9]\./) ) { ( $time_text ) = $fulltext =~ m/^([0-9-]* [0-9:]*) [0-9a-fx]* INNODB MONITOR OUTPUT/m; $innodb_data{'ts'} = [ parse_innodb_timestamp_56( $time_text ) ]; } else { @@ -634,7 +634,7 @@ sub parse_fk_section { return 0 unless $fulltext; my ( $ts, $type ); - if ( ($mysqlversion =~ /^5.[67]\./) || ($mysqlversion =~ /^10.[0-9]\./) ) { + if ( ($mysqlversion =~ /^5.[67]\./) || ($mysqlversion =~ /^10|11.[0-9]\./) ) { ( $ts, $type ) = $fulltext =~ m/^([0-9-]* [0-9:]*)\s[0-9a-fx]*\s+(\w+)/m; $section->{'ts'} = [ parse_innodb_timestamp_56( $ts ) ]; } else { @@ -894,7 +894,7 @@ sub parse_dl_section { my ( $ts ) = $fulltext =~ m/^$s$/m; return 0 unless $ts; - if ( ($mysqlversion =~ /^5\.[67]\./) || ($mysqlversion =~ /^10\.[0-9]\./) ) { + if ( ($mysqlversion =~ /^5\.[67]\./) || ($mysqlversion =~ /^10|11\.[0-9]\./) ) { $dl->{'ts'} = [ parse_innodb_timestamp_56( $ts ) ]; } else { From 70be59913c90e93fe5136d6f6df03c4254aa515d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sat, 26 Nov 2022 18:19:35 -0800 Subject: [PATCH 105/113] Deb: Misc fixes for 10.11 series - Prefer Breaks+Replaces over Conflicts+Replaces in debian/control. - Clean away conflict/break/replace with self as it either has no effect or harmfully prevents upgrades to self (packages from this source version). - Remove references to mariadb-server-10.11 as the package names no longer have versions and thus such references are unnecessary cruft. - Apply 'wrap-and-sort -av' and minor typo fixing. - Extend Salsa-CI to test for upgrades from 10.9 and 10.10 to 10.11. - Add minimal required new Lintian overrides so Salsa-CI would not fail on Lintian. --- debian/autobake-deb.sh | 2 +- debian/control | 23 ++----- ...db-plugin-provider-bzip2.lintian-overrides | 2 +- ...iadb-plugin-provider-lz4.lintian-overrides | 2 +- ...adb-plugin-provider-lzma.lintian-overrides | 2 +- ...iadb-plugin-provider-lzo.lintian-overrides | 2 +- ...b-plugin-provider-snappy.lintian-overrides | 2 +- debian/mariadb-server-core.install | 2 +- debian/mariadb-test-data.lintian-overrides | 2 - debian/mariadb-test.lintian-overrides | 2 - debian/salsa-ci.yml | 69 +++++++++++++++++-- debian/source/lintian-overrides | 16 +++-- 12 files changed, 89 insertions(+), 37 deletions(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 36cf47b6b9426..d9b2b007066df 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -70,7 +70,7 @@ disable_pmem() disable_libfmt() { - # 0.7+ required + # 7.0+ required sed '/libfmt-dev/d' -i debian/control } diff --git a/debian/control b/debian/control index 81418c1365626..91766d64b3ea3 100644 --- a/debian/control +++ b/debian/control @@ -271,8 +271,7 @@ Depends: libmariadb3 (>= 10.5.4), mariadb-common (>= ${source:Version}), ${misc:Depends}, ${shlibs:Depends} -Conflicts: mariadb-client (<< ${source:Version}), - mariadb-client-10.0, +Conflicts: mariadb-client-10.0, mariadb-client-10.1, mariadb-client-10.2, mariadb-client-10.3, @@ -308,7 +307,8 @@ Conflicts: mariadb-client (<< ${source:Version}), mysql-client-core-5.7, mysql-client-core-8.0, virtual-mysql-client-core -Breaks: mariadb-server-10.0, +Breaks: mariadb-client (<< ${source:Version}), + mariadb-server-10.0, mariadb-server-10.1, mariadb-server-core (<< ${source:Version}), mariadb-server-core-10.0, @@ -384,7 +384,6 @@ Replaces: mariadb-client (<< ${source:Version}), percona-xtradb-cluster-server-5.7, virtual-mysql-client-core Provides: default-mysql-client-core, - mariadb-client-core-10.11, virtual-mysql-client-core Description: MariaDB database core client binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database @@ -403,8 +402,7 @@ Depends: debianutils (>=1.6), ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends} -Conflicts: mariadb-client (<< ${source:Version}), - mariadb-client-10.0, +Conflicts: mariadb-client-10.0, mariadb-client-10.1, mariadb-client-10.2, mariadb-client-10.3, @@ -473,8 +471,7 @@ Breaks: mariadb-client-core (<< ${source:Version}), percona-server-server-5.6, percona-xtradb-cluster-server-5.6, percona-xtradb-cluster-server-5.7 -Replaces: mariadb-client (<< ${source:Version}), - mariadb-client-10.0, +Replaces: mariadb-client-10.0, mariadb-client-10.1, mariadb-client-10.2, mariadb-client-10.3, @@ -544,7 +541,6 @@ Replaces: mariadb-client (<< ${source:Version}), percona-xtradb-cluster-server-5.7, virtual-mysql-client Provides: default-mysql-client, - mariadb-client-10.11, virtual-mysql-client Recommends: libdbd-mariadb-perl | libdbd-mysql-perl, libdbi-perl, @@ -563,8 +559,7 @@ Architecture: any Depends: mariadb-common (>= ${source:Version}), ${misc:Depends}, ${shlibs:Depends} -Conflicts: mariadb-server-core (<< ${source:Version}), - mariadb-server-core-10.0, +Conflicts: mariadb-server-core-10.0, mariadb-server-core-10.1, mariadb-server-core-10.2, mariadb-server-core-10.3, @@ -658,7 +653,6 @@ Replaces: mariadb-client (<< ${source:Version}), percona-xtradb-cluster-server-5.7, virtual-mysql-server-core Provides: default-mysql-server-core, - mariadb-server-core-10.11, virtual-mysql-server-core Description: MariaDB database core server files MariaDB is a fast, stable and true multi-user, multi-threaded SQL database @@ -695,8 +689,7 @@ Depends: galera-4 (>= 26.4), ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends} -Conflicts: mariadb-server (<< ${source:Version}), - mariadb-server-10.0, +Conflicts: mariadb-server-10.0, mariadb-server-10.1, mariadb-server-10.2, mariadb-server-10.3, @@ -739,7 +732,6 @@ Replaces: handlersocket-mysql-5.5, mariadb-client-10.6, mariadb-client-10.7, mariadb-client-10.8, - mariadb-server (<< ${source:Version}), mariadb-server-10.0, mariadb-server-10.1, mariadb-server-10.2, @@ -771,7 +763,6 @@ Replaces: handlersocket-mysql-5.5, percona-xtradb-cluster-server-5.7, virtual-mysql-server Provides: default-mysql-server, - mariadb-server-10.11, virtual-mysql-server Description: MariaDB database server binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database diff --git a/debian/mariadb-plugin-provider-bzip2.lintian-overrides b/debian/mariadb-plugin-provider-bzip2.lintian-overrides index 563c05a3a6b05..47298832bcfda 100644 --- a/debian/mariadb-plugin-provider-bzip2.lintian-overrides +++ b/debian/mariadb-plugin-provider-bzip2.lintian-overrides @@ -1,3 +1,3 @@ # It's intentional that bzip2 compression plugin doesn't have symbols from libc # More info https://jira.mariadb.org/browse/MDEV-28120 -library-not-linked-against-libc usr/lib/mysql/plugin/provider_bzip2.so \ No newline at end of file +library-not-linked-against-libc [usr/lib/mysql/plugin/provider_bzip2.so] diff --git a/debian/mariadb-plugin-provider-lz4.lintian-overrides b/debian/mariadb-plugin-provider-lz4.lintian-overrides index 3f7d7e9ecfbb8..dbfde13313538 100644 --- a/debian/mariadb-plugin-provider-lz4.lintian-overrides +++ b/debian/mariadb-plugin-provider-lz4.lintian-overrides @@ -1,3 +1,3 @@ # It's intentional that LZ4 compression plugin doesn't have symbols from libc # More info https://jira.mariadb.org/browse/MDEV-28120 -library-not-linked-against-libc usr/lib/mysql/plugin/provider_lz4.so \ No newline at end of file +library-not-linked-against-libc [usr/lib/mysql/plugin/provider_lz4.so] diff --git a/debian/mariadb-plugin-provider-lzma.lintian-overrides b/debian/mariadb-plugin-provider-lzma.lintian-overrides index 94eafa766a408..79f6cb793c279 100644 --- a/debian/mariadb-plugin-provider-lzma.lintian-overrides +++ b/debian/mariadb-plugin-provider-lzma.lintian-overrides @@ -1,3 +1,3 @@ # It's intentional that LZMA compression plugin doesn't have symbols from libc # More info https://jira.mariadb.org/browse/MDEV-28120 -library-not-linked-against-libc usr/lib/mysql/plugin/provider_lzma.so \ No newline at end of file +library-not-linked-against-libc [usr/lib/mysql/plugin/provider_lzma.so] diff --git a/debian/mariadb-plugin-provider-lzo.lintian-overrides b/debian/mariadb-plugin-provider-lzo.lintian-overrides index 8184923cf9a15..ccca4e2d355d3 100644 --- a/debian/mariadb-plugin-provider-lzo.lintian-overrides +++ b/debian/mariadb-plugin-provider-lzo.lintian-overrides @@ -1,3 +1,3 @@ # It's intentional that LZO compression plugin doesn't have symbols from libc # More info https://jira.mariadb.org/browse/MDEV-28120 -library-not-linked-against-libc usr/lib/mysql/plugin/provider_lzo.so \ No newline at end of file +library-not-linked-against-libc [usr/lib/mysql/plugin/provider_lzo.so] diff --git a/debian/mariadb-plugin-provider-snappy.lintian-overrides b/debian/mariadb-plugin-provider-snappy.lintian-overrides index 6c76162573d74..b62907c34698a 100644 --- a/debian/mariadb-plugin-provider-snappy.lintian-overrides +++ b/debian/mariadb-plugin-provider-snappy.lintian-overrides @@ -1,3 +1,3 @@ # It's intentional that Snappy compression plugin doesn't have symbols from libc # More info https://jira.mariadb.org/browse/MDEV-28120 -library-not-linked-against-libc usr/lib/mysql/plugin/provider_snappy.so \ No newline at end of file +library-not-linked-against-libc [usr/lib/mysql/plugin/provider_snappy.so] diff --git a/debian/mariadb-server-core.install b/debian/mariadb-server-core.install index 1a07a3fea9494..4eee370672a91 100644 --- a/debian/mariadb-server-core.install +++ b/debian/mariadb-server-core.install @@ -15,8 +15,8 @@ usr/share/man/man1/resolveip.1 usr/share/man/man8/mariadbd.8 usr/share/man/man8/mysqld.8 usr/share/mysql/bulgarian -usr/share/mysql/chinese usr/share/mysql/charsets +usr/share/mysql/chinese usr/share/mysql/czech usr/share/mysql/danish usr/share/mysql/dutch diff --git a/debian/mariadb-test-data.lintian-overrides b/debian/mariadb-test-data.lintian-overrides index 85e40a8b429bd..b73e31029e6ca 100644 --- a/debian/mariadb-test-data.lintian-overrides +++ b/debian/mariadb-test-data.lintian-overrides @@ -1,7 +1,5 @@ # These should be moved, see https://jira.mariadb.org/browse/MDEV-21654 -arch-dependent-file-in-usr-share usr/share/mysql/mysql-test/suite/plugins/pam/pam_mariadb_mtr.so arch-dependent-file-in-usr-share [usr/share/mysql/mysql-test/suite/plugins/pam/pam_mariadb_mtr.so] -arch-independent-package-contains-binary-or-object usr/share/mysql/mysql-test/suite/plugins/pam/pam_mariadb_mtr.so arch-independent-package-contains-binary-or-object [usr/share/mysql/mysql-test/suite/plugins/pam/pam_mariadb_mtr.so] # Mainly for support for *BSD family. Not right way to do but this is test package and not for production incorrect-path-for-interpreter /usr/bin/env perl != /usr/bin/perl [usr/share/mysql/mysql-test/std_data/checkDBI_DBD-MariaDB.pl] diff --git a/debian/mariadb-test.lintian-overrides b/debian/mariadb-test.lintian-overrides index 5bac3d60cacf4..d09cfe3c537da 100644 --- a/debian/mariadb-test.lintian-overrides +++ b/debian/mariadb-test.lintian-overrides @@ -1,6 +1,4 @@ # These should be moved, see https://jira.mariadb.org/browse/MDEV-21653 -arch-dependent-file-in-usr-share usr/share/mysql/mysql-test/lib/My/SafeProcess/my_safe_process -arch-dependent-file-in-usr-share usr/share/mysql/mysql-test/lib/My/SafeProcess/wsrep_check_version arch-dependent-file-in-usr-share [usr/share/mysql/mysql-test/lib/My/SafeProcess/my_safe_process] arch-dependent-file-in-usr-share [usr/share/mysql/mysql-test/lib/My/SafeProcess/wsrep_check_version] # Mainly for support for *BSD family. Not right way to do but this is test package and not for production diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml index dc3ee9e9db108..23a736ec6fdb0 100644 --- a/debian/salsa-ci.yml +++ b/debian/salsa-ci.yml @@ -522,6 +522,70 @@ mysql-8.0 Jammy to mariadb upgrade: variables: - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ +mariadb.org 10.11 to mariadb upgrade: + stage: upgrade extras + needs: + - job: build + image: debian:${RELEASE} + artifacts: + when: always + name: "$CI_BUILD_NAME" + paths: + - ${WORKING_DIR}/debug + script: + - *test-prepare-container + - apt install -y curl + - curl -sS https://mariadb.org/mariadb_release_signing_key.asc -o /etc/apt/trusted.gpg.d/mariadb.asc + - echo "deb https://deb.mariadb.org/10.11/debian ${RELEASE} main" > /etc/apt/sources.list.d/mariadb.list + - apt-get update + - apt-get install -y mariadb-server + - *test-verify-initial + # Install MariaDB built in this commit + # Force downgrades so our version installs on top of upstream revision, e.g. 1:10.9.1-1 vs 1:10.9.1+mariadb~sid + - apt-get install -y --allow-downgrades ./*.deb + # Verify installation of MariaDB built in this commit + - dpkg -l | grep -iE 'maria|mysql|galera' || true # List installed + - mariadb --version # Client version + - service mariadb status # There is no init.d/mysql in MariaDB 10.5+ + - *test-verify-final + variables: + GIT_STRATEGY: none + except: + variables: + - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ + +mariadb.org 10.10 to mariadb upgrade: + stage: upgrade extras + needs: + - job: build + image: debian:${RELEASE} + artifacts: + when: always + name: "$CI_BUILD_NAME" + paths: + - ${WORKING_DIR}/debug + script: + - *test-prepare-container + - apt install -y curl + - curl -sS https://mariadb.org/mariadb_release_signing_key.asc -o /etc/apt/trusted.gpg.d/mariadb.asc + - echo "deb https://deb.mariadb.org/10.10/debian ${RELEASE} main" > /etc/apt/sources.list.d/mariadb.list + - apt-get update + - apt-get install -y mariadb-server + - *test-verify-initial + # Install MariaDB built in this commit + # Force downgrades so our version installs on top of upstream revision, e.g. 1:10.9.1-1 vs 1:10.9.1+mariadb~sid + - apt-get install -y --allow-downgrades ./*.deb + # Verify installation of MariaDB built in this commit + - dpkg -l | grep -iE 'maria|mysql|galera' || true # List installed + - mariadb --version # Client version + - service mariadb status # There is no init.d/mysql in MariaDB 10.5+ + - *test-verify-final + variables: + GIT_STRATEGY: none + except: + variables: + - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ + mariadb.org 10.9 to mariadb upgrade: stage: upgrade extras needs: @@ -538,7 +602,7 @@ mariadb.org 10.9 to mariadb upgrade: - curl -sS https://mariadb.org/mariadb_release_signing_key.asc -o /etc/apt/trusted.gpg.d/mariadb.asc - echo "deb https://deb.mariadb.org/10.9/debian ${RELEASE} main" > /etc/apt/sources.list.d/mariadb.list - apt-get update - - apt-get install -y mariadb-server-10.9 + - apt-get install -y mariadb-server - *test-verify-initial # Install MariaDB built in this commit # Force downgrades so our version installs on top of upstream revision, e.g. 1:10.9.1-1 vs 1:10.9.1+mariadb~sid @@ -553,7 +617,6 @@ mariadb.org 10.9 to mariadb upgrade: except: variables: - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ - allow_failure: true mariadb.org-10.8 to mariadb upgrade: stage: upgrade extras @@ -586,7 +649,6 @@ mariadb.org-10.8 to mariadb upgrade: except: variables: - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ - allow_failure: true mariadb.org-10.7 to mariadb upgrade: stage: upgrade extras @@ -619,7 +681,6 @@ mariadb.org-10.7 to mariadb upgrade: except: variables: - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ - allow_failure: true mariadb.org-10.6 to mariadb upgrade: stage: upgrade extras diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides index 1deb9f8c4e9a6..306ab27271dc6 100644 --- a/debian/source/lintian-overrides +++ b/debian/source/lintian-overrides @@ -4,13 +4,10 @@ version-substvar-for-external-package mariadb-client-core -> mysql-client-5.5 version-substvar-for-external-package mariadb-server -> mysql-server version-substvar-for-external-package libmariadb-dev -> libmysqlclient-dev version-substvar-for-external-package libmariadb-dev -> libmysqld-dev -version-substvar-for-external-package mariadb-server-10.9 -> mysql-client-5.* -version-substvar-for-external-package mariadb-server-10.9 -> mysql-client-8.* -version-substvar-for-external-package mariadb-client-10.9 -> mysql-client-core-5.* -version-substvar-for-external-package mariadb-client-10.9 -> mysql-client-core-8.* +version-substvar-for-external-package Replaces ${source:Version} libmariadb-dev -> libmysqlclient-dev [debian/control:74] +version-substvar-for-external-package Replaces ${source:Version} libmariadb-dev -> libmysqld-dev [debian/control:74] version-substvar-for-external-package libmariadbd-dev -> libmariadbclient-dev -# Intentional version-substvar-for-external-package as long as mariadb-server -# provides mariadb-server-10.11 and mariadb-client provides mariadb-client-10.11 +version-substvar-for-external-package Replaces ${source:Version} libmariadbd-dev -> libmariadbclient-dev [debian/control:232] version-substvar-for-external-package Conflicts (line 408) ${source:Version} mariadb-client -> mariadb-client-10.11 version-substvar-for-external-package Conflicts (line 575) ${source:Version} mariadb-server-core -> mariadb-server-core-10.11 version-substvar-for-external-package Conflicts (line 711) ${source:Version} mariadb-server -> mariadb-server-10.11 @@ -106,3 +103,10 @@ source-contains-autogenerated-visual-c++-file storage/columnstore/columnstore/*. source-contains-autogenerated-visual-c++-file storage/columnstore/columnstore/*.h source-contains-autogenerated-visual-c++-file win/upgrade_wizard/resource.h source-contains-autogenerated-visual-c++-file win/upgrade_wizard/upgrade.rc + +# New in 10.11 +version-substvar-for-external-package Conflicts ${source:Version} libmariadb-dev-compat -> libmariadbclient-dev [debian/control:95] +version-substvar-for-external-package Replaces ${source:Version} libmariadb-dev-compat -> libmariadbclient-dev [debian/control:109] +missing-build-dependency-for-dh-addon systemd (does not satisfy debhelper:any (>= 9.20160709~) | debhelper-compat:any | dh-sequence-systemd:any | dh-systemd:any) [debian/rules] +source-is-missing [sql/share/charsets/languages.html] +source-is-missing [storage/rocksdb/rocksdb/docs/_includes/footer.html] From d29d915790f7da41cd89c469f0a4c6c9b8f8a5c3 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 12 Dec 2022 12:47:01 +1100 Subject: [PATCH 106/113] Use MariaDB as the project name in CMakeLists.txt As a consequence of this it doesn't need to manually set CPACK_PACKAGE_NAME or CPACK_RPM_PACKAGE_NAME. --- CMakeLists.txt | 3 +-- cmake/cpack_rpm.cmake | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77034d38118bb..95034a6acecbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) "None" "Debug" "Release" "MinSizeRel" "RelWithDebInfo") ENDIF() -PROJECT(MySQL) +PROJECT(MariaDB) # Remove the following comment if you don't want to have striped binaries # in RPM's: @@ -88,7 +88,6 @@ ELSE() SET(CMAKE_CXX_STANDARD 11) ENDIF() -SET(CPACK_PACKAGE_NAME "MariaDB") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MariaDB: a very fast and robust SQL database server") SET(CPACK_PACKAGE_URL "http://mariadb.org") diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 339363b216943..f14bc9e93b8e9 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -34,7 +34,6 @@ SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts backup ) -SET(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) SET(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) IF(CMAKE_VERSION VERSION_LESS "3.6.0") SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${SERVER_VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}") From e581396b7aea94485580d2c9edaa9c5df647f2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 14 Dec 2022 14:42:20 +0200 Subject: [PATCH 107/113] MDEV-29983 Deprecate innodb_file_per_table Before commit 6112853cdab2770e92f9cfefdfef9c0a14b71cb7 in MySQL 4.1.1 introduced the parameter innodb_file_per_table, all InnoDB data was written to the InnoDB system tablespace (often named ibdata1). A serious design problem is that once the system tablespace has grown to some size, it cannot shrink even if the data inside it has been deleted. There are also other design problems, such as the server hang MDEV-29930 that should only be possible when using innodb_file_per_table=0 and innodb_undo_tablespaces=0 (storing both tables and undo logs in the InnoDB system tablespace). The parameter innodb_change_buffering was deprecated in commit b5852ffbeebc3000982988383daeefb0549e058a. Starting with commit baf276e6d4a44fe7cdf3b435c0153da0a42af2b6 (MDEV-19229) the number of innodb_undo_tablespaces can be increased, so that the undo logs can be moved out of the system tablespace of an existing installation. If all these things (tables, undo logs, and the change buffer) are removed from the InnoDB system tablespace, the only variable-size data structure inside it is the InnoDB data dictionary. DDL operations on .ibd files was optimized in commit 86dc7b4d4cfe15a2d37f8b5f60c4fce5dba9491d (MDEV-24626). That should have removed any thinkable performance advantage of using innodb_file_per_table=0. Since there should be no benefit of setting innodb_file_per_table=0, the parameter should be deprecated. Starting with MySQL 5.6 and MariaDB Server 10.0, the default value is innodb_file_per_table=1. --- mysql-test/main/bug46760-master.opt | 1 - mysql-test/main/column_compression_parts.test | 1 - .../main/crash_commit_before-master.opt | 1 - mysql-test/main/flush-innodb.result | 5 ---- mysql-test/main/flush-innodb.test | 7 ------ mysql-test/main/partition_exchange.result | 2 +- mysql-test/main/partition_exchange.test | 2 +- .../main/partition_innodb_plugin.result | 6 +++++ .../binlog_encryption/rpl_sync-master.opt | 1 - .../binlog_encryption/rpl_sync-slave.opt | 2 +- .../encryption/r/encrypt_and_grep.result | 1 - .../suite/encryption/r/innochecksum.result | 1 - .../encryption/r/innodb-bad-key-change.result | 1 - .../r/innodb-bad-key-change2.result | 1 - .../r/innodb-bad-key-change4.result | 1 - .../r/innodb-checksum-algorithm.result | 3 --- .../r/innodb-compressed-blob.result | 1 - .../encryption/r/innodb-force-corrupt.result | 1 - .../r/innodb-key-rotation-disable.result | 1 - .../encryption/r/innodb-redo-badkey.result | 1 - .../encryption/r/innodb-redo-nokeys.result | 1 - .../r/innodb-remove-encryption.result | 2 ++ .../r/innodb_onlinealter_encryption.result | 1 - .../suite/encryption/t/encrypt_and_grep.test | 2 -- .../suite/encryption/t/innochecksum.test | 1 - .../encryption/t/innodb-bad-key-change.test | 2 -- .../encryption/t/innodb-bad-key-change2.test | 2 -- .../encryption/t/innodb-bad-key-change4.test | 2 -- .../t/innodb-checksum-algorithm.test | 3 --- .../encryption/t/innodb-compressed-blob.test | 2 -- .../encryption/t/innodb-force-corrupt.test | 1 - .../t/innodb-key-rotation-disable.test | 1 - .../encryption/t/innodb-redo-badkey.test | 2 -- .../encryption/t/innodb-redo-nokeys.test | 2 -- .../t/innodb_onlinealter_encryption.test | 2 -- .../suite/galera/t/galera_ist_MDEV-28423.cnf | 2 -- .../suite/galera/t/galera_ist_MDEV-28583.cnf | 2 -- .../suite/galera/t/galera_load_data.cnf | 2 -- .../suite/galera/t/galera_sst_encrypted.cnf | 1 - .../galera_sst_mariabackup_table_options.cnf | 1 - .../include/innodb_bulk_create_index.inc | 8 ------- .../innodb_bulk_create_index_debug.inc | 8 ------- .../include/innodb_merge_threshold_delete.inc | 2 +- .../innodb_merge_threshold_secondary.inc | 2 +- .../include/innodb_merge_threshold_update.inc | 2 +- mysql-test/suite/innodb/r/alter_kill.result | 2 -- .../innodb/r/alter_missing_tablespace.result | 1 - .../innodb/r/alter_rename_existing.result | 6 +++++ mysql-test/suite/innodb/r/dropdb_cs.result | 4 ++++ .../innodb/r/index_tree_operation.result | 1 - .../suite/innodb/r/innodb-fkcheck.result | 7 ++---- .../suite/innodb/r/innodb-index-online.result | 3 --- .../suite/innodb/r/innodb-table-online.result | 3 --- .../suite/innodb/r/innodb-wl5522-debug.result | 6 ----- .../suite/innodb/r/innodb-wl5522.result | 5 +++- .../suite/innodb/r/innodb-wl5980-alter.result | 3 --- .../suite/innodb/r/innodb_bug14147491.result | 1 - .../suite/innodb/r/innodb_bug56947.result | 9 ++++++-- .../suite/innodb/r/innodb_bug68148.result | 1 - .../innodb/r/innodb_bulk_create_index.result | 2 -- .../r/innodb_bulk_create_index_debug.result | 4 ---- .../r/innodb_bulk_create_index_small.result | 3 --- .../suite/innodb/r/log_data_file_size.result | 4 ++++ .../suite/innodb/r/log_file_name.result | 1 - mysql-test/suite/innodb/r/mvcc.result | 3 --- .../innodb/r/row_format_redundant.result | 4 ++-- mysql-test/suite/innodb/r/table_flags.result | 1 - mysql-test/suite/innodb/t/alter_kill.test | 3 --- .../innodb/t/alter_missing_tablespace.test | 1 - .../suite/innodb/t/index_tree_operation.test | 10 -------- .../suite/innodb/t/innodb-bug-14068765.test | 2 +- .../suite/innodb/t/innodb-bug-14084530.test | 2 +- .../suite/innodb/t/innodb-enlarge-blob.opt | 1 - mysql-test/suite/innodb/t/innodb-fkcheck.test | 23 +++---------------- .../suite/innodb/t/innodb-index-online.test | 5 ---- .../suite/innodb/t/innodb-table-online.test | 5 ---- .../suite/innodb/t/innodb-wl5522-debug.test | 10 -------- mysql-test/suite/innodb/t/innodb-wl5522.test | 9 ++++---- .../suite/innodb/t/innodb-wl5980-alter.test | 4 ---- .../innodb/t/innodb_bug14147491-master.opt | 1 - .../suite/innodb/t/innodb_bug14147491.test | 2 -- .../suite/innodb/t/innodb_bug39438-master.opt | 1 - .../suite/innodb/t/innodb_bug39438.test | 4 ---- .../suite/innodb/t/innodb_bug56947.test | 5 ++-- .../suite/innodb/t/innodb_bug68148.test | 2 -- .../t/innodb_bulk_create_index_small.test | 7 ------ .../suite/innodb/t/innodb_defragment.opt | 3 +-- mysql-test/suite/innodb/t/log_file_name.test | 1 - mysql-test/suite/innodb/t/monitor.test | 2 +- mysql-test/suite/innodb/t/mvcc.test | 5 ---- .../suite/innodb/t/row_format_redundant.test | 3 --- mysql-test/suite/innodb/t/table_flags.test | 1 - .../suite/innodb_fts/r/crash_recovery.result | 2 ++ mysql-test/suite/innodb_fts/r/fulltext.result | 4 ++++ .../innodb_fts/r/innodb_fts_misc_1.result | 5 ++-- .../innodb_fts/r/innodb_fts_proximity.result | 3 --- .../suite/innodb_fts/t/innodb_fts_misc_1.test | 11 +-------- .../innodb_fts/t/innodb_fts_proximity.test | 12 ---------- mysql-test/suite/innodb_zip/r/bug36169.result | 2 +- mysql-test/suite/innodb_zip/r/bug53591.result | 7 ------ mysql-test/suite/innodb_zip/r/bug56680.result | 1 - .../suite/innodb_zip/r/cmp_drop_table.result | 1 - .../suite/innodb_zip/r/create_options.result | 17 +++++++++++++- .../innodb_zip/r/index_large_prefix.result | 2 -- .../suite/innodb_zip/r/innodb-zip.result | 12 +++++++++- .../suite/innodb_zip/r/large_blob.result | 5 +++- .../suite/innodb_zip/r/page_size,4k.rdiff | 20 ++++++++-------- .../suite/innodb_zip/r/page_size,8k.rdiff | 20 ++++++++-------- .../suite/innodb_zip/r/page_size.result | 4 ++++ mysql-test/suite/innodb_zip/r/restart.result | 10 -------- .../suite/innodb_zip/r/wl5522_zip.result | 4 ++++ .../innodb_zip/r/wl6347_comp_indx_stat.result | 16 ------------- mysql-test/suite/innodb_zip/t/bug36169.test | 7 +----- mysql-test/suite/innodb_zip/t/bug53591.test | 10 -------- mysql-test/suite/innodb_zip/t/bug56680.test | 1 - .../suite/innodb_zip/t/cmp_drop_table.test | 11 --------- .../suite/innodb_zip/t/create_options.test | 9 -------- .../innodb_zip/t/index_large_prefix.test | 6 ----- .../innodb_zip/t/index_large_prefix_4k.test | 6 ----- .../innodb_zip/t/index_large_prefix_8k.test | 6 ----- mysql-test/suite/innodb_zip/t/innodb-zip.test | 8 ++----- mysql-test/suite/innodb_zip/t/large_blob.test | 9 -------- mysql-test/suite/innodb_zip/t/restart.test | 13 ----------- mysql-test/suite/innodb_zip/t/wl5522_zip.test | 8 +++---- .../innodb_zip/t/wl6347_comp_indx_stat.test | 16 ------------- .../suite/mariabackup/mdev-14447.result | 2 ++ .../mariabackup/xb_compressed_encrypted.opt | 1 - .../mariabackup/xb_fulltext_encrypted.opt | 1 - .../r/alter_data_directory_innodb.result | 4 ++++ mysql-test/suite/parts/r/longname.result | 4 ++++ .../r/partition_basic_symlink_innodb.result | 8 +++++++ .../r/reorganize_partition_innodb.result | 4 ++++ .../parts/t/debug_innodb_crash-master.opt | 2 +- .../t/partition_debug_sync_innodb-master.opt | 1 - .../r/innodb_file_per_table_basic.result | 10 ++++++++ storage/innobase/handler/ha_innodb.cc | 2 +- 136 files changed, 170 insertions(+), 419 deletions(-) delete mode 100644 mysql-test/suite/innodb/t/innodb_bug39438-master.opt delete mode 100644 mysql-test/suite/parts/t/partition_debug_sync_innodb-master.opt diff --git a/mysql-test/main/bug46760-master.opt b/mysql-test/main/bug46760-master.opt index 2d7be7fb9b17f..5b4331aa7a68a 100644 --- a/mysql-test/main/bug46760-master.opt +++ b/mysql-test/main/bug46760-master.opt @@ -1,2 +1 @@ --loose-innodb-lock-wait-timeout=2 ---loose-innodb-file-per-table diff --git a/mysql-test/main/column_compression_parts.test b/mysql-test/main/column_compression_parts.test index 4c77a7308f71a..8dfb304173b8f 100644 --- a/mysql-test/main/column_compression_parts.test +++ b/mysql-test/main/column_compression_parts.test @@ -141,7 +141,6 @@ CREATE TABLE t1 (a BLOB COMPRESSED) CREATE TABLE t1 (a VARCHAR(200) COMPRESSED) PARTITION BY KEY(a) partitions 30; ALTER TABLE t1 COALESCE PARTITION 20; -#ALTER TABLE t1 ADD PARTITION (PARTITION pm TABLESPACE = `innodb_file_per_table`); --mdev MDEV-13584 ALTER TABLE t1 ADD PARTITION (PARTITION pm); CREATE TABLE t2 like t1; ALTER TABLE t2 REMOVE PARTITIONING; diff --git a/mysql-test/main/crash_commit_before-master.opt b/mysql-test/main/crash_commit_before-master.opt index f464a1013d7d8..d1bf57fe8206e 100644 --- a/mysql-test/main/crash_commit_before-master.opt +++ b/mysql-test/main/crash_commit_before-master.opt @@ -1,3 +1,2 @@ --loose-skip-stack-trace --skip-core-file --default-storage-engine=MyISAM ---loose-skip-innodb-file-per-table diff --git a/mysql-test/main/flush-innodb.result b/mysql-test/main/flush-innodb.result index 2c886e4f9fcc6..5df79e4cc0c05 100644 --- a/mysql-test/main/flush-innodb.result +++ b/mysql-test/main/flush-innodb.result @@ -8,9 +8,6 @@ DROP TABLE t1; # WL#6168: FLUSH TABLES ... FOR EXPORT -- parser # -# Requires innodb_file_per_table -SET @old_innodb_file_per_table= @@GLOBAL.innodb_file_per_table; -SET GLOBAL innodb_file_per_table= 1; # new "EXPORT" keyword is a valid user variable name: SET @export = 10; # new "EXPORT" keyword is a valid SP parameter name: @@ -300,6 +297,4 @@ DROP TABLE t1; connection con1; disconnect con1; connection default; -# Reset innodb_file_per_table -SET GLOBAL innodb_file_per_table= @old_innodb_file_per_table; # End of 5.6 tests diff --git a/mysql-test/main/flush-innodb.test b/mysql-test/main/flush-innodb.test index 7665ae5e07726..fcb0608373e32 100644 --- a/mysql-test/main/flush-innodb.test +++ b/mysql-test/main/flush-innodb.test @@ -18,10 +18,6 @@ DROP TABLE t1; --echo # --echo ---echo # Requires innodb_file_per_table -SET @old_innodb_file_per_table= @@GLOBAL.innodb_file_per_table; -SET GLOBAL innodb_file_per_table= 1; - --echo # new "EXPORT" keyword is a valid user variable name: SET @export = 10; @@ -432,7 +428,4 @@ DROP TABLE t1; --source include/wait_until_disconnected.inc --connection default ---echo # Reset innodb_file_per_table -SET GLOBAL innodb_file_per_table= @old_innodb_file_per_table; - --echo # End of 5.6 tests diff --git a/mysql-test/main/partition_exchange.result b/mysql-test/main/partition_exchange.result index b7c9be3480eda..f68267c0f55d2 100644 --- a/mysql-test/main/partition_exchange.result +++ b/mysql-test/main/partition_exchange.result @@ -1231,7 +1231,7 @@ DROP TABLE t, t2, tp; # failed during EXCHANGE PARTITION with different TABLESPACE. # CREATE TABLE t1 (a VARCHAR(200)) PARTITION BY KEY(a) partitions 10; -ALTER TABLE t1 ADD PARTITION (PARTITION pm TABLESPACE = `innodb_file_per_table`); +ALTER TABLE t1 ADD PARTITION (PARTITION pm); CREATE TABLE t2 like t1; ALTER TABLE t2 REMOVE PARTITIONING; ALTER TABLE t1 EXCHANGE PARTITION pm WITH TABLE t2; diff --git a/mysql-test/main/partition_exchange.test b/mysql-test/main/partition_exchange.test index 82ccc29e00ef9..e35d8e1f9d1ce 100644 --- a/mysql-test/main/partition_exchange.test +++ b/mysql-test/main/partition_exchange.test @@ -525,7 +525,7 @@ DROP TABLE t, t2, tp; --echo # failed during EXCHANGE PARTITION with different TABLESPACE. --echo # CREATE TABLE t1 (a VARCHAR(200)) PARTITION BY KEY(a) partitions 10; -ALTER TABLE t1 ADD PARTITION (PARTITION pm TABLESPACE = `innodb_file_per_table`); +ALTER TABLE t1 ADD PARTITION (PARTITION pm); CREATE TABLE t2 like t1; ALTER TABLE t2 REMOVE PARTITIONING; # The following works as table spaces are not checked anymore diff --git a/mysql-test/main/partition_innodb_plugin.result b/mysql-test/main/partition_innodb_plugin.result index 8211f0aac8981..25b69212e5b66 100644 --- a/mysql-test/main/partition_innodb_plugin.result +++ b/mysql-test/main/partition_innodb_plugin.result @@ -42,6 +42,8 @@ SET @old_innodb_file_per_table = @@global.innodb_file_per_table; SET @old_innodb_strict_mode = @@global.innodb_strict_mode; SET @@global.innodb_file_per_table = ON, @@global.innodb_strict_mode = ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release connect con1,localhost,root,,; CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, @@ -62,6 +64,8 @@ t1 CREATE TABLE `t1` ( PARTITION BY HASH (`id`) PARTITIONS 1 SET GLOBAL innodb_file_per_table = OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release disconnect con1; connect con2,localhost,root,,; LOCK TABLE t1 WRITE; @@ -104,6 +108,8 @@ disconnect con2; connection default; SET @@global.innodb_strict_mode = @old_innodb_strict_mode; SET @@global.innodb_file_per_table = @old_innodb_file_per_table; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SET @save_detect= @@GLOBAL.innodb_deadlock_detect; SET @save_report= @@GLOBAL.innodb_deadlock_report; SET GLOBAL innodb_deadlock_detect=ON; diff --git a/mysql-test/suite/binlog_encryption/rpl_sync-master.opt b/mysql-test/suite/binlog_encryption/rpl_sync-master.opt index 04b06bfa0f225..96f0ce3f36c0b 100644 --- a/mysql-test/suite/binlog_encryption/rpl_sync-master.opt +++ b/mysql-test/suite/binlog_encryption/rpl_sync-master.opt @@ -1,2 +1 @@ --default-storage-engine=MyISAM ---loose-innodb-file-per-table=0 diff --git a/mysql-test/suite/binlog_encryption/rpl_sync-slave.opt b/mysql-test/suite/binlog_encryption/rpl_sync-slave.opt index 795330535c1ab..d1a481cd37dd0 100644 --- a/mysql-test/suite/binlog_encryption/rpl_sync-slave.opt +++ b/mysql-test/suite/binlog_encryption/rpl_sync-slave.opt @@ -1,2 +1,2 @@ ---sync-relay-log-info=1 --relay-log-recovery=1 --default-storage-engine=MyISAM --loose-innodb-file-per-table=0 +--sync-relay-log-info=1 --relay-log-recovery=1 --default-storage-engine=MyISAM --skip-core-file --skip-slave-start diff --git a/mysql-test/suite/encryption/r/encrypt_and_grep.result b/mysql-test/suite/encryption/r/encrypt_and_grep.result index 72d612eeac897..e52ec0e453f00 100644 --- a/mysql-test/suite/encryption/r/encrypt_and_grep.result +++ b/mysql-test/suite/encryption/r/encrypt_and_grep.result @@ -1,4 +1,3 @@ -SET GLOBAL innodb_file_per_table = ON; create table t1 (a varchar(255)) engine=innodb encrypted=yes; create table t2 (a varchar(255)) engine=innodb; show warnings; diff --git a/mysql-test/suite/encryption/r/innochecksum.result b/mysql-test/suite/encryption/r/innochecksum.result index 7c68164e52a43..dc0bf63a71eae 100644 --- a/mysql-test/suite/encryption/r/innochecksum.result +++ b/mysql-test/suite/encryption/r/innochecksum.result @@ -1,4 +1,3 @@ -SET GLOBAL innodb_file_per_table = ON; set global innodb_compression_algorithm = 1; # Create and populate a tables CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; 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 e2034f14e31fd..eb114fcf6fc4f 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change.result @@ -9,7 +9,6 @@ call mtr.add_suppression("File '.*mysql-test.std_data.keysbad3\\.txt' not found" call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space="); # Start server with keys2.txt # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt -SET GLOBAL innodb_file_per_table = ON; CREATE TABLE t1 (c VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=2; INSERT INTO t1 VALUES ('foobar'); ALTER TABLE t1 ADD COLUMN c2 INT; 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 3cda2bd537b09..ab67b6fedadb3 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change2.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change2.result @@ -8,7 +8,6 @@ call mtr.add_suppression("InnoDB: Cannot delete tablespace .* because it is not call mtr.add_suppression("InnoDB: ALTER TABLE `test`\\.`t1` DISCARD TABLESPACE failed to find tablespace"); call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space="); # restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt -SET GLOBAL innodb_file_per_table = ON; CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); 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 e808d50b54426..9983c26c9d7b8 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change4.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change4.result @@ -5,7 +5,6 @@ call mtr.add_suppression("Couldn't load plugins from 'file_key_management"); call mtr.add_suppression("Table .*t1.* is corrupted"); call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space="); # restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt -SET GLOBAL innodb_file_per_table = ON; CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); diff --git a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result index 7b97eb6b5bdc6..f88f18d092822 100644 --- a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result +++ b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result @@ -1,8 +1,6 @@ -SET @saved_file_per_table = @@global.innodb_file_per_table; SET @saved_encrypt_tables = @@global.innodb_encrypt_tables; SET @saved_encryption_threads = @@global.innodb_encryption_threads; SET @saved_encryption_key_id = @@global.innodb_default_encryption_key_id; -SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_encrypt_tables = ON; SET GLOBAL innodb_encryption_threads = 4; SET GLOBAL innodb_default_encryption_key_id=4; @@ -92,7 +90,6 @@ test.t check status OK test.tpe check status OK test.tp check status OK DROP TABLE tce, tc, te, t, tpe, tp; -SET GLOBAL innodb_file_per_table = @saved_file_per_table; SET GLOBAL innodb_encrypt_tables = @saved_encrypt_tables; SET GLOBAL innodb_encryption_threads = @saved_encryption_threads; SET GLOBAL innodb_default_encryption_key_id = @saved_encryption_key_id; diff --git a/mysql-test/suite/encryption/r/innodb-compressed-blob.result b/mysql-test/suite/encryption/r/innodb-compressed-blob.result index 0dc873b99ab42..bb87d1716010b 100644 --- a/mysql-test/suite/encryption/r/innodb-compressed-blob.result +++ b/mysql-test/suite/encryption/r/innodb-compressed-blob.result @@ -4,7 +4,6 @@ call mtr.add_suppression("InnoDB: Unable to decompress ..test.t[1-3]\\.ibd\\[pag call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` is corrupted"); # Restart mysqld --file-key-management-filename=keys2.txt # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt -SET GLOBAL innodb_file_per_table = ON; set GLOBAL innodb_default_encryption_key_id=4; create table t1(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed; create table t2(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes; diff --git a/mysql-test/suite/encryption/r/innodb-force-corrupt.result b/mysql-test/suite/encryption/r/innodb-force-corrupt.result index ad75df952b339..219dbd7cfc33c 100644 --- a/mysql-test/suite/encryption/r/innodb-force-corrupt.result +++ b/mysql-test/suite/encryption/r/innodb-force-corrupt.result @@ -2,7 +2,6 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t[13]` (has an unreadable root call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page number=[36]\\] in file .*test.t[123]\\.ibd looks corrupted; key_version="); call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption in an InnoDB type table"); call mtr.add_suppression("\\[ERROR\\] (mysqld|mariadbd).*: Index for table 't2' is corrupt; try to repair it"); -SET GLOBAL innodb_file_per_table = ON; set global innodb_compression_algorithm = 1; # Create and populate tables to be corrupted CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT,c char(200)) ENGINE=InnoDB encrypted=yes; diff --git a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result index 4e816bea43b23..4eb203d278709 100644 --- a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result +++ b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result @@ -1,4 +1,3 @@ -SET GLOBAL innodb_file_per_table = ON; set global innodb_compression_algorithm = 1; create database enctests; use enctests; diff --git a/mysql-test/suite/encryption/r/innodb-redo-badkey.result b/mysql-test/suite/encryption/r/innodb-redo-badkey.result index 34fd043a7bd32..6b8f6aa11daa5 100644 --- a/mysql-test/suite/encryption/r/innodb-redo-badkey.result +++ b/mysql-test/suite/encryption/r/innodb-redo-badkey.result @@ -14,7 +14,6 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space="); # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt # Wait max 10 min for key encryption threads to encrypt all spaces -SET GLOBAL innodb_file_per_table = ON; create table t1(a int not null primary key auto_increment, c char(250), b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes encryption_key_id=4; create table t2(a int not null primary key auto_increment, c char(250), b blob, index(b(10))) engine=innodb row_format=compressed; create table t3(a int not null primary key auto_increment, c char(250), b blob, index(b(10))) engine=innodb encrypted=yes encryption_key_id=4; diff --git a/mysql-test/suite/encryption/r/innodb-redo-nokeys.result b/mysql-test/suite/encryption/r/innodb-redo-nokeys.result index 9f9cc85289893..fd6ce1d979a5b 100644 --- a/mysql-test/suite/encryption/r/innodb-redo-nokeys.result +++ b/mysql-test/suite/encryption/r/innodb-redo-nokeys.result @@ -11,7 +11,6 @@ call mtr.add_suppression("InnoDB: Missing FILE_CHECKPOINT"); call mtr.add_suppression("InnoDB: Log scan aborted at LSN"); call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corruption"); # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt -SET GLOBAL innodb_file_per_table = ON; create table t1(a int not null primary key auto_increment, c char(200), b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes encryption_key_id=20; create table t2(a int not null primary key auto_increment, c char(200), b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes; create table t3(a int not null primary key auto_increment, c char(200), b blob, index(b(10))) engine=innodb encrypted=yes encryption_key_id=20; diff --git a/mysql-test/suite/encryption/r/innodb-remove-encryption.result b/mysql-test/suite/encryption/r/innodb-remove-encryption.result index e241d213c8ec6..22207f8184abd 100644 --- a/mysql-test/suite/encryption/r/innodb-remove-encryption.result +++ b/mysql-test/suite/encryption/r/innodb-remove-encryption.result @@ -1,4 +1,6 @@ set global innodb_file_per_table=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release call mtr.add_suppression("(mysqld|mariadbd).*: 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."); diff --git a/mysql-test/suite/encryption/r/innodb_onlinealter_encryption.result b/mysql-test/suite/encryption/r/innodb_onlinealter_encryption.result index d6e32989c0999..3a28082751b79 100644 --- a/mysql-test/suite/encryption/r/innodb_onlinealter_encryption.result +++ b/mysql-test/suite/encryption/r/innodb_onlinealter_encryption.result @@ -41,7 +41,6 @@ NOT FOUND /mangled/ in t6.ibd # t7 ... on expecting NOT FOUND NOT FOUND /mysql/ in t7.ibd # restart -SET GLOBAL innodb_file_per_table = ON; ALTER TABLE t1 ADD COLUMN b int default 2; ALTER TABLE t2 ADD COLUMN b int default 2; ALTER TABLE t7 ADD COLUMN b int default 2; diff --git a/mysql-test/suite/encryption/t/encrypt_and_grep.test b/mysql-test/suite/encryption/t/encrypt_and_grep.test index 687f14e8a55ae..485a3eb2ec8dd 100644 --- a/mysql-test/suite/encryption/t/encrypt_and_grep.test +++ b/mysql-test/suite/encryption/t/encrypt_and_grep.test @@ -12,8 +12,6 @@ --let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd --let SEARCH_RANGE = 10000000 -SET GLOBAL innodb_file_per_table = ON; - create table t1 (a varchar(255)) engine=innodb encrypted=yes; create table t2 (a varchar(255)) engine=innodb; show warnings; diff --git a/mysql-test/suite/encryption/t/innochecksum.test b/mysql-test/suite/encryption/t/innochecksum.test index 516bc0733d986..358a6a0fccaf1 100644 --- a/mysql-test/suite/encryption/t/innochecksum.test +++ b/mysql-test/suite/encryption/t/innochecksum.test @@ -26,7 +26,6 @@ call mtr.add_suppression("InnoDB: Crash recovery is broken due to insufficient i --enable_query_log let $checksum_algorithm = `SELECT @@innodb_checksum_algorithm`; -SET GLOBAL innodb_file_per_table = ON; # zlib set global innodb_compression_algorithm = 1; 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 05a3b5f4d06b4..5eefded9ae1bf 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change.test @@ -23,8 +23,6 @@ call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space=" -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt -- source include/restart_mysqld.inc -SET GLOBAL innodb_file_per_table = ON; - CREATE TABLE t1 (c VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=2; INSERT INTO t1 VALUES ('foobar'); ALTER TABLE t1 ADD COLUMN c2 INT; 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 21a9ddb217d01..a6cc581e448e3 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change2.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change2.test @@ -23,8 +23,6 @@ call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space=" --let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --source include/restart_mysqld.inc -SET GLOBAL innodb_file_per_table = ON; - CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); 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 c37eb365e7c18..b041c9888516a 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change4.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change4.test @@ -19,8 +19,6 @@ call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space=" --let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --source include/restart_mysqld.inc -SET GLOBAL innodb_file_per_table = ON; - CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); diff --git a/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test b/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test index 157fb25b1858f..2de7c171981d0 100644 --- a/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test +++ b/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test @@ -2,12 +2,10 @@ -- source include/innodb_page_size.inc -- source include/have_file_key_management_plugin.inc -SET @saved_file_per_table = @@global.innodb_file_per_table; SET @saved_encrypt_tables = @@global.innodb_encrypt_tables; SET @saved_encryption_threads = @@global.innodb_encryption_threads; SET @saved_encryption_key_id = @@global.innodb_default_encryption_key_id; -SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_encrypt_tables = ON; SET GLOBAL innodb_encryption_threads = 4; @@ -77,7 +75,6 @@ update tp set b=substr(b,1); CHECK TABLE tce, tc, te, t, tpe, tp; DROP TABLE tce, tc, te, t, tpe, tp; -SET GLOBAL innodb_file_per_table = @saved_file_per_table; SET GLOBAL innodb_encrypt_tables = @saved_encrypt_tables; SET GLOBAL innodb_encryption_threads = @saved_encryption_threads; SET GLOBAL innodb_default_encryption_key_id = @saved_encryption_key_id; diff --git a/mysql-test/suite/encryption/t/innodb-compressed-blob.test b/mysql-test/suite/encryption/t/innodb-compressed-blob.test index 12d061a852f3d..d3d53e2c41ae1 100644 --- a/mysql-test/suite/encryption/t/innodb-compressed-blob.test +++ b/mysql-test/suite/encryption/t/innodb-compressed-blob.test @@ -13,8 +13,6 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` is corrupted"); -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt -- source include/restart_mysqld.inc -SET GLOBAL innodb_file_per_table = ON; - set GLOBAL innodb_default_encryption_key_id=4; create table t1(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed; create table t2(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes; diff --git a/mysql-test/suite/encryption/t/innodb-force-corrupt.test b/mysql-test/suite/encryption/t/innodb-force-corrupt.test index 51771f1e14b89..73fa0cde0cf6c 100644 --- a/mysql-test/suite/encryption/t/innodb-force-corrupt.test +++ b/mysql-test/suite/encryption/t/innodb-force-corrupt.test @@ -12,7 +12,6 @@ call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page nu call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption in an InnoDB type table"); call mtr.add_suppression("\\[ERROR\\] (mysqld|mariadbd).*: Index for table 't2' is corrupt; try to repair it"); -SET GLOBAL innodb_file_per_table = ON; set global innodb_compression_algorithm = 1; --echo # Create and populate tables to be corrupted diff --git a/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test b/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test index 96b62f7c05b71..0139b9fb8176d 100644 --- a/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test +++ b/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test @@ -4,7 +4,6 @@ -- source include/not_embedded.inc let $encryption = `SELECT @@innodb_encrypt_tables`; -SET GLOBAL innodb_file_per_table = ON; # zlib set global innodb_compression_algorithm = 1; diff --git a/mysql-test/suite/encryption/t/innodb-redo-badkey.test b/mysql-test/suite/encryption/t/innodb-redo-badkey.test index 393ca4ad375eb..de6d7f2f2537b 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-badkey.test +++ b/mysql-test/suite/encryption/t/innodb-redo-badkey.test @@ -31,8 +31,6 @@ call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space=" --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 --source include/wait_condition.inc -SET GLOBAL innodb_file_per_table = ON; - create table t1(a int not null primary key auto_increment, c char(250), b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes encryption_key_id=4; create table t2(a int not null primary key auto_increment, c char(250), b blob, index(b(10))) engine=innodb row_format=compressed; create table t3(a int not null primary key auto_increment, c char(250), b blob, index(b(10))) engine=innodb encrypted=yes encryption_key_id=4; diff --git a/mysql-test/suite/encryption/t/innodb-redo-nokeys.test b/mysql-test/suite/encryption/t/innodb-redo-nokeys.test index 0aaed201d43f2..2624bb6ff9c6a 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-nokeys.test +++ b/mysql-test/suite/encryption/t/innodb-redo-nokeys.test @@ -19,8 +19,6 @@ call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corrupti -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt -- source include/restart_mysqld.inc -SET GLOBAL innodb_file_per_table = ON; - create table t1(a int not null primary key auto_increment, c char(200), b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes encryption_key_id=20; create table t2(a int not null primary key auto_increment, c char(200), b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes; create table t3(a int not null primary key auto_increment, c char(200), b blob, index(b(10))) engine=innodb encrypted=yes encryption_key_id=20; diff --git a/mysql-test/suite/encryption/t/innodb_onlinealter_encryption.test b/mysql-test/suite/encryption/t/innodb_onlinealter_encryption.test index 9f61bf118aa56..dc6d1e6f93c86 100644 --- a/mysql-test/suite/encryption/t/innodb_onlinealter_encryption.test +++ b/mysql-test/suite/encryption/t/innodb_onlinealter_encryption.test @@ -75,8 +75,6 @@ set autocommit=1; -- source include/start_mysqld.inc -SET GLOBAL innodb_file_per_table = ON; - ALTER TABLE t1 ADD COLUMN b int default 2; ALTER TABLE t2 ADD COLUMN b int default 2; ALTER TABLE t7 ADD COLUMN b int default 2; diff --git a/mysql-test/suite/galera/t/galera_ist_MDEV-28423.cnf b/mysql-test/suite/galera/t/galera_ist_MDEV-28423.cnf index 691e52208b1da..3d43138f3c771 100644 --- a/mysql-test/suite/galera/t/galera_ist_MDEV-28423.cnf +++ b/mysql-test/suite/galera/t/galera_ist_MDEV-28423.cnf @@ -3,7 +3,6 @@ [mysqld.1] # server-id=101 #wsrep-debug=1 -innodb_file_per_table innodb_autoinc_lock_mode=2 #wsrep_sst_method=rsync wsrep_sst_method=mariabackup @@ -20,7 +19,6 @@ log_bin=binlog [mysqld.2] # server-id=102 #wsrep-debug=1 -innodb_file_per_table innodb_autoinc_lock_mode=2 #wsrep_sst_method=rsync wsrep_sst_method=mariabackup diff --git a/mysql-test/suite/galera/t/galera_ist_MDEV-28583.cnf b/mysql-test/suite/galera/t/galera_ist_MDEV-28583.cnf index 3835cd02a414b..6fc6e3421cbf0 100644 --- a/mysql-test/suite/galera/t/galera_ist_MDEV-28583.cnf +++ b/mysql-test/suite/galera/t/galera_ist_MDEV-28583.cnf @@ -3,7 +3,6 @@ [mysqld.1] # server-id=101 #wsrep-debug=1 -innodb_file_per_table innodb_autoinc_lock_mode=2 wsrep_sst_method=rsync #wsrep_sst_method=mariabackup @@ -20,7 +19,6 @@ log_bin=binlog [mysqld.2] # server-id=102 #wsrep-debug=1 -innodb_file_per_table innodb_autoinc_lock_mode=2 wsrep_sst_method=rsync #wsrep_sst_method=mariabackup diff --git a/mysql-test/suite/galera/t/galera_load_data.cnf b/mysql-test/suite/galera/t/galera_load_data.cnf index 43cc352c020a9..3385fbac1f61d 100644 --- a/mysql-test/suite/galera/t/galera_load_data.cnf +++ b/mysql-test/suite/galera/t/galera_load_data.cnf @@ -2,7 +2,6 @@ [mysqld.1] secure-file-priv = "" -innodb_file_per_table = ON innodb_stats_persistent=ON innodb_stats_auto_recalc=ON innodb_stats_persistent_sample_pages=20 @@ -11,7 +10,6 @@ skip-innodb-read-only-compressed [mysqld.2] secure-file-priv = "" -innodb_file_per_table = ON innodb_stats_persistent=ON innodb_stats_auto_recalc=ON innodb_stats_persistent_sample_pages=20 diff --git a/mysql-test/suite/galera/t/galera_sst_encrypted.cnf b/mysql-test/suite/galera/t/galera_sst_encrypted.cnf index e10c3e9f21529..596bb95ac6a82 100644 --- a/mysql-test/suite/galera/t/galera_sst_encrypted.cnf +++ b/mysql-test/suite/galera/t/galera_sst_encrypted.cnf @@ -7,7 +7,6 @@ loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys.txt loose-file-key-management-encryption-algorithm=aes_cbc wsrep-debug=1 innodb_encryption_threads = 4 -innodb_file_per_table=1 wsrep_sst_method=rsync [mysqld.1] diff --git a/mysql-test/suite/galera/t/galera_sst_mariabackup_table_options.cnf b/mysql-test/suite/galera/t/galera_sst_mariabackup_table_options.cnf index d3fff4fcb0b2c..857a410140655 100644 --- a/mysql-test/suite/galera/t/galera_sst_mariabackup_table_options.cnf +++ b/mysql-test/suite/galera/t/galera_sst_mariabackup_table_options.cnf @@ -4,7 +4,6 @@ wsrep_sst_method=mariabackup wsrep_sst_auth="root:" wsrep_debug=1 -innodb-file-per-table=ON [mysqld.1] wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' diff --git a/mysql-test/suite/innodb/include/innodb_bulk_create_index.inc b/mysql-test/suite/innodb/include/innodb_bulk_create_index.inc index 3c10517933f0e..438b7b17d51d0 100644 --- a/mysql-test/suite/innodb/include/innodb_bulk_create_index.inc +++ b/mysql-test/suite/innodb/include/innodb_bulk_create_index.inc @@ -35,8 +35,6 @@ if ($row_format != 'COMPRESSED') if ($row_format == 'COMPRESSED') { - SET GLOBAL innodb_file_per_table=1; - eval CREATE TABLE t1( class INT, id INT, @@ -176,10 +174,4 @@ SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; DROP TABLE t1; -# Restore global variables -if ($row_format == 'COMPRESSED') -{ - SET GLOBAL innodb_file_per_table=default; -} - DROP PROCEDURE populate_t1; diff --git a/mysql-test/suite/innodb/include/innodb_bulk_create_index_debug.inc b/mysql-test/suite/innodb/include/innodb_bulk_create_index_debug.inc index 85466e5e4ae3c..dbdadd0b7f9c8 100644 --- a/mysql-test/suite/innodb/include/innodb_bulk_create_index_debug.inc +++ b/mysql-test/suite/innodb/include/innodb_bulk_create_index_debug.inc @@ -38,8 +38,6 @@ if ($row_format != 'COMPRESSED') if ($row_format == 'COMPRESSED') { - SET GLOBAL innodb_file_per_table=1; - eval CREATE TABLE t1( class INT, id INT, @@ -69,8 +67,6 @@ if ($row_format != 'COMPRESSED') { } if ($row_format == 'COMPRESSED') { - SET GLOBAL innodb_file_per_table=1; - eval CREATE TABLE t1( a INT PRIMARY KEY, b TEXT, @@ -124,8 +120,6 @@ if ($row_format != 'COMPRESSED') if ($row_format == 'COMPRESSED') { - SET GLOBAL innodb_file_per_table=1; - eval CREATE TABLE t1( class INT, id INT, @@ -174,8 +168,6 @@ if ($row_format != 'COMPRESSED') { } if ($row_format == 'COMPRESSED') { - SET GLOBAL innodb_file_per_table=1; - eval CREATE TABLE t1( a INT PRIMARY KEY, b TEXT, diff --git a/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc b/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc index 8c60cd6e23024..68f34978f2346 100644 --- a/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc +++ b/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc @@ -1,6 +1,6 @@ # # Test to cause merge of the pages (by deleting) -# test/tab1 should be created already with innodb_file_per_table=ON +# test/tab1 should be created already # The definition is intended to be based on # "create table tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;" # diff --git a/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc b/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc index 8e821365e3f81..d49272c4087e0 100644 --- a/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc +++ b/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc @@ -1,6 +1,6 @@ # # Test to cause merge of the pages (at secondary index by deleting) -# test/tab1 should be created already with innodb_file_per_table=ON +# test/tab1 should be created already # The definition is intended to be based on # "create table tab1 (a bigint primary key, b blob) engine=InnoDB row_format=dynamic;" # "create index index1 on tab1(b(750));" diff --git a/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc b/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc index 61e961ac6ae13..ae720e0488d05 100644 --- a/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc +++ b/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc @@ -1,6 +1,6 @@ # # Test to cause merge of the pages (by updating to smaller) -# test/tab1 should be created already with innodb_file_per_table=ON +# test/tab1 should be created already # The definition is intended to be based on # "create table tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;" # diff --git a/mysql-test/suite/innodb/r/alter_kill.result b/mysql-test/suite/innodb/r/alter_kill.result index 0283d1079e188..037b06fffbcdb 100644 --- a/mysql-test/suite/innodb/r/alter_kill.result +++ b/mysql-test/suite/innodb/r/alter_kill.result @@ -1,7 +1,6 @@ # # Bug#16720368 INNODB CRASHES ON BROKEN #SQL*.IBD FILE AT STARTUP # -SET GLOBAL innodb_file_per_table=1; SET GLOBAL innodb_purge_rseg_truncate_frequency=1; CREATE TABLE bug16720368_1 (a INT PRIMARY KEY) ENGINE=InnoDB; connect con1,localhost,root; @@ -30,7 +29,6 @@ DROP TABLE bug16720368, bug16720368_1; # Bug#16735660 ASSERT TABLE2 == NULL, ROLLBACK OF RESURRECTED TXNS, # DICT_TABLE_ADD_TO_CACHE # -SET GLOBAL innodb_file_per_table=1; CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; BEGIN; INSERT INTO t1 VALUES(42); diff --git a/mysql-test/suite/innodb/r/alter_missing_tablespace.result b/mysql-test/suite/innodb/r/alter_missing_tablespace.result index 3d07158425600..65b01d89d91ce 100644 --- a/mysql-test/suite/innodb/r/alter_missing_tablespace.result +++ b/mysql-test/suite/innodb/r/alter_missing_tablespace.result @@ -2,7 +2,6 @@ # Bug#13955083 ALLOW IN-PLACE DDL OPERATIONS ON MISSING # OR DISCARDED TABLESPACES # -SET GLOBAL innodb_file_per_table=1; CREATE TABLE t(a SERIAL)ENGINE=InnoDB; CREATE TABLE `x..d` (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; CREATE TABLE t1(a SERIAL)ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/r/alter_rename_existing.result b/mysql-test/suite/innodb/r/alter_rename_existing.result index 1fdc2011a24de..e4fee34196498 100644 --- a/mysql-test/suite/innodb/r/alter_rename_existing.result +++ b/mysql-test/suite/innodb/r/alter_rename_existing.result @@ -36,6 +36,8 @@ ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 " # Create another t1, but in the system tablespace. # SET GLOBAL innodb_file_per_table=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB; INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); SHOW CREATE TABLE t1; @@ -58,6 +60,8 @@ ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY; # while a blocking t1.ibd file exists. # SET GLOBAL innodb_file_per_table=ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; ERROR HY000: Tablespace for table 'test/#sql-ib' exists. Please DISCARD the tablespace before IMPORT ALTER TABLE t1 FORCE, ALGORITHM=COPY; @@ -93,3 +97,5 @@ a b 2 two 3 three DROP TABLE t1; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release diff --git a/mysql-test/suite/innodb/r/dropdb_cs.result b/mysql-test/suite/innodb/r/dropdb_cs.result index 59f02c74a049d..3837bf9e3f51c 100644 --- a/mysql-test/suite/innodb/r/dropdb_cs.result +++ b/mysql-test/suite/innodb/r/dropdb_cs.result @@ -3,6 +3,8 @@ # SET @save_fpt=@@GLOBAL.innodb_file_per_table; SET GLOBAL innodb_file_per_table=0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE DATABASE Db; CREATE TABLE Db.t1 (c1 INT KEY) ENGINE=InnoDB; CREATE DATABASE DB; @@ -14,3 +16,5 @@ DROP DATABASE Db; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'D%'; TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE SET GLOBAL innodb_file_per_table=@save_fpt; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release diff --git a/mysql-test/suite/innodb/r/index_tree_operation.result b/mysql-test/suite/innodb/r/index_tree_operation.result index 29660962e0c0b..92565333a9359 100644 --- a/mysql-test/suite/innodb/r/index_tree_operation.result +++ b/mysql-test/suite/innodb/r/index_tree_operation.result @@ -2,7 +2,6 @@ # Bug#15923864 (Bug#67718): # INNODB DRASTICALLY UNDER-FILLS PAGES IN CERTAIN CONDITIONS # -SET GLOBAL innodb_file_per_table=ON; CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB; INSERT INTO t1 VALUES (0, REPEAT('a', 4096)); INSERT INTO t1 VALUES (1000, REPEAT('a', 4096)); diff --git a/mysql-test/suite/innodb/r/innodb-fkcheck.result b/mysql-test/suite/innodb/r/innodb-fkcheck.result index f86ba50597fac..357d8aa11c12d 100644 --- a/mysql-test/suite/innodb/r/innodb-fkcheck.result +++ b/mysql-test/suite/innodb/r/innodb-fkcheck.result @@ -1,6 +1,3 @@ -set global innodb_file_per_table = 1; -drop table if exists b; -drop database if exists bug_fk; create database bug_fk; use bug_fk; CREATE TABLE b ( @@ -93,5 +90,5 @@ show warnings; Level Code Message b.frm b.ibd -drop table if exists b; -drop database if exists bug_fk; +drop table b; +drop database bug_fk; diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result index 7138c5d7a1830..6404a3812b3c5 100644 --- a/mysql-test/suite/innodb/r/innodb-index-online.result +++ b/mysql-test/suite/innodb/r/innodb-index-online.result @@ -1,6 +1,4 @@ call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); -SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; -SET GLOBAL innodb_file_per_table = on; CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 TEXT) ENGINE=InnoDB STATS_PERSISTENT=0; INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); @@ -540,6 +538,5 @@ Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1; SET DEBUG_SYNC = 'RESET'; -SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; SET GLOBAL innodb_monitor_enable = default; SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb-table-online.result b/mysql-test/suite/innodb/r/innodb-table-online.result index 5a8b3d24d757d..8ac0d4d41fab2 100644 --- a/mysql-test/suite/innodb/r/innodb-table-online.result +++ b/mysql-test/suite/innodb/r/innodb-table-online.result @@ -1,8 +1,6 @@ call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); call mtr.add_suppression("InnoDB: Error: table 'test/t1'"); call mtr.add_suppression("MariaDB is trying to open a table handle but the .ibd file for"); -SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; -SET GLOBAL innodb_file_per_table = on; CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 CHAR(255) NOT NULL) ENGINE = InnoDB; INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); @@ -472,6 +470,5 @@ DROP TABLE t1; connection default; SET DEBUG_SYNC=RESET; disconnect con1; -SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; SET GLOBAL innodb_monitor_enable = default; SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result index e7af2d9469ed6..ff0f8b2acc8a5 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result +++ b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result @@ -12,21 +12,18 @@ call mtr.add_suppression("InnoDB: Cannot save statistics for table `test`\\.`t1` call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*ibdata1' page"); call mtr.add_suppression("InnoDB: File '.*ibdata1' is corrupted"); FLUSH TABLES; -SET GLOBAL innodb_file_per_table = 1; CREATE TABLE t1 (c1 INT) ENGINE = InnoDB; INSERT INTO t1 VALUES(1),(2),(3); SET SESSION debug_dbug="+d,ib_discard_before_commit_crash"; ALTER TABLE t1 DISCARD TABLESPACE; ERROR HY000: Lost connection to server during query DROP TABLE t1; -SET GLOBAL innodb_file_per_table = 1; CREATE TABLE t1 (c1 INT) ENGINE = InnoDB; INSERT INTO t1 VALUES(1),(2),(3); SET SESSION debug_dbug="+d,ib_discard_after_commit_crash"; ALTER TABLE t1 DISCARD TABLESPACE; ERROR HY000: Lost connection to server during query DROP TABLE t1; -SET GLOBAL innodb_file_per_table = 1; CREATE TABLE t1 (c1 INT) ENGINE = Innodb; INSERT INTO t1 VALUES (1), (2), (3), (4); FLUSH TABLES t1 FOR EXPORT; @@ -52,8 +49,6 @@ ERROR HY000: Lost connection to server during query unlink: t1.ibd unlink: t1.cfg DROP TABLE t1; -SET @file_per_table= @@innodb_file_per_table; -SET GLOBAL innodb_file_per_table = 1; CREATE TABLE t1 (c1 INT) ENGINE = Innodb; ALTER TABLE t1 DISCARD TABLESPACE; restore: t1 .ibd and .cfg files @@ -943,4 +938,3 @@ SET SESSION debug_dbug=@saved_debug_dbug; DROP TABLE t1; unlink: t1.ibd unlink: t1.cfg -SET GLOBAL INNODB_FILE_PER_TABLE=@file_per_table; diff --git a/mysql-test/suite/innodb/r/innodb-wl5522.result b/mysql-test/suite/innodb/r/innodb-wl5522.result index 7bcc57c5bd59d..819ca949c8832 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5522.result +++ b/mysql-test/suite/innodb/r/innodb-wl5522.result @@ -120,7 +120,6 @@ ALTER TABLE t2 IMPORT TABLESPACE; Warnings: Warning 1810 IO Read error: (2, No such file or directory) Error opening './test/t2.cfg', will attempt to import without schema verification DROP TABLE t2; -SET GLOBAL innodb_file_per_table = 1; SELECT @@innodb_file_per_table; @@innodb_file_per_table 1 @@ -285,6 +284,8 @@ c1 c2 unlink: t1.cfg DROP TABLE t1; SET GLOBAL innodb_file_per_table = 0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1( c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 INT) ENGINE=InnoDB; @@ -302,6 +303,8 @@ Warning 1809 Table `test`.`t1` in system tablespace UNLOCK TABLES; DROP TABLE t1; SET GLOBAL innodb_file_per_table = 1; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1( c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 INT, INDEX idx(c2)) ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/r/innodb-wl5980-alter.result b/mysql-test/suite/innodb/r/innodb-wl5980-alter.result index 4d6ac474da882..84f3d7811c21b 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5980-alter.result +++ b/mysql-test/suite/innodb/r/innodb-wl5980-alter.result @@ -2,9 +2,7 @@ # This is a copy of innodb-alter.test except using remote tablespaces # and showing those files. # -SET @innodb_file_per_table_orig=@@GLOBAL.innodb_file_per_table; SET default_storage_engine=InnoDB; -SET GLOBAL innodb_file_per_table=ON; SET NAMES utf8mb4; CREATE TABLE t1 ( c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, @@ -1589,4 +1587,3 @@ DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; ### files in MYSQL_DATA_DIR/test db.opt ### files in MYSQL_TMP_DIR/alt_dir/test -SET GLOBAL innodb_file_per_table = @innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb/r/innodb_bug14147491.result b/mysql-test/suite/innodb/r/innodb_bug14147491.result index 533eaeafeb8aa..b33b7f0d587d3 100644 --- a/mysql-test/suite/innodb/r/innodb_bug14147491.result +++ b/mysql-test/suite/innodb/r/innodb_bug14147491.result @@ -2,7 +2,6 @@ SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; SET GLOBAL innodb_fast_shutdown=0; # Create and populate the table to be corrupted -set global innodb_file_per_table=ON; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB; INSERT INTO t1 (b) VALUES ('corrupt me'); INSERT INTO t1 (b) VALUES ('corrupt me'); diff --git a/mysql-test/suite/innodb/r/innodb_bug56947.result b/mysql-test/suite/innodb/r/innodb_bug56947.result index aa922776f7bd9..a4ed3bfcfaadb 100644 --- a/mysql-test/suite/innodb/r/innodb_bug56947.result +++ b/mysql-test/suite/innodb/r/innodb_bug56947.result @@ -1,4 +1,7 @@ -SET GLOBAL innodb_file_per_table=0; +SET @save_fpt=@@GLOBAL.innodb_file_per_table; +SET GLOBAL innodb_file_per_table=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release create table bug56947(a int not null) engine = innodb; SET @saved_dbug = @@SESSION.debug_dbug; SET DEBUG_DBUG='+d,ib_rebuild_cannot_rename'; @@ -8,5 +11,7 @@ check table bug56947; Table Op Msg_type Msg_text test.bug56947 check status OK drop table bug56947; -SET @@global.innodb_file_per_table=DEFAULT; +SET GLOBAL innodb_file_per_table=@save_fpt; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SET debug_dbug= @saved_dbug; diff --git a/mysql-test/suite/innodb/r/innodb_bug68148.result b/mysql-test/suite/innodb/r/innodb_bug68148.result index 25bf7f58eb97a..1c79f881befc9 100644 --- a/mysql-test/suite/innodb/r/innodb_bug68148.result +++ b/mysql-test/suite/innodb/r/innodb_bug68148.result @@ -1,4 +1,3 @@ -set global innodb_file_per_table=1; CREATE TABLE ref_table1 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; CREATE TABLE ref_table2 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; CREATE TABLE `main` ( diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index.result b/mysql-test/suite/innodb/r/innodb_bulk_create_index.result index ec7ce044cb794..060e9008f3fdf 100644 --- a/mysql-test/suite/innodb/r/innodb_bulk_create_index.result +++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index.result @@ -532,7 +532,6 @@ END| SELECT @@innodb_fill_factor; @@innodb_fill_factor 100 -SET GLOBAL innodb_file_per_table=1; CREATE TABLE t1( class INT, id INT, @@ -686,7 +685,6 @@ test.t1 check status OK SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; CHAR_LENGTH(b) DROP TABLE t1; -SET GLOBAL innodb_file_per_table=default; DROP PROCEDURE populate_t1; SET GLOBAL innodb_fill_factor=10; CREATE PROCEDURE populate_t1(load_even INT) diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index_debug.result b/mysql-test/suite/innodb/r/innodb_bulk_create_index_debug.result index 295a9f1bed8ce..debb5d0f14a03 100644 --- a/mysql-test/suite/innodb/r/innodb_bulk_create_index_debug.result +++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index_debug.result @@ -407,7 +407,6 @@ SET i = i + 1; END WHILE; COMMIT; END| -SET GLOBAL innodb_file_per_table=1; CREATE TABLE t1( class INT, id INT, @@ -421,7 +420,6 @@ affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 RENAME TABLE t1 TO t0; # Test Blob -SET GLOBAL innodb_file_per_table=1; CREATE TABLE t1( a INT PRIMARY KEY, b TEXT, @@ -467,7 +465,6 @@ class id title SELECT * FROM t1 WHERE title = 'a10010'; class id title DROP TABLE t1; -SET GLOBAL innodb_file_per_table=1; CREATE TABLE t1( class INT, id INT, @@ -501,7 +498,6 @@ SELECT * FROM t1 WHERE title = 'a10010'; class id title DROP TABLE t1; # Test Blob -SET GLOBAL innodb_file_per_table=1; CREATE TABLE t1( a INT PRIMARY KEY, b TEXT, diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result b/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result index b48207d4497a1..bdc40d1a0709b 100644 --- a/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result +++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result @@ -72,8 +72,6 @@ test.t1 check status OK SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; CHAR_LENGTH(b) DROP TABLE t1; -SET GLOBAL innodb_file_per_table=default; -SET GLOBAL innodb_file_per_table=1; CREATE TABLE t1( class INT, id INT, @@ -135,5 +133,4 @@ test.t1 check status OK SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; CHAR_LENGTH(b) DROP TABLE t1; -SET GLOBAL innodb_file_per_table=default; DROP PROCEDURE populate_t1; diff --git a/mysql-test/suite/innodb/r/log_data_file_size.result b/mysql-test/suite/innodb/r/log_data_file_size.result index d33752b089cfd..ddb8e694e40ff 100644 --- a/mysql-test/suite/innodb/r/log_data_file_size.result +++ b/mysql-test/suite/innodb/r/log_data_file_size.result @@ -1,6 +1,10 @@ SET GLOBAL innodb_file_per_table=0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t(a INT)ENGINE=InnoDB; SET GLOBAL innodb_file_per_table=1; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE ibd4(a INT UNIQUE)ENGINE=InnoDB; CREATE TABLE ibd4f(a INT UNIQUE)ENGINE=InnoDB; CREATE TABLE ibd5(a INT UNIQUE, b INT UNIQUE)ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/r/log_file_name.result b/mysql-test/suite/innodb/r/log_file_name.result index 766122959ab78..7ac212916de00 100644 --- a/mysql-test/suite/innodb/r/log_file_name.result +++ b/mysql-test/suite/innodb/r/log_file_name.result @@ -1,4 +1,3 @@ -SET GLOBAL innodb_file_per_table=ON; FLUSH TABLES; CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; # restart diff --git a/mysql-test/suite/innodb/r/mvcc.result b/mysql-test/suite/innodb/r/mvcc.result index 215b2165b8cf9..3e6b0ad35dbf2 100644 --- a/mysql-test/suite/innodb/r/mvcc.result +++ b/mysql-test/suite/innodb/r/mvcc.result @@ -1,5 +1,3 @@ -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 # @@ -43,4 +41,3 @@ $$ INSERT INTO t1 SET id=1,c294=1; REPLACE t1 SET id=1,c294=1; DROP TABLE t1; -SET GLOBAL innodb_file_per_table= @save_per_table; diff --git a/mysql-test/suite/innodb/r/row_format_redundant.result b/mysql-test/suite/innodb/r/row_format_redundant.result index b798832e96f0d..e7e15983dfd3e 100644 --- a/mysql-test/suite/innodb/r/row_format_redundant.result +++ b/mysql-test/suite/innodb/r/row_format_redundant.result @@ -1,11 +1,9 @@ SET GLOBAL innodb_fast_shutdown=0; # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-data-file-path=ibdata1:1M:autoextend --innodb-undo-tablespaces=0 --innodb-stats-persistent=0 -SET GLOBAL innodb_file_per_table=1; # # Bug#21644827 - FTS, ASSERT !SRV_READ_ONLY_MODE || M_IMPL.M_LOG_MODE == # MTR_LOG_NO_REDO # -SET GLOBAL innodb_file_per_table=ON; create table t1 (a int not null, d varchar(15) not null, b varchar(198) not null, c char(156)) engine=InnoDB row_format=redundant; @@ -16,6 +14,8 @@ insert into t values(789, 'abcdef', 'jghikl', 'mnop'); insert into t values(134, 'kasdfsdsadf', 'adfjlasdkfjasd', 'adfsadflkasdasdfljasdf'); insert into t1 select a,d,b,c from t, seq_1_to_1024; SET GLOBAL innodb_file_per_table=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release create table t2 (a int not null, d varchar(15) not null, b varchar(198) not null, c char(156), fulltext ftsic(c)) engine=InnoDB row_format=redundant; diff --git a/mysql-test/suite/innodb/r/table_flags.result b/mysql-test/suite/innodb/r/table_flags.result index 779990351c6e7..e421126d2eb18 100644 --- a/mysql-test/suite/innodb/r/table_flags.result +++ b/mysql-test/suite/innodb/r/table_flags.result @@ -1,5 +1,4 @@ # restart: with restart_parameters -SET GLOBAL innodb_file_per_table=1; CREATE TABLE tr(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=REDUNDANT; CREATE TABLE tc(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPACT; CREATE TABLE td(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC; diff --git a/mysql-test/suite/innodb/t/alter_kill.test b/mysql-test/suite/innodb/t/alter_kill.test index 277d9b4e71b1c..fdff21e1ec061 100644 --- a/mysql-test/suite/innodb/t/alter_kill.test +++ b/mysql-test/suite/innodb/t/alter_kill.test @@ -25,7 +25,6 @@ call mtr.add_suppression("Table .*bug16720368.* is corrupted"); -- echo # Bug#16720368 INNODB CRASHES ON BROKEN #SQL*.IBD FILE AT STARTUP -- echo # -SET GLOBAL innodb_file_per_table=1; SET GLOBAL innodb_purge_rseg_truncate_frequency=1; CREATE TABLE bug16720368_1 (a INT PRIMARY KEY) ENGINE=InnoDB; @@ -129,8 +128,6 @@ DROP TABLE bug16720368, bug16720368_1; -- echo # DICT_TABLE_ADD_TO_CACHE -- echo # -SET GLOBAL innodb_file_per_table=1; - CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; BEGIN; INSERT INTO t1 VALUES(42); diff --git a/mysql-test/suite/innodb/t/alter_missing_tablespace.test b/mysql-test/suite/innodb/t/alter_missing_tablespace.test index 9742adc30a613..ff93ec5f9c67c 100644 --- a/mysql-test/suite/innodb/t/alter_missing_tablespace.test +++ b/mysql-test/suite/innodb/t/alter_missing_tablespace.test @@ -21,7 +21,6 @@ call mtr.add_suppression("InnoDB: ALTER TABLE `test`.`t` DISCARD TABLESPACE fail --enable_query_log let $MYSQLD_DATADIR=`select @@datadir`; -SET GLOBAL innodb_file_per_table=1; CREATE TABLE t(a SERIAL)ENGINE=InnoDB; CREATE TABLE `x..d` (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; CREATE TABLE t1(a SERIAL)ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/t/index_tree_operation.test b/mysql-test/suite/innodb/t/index_tree_operation.test index b9695db9346be..e7958b2955dcc 100644 --- a/mysql-test/suite/innodb/t/index_tree_operation.test +++ b/mysql-test/suite/innodb/t/index_tree_operation.test @@ -9,12 +9,6 @@ # Otherwise, the follwing records 999,998,997 cause each page per record. # ---disable_query_log -SET @old_innodb_file_per_table = @@innodb_file_per_table; ---enable_query_log - -SET GLOBAL innodb_file_per_table=ON; - CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB; INSERT INTO t1 VALUES (0, REPEAT('a', 4096)); INSERT INTO t1 VALUES (1000, REPEAT('a', 4096)); @@ -68,7 +62,3 @@ WHERE s1.space = s2.space AND name = 'test/t1' AND page_type = "INDEX" ORDER BY page_number; DROP TABLE t1; - ---disable_query_log -SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table; ---enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb-bug-14068765.test b/mysql-test/suite/innodb/t/innodb-bug-14068765.test index c2446e0fecf91..4435ac6802165 100644 --- a/mysql-test/suite/innodb/t/innodb-bug-14068765.test +++ b/mysql-test/suite/innodb/t/innodb-bug-14068765.test @@ -2,7 +2,7 @@ let MYSQLD_DATADIR =`SELECT @@datadir`; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance CREATE DATABASE testdb_wl5522; CREATE TABLE testdb_wl5522.t1(col1 bit(1) , col2 boolean,col3 tinyint , col4 smallint , col5 mediumint ,col6 int , col7 bigint , col8 float (14,3) ,col9 double (14,3), col10 VARCHAR(20) CHARACTER SET utf8 , col11 TEXT CHARACTER SET binary , col12 ENUM('a','b','c') CHARACTER SET binary ,col13 TEXT CHARACTER SET latin1 COLLATE latin1_general_cs ,col14 CHAR(20) , col15 VARBINARY (400) , col16 BINARY(40), col17 BLOB (400) , col18 int not null primary key,col19 DATE ,col20 DATETIME , col21 TIMESTAMP ,col22 TIME , col23 YEAR ) ENGINE = Innodb; diff --git a/mysql-test/suite/innodb/t/innodb-bug-14084530.test b/mysql-test/suite/innodb/t/innodb-bug-14084530.test index f27fbbe31d7cb..2285b86c21a90 100644 --- a/mysql-test/suite/innodb/t/innodb-bug-14084530.test +++ b/mysql-test/suite/innodb/t/innodb-bug-14084530.test @@ -4,7 +4,7 @@ let MYSQLD_DATADIR =`SELECT @@datadir`; SET AUTOCOMMIT = 0; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance CREATE DATABASE testdb_wl5522; CREATE TABLE testdb_wl5522.t1 (c1 int ) engine = Innodb; diff --git a/mysql-test/suite/innodb/t/innodb-enlarge-blob.opt b/mysql-test/suite/innodb/t/innodb-enlarge-blob.opt index 2f9bf78f82edf..1251c5f2aedde 100644 --- a/mysql-test/suite/innodb/t/innodb-enlarge-blob.opt +++ b/mysql-test/suite/innodb/t/innodb-enlarge-blob.opt @@ -1,4 +1,3 @@ ---innodb-file-per-table --innodb-buffer-pool-size=32M --innodb-page-size=64k --innodb-strict-mode=OFF diff --git a/mysql-test/suite/innodb/t/innodb-fkcheck.test b/mysql-test/suite/innodb/t/innodb-fkcheck.test index 5ff3533fce1ce..bec4de7b67003 100644 --- a/mysql-test/suite/innodb/t/innodb-fkcheck.test +++ b/mysql-test/suite/innodb/t/innodb-fkcheck.test @@ -4,17 +4,6 @@ # # MDEV-10083: Orphan ibd file when playing with foreign keys # ---disable_query_log -SET @start_global_fpt = @@global.innodb_file_per_table; -SET @start_global_fkc = @@global.foreign_key_checks; ---enable_query_log - -set global innodb_file_per_table = 1; - ---disable_warnings -drop table if exists b; -drop database if exists bug_fk; ---enable_warnings let $MYSQLD_DATADIR = `select @@datadir`; @@ -114,12 +103,6 @@ show warnings; # # Cleanup # ---disable_query_log -SET @@global.innodb_file_per_table = @start_global_fpt; -SET @@global.foreign_key_checks = @start_global_fkc; ---enable_query_log - ---disable_warnings -drop table if exists b; -drop database if exists bug_fk; ---enable_warnings + +drop table b; +drop database bug_fk; diff --git a/mysql-test/suite/innodb/t/innodb-index-online.test b/mysql-test/suite/innodb/t/innodb-index-online.test index ab4f5a965daf8..827941817f622 100644 --- a/mysql-test/suite/innodb/t/innodb-index-online.test +++ b/mysql-test/suite/innodb/t/innodb-index-online.test @@ -9,10 +9,6 @@ SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); -# DISCARD TABLESPACE needs file-per-table -SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; -SET GLOBAL innodb_file_per_table = on; - # Save the initial number of concurrent sessions. --source include/count_sessions.inc @@ -515,7 +511,6 @@ SET DEBUG_SYNC = 'RESET'; # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc -SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; --disable_warnings SET GLOBAL innodb_monitor_enable = default; SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/t/innodb-table-online.test b/mysql-test/suite/innodb/t/innodb-table-online.test index 45b1bc1ec8e68..5f0562e11ed30 100644 --- a/mysql-test/suite/innodb/t/innodb-table-online.test +++ b/mysql-test/suite/innodb/t/innodb-table-online.test @@ -11,10 +11,6 @@ call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); call mtr.add_suppression("InnoDB: Error: table 'test/t1'"); call mtr.add_suppression("MariaDB is trying to open a table handle but the .ibd file for"); -# DISCARD TABLESPACE needs file-per-table -SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; -SET GLOBAL innodb_file_per_table = on; - # Save the initial number of concurrent sessions. --source include/count_sessions.inc @@ -447,7 +443,6 @@ disconnect con1; # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc -SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; --disable_warnings SET GLOBAL innodb_monitor_enable = default; SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test index efa2b1ea403d8..16c5713cc7ba6 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test @@ -35,7 +35,6 @@ FLUSH TABLES; let MYSQLD_DATADIR =`SELECT @@datadir`; let $strerrfix=/ (\(.+\))//; -SET GLOBAL innodb_file_per_table = 1; CREATE TABLE t1 (c1 INT) ENGINE = InnoDB; INSERT INTO t1 VALUES(1),(2),(3); @@ -52,8 +51,6 @@ ALTER TABLE t1 DISCARD TABLESPACE; DROP TABLE t1; -SET GLOBAL innodb_file_per_table = 1; - CREATE TABLE t1 (c1 INT) ENGINE = InnoDB; INSERT INTO t1 VALUES(1),(2),(3); @@ -66,8 +63,6 @@ ALTER TABLE t1 DISCARD TABLESPACE; DROP TABLE t1; -SET GLOBAL innodb_file_per_table = 1; - # Create the table that we will use for crash recovery (during IMPORT) CREATE TABLE t1 (c1 INT) ENGINE = Innodb; INSERT INTO t1 VALUES (1), (2), (3), (4); @@ -130,9 +125,6 @@ EOF DROP TABLE t1; -SET @file_per_table= @@innodb_file_per_table; -SET GLOBAL innodb_file_per_table = 1; - CREATE TABLE t1 (c1 INT) ENGINE = Innodb; ALTER TABLE t1 DISCARD TABLESPACE; @@ -1397,5 +1389,3 @@ call mtr.add_suppression("Index for table 't1' is corrupt; try to repair it"); #cleanup --remove_file $MYSQLTEST_VARDIR/tmp/t1.cfg --remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd - -SET GLOBAL INNODB_FILE_PER_TABLE=@file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb-wl5522.test b/mysql-test/suite/innodb/t/innodb-wl5522.test index 19652d8e8fd16..c5c61ded6513c 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522.test @@ -98,7 +98,6 @@ if ($checksum_algorithm == "strict_full_crc32") { ALTER TABLE t2 IMPORT TABLESPACE; DROP TABLE t2; -SET GLOBAL innodb_file_per_table = 1; SELECT @@innodb_file_per_table; let MYSQLD_DATADIR =`SELECT @@datadir`; @@ -114,7 +113,7 @@ ALTER TABLE t1 IMPORT TABLESPACE; SELECT * FROM t1; DROP TABLE t1; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance CREATE TABLE t1( c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 INT) ENGINE=InnoDB; @@ -158,7 +157,7 @@ SELECT COUNT(*) FROM t1; DROP TABLE t1; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance # Insert some more records to move the LSN forward and then drop the # table and restore CREATE TABLE t1( @@ -204,7 +203,7 @@ SELECT COUNT(*) FROM t1; DROP TABLE t1; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance # Insert some more records to move the LSN forward and then drop the # table and restore, this time the table has a secondary index too. CREATE TABLE t1( @@ -245,7 +244,7 @@ SELECT COUNT(*) FROM t1 WHERE c2 = 1; DROP TABLE t1; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance # Insert some more records to move the LSN forward and then drop the # table and restore, this time the table has a secondary index too. # Rename the index on the create so that the IMPORT fails, drop index diff --git a/mysql-test/suite/innodb/t/innodb-wl5980-alter.test b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test index 09c54db644fad..6627b77ed9c5f 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5980-alter.test +++ b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test @@ -6,7 +6,6 @@ --source include/have_innodb.inc --source include/have_symlink.inc -SET @innodb_file_per_table_orig=@@GLOBAL.innodb_file_per_table; LET $regexp=/FTS_[0-9a-f_]+([A-Z0-9_]+)\.([islbd]{3})/FTS_AUX_\1.\2/; # Set up some variables @@ -14,7 +13,6 @@ LET $MYSQL_DATA_DIR = `select @@datadir`; LET $data_directory_clause = DATA DIRECTORY='$MYSQL_TMP_DIR/alt_dir'; SET default_storage_engine=InnoDB; -SET GLOBAL innodb_file_per_table=ON; SET NAMES utf8mb4; @@ -706,5 +704,3 @@ DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; --list_files $MYSQL_TMP_DIR/alt_dir/test --rmdir $MYSQL_TMP_DIR/alt_dir/test --rmdir $MYSQL_TMP_DIR/alt_dir - -SET GLOBAL innodb_file_per_table = @innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb/t/innodb_bug14147491-master.opt b/mysql-test/suite/innodb/t/innodb_bug14147491-master.opt index 614dd9356f1ee..8434ff04c6c20 100644 --- a/mysql-test/suite/innodb/t/innodb_bug14147491-master.opt +++ b/mysql-test/suite/innodb/t/innodb_bug14147491-master.opt @@ -1,4 +1,3 @@ ---innodb_file_per_table=1 --loose-skip-stack-trace --skip-core-file --loose-innodb_buffer_pool_load_at_startup=OFF diff --git a/mysql-test/suite/innodb/t/innodb_bug14147491.test b/mysql-test/suite/innodb/t/innodb_bug14147491.test index 3c37f1b7cce33..4f4810f84ae49 100644 --- a/mysql-test/suite/innodb/t/innodb_bug14147491.test +++ b/mysql-test/suite/innodb/t/innodb_bug14147491.test @@ -21,8 +21,6 @@ SET GLOBAL innodb_fast_shutdown=0; --echo # Create and populate the table to be corrupted -set global innodb_file_per_table=ON; - CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB; INSERT INTO t1 (b) VALUES ('corrupt me'); --disable_query_log diff --git a/mysql-test/suite/innodb/t/innodb_bug39438-master.opt b/mysql-test/suite/innodb/t/innodb_bug39438-master.opt deleted file mode 100644 index 0746d13d1c0ba..0000000000000 --- a/mysql-test/suite/innodb/t/innodb_bug39438-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb-file-per-table=1 diff --git a/mysql-test/suite/innodb/t/innodb_bug39438.test b/mysql-test/suite/innodb/t/innodb_bug39438.test index 635d65f045b96..04275197e1317 100644 --- a/mysql-test/suite/innodb/t/innodb_bug39438.test +++ b/mysql-test/suite/innodb/t/innodb_bug39438.test @@ -3,10 +3,6 @@ # Bug#39438 Testcase for Bug#39436 crashes on 5.1 in fil_space_get_latch # http://bugs.mysql.com/39438 # -# This test must be run with innodb_file_per_table=1 because the crash -# only occurs if that option is turned on and DISCARD TABLESPACE only -# works with innodb_file_per_table. -# SET default_storage_engine=InnoDB; diff --git a/mysql-test/suite/innodb/t/innodb_bug56947.test b/mysql-test/suite/innodb/t/innodb_bug56947.test index ce64f1a83223d..3e85e6148128c 100644 --- a/mysql-test/suite/innodb/t/innodb_bug56947.test +++ b/mysql-test/suite/innodb/t/innodb_bug56947.test @@ -4,7 +4,8 @@ -- source include/have_innodb.inc -- source include/have_debug.inc -SET GLOBAL innodb_file_per_table=0; +SET @save_fpt=@@GLOBAL.innodb_file_per_table; +SET GLOBAL innodb_file_per_table=OFF; create table bug56947(a int not null) engine = innodb; SET @saved_dbug = @@SESSION.debug_dbug; @@ -15,5 +16,5 @@ alter table bug56947 add unique index (a); check table bug56947; drop table bug56947; -SET @@global.innodb_file_per_table=DEFAULT; +SET GLOBAL innodb_file_per_table=@save_fpt; SET debug_dbug= @saved_dbug; diff --git a/mysql-test/suite/innodb/t/innodb_bug68148.test b/mysql-test/suite/innodb/t/innodb_bug68148.test index ab4e031165677..432e8fbf03ebb 100644 --- a/mysql-test/suite/innodb/t/innodb_bug68148.test +++ b/mysql-test/suite/innodb/t/innodb_bug68148.test @@ -6,8 +6,6 @@ # MDEV-8845: Table disappear after modifying FK # -set global innodb_file_per_table=1; - CREATE TABLE ref_table1 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; CREATE TABLE ref_table2 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/t/innodb_bulk_create_index_small.test b/mysql-test/suite/innodb/t/innodb_bulk_create_index_small.test index d04dd59f7e734..75e011a5094f3 100644 --- a/mysql-test/suite/innodb/t/innodb_bulk_create_index_small.test +++ b/mysql-test/suite/innodb/t/innodb_bulk_create_index_small.test @@ -80,11 +80,6 @@ SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; DROP TABLE t1; -SET GLOBAL innodb_file_per_table=default; - -# Test Compressed Table -SET GLOBAL innodb_file_per_table=1; - CREATE TABLE t1( class INT, id INT, @@ -143,6 +138,4 @@ SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; DROP TABLE t1; -SET GLOBAL innodb_file_per_table=default; - DROP PROCEDURE populate_t1; diff --git a/mysql-test/suite/innodb/t/innodb_defragment.opt b/mysql-test/suite/innodb/t/innodb_defragment.opt index aea3d480c244b..12b046be78663 100644 --- a/mysql-test/suite/innodb/t/innodb_defragment.opt +++ b/mysql-test/suite/innodb/t/innodb_defragment.opt @@ -1,5 +1,4 @@ --loose-innodb-buffer-pool-stats --loose-innodb-buffer-page --loose-innodb-buffer-page-lru ---innodb-file-per-table ---innodb-defragment=1 \ No newline at end of file +--innodb-defragment=1 diff --git a/mysql-test/suite/innodb/t/log_file_name.test b/mysql-test/suite/innodb/t/log_file_name.test index eb616d7f835db..1945be89599d6 100644 --- a/mysql-test/suite/innodb/t/log_file_name.test +++ b/mysql-test/suite/innodb/t/log_file_name.test @@ -7,7 +7,6 @@ # Embedded server does not support crashing --source include/not_embedded.inc -SET GLOBAL innodb_file_per_table=ON; FLUSH TABLES; CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/t/monitor.test b/mysql-test/suite/innodb/t/monitor.test index 9b093d41892e4..7d41a5507e80c 100644 --- a/mysql-test/suite/innodb/t/monitor.test +++ b/mysql-test/suite/innodb/t/monitor.test @@ -258,7 +258,7 @@ drop table monitor_test; set global innodb_monitor_enable = file_num_open_files; -# Counters are unpredictable when innodb-file-per-table is on +# Counters are unpredictable --replace_column 2 # 3 # 4 # 5 # 6 # 7 # select name, max_count, min_count, count, max_count_reset, min_count_reset, count_reset, diff --git a/mysql-test/suite/innodb/t/mvcc.test b/mysql-test/suite/innodb/t/mvcc.test index 7c37718c28a34..e0baf7f83d365 100644 --- a/mysql-test/suite/innodb/t/mvcc.test +++ b/mysql-test/suite/innodb/t/mvcc.test @@ -1,9 +1,6 @@ --source include/have_innodb.inc --source include/have_sequence.inc -SET @save_per_table= @@GLOBAL.innodb_file_per_table; -SET GLOBAL innodb_file_per_table= 1; - let MYSQLD_DATADIR =`SELECT @@datadir`; --echo # @@ -68,5 +65,3 @@ DELIMITER ;$$ INSERT INTO t1 SET id=1,c294=1; REPLACE t1 SET id=1,c294=1; DROP TABLE t1; - -SET GLOBAL innodb_file_per_table= @save_per_table; diff --git a/mysql-test/suite/innodb/t/row_format_redundant.test b/mysql-test/suite/innodb/t/row_format_redundant.test index 6de7597e98335..6ab1eabe15b7b 100644 --- a/mysql-test/suite/innodb/t/row_format_redundant.test +++ b/mysql-test/suite/innodb/t/row_format_redundant.test @@ -26,14 +26,11 @@ let bugdir= $MYSQLTEST_VARDIR/tmp/row_format_redundant; SET GLOBAL innodb_fast_shutdown=0; --source include/restart_mysqld.inc -SET GLOBAL innodb_file_per_table=1; - --echo # --echo # Bug#21644827 - FTS, ASSERT !SRV_READ_ONLY_MODE || M_IMPL.M_LOG_MODE == --echo # MTR_LOG_NO_REDO --echo # -SET GLOBAL innodb_file_per_table=ON; create table t1 (a int not null, d varchar(15) not null, b varchar(198) not null, c char(156)) engine=InnoDB row_format=redundant; diff --git a/mysql-test/suite/innodb/t/table_flags.test b/mysql-test/suite/innodb/t/table_flags.test index 6b2e6ee3ea629..1c3efa1fbba28 100644 --- a/mysql-test/suite/innodb/t/table_flags.test +++ b/mysql-test/suite/innodb/t/table_flags.test @@ -40,7 +40,6 @@ let bugdir= $MYSQLTEST_VARDIR/tmp/table_flags; --let $restart_parameters=$d --innodb-stats-persistent=0 --source include/restart_mysqld.inc -SET GLOBAL innodb_file_per_table=1; CREATE TABLE tr(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=REDUNDANT; CREATE TABLE tc(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPACT; CREATE TABLE td(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC; diff --git a/mysql-test/suite/innodb_fts/r/crash_recovery.result b/mysql-test/suite/innodb_fts/r/crash_recovery.result index 83e5ddaea90b3..52a58c7034dd9 100644 --- a/mysql-test/suite/innodb_fts/r/crash_recovery.result +++ b/mysql-test/suite/innodb_fts/r/crash_recovery.result @@ -161,6 +161,8 @@ DROP TABLE mdev19073, mdev19073_2; # MDEV-28706 Redundant InnoDB table fails during alter # SET @@global.innodb_file_per_table = 0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1 ( col_int INTEGER, col_text TEXT, col_text_1 TEXT diff --git a/mysql-test/suite/innodb_fts/r/fulltext.result b/mysql-test/suite/innodb_fts/r/fulltext.result index 32dc87daa0447..cb61506906740 100644 --- a/mysql-test/suite/innodb_fts/r/fulltext.result +++ b/mysql-test/suite/innodb_fts/r/fulltext.result @@ -721,6 +721,8 @@ DROP TABLE t1; # SET @save = @@global.innodb_file_per_table; SET @@global.innodb_file_per_table = 0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1 ( col_int INTEGER, col_text TEXT, col_int_g INTEGER GENERATED ALWAYS AS (col_int) @@ -730,6 +732,8 @@ ALTER TABLE t1 DROP KEY `ftidx` ; INSERT INTO t1 (col_int, col_text) VALUES ( 1255, NULL); DROP TABLE t1; SET @@global.innodb_file_per_table = @save; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release # # MDEV-20797 FULLTEXT search with apostrophe, # and mandatory words diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result b/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result index 52cbede731451..6d7a5647a633b 100644 --- a/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result @@ -466,7 +466,8 @@ ROLLBACK; SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); s1 s2 DROP TABLE t2 , t1; -set global innodb_file_per_table=1; +SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; +SET GLOBAL innodb_read_only_compressed=OFF; CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, a VARCHAR(200), @@ -649,7 +650,7 @@ id a b 6 MYSQL SECURITY when configured properly, mysql ... 7 TEST QUERY EXPANSION for database ... DROP TABLE t1; -SET GLOBAL innodb_file_per_table=1; +SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, a VARCHAR(200), diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_proximity.result b/mysql-test/suite/innodb_fts/r/innodb_fts_proximity.result index d67981e08511b..0cbe1090e89ae 100644 --- a/mysql-test/suite/innodb_fts/r/innodb_fts_proximity.result +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_proximity.result @@ -1,4 +1,3 @@ -drop table if exists t1; CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, a VARCHAR(200), @@ -133,7 +132,6 @@ AGAINST ('"xyz blob"@3' IN BOOLEAN MODE); count(*) 2 DROP TABLE t1; -set global innodb_file_per_table=1; CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, a TEXT, @@ -214,4 +212,3 @@ AGAINST ('"very blob"@3' IN BOOLEAN MODE); count(*) 1 DROP TABLE t1; -SET GLOBAL innodb_file_per_table=1; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test index 4eaf5b2e0bd39..c0836372e9e48 100644 --- a/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test @@ -427,15 +427,9 @@ DROP TABLE t2 , t1; # FTS index with compressed row format #------------------------------------------------------------------------------ -# Save innodb variables -let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; - -set global innodb_file_per_table=1; - ---disable_query_log SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; SET GLOBAL innodb_read_only_compressed=OFF; ---enable_query_log + # Create FTS table CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, @@ -583,10 +577,7 @@ SELECT * FROM t1 WHERE MATCH (a,b) SELECT * FROM t1 ORDER BY id; DROP TABLE t1; ---disable_query_log SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; ---enable_query_log -eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; #------------------------------------------------------------------------------ # FTS index with utf8 character testcase diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_proximity.test b/mysql-test/suite/innodb_fts/t/innodb_fts_proximity.test index e3d8eb0c13b11..25ad4f0355ff3 100644 --- a/mysql-test/suite/innodb_fts/t/innodb_fts_proximity.test +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_proximity.test @@ -5,14 +5,6 @@ # Functional testing with FTS proximity search using '@' # and try search default words ---disable_warnings -drop table if exists t1; ---enable_warnings - ---disable_query_log -let $innodb_file_per_table_orig = `select @@innodb_file_per_table`; ---enable_query_log - # Create FTS table CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, @@ -161,8 +153,6 @@ SELECT count(*) FROM t1 DROP TABLE t1; -set global innodb_file_per_table=1; - # Test fts with externally stored long column CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, @@ -257,5 +247,3 @@ SELECT count(*) FROM t1 AGAINST ('"very blob"@3' IN BOOLEAN MODE); DROP TABLE t1; - -eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb_zip/r/bug36169.result b/mysql-test/suite/innodb_zip/r/bug36169.result index 7e165e0f7d45b..c7e234b5ba11b 100644 --- a/mysql-test/suite/innodb_zip/r/bug36169.result +++ b/mysql-test/suite/innodb_zip/r/bug36169.result @@ -1 +1 @@ -SET GLOBAL innodb_file_per_table=ON; +DROP TABLE IF EXISTS table6; diff --git a/mysql-test/suite/innodb_zip/r/bug53591.result b/mysql-test/suite/innodb_zip/r/bug53591.result index 779064d054f49..0c6386df022a5 100644 --- a/mysql-test/suite/innodb_zip/r/bug53591.result +++ b/mysql-test/suite/innodb_zip/r/bug53591.result @@ -1,9 +1,4 @@ call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the row size is'); -SET GLOBAL innodb_file_per_table=on; -SET GLOBAL innodb_strict_mode=on; -set old_alter_table=0; -Warnings: -Warning 1287 '@@old_alter_table' is deprecated and will be removed in a future release. Please use '@@alter_algorithm' instead CREATE TABLE bug53591(a text charset utf8 not null) ENGINE=InnoDB KEY_BLOCK_SIZE=1; ALTER TABLE bug53591 ADD PRIMARY KEY(a(220)); @@ -12,5 +7,3 @@ SHOW WARNINGS; Level Code Message Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is {checked_valid}. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs DROP TABLE bug53591; -SET GLOBAL innodb_file_per_table=1; -SET GLOBAL innodb_strict_mode=DEFAULT; diff --git a/mysql-test/suite/innodb_zip/r/bug56680.result b/mysql-test/suite/innodb_zip/r/bug56680.result index 1a1a5b407074c..3c325351c3ae4 100644 --- a/mysql-test/suite/innodb_zip/r/bug56680.result +++ b/mysql-test/suite/innodb_zip/r/bug56680.result @@ -1,5 +1,4 @@ SET GLOBAL tx_isolation='REPEATABLE-READ'; -SET GLOBAL innodb_file_per_table=on; CREATE TABLE bug56680( a INT AUTO_INCREMENT PRIMARY KEY, b CHAR(1), diff --git a/mysql-test/suite/innodb_zip/r/cmp_drop_table.result b/mysql-test/suite/innodb_zip/r/cmp_drop_table.result index e1f63268d0b25..530932e99fb51 100644 --- a/mysql-test/suite/innodb_zip/r/cmp_drop_table.result +++ b/mysql-test/suite/innodb_zip/r/cmp_drop_table.result @@ -1,4 +1,3 @@ -set global innodb_file_per_table=on; create table t1(a text) engine=innodb key_block_size=4; SELECT page_size FROM information_schema.innodb_cmpmem WHERE pages_used > 0; page_size diff --git a/mysql-test/suite/innodb_zip/r/create_options.result b/mysql-test/suite/innodb_zip/r/create_options.result index a678d7a85f329..0f4c1239d7379 100644 --- a/mysql-test/suite/innodb_zip/r/create_options.result +++ b/mysql-test/suite/innodb_zip/r/create_options.result @@ -1,5 +1,4 @@ SET default_storage_engine=InnoDB; -SET GLOBAL innodb_file_per_table=ON; SET SESSION innodb_strict_mode = ON; # Test 1) StrictMode=ON, CREATE and ALTER with each ROW_FORMAT & KEY_BLOCK_SIZE=0 # KEY_BLOCK_SIZE=0 means 'no KEY_BLOCK_SIZE is specified' @@ -280,6 +279,8 @@ Level Code Message # innodb_file_per_table=OFF and that they can be set to default # values during strict mode. SET GLOBAL innodb_file_per_table=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release DROP TABLE t1; CREATE TABLE t1 ( i INT ) KEY_BLOCK_SIZE=1; Got one of the listed errors @@ -354,9 +355,13 @@ SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME ROW_FORMAT CREATE_OPTIONS t1 Dynamic SET GLOBAL innodb_file_per_table=ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; SET GLOBAL innodb_file_per_table=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t1 ADD COLUMN f1 INT; SHOW WARNINGS; Level Code Message @@ -367,6 +372,8 @@ ALTER TABLE t1 ADD COLUMN f2 INT; SHOW WARNINGS; Level Code Message SET GLOBAL innodb_file_per_table=ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ################################################## SET SESSION innodb_strict_mode = OFF; # Test 9) StrictMode=OFF, CREATE and ALTER with each ROW_FORMAT & KEY_BLOCK_SIZE=0 @@ -722,6 +729,8 @@ SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME ROW_FORMAT CREATE_OPTIONS t1 Compressed row_format=COMPRESSED key_block_size=2 SET GLOBAL innodb_file_per_table=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t1 ADD COLUMN f1 INT; SHOW WARNINGS; Level Code Message @@ -729,6 +738,8 @@ SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME ROW_FORMAT CREATE_OPTIONS t1 Compressed row_format=COMPRESSED key_block_size=2 SET GLOBAL innodb_file_per_table=ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t1 ADD COLUMN f2 INT; SHOW WARNINGS; Level Code Message @@ -743,6 +754,8 @@ SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME ROW_FORMAT CREATE_OPTIONS t1 Dynamic row_format=DYNAMIC SET GLOBAL innodb_file_per_table=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t1 ADD COLUMN f1 INT; SHOW WARNINGS; Level Code Message @@ -750,6 +763,8 @@ SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME ROW_FORMAT CREATE_OPTIONS t1 Dynamic row_format=DYNAMIC SET GLOBAL innodb_file_per_table=ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t1 ADD COLUMN f2 INT; SHOW WARNINGS; Level Code Message diff --git a/mysql-test/suite/innodb_zip/r/index_large_prefix.result b/mysql-test/suite/innodb_zip/r/index_large_prefix.result index ce3023277136e..81bdcdeb7400f 100644 --- a/mysql-test/suite/innodb_zip/r/index_large_prefix.result +++ b/mysql-test/suite/innodb_zip/r/index_large_prefix.result @@ -1,5 +1,4 @@ SET default_storage_engine=InnoDB; -set global innodb_file_per_table=1; ### Test 1 ### create table worklog5743(a TEXT not null, primary key (a(1000))) ROW_FORMAT=DYNAMIC; show warnings; @@ -449,4 +448,3 @@ create index idx on worklog5743(a(768)); ERROR HY000: Index column size too large. The maximum column size is 767 bytes create index idx2 on worklog5743(a(767)); drop table worklog5743; -SET GLOBAL innodb_file_per_table=1; diff --git a/mysql-test/suite/innodb_zip/r/innodb-zip.result b/mysql-test/suite/innodb_zip/r/innodb-zip.result index 0a3119f48a489..c44eefcbbb01e 100644 --- a/mysql-test/suite/innodb_zip/r/innodb-zip.result +++ b/mysql-test/suite/innodb_zip/r/innodb-zip.result @@ -6,7 +6,10 @@ WHERE table_schema='mysqltest_innodb_zip'; table_name row_format data_length index_length SET @save_innodb_stats_on_metadata=@@global.innodb_stats_on_metadata; set session innodb_strict_mode=0; +SET @save_fpt=@@GLOBAL.innodb_file_per_table; set global innodb_file_per_table=off; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SET @@global.innodb_stats_on_metadata=ON; create table t0(a int primary key) engine=innodb row_format=compressed; Warnings: @@ -32,6 +35,8 @@ Warnings: Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table. Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=1. set global innodb_file_per_table=on; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release create table t6(a int primary key) engine=innodb key_block_size=1 row_format=redundant; Warnings: @@ -153,7 +158,6 @@ count(*) 1 update t1 set c3 = repeat('E', 20000) where c1 = 1; drop table t1; -set global innodb_file_per_table = on; set innodb_strict_mode = off; create table t1 (id int primary key) engine = innodb key_block_size = 0; drop table t1; @@ -247,6 +251,8 @@ Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb' AND table_schema != 'mysql' and table_schema != 'sys' order by table_name; table_schema table_name row_format data_length index_length set global innodb_file_per_table = off; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release create table t1 (id int primary key) engine = innodb key_block_size = 1; ERROR HY000: Can't create table `mysqltest_innodb_zip`.`t1` (errno: 140 "Wrong create options") show warnings; @@ -286,4 +292,8 @@ mysqltest_innodb_zip t7 Dynamic {valid} 0 mysqltest_innodb_zip t8 Compact {valid} 0 mysqltest_innodb_zip t9 Redundant {valid} 0 drop table t7, t8, t9; +SET GLOBAL innodb_file_per_table=@save_fpt; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release +SET @@global.innodb_stats_on_metadata=@save_innodb_stats_on_metadata; DROP DATABASE mysqltest_innodb_zip; diff --git a/mysql-test/suite/innodb_zip/r/large_blob.result b/mysql-test/suite/innodb_zip/r/large_blob.result index 7070d610f584c..55bb90aab5c83 100644 --- a/mysql-test/suite/innodb_zip/r/large_blob.result +++ b/mysql-test/suite/innodb_zip/r/large_blob.result @@ -1,8 +1,9 @@ # # This tests the use of large blobs in InnoDB. # -call mtr.add_suppression("InnoDB: Warning: a long semaphore wait"); SET GLOBAL innodb_file_per_table = OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release # # System tablespace, Row Format = Redundant # @@ -26,6 +27,8 @@ INSERT INTO t1 VALUES (1, ''); UPDATE t1 SET c2=@longblob; DROP TABLE t1; SET GLOBAL innodb_file_per_table = ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release # # Separate tablespace, Row Format = Redundant # diff --git a/mysql-test/suite/innodb_zip/r/page_size,4k.rdiff b/mysql-test/suite/innodb_zip/r/page_size,4k.rdiff index 494da214f2e65..0ba8a299ab96c 100644 --- a/mysql-test/suite/innodb_zip/r/page_size,4k.rdiff +++ b/mysql-test/suite/innodb_zip/r/page_size,4k.rdiff @@ -21,9 +21,9 @@ -test/t3 DEFAULT 8192 MYSQLD_DATADIR/test/t3.ibd +test/t3 DEFAULT 2048 MYSQLD_DATADIR/test/t3.ibd test/t4 DEFAULT DEFAULT MYSQLD_DATADIR/test/t4.ibd + innodb_temporary DEFAULT DEFAULT MYSQLD_DATADIR/ibtmp1 DROP TABLE t1, t2, t3, t4; - # Test 4) The maximum row size is dependent upon the page size. -@@ -51,141 +51,90 @@ +@@ -52,141 +52,90 @@ SET SESSION innodb_strict_mode = ON; CREATE TABLE t1 ( c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), @@ -211,7 +211,7 @@ ALTER TABLE t1 KEY_BLOCK_SIZE=4; SHOW WARNINGS; Level Code Message -@@ -217,15 +166,21 @@ +@@ -218,15 +167,21 @@ DROP TABLE t1; SET SESSION innodb_strict_mode = OFF; CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; @@ -233,7 +233,7 @@ SELECT table_name, row_format, create_options FROM information_schema.tables WHERE table_name = 't1'; table_name row_format create_options -@@ -269,6 +224,7 @@ +@@ -272,6 +227,7 @@ ERROR HY000: Can't create table `test`.`t4` (errno: 140 "Wrong create options") SHOW WARNINGS; Level Code Message @@ -241,7 +241,7 @@ Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table. Error 1005 Can't create table `test`.`t4` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB -@@ -276,105 +232,11 @@ +@@ -279,107 +235,13 @@ ERROR HY000: Can't create table `test`.`t5` (errno: 140 "Wrong create options") SHOW WARNINGS; Level Code Message @@ -250,6 +250,8 @@ Error 1005 Can't create table `test`.`t5` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB SET GLOBAL innodb_file_per_table = ON; + Warnings: + Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release -# Test 7) This series of tests were moved from innodb-index to here -# because the second alter table t1 assumes a 16k page size. -# Moving the test allows the rest of innodb-index to be run on all @@ -348,7 +350,7 @@ # Test 8) Test creating a table that could lead to undo log overflow. CREATE TABLE t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob, h blob,i blob,j blob,k blob,l blob,m blob,n blob, -@@ -389,10 +251,6 @@ +@@ -394,10 +256,6 @@ UPDATE t1 SET a=@b,b=@b,c=@b,d=@b,e=@b,f=@b,g=@b,h=@b,i=@b,j=@b, k=@b,l=@b,m=@b,n=@b,o=@b,p=@b,q=@b,r=@b,s=@b,t=@b,u=@b; CREATE INDEX t1a ON t1 (a(767)); @@ -359,7 +361,7 @@ UPDATE t1 SET a=@c,b=@c,c=@c,d=@c,e=@c,f=@c,g=@c,h=@c,i=@c,j=@c, k=@c,l=@c,m=@c,n=@c,o=@c,p=@c,q=@c,r=@c,s=@c,t=@c,u=@c; CREATE INDEX t1f ON t1 (f(767)); -@@ -407,37 +265,15 @@ +@@ -412,37 +270,15 @@ COMMIT; CREATE INDEX t1g ON t1 (g(767)); UPDATE t1 SET g=@e; @@ -401,7 +403,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( -@@ -463,28 +299,12 @@ +@@ -468,28 +304,12 @@ `t` blob DEFAULT NULL, `u` blob DEFAULT NULL, KEY `t1a` (`a`(767)), @@ -432,7 +434,7 @@ ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=DYNAMIC DROP TABLE t1; # Bug#12547647 UPDATE LOGGING COULD EXCEED LOG PAGE SIZE -@@ -569,27 +389,25 @@ +@@ -574,27 +394,25 @@ DROP TABLE t1; CREATE TABLE t1( c text NOT NULL, d text NOT NULL, diff --git a/mysql-test/suite/innodb_zip/r/page_size,8k.rdiff b/mysql-test/suite/innodb_zip/r/page_size,8k.rdiff index a22fa9e9b9580..0d215684e2fd9 100644 --- a/mysql-test/suite/innodb_zip/r/page_size,8k.rdiff +++ b/mysql-test/suite/innodb_zip/r/page_size,8k.rdiff @@ -21,9 +21,9 @@ -test/t3 DEFAULT 8192 MYSQLD_DATADIR/test/t3.ibd +test/t3 DEFAULT 4096 MYSQLD_DATADIR/test/t3.ibd test/t4 DEFAULT DEFAULT MYSQLD_DATADIR/test/t4.ibd + innodb_temporary DEFAULT DEFAULT MYSQLD_DATADIR/ibtmp1 DROP TABLE t1, t2, t3, t4; - # Test 4) The maximum row size is dependent upon the page size. -@@ -53,133 +53,97 @@ +@@ -54,133 +54,97 @@ c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200), c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200), c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200), @@ -199,7 +199,7 @@ SHOW WARNINGS; Level Code Message SELECT table_name, row_format, create_options -@@ -217,8 +181,11 @@ +@@ -218,8 +182,11 @@ DROP TABLE t1; SET SESSION innodb_strict_mode = OFF; CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; @@ -211,7 +211,7 @@ SELECT table_name, row_format, create_options FROM information_schema.tables WHERE table_name = 't1'; table_name row_format create_options -@@ -276,105 +243,11 @@ +@@ -279,107 +246,13 @@ ERROR HY000: Can't create table `test`.`t5` (errno: 140 "Wrong create options") SHOW WARNINGS; Level Code Message @@ -220,6 +220,8 @@ Error 1005 Can't create table `test`.`t5` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB SET GLOBAL innodb_file_per_table = ON; + Warnings: + Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release -# Test 7) This series of tests were moved from innodb-index to here -# because the second alter table t1 assumes a 16k page size. -# Moving the test allows the rest of innodb-index to be run on all @@ -318,7 +320,7 @@ # Test 8) Test creating a table that could lead to undo log overflow. CREATE TABLE t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob, h blob,i blob,j blob,k blob,l blob,m blob,n blob, -@@ -389,10 +262,6 @@ +@@ -394,10 +267,6 @@ UPDATE t1 SET a=@b,b=@b,c=@b,d=@b,e=@b,f=@b,g=@b,h=@b,i=@b,j=@b, k=@b,l=@b,m=@b,n=@b,o=@b,p=@b,q=@b,r=@b,s=@b,t=@b,u=@b; CREATE INDEX t1a ON t1 (a(767)); @@ -329,7 +331,7 @@ UPDATE t1 SET a=@c,b=@c,c=@c,d=@c,e=@c,f=@c,g=@c,h=@c,i=@c,j=@c, k=@c,l=@c,m=@c,n=@c,o=@c,p=@c,q=@c,r=@c,s=@c,t=@c,u=@c; CREATE INDEX t1f ON t1 (f(767)); -@@ -407,30 +276,6 @@ +@@ -412,30 +281,6 @@ COMMIT; CREATE INDEX t1g ON t1 (g(767)); UPDATE t1 SET g=@e; @@ -360,7 +362,7 @@ CREATE INDEX t1t ON t1 (t(767)); BEGIN; UPDATE t1 SET t=@e; -@@ -463,24 +308,8 @@ +@@ -468,24 +313,8 @@ `t` blob DEFAULT NULL, `u` blob DEFAULT NULL, KEY `t1a` (`a`(767)), @@ -385,7 +387,7 @@ KEY `t1t` (`t`(767)), KEY `t1u` (`u`(767)), KEY `t1ut` (`u`(767),`t`(767)), -@@ -572,14 +401,14 @@ +@@ -577,14 +406,14 @@ PRIMARY KEY (c(767),d(767))) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII; Warnings: @@ -402,7 +404,7 @@ DROP TABLE t1; CREATE TABLE t1( c text NOT NULL, d text NOT NULL, -@@ -589,7 +418,7 @@ +@@ -594,7 +423,7 @@ CREATE TABLE t1(c text, PRIMARY KEY (c(440))) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII; Warnings: diff --git a/mysql-test/suite/innodb_zip/r/page_size.result b/mysql-test/suite/innodb_zip/r/page_size.result index 47effe0688443..71e8e5461d3a0 100644 --- a/mysql-test/suite/innodb_zip/r/page_size.result +++ b/mysql-test/suite/innodb_zip/r/page_size.result @@ -263,6 +263,8 @@ DROP TABLE t1; # Test 6) KEY_BLOCK_SIZE with innodb_file_per_table=OFF SET SESSION innodb_strict_mode = ON; SET GLOBAL innodb_file_per_table = OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SHOW VARIABLES LIKE 'innodb_file_per_table'; Variable_name Value innodb_file_per_table OFF @@ -281,6 +283,8 @@ Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table. Error 1005 Can't create table `test`.`t5` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB SET GLOBAL innodb_file_per_table = ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release # Test 7) This series of tests were moved from innodb-index to here # because the second alter table t1 assumes a 16k page size. # Moving the test allows the rest of innodb-index to be run on all diff --git a/mysql-test/suite/innodb_zip/r/restart.result b/mysql-test/suite/innodb_zip/r/restart.result index eb1bfe67c5d47..b57fe1e89e6d6 100644 --- a/mysql-test/suite/innodb_zip/r/restart.result +++ b/mysql-test/suite/innodb_zip/r/restart.result @@ -3,7 +3,6 @@ SET default_storage_engine=InnoDB; # A series of tests to make sure tables are opened after restart. # Bug#13357607 Compressed file-per-table tablespaces fail to open # -set global innodb_file_per_table=on; # # Create and insert records into a REDUNDANT row formatted table. # @@ -265,9 +264,6 @@ t7_restart#p#p1#sp#s3.ibd # Start the server and show that tables are still visible and accessible. # # restart -SHOW VARIABLES LIKE 'innodb_file_per_table'; -Variable_name Value -innodb_file_per_table ON SHOW CREATE TABLE t1_restart; Table Create Table t1_restart CREATE TABLE `t1_restart` ( @@ -522,9 +518,6 @@ t7_restart#p#p1#sp#s3.ibd # Start the server and show the tablespaces. # # restart -SHOW VARIABLES LIKE 'innodb_file_per_table'; -Variable_name Value -innodb_file_per_table ON === information_schema.innodb_sys_tablespaces and innodb_sys_datafiles === Space_Name Page_Size Zip_Size Path test/t4_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t4_restart.ibd @@ -723,9 +716,6 @@ t77_restart#p#p1#sp#s3.ibd # Restart the server # # restart -SHOW VARIABLES LIKE 'innodb_file_per_table'; -Variable_name Value -innodb_file_per_table ON === information_schema.innodb_sys_tablespaces and innodb_sys_datafiles === Space_Name Page_Size Zip_Size Path test/t4_restart DEFAULT DEFAULT MYSQLD_DATADIR/test/t4_restart.ibd diff --git a/mysql-test/suite/innodb_zip/r/wl5522_zip.result b/mysql-test/suite/innodb_zip/r/wl5522_zip.result index 1b044d68680fd..a7cc00cb1fd4c 100644 --- a/mysql-test/suite/innodb_zip/r/wl5522_zip.result +++ b/mysql-test/suite/innodb_zip/r/wl5522_zip.result @@ -263,6 +263,8 @@ c1 c2 unlink: t1.cfg DROP TABLE t1; SET GLOBAL innodb_file_per_table = 0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1( c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 INT) ENGINE=InnoDB; @@ -280,6 +282,8 @@ Warning 1809 Table `test`.`t1` in system tablespace UNLOCK TABLES; DROP TABLE t1; SET GLOBAL innodb_file_per_table = 1; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1( c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 INT, INDEX idx(c2)) ENGINE=InnoDB diff --git a/mysql-test/suite/innodb_zip/r/wl6347_comp_indx_stat.result b/mysql-test/suite/innodb_zip/r/wl6347_comp_indx_stat.result index 05b4793eb4d87..f46678340e2a7 100644 --- a/mysql-test/suite/innodb_zip/r/wl6347_comp_indx_stat.result +++ b/mysql-test/suite/innodb_zip/r/wl6347_comp_indx_stat.result @@ -8,7 +8,6 @@ # check the size and compression stats of the table tab5 #****************************************************************** # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_cmp_per_index_enabled=ON; SET GLOBAL innodb_compression_level=0; #****************************************************************** @@ -318,7 +317,6 @@ The size of the tab5.ibd file: 5242880 # set the flag on (default off) SET GLOBAL innodb_cmp_per_index_enabled=ON; # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=0; # fetch the compressed page and check the stats # The stats figure may be different/same for each restart. @@ -655,7 +653,6 @@ The size of the tab5.ibd file: 2097152 # set the flag on (default off) SET GLOBAL innodb_cmp_per_index_enabled=ON; # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=0; # fetch the compressed page and check the stats # The stats figure may be different/same for each restart. @@ -1615,7 +1612,6 @@ DROP TABLE tab5; SET GLOBAL innodb_cmp_per_index_enabled=0; SET GLOBAL innodb_cmp_per_index_enabled=1; # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=9; #****************************************************************** # Test 2-1K: innodb_cmp_per_index_enabled=ON and innodb_compression_level=9 with page size 1K @@ -1926,7 +1922,6 @@ The size of the tab5.ibd file: 65536 # set the flag on (default off) SET GLOBAL innodb_cmp_per_index_enabled=ON; # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=9; # fetch the compressed page and check the stats # The stats figure may be different/same for each restart. @@ -2265,7 +2260,6 @@ The size of the tab5.ibd file: 65536 # set the flag on (default off) SET GLOBAL innodb_cmp_per_index_enabled=ON; # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=9; # fetch the compressed page and check the stats # The stats figure may be different/same for each restart. @@ -4710,8 +4704,6 @@ SELECT @@innodb_cmp_per_index_enabled; @@innodb_cmp_per_index_enabled 1 SELECT @@innodb_compression_failure_threshold_pct; @@innodb_compression_failure_threshold_pct 0 -SELECT @@innodb_file_per_table; -@@innodb_file_per_table 1 SELECT @@innodb_compression_level; @@innodb_compression_level 6 #****************************************************************** @@ -5022,7 +5014,6 @@ The size of the tab5.ibd file: 65536 SET GLOBAL innodb_cmp_per_index_enabled=ON; # set the flags SET GLOBAL innodb_compression_failure_threshold_pct=0; -SET GLOBAL innodb_file_per_table=on; # fetch the compressed page and check the stats # The stats figure may be different/same for each restart. =============== @@ -6289,7 +6280,6 @@ DROP TABLE tab5; SET GLOBAL innodb_cmp_per_index_enabled=OFF; SET GLOBAL innodb_cmp_per_index_enabled=ON; # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_cmp_per_index_enabled=ON; SET GLOBAL innodb_compression_failure_threshold_pct=10; SET GLOBAL innodb_compression_level=Default; @@ -6298,8 +6288,6 @@ SELECT @@innodb_cmp_per_index_enabled; @@innodb_cmp_per_index_enabled 1 SELECT @@innodb_compression_failure_threshold_pct; @@innodb_compression_failure_threshold_pct 10 -SELECT @@innodb_file_per_table; -@@innodb_file_per_table 1 SELECT @@innodb_compression_level; @@innodb_compression_level 6 #****************************************************************** @@ -6610,8 +6598,6 @@ The size of the tab5.ibd file: 65536 SET GLOBAL innodb_cmp_per_index_enabled=ON; # set the flags SET GLOBAL innodb_compression_failure_threshold_pct=10; -SET GLOBAL innodb_file_per_table=on; -SET GLOBAL innodb_compression_failure_threshold_pct=10; # fetch the compressed page and check the stats # The stats figure may be different/same for each restart. =============== @@ -7874,7 +7860,6 @@ DROP TABLE tab5; # reset the stat table before starting next testcase SET GLOBAL innodb_cmp_per_index_enabled=0; SET GLOBAL innodb_cmp_per_index_enabled=1; -SET GLOBAL innodb_file_per_table=ON; SET GLOBAL innodb_compression_level=default; SET GLOBAL innodb_compression_failure_threshold_pct=default; # create a table page size=1K @@ -7923,6 +7908,5 @@ compress_ops_ok 1 DROP TABLE tab5, test.tab5; DROP DATABASE sb; # reset the flags -SET GLOBAL innodb_file_per_table=default; SET GLOBAL innodb_cmp_per_index_enabled=default; SET GLOBAL innodb_compression_failure_threshold_pct=default; diff --git a/mysql-test/suite/innodb_zip/t/bug36169.test b/mysql-test/suite/innodb_zip/t/bug36169.test index 07566b204bdca..8ab970f67b2cf 100644 --- a/mysql-test/suite/innodb_zip/t/bug36169.test +++ b/mysql-test/suite/innodb_zip/t/bug36169.test @@ -5,9 +5,6 @@ -- source include/innodb_page_size_small.inc -let $file_per_table=`select @@innodb_file_per_table`; -SET GLOBAL innodb_file_per_table=ON; - # # The following is copied from http://bugs.mysql.com/36169 # (http://bugs.mysql.com/file.php?id=9121) @@ -1155,7 +1152,5 @@ DROP TABLE IF EXISTS table2; DROP TABLE IF EXISTS table3; DROP TABLE IF EXISTS table4; DROP TABLE IF EXISTS table5; +-- enable_query_log DROP TABLE IF EXISTS table6; - -EVAL SET GLOBAL innodb_file_per_table=$file_per_table; -SET sql_mode = default; diff --git a/mysql-test/suite/innodb_zip/t/bug53591.test b/mysql-test/suite/innodb_zip/t/bug53591.test index 17c79e0f6f881..ef4d12ad078ec 100644 --- a/mysql-test/suite/innodb_zip/t/bug53591.test +++ b/mysql-test/suite/innodb_zip/t/bug53591.test @@ -2,13 +2,6 @@ call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the row size is'); -let $file_per_table=`select @@innodb_file_per_table`; - -SET GLOBAL innodb_file_per_table=on; -SET GLOBAL innodb_strict_mode=on; - -set old_alter_table=0; - CREATE TABLE bug53591(a text charset utf8 not null) ENGINE=InnoDB KEY_BLOCK_SIZE=1; -- replace_result 8126 {checked_valid} 4030 {checked_valid} 1982 {checked_valid} @@ -18,6 +11,3 @@ ALTER TABLE bug53591 ADD PRIMARY KEY(a(220)); SHOW WARNINGS; DROP TABLE bug53591; - -EVAL SET GLOBAL innodb_file_per_table=$file_per_table; -SET GLOBAL innodb_strict_mode=DEFAULT; diff --git a/mysql-test/suite/innodb_zip/t/bug56680.test b/mysql-test/suite/innodb_zip/t/bug56680.test index 54cbc7ca798ca..0d441dea0f563 100644 --- a/mysql-test/suite/innodb_zip/t/bug56680.test +++ b/mysql-test/suite/innodb_zip/t/bug56680.test @@ -16,7 +16,6 @@ SET GLOBAL innodb_change_buffering_debug = 1; -- enable_query_log SET GLOBAL tx_isolation='REPEATABLE-READ'; -SET GLOBAL innodb_file_per_table=on; CREATE TABLE bug56680( a INT AUTO_INCREMENT PRIMARY KEY, diff --git a/mysql-test/suite/innodb_zip/t/cmp_drop_table.test b/mysql-test/suite/innodb_zip/t/cmp_drop_table.test index ae6bfd9fb594b..e64514fc9fbbe 100644 --- a/mysql-test/suite/innodb_zip/t/cmp_drop_table.test +++ b/mysql-test/suite/innodb_zip/t/cmp_drop_table.test @@ -3,12 +3,8 @@ # scans through pages -- source include/not_encrypted.inc -let $per_table=`select @@innodb_file_per_table`; - -- let $query_i_s = SELECT page_size FROM information_schema.innodb_cmpmem WHERE pages_used > 0 -set global innodb_file_per_table=on; - create table t1(a text) engine=innodb key_block_size=4; -- disable_query_log @@ -50,10 +46,3 @@ while ($i) -- eval $query_i_s drop table t2; - -# -# restore environment to the state it was before this test execution -# - --- disable_query_log -eval set global innodb_file_per_table=$per_table; diff --git a/mysql-test/suite/innodb_zip/t/create_options.test b/mysql-test/suite/innodb_zip/t/create_options.test index fce64060df3df..9840a28a2ce13 100644 --- a/mysql-test/suite/innodb_zip/t/create_options.test +++ b/mysql-test/suite/innodb_zip/t/create_options.test @@ -59,11 +59,6 @@ --source include/innodb_page_size_small.inc SET default_storage_engine=InnoDB; -# These values can change during the test -LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`; - -SET GLOBAL innodb_file_per_table=ON; - # The first half of these tests are with strict mode ON. SET SESSION innodb_strict_mode = ON; @@ -481,7 +476,3 @@ SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE --echo # Cleanup DROP TABLE t1; - ---disable_query_log -EVAL SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; ---enable_query_log diff --git a/mysql-test/suite/innodb_zip/t/index_large_prefix.test b/mysql-test/suite/innodb_zip/t/index_large_prefix.test index a254c4e61eea5..5c1e31a2db770 100644 --- a/mysql-test/suite/innodb_zip/t/index_large_prefix.test +++ b/mysql-test/suite/innodb_zip/t/index_large_prefix.test @@ -10,10 +10,6 @@ SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; SET GLOBAL innodb_read_only_compressed=OFF; --enable_query_log -let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; - -set global innodb_file_per_table=1; - -- echo ### Test 1 ### # Create a table of DYNAMIC format, with a primary index of 1000 bytes in # size @@ -408,5 +404,3 @@ create index idx2 on worklog5743(a(767)); SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; --enable_query_log drop table worklog5743; - -eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb_zip/t/index_large_prefix_4k.test b/mysql-test/suite/innodb_zip/t/index_large_prefix_4k.test index 04f7ac65edf71..8ada226779aaa 100644 --- a/mysql-test/suite/innodb_zip/t/index_large_prefix_4k.test +++ b/mysql-test/suite/innodb_zip/t/index_large_prefix_4k.test @@ -10,10 +10,6 @@ SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; SET GLOBAL innodb_read_only_compressed=OFF; --enable_query_log -let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; - -set global innodb_file_per_table=1; - -- echo ### Test 1 ### # Create a table of DYNAMIC format, with a primary index of 768 bytes in # size @@ -380,5 +376,3 @@ create index idx2 on worklog5743(a(767)); SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; --enable_query_log drop table worklog5743; - -eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb_zip/t/index_large_prefix_8k.test b/mysql-test/suite/innodb_zip/t/index_large_prefix_8k.test index c9cd9574a95c8..e20de5e3e9395 100644 --- a/mysql-test/suite/innodb_zip/t/index_large_prefix_8k.test +++ b/mysql-test/suite/innodb_zip/t/index_large_prefix_8k.test @@ -10,10 +10,6 @@ SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; SET GLOBAL innodb_read_only_compressed=OFF; --enable_query_log -let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; - -set global innodb_file_per_table=1; - -- echo ### Test 1 ### # Create a table of DYNAMIC format, with a primary index of 1000 bytes in # size @@ -402,5 +398,3 @@ create index idx2 on worklog5743(a(767)); SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; --enable_query_log drop table worklog5743; - -eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb_zip/t/innodb-zip.test b/mysql-test/suite/innodb_zip/t/innodb-zip.test index 507900aa88cce..47867f3fa3e17 100644 --- a/mysql-test/suite/innodb_zip/t/innodb-zip.test +++ b/mysql-test/suite/innodb_zip/t/innodb-zip.test @@ -6,12 +6,12 @@ SELECT table_name, row_format, data_length, index_length FROM information_schema.tables WHERE table_schema='mysqltest_innodb_zip'; -let $per_table=`select @@innodb_file_per_table`; SET @save_innodb_stats_on_metadata=@@global.innodb_stats_on_metadata; --let $query_i_s = SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb' AND table_schema != 'mysql' and table_schema != 'sys' order by table_name set session innodb_strict_mode=0; +SET @save_fpt=@@GLOBAL.innodb_file_per_table; set global innodb_file_per_table=off; SET @@global.innodb_stats_on_metadata=ON; @@ -123,8 +123,6 @@ select count(*) from t1 where c4 = repeat('C', 20000); update t1 set c3 = repeat('E', 20000) where c1 = 1; drop table t1; -set global innodb_file_per_table = on; - set innodb_strict_mode = off; create table t1 (id int primary key) engine = innodb key_block_size = 0; drop table t1; @@ -254,9 +252,7 @@ drop table t7, t8, t9; # restore environment to the state it was before this test execution # --- disable_query_log -eval set global innodb_file_per_table=$per_table; +SET GLOBAL innodb_file_per_table=@save_fpt; SET @@global.innodb_stats_on_metadata=@save_innodb_stats_on_metadata; ---enable_query_log DROP DATABASE mysqltest_innodb_zip; diff --git a/mysql-test/suite/innodb_zip/t/large_blob.test b/mysql-test/suite/innodb_zip/t/large_blob.test index dd208129d0871..d8163737a173c 100644 --- a/mysql-test/suite/innodb_zip/t/large_blob.test +++ b/mysql-test/suite/innodb_zip/t/large_blob.test @@ -7,9 +7,6 @@ --source include/big_test.inc --disable_query_log -# These values can change during the test -let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`; - # Create a 20MB blob that does not compress easily. # 1000 Random characters is enough to keep compression low. set @alphabet="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -27,8 +24,6 @@ while ($1 > 1) set @longblob=repeat(@blob,200000); --enable_query_log -call mtr.add_suppression("InnoDB: Warning: a long semaphore wait"); - SET GLOBAL innodb_file_per_table = OFF; --echo # @@ -123,7 +118,3 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (1, ''); UPDATE t1 SET c2=@longblob; DROP TABLE t1; - ---disable_query_log -EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig; ---enable_query_log diff --git a/mysql-test/suite/innodb_zip/t/restart.test b/mysql-test/suite/innodb_zip/t/restart.test index c442b919d71ad..644496d70d654 100644 --- a/mysql-test/suite/innodb_zip/t/restart.test +++ b/mysql-test/suite/innodb_zip/t/restart.test @@ -34,12 +34,8 @@ call mtr.add_suppression("\\[ERROR\\] InnoDB: The error means the system cannot --disable_query_log let $MYSQL_DATA_DIR= `select @@datadir`; let $data_directory = DATA DIRECTORY='$MYSQL_TMP_DIR/alt_dir'; - -let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; --enable_query_log -set global innodb_file_per_table=on; - --echo # --echo # Create and insert records into a REDUNDANT row formatted table. --echo # @@ -181,7 +177,6 @@ SELECT count(*) FROM t7_restart; --echo # --source include/start_mysqld.inc -SHOW VARIABLES LIKE 'innodb_file_per_table'; SHOW CREATE TABLE t1_restart; SHOW CREATE TABLE t2_restart; SHOW CREATE TABLE t3_restart; @@ -274,8 +269,6 @@ SHOW CREATE TABLE t7_restart; --echo # --source include/start_mysqld.inc -SHOW VARIABLES LIKE 'innodb_file_per_table'; - --source suite/innodb/include/show_i_s_tablespaces.inc SELECT count(*) FROM t5_restart; @@ -364,7 +357,6 @@ SHOW CREATE TABLE t77_restart; --echo # Restart the server --echo # --source include/restart_mysqld.inc -SHOW VARIABLES LIKE 'innodb_file_per_table'; --source suite/innodb/include/show_i_s_tablespaces.inc @@ -599,8 +591,3 @@ DROP TABLE t77_restart; --rmdir $MYSQL_TMP_DIR/alt_dir --rmdir $MYSQL_TMP_DIR/new_dir/test --rmdir $MYSQL_TMP_DIR/new_dir - --- disable_query_log -eval set global innodb_file_per_table=$innodb_file_per_table_orig; --- enable_query_log - diff --git a/mysql-test/suite/innodb_zip/t/wl5522_zip.test b/mysql-test/suite/innodb_zip/t/wl5522_zip.test index dbb698cc545f3..f223d36a6de7b 100644 --- a/mysql-test/suite/innodb_zip/t/wl5522_zip.test +++ b/mysql-test/suite/innodb_zip/t/wl5522_zip.test @@ -83,7 +83,7 @@ ALTER TABLE t1 IMPORT TABLESPACE; SELECT * FROM t1; DROP TABLE t1; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance CREATE TABLE t1( c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2; @@ -127,7 +127,7 @@ SELECT COUNT(*) FROM t1; DROP TABLE t1; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance # Insert some more records to move the LSN forward and then drop the # table and restore CREATE TABLE t1( @@ -174,7 +174,7 @@ SELECT COUNT(*) FROM t1; DROP TABLE t1; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance # Insert some more records to move the LSN forward and then drop the # table and restore, this time the table has a secondary index too. CREATE TABLE t1( @@ -217,7 +217,7 @@ SELECT COUNT(*) FROM t1 WHERE c2 = 1; DROP TABLE t1; -# Export/import on the same instance, with --innodb-file-per-table=1 +# Export/import on the same instance # Insert some more records to move the LSN forward and then drop the # table and restore, this time the table has a secondary index too. # Rename the index on the create so that the IMPORT fails, drop index diff --git a/mysql-test/suite/innodb_zip/t/wl6347_comp_indx_stat.test b/mysql-test/suite/innodb_zip/t/wl6347_comp_indx_stat.test index be9a05b36ce54..ae32b03a78670 100644 --- a/mysql-test/suite/innodb_zip/t/wl6347_comp_indx_stat.test +++ b/mysql-test/suite/innodb_zip/t/wl6347_comp_indx_stat.test @@ -20,7 +20,6 @@ let MYSQLD_DATADIR=`SELECT @@datadir`; let $innodb_compression_level = `SELECT @@global.innodb_compression_level`; --echo # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_cmp_per_index_enabled=ON; SET GLOBAL innodb_compression_level=0; --disable_query_log @@ -73,7 +72,6 @@ SET GLOBAL innodb_read_only_compressed=OFF; --enable_query_log --echo # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=0; --echo # fetch the compressed page and check the stats @@ -135,7 +133,6 @@ SET @inl_val=2; SET GLOBAL innodb_cmp_per_index_enabled=ON; --echo # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=0; --echo # fetch the compressed page and check the stats @@ -296,7 +293,6 @@ SET GLOBAL innodb_cmp_per_index_enabled=0; SET GLOBAL innodb_cmp_per_index_enabled=1; --echo # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=9; @@ -345,7 +341,6 @@ SET @inl_val=2; SET GLOBAL innodb_cmp_per_index_enabled=ON; --echo # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=9; @@ -413,7 +408,6 @@ SET @inl_val=2; SET GLOBAL innodb_cmp_per_index_enabled=ON; --echo # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_compression_level=9; @@ -801,7 +795,6 @@ SET GLOBAL innodb_cmp_per_index_enabled=ON; --echo # check the flags SELECT @@innodb_cmp_per_index_enabled; SELECT @@innodb_compression_failure_threshold_pct; -SELECT @@innodb_file_per_table; SELECT @@innodb_compression_level; --echo #****************************************************************** @@ -848,8 +841,6 @@ SET GLOBAL innodb_cmp_per_index_enabled=ON; --echo # set the flags SET GLOBAL innodb_compression_failure_threshold_pct=0; -SET GLOBAL innodb_file_per_table=on; - --echo # fetch the compressed page and check the stats --echo # The stats figure may be different/same for each restart. @@ -1053,7 +1044,6 @@ SET GLOBAL innodb_cmp_per_index_enabled=OFF; SET GLOBAL innodb_cmp_per_index_enabled=ON; --echo # set the flags -SET GLOBAL innodb_file_per_table=on; SET GLOBAL innodb_cmp_per_index_enabled=ON; SET GLOBAL innodb_compression_failure_threshold_pct=10; SET GLOBAL innodb_compression_level=Default; @@ -1062,7 +1052,6 @@ SET GLOBAL innodb_compression_level=Default; --echo # check the flags SELECT @@innodb_cmp_per_index_enabled; SELECT @@innodb_compression_failure_threshold_pct; -SELECT @@innodb_file_per_table; SELECT @@innodb_compression_level; --echo #****************************************************************** @@ -1109,9 +1098,6 @@ SET GLOBAL innodb_cmp_per_index_enabled=ON; --echo # set the flags SET GLOBAL innodb_compression_failure_threshold_pct=10; -SET GLOBAL innodb_file_per_table=on; -SET GLOBAL innodb_compression_failure_threshold_pct=10; - --echo # fetch the compressed page and check the stats --echo # The stats figure may be different/same for each restart. @@ -1312,7 +1298,6 @@ DROP TABLE tab5; SET GLOBAL innodb_cmp_per_index_enabled=0; SET GLOBAL innodb_cmp_per_index_enabled=1; -SET GLOBAL innodb_file_per_table=ON; SET GLOBAL innodb_compression_level=default; SET GLOBAL innodb_compression_failure_threshold_pct=default; @@ -1351,7 +1336,6 @@ DROP TABLE tab5, test.tab5; DROP DATABASE sb; --echo # reset the flags -eval SET GLOBAL innodb_file_per_table=default; eval SET GLOBAL innodb_cmp_per_index_enabled=default; --disable_query_log eval SET GLOBAL innodb_compression_level=$innodb_compression_level; diff --git a/mysql-test/suite/mariabackup/mdev-14447.result b/mysql-test/suite/mariabackup/mdev-14447.result index 16d3ab561f6ee..5db4693d75fb2 100644 --- a/mysql-test/suite/mariabackup/mdev-14447.result +++ b/mysql-test/suite/mariabackup/mdev-14447.result @@ -1,5 +1,7 @@ call mtr.add_suppression("InnoDB: New log files created"); SET GLOBAL innodb_file_per_table=0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t(a varchar(40) PRIMARY KEY, b varchar(40), c varchar(40), d varchar(40), index(b,c,d)) ENGINE INNODB; # Create full backup , modify table, then create incremental/differential backup SET debug_dbug='+d,skip_page_checksum',foreign_key_checks=0,unique_checks=0; diff --git a/mysql-test/suite/mariabackup/xb_compressed_encrypted.opt b/mysql-test/suite/mariabackup/xb_compressed_encrypted.opt index 4105fecfe5852..52ef47f3fca12 100644 --- a/mysql-test/suite/mariabackup/xb_compressed_encrypted.opt +++ b/mysql-test/suite/mariabackup/xb_compressed_encrypted.opt @@ -5,4 +5,3 @@ --loose-file-key-management --loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/logkey.txt --innodb_strict_mode ---innodb_file_per_table diff --git a/mysql-test/suite/mariabackup/xb_fulltext_encrypted.opt b/mysql-test/suite/mariabackup/xb_fulltext_encrypted.opt index b3ef366361ade..e3a9e5a437f11 100644 --- a/mysql-test/suite/mariabackup/xb_fulltext_encrypted.opt +++ b/mysql-test/suite/mariabackup/xb_fulltext_encrypted.opt @@ -1,6 +1,5 @@ --plugin-load-add=$FILE_KEY_MANAGEMENT_SO --innodb_strict_mode ---innodb_file_per_table --innodb-encryption-rotate-key-age=2 --innodb-encryption-threads=4 --innodb-tablespaces-encryption diff --git a/mysql-test/suite/parts/r/alter_data_directory_innodb.result b/mysql-test/suite/parts/r/alter_data_directory_innodb.result index 8c07093f12728..e8f976372d6d5 100644 --- a/mysql-test/suite/parts/r/alter_data_directory_innodb.result +++ b/mysql-test/suite/parts/r/alter_data_directory_innodb.result @@ -40,6 +40,8 @@ t CREATE TABLE `t` ( PARTITION `p2` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) SET @TMP = @@GLOBAL.INNODB_FILE_PER_TABLE; SET GLOBAL INNODB_FILE_PER_TABLE=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE; Warnings: Warning 1280 Name 'pk' ignored for PRIMARY key. @@ -53,6 +55,8 @@ t CREATE TABLE `t` ( (PARTITION `p1` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, PARTITION `p2` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) SET GLOBAL INNODB_FILE_PER_TABLE=@TMP; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO ( PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB, PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB diff --git a/mysql-test/suite/parts/r/longname.result b/mysql-test/suite/parts/r/longname.result index eb850d6f16c4d..8524eb8499d54 100644 --- a/mysql-test/suite/parts/r/longname.result +++ b/mysql-test/suite/parts/r/longname.result @@ -31,6 +31,8 @@ PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB); ERROR HY000: The path specified for @0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@... is too long SET @file_per_table=@@GLOBAL.innodb_file_per_table; SET GLOBAL innodb_file_per_table=0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE mysqltest1.t1 (a INT) ENGINE=INNODB PARTITION BY RANGE (a) SUBPARTITION BY HASH(a) (PARTITION `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$` @@ -41,6 +43,8 @@ SUBPARTITION `0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef`) ); SET GLOBAL innodb_file_per_table=@file_per_table; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SHOW CREATE TABLE mysqltest1.t1; Table Create Table t1 CREATE TABLE `t1` ( 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 9d05d04cccade..6d361bb14655c 100644 --- a/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result +++ b/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result @@ -8,6 +8,8 @@ SET SESSION innodb_strict_mode = ON; # InnoDB only supports DATA DIRECTORY with innodb_file_per_table=ON # SET GLOBAL innodb_file_per_table = OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1 (c1 INT) ENGINE = InnoDB PARTITION BY HASH (c1) ( PARTITION p0 @@ -36,6 +38,8 @@ Error 6 Error on delete of 'MYSQLD_DATADIR/test/t1.par' (Errcode: 2 "No such fil # SET SESSION innodb_strict_mode = OFF; SET GLOBAL innodb_file_per_table = ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1 (c1 INT) ENGINE = InnoDB PARTITION BY HASH (c1) (PARTITION p0 @@ -134,6 +138,8 @@ DROP TABLE t1; # properly when used with DATA DIRECTORY # SET GLOBAL innodb_file_per_table = ON; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release CREATE TABLE t1 ( myid INT(11) NOT NULL, @@ -326,4 +332,6 @@ DROP TABLE t1, t2; # Cleanup # SET GLOBAL innodb_file_per_table=@file_per_table; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SET SESSION innodb_strict_mode=@strict_mode; diff --git a/mysql-test/suite/parts/r/reorganize_partition_innodb.result b/mysql-test/suite/parts/r/reorganize_partition_innodb.result index b56cb6bbaeb2e..b22337812199d 100644 --- a/mysql-test/suite/parts/r/reorganize_partition_innodb.result +++ b/mysql-test/suite/parts/r/reorganize_partition_innodb.result @@ -40,6 +40,8 @@ t CREATE TABLE `t` ( PARTITION `p2` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) SET @TMP = @@GLOBAL.INNODB_FILE_PER_TABLE; SET GLOBAL INNODB_FILE_PER_TABLE=OFF; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE; Warnings: Warning 1280 Name 'pk' ignored for PRIMARY key. @@ -53,6 +55,8 @@ t CREATE TABLE `t` ( (PARTITION `p1` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, PARTITION `p2` DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) SET GLOBAL INNODB_FILE_PER_TABLE=@TMP; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO ( PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB, PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB diff --git a/mysql-test/suite/parts/t/debug_innodb_crash-master.opt b/mysql-test/suite/parts/t/debug_innodb_crash-master.opt index b7f94e14e12c0..d8813652cd63a 100644 --- a/mysql-test/suite/parts/t/debug_innodb_crash-master.opt +++ b/mysql-test/suite/parts/t/debug_innodb_crash-master.opt @@ -1 +1 @@ ---loose-innodb-file-per-table=1 --loose-skip-stack-trace --skip-core-file --loose-innodb-buffer-pool-size=32M +--loose-skip-stack-trace --skip-core-file --loose-innodb-buffer-pool-size=32M diff --git a/mysql-test/suite/parts/t/partition_debug_sync_innodb-master.opt b/mysql-test/suite/parts/t/partition_debug_sync_innodb-master.opt deleted file mode 100644 index 115a0ba2cc8db..0000000000000 --- a/mysql-test/suite/parts/t/partition_debug_sync_innodb-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb_file_per_table diff --git a/mysql-test/suite/sys_vars/r/innodb_file_per_table_basic.result b/mysql-test/suite/sys_vars/r/innodb_file_per_table_basic.result index 9780357e69ff1..9d7555335a7e0 100644 --- a/mysql-test/suite/sys_vars/r/innodb_file_per_table_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_file_per_table_basic.result @@ -9,18 +9,26 @@ COUNT(@@GLOBAL.innodb_file_per_table) 1 Expected '#---------------------BS_STVARS_028_02----------------------#' SET @@global.innodb_file_per_table = 0; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SELECT @@global.innodb_file_per_table; @@global.innodb_file_per_table 0 SET @@global.innodb_file_per_table ='On' ; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SELECT @@global.innodb_file_per_table; @@global.innodb_file_per_table 1 SET @@global.innodb_file_per_table ='Off' ; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SELECT @@global.innodb_file_per_table; @@global.innodb_file_per_table 0 SET @@global.innodb_file_per_table = 1; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SELECT @@global.innodb_file_per_table; @@global.innodb_file_per_table 1 @@ -64,6 +72,8 @@ COUNT(@@GLOBAL.innodb_file_per_table) SELECT innodb_file_per_table = @@SESSION.innodb_file_per_table; ERROR 42S22: Unknown column 'innodb_file_per_table' in 'field list' SET @@global.innodb_file_per_table = @start_global_value; +Warnings: +Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release SELECT @@global.innodb_file_per_table; @@global.innodb_file_per_table 1 diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 08f55baf1d383..86fc747faedec 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -18846,7 +18846,7 @@ static MYSQL_SYSVAR_UINT(fast_shutdown, srv_fast_shutdown, fast_shutdown_validate, NULL, 1, 0, 3, 0); static MYSQL_SYSVAR_BOOL(file_per_table, srv_file_per_table, - PLUGIN_VAR_NOCMDARG, + PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_DEPRECATED, "Stores each InnoDB table to an .ibd file in the database dir.", NULL, NULL, TRUE); From 24648768b443f6adeb8a0f4302958bfb300d536f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 14 Dec 2022 14:43:32 +0200 Subject: [PATCH 108/113] MDEV-30136: Deprecate innodb_flush_method We introduce the following settable Boolean global variables: innodb_log_file_write_through: Whether writes to ib_logfile0 are write-through (disabling any caching, as in O_SYNC or O_DSYNC). innodb_data_file_write_through: Whether writes to any InnoDB data files (including the temporary tablespace) are write-through. innodb_data_file_buffering: Whether the file system cache is enabled for InnoDB data files. All these parameters are OFF by default, that is, the file system cache will be disabled, but any hardware caching is enabled, that is, explicit calls to fsync(), fdatasync() or similar functions are needed. On systems that support FUA it may make sense to enable write-through, to avoid extra system calls. If the deprecated read-only start-up parameter is set to one of the following values, then the values of the 4 Boolean flags (the above 3 plus innodb_log_file_buffering) will be set as follows: O_DSYNC: innodb_log_file_write_through=ON, innodb_data_file_write_through=ON, innodb_data_file_buffering=OFF, and (if supported) innodb_log_file_buffering=OFF. fsync, littlesync, nosync, or (Microsoft Windows specific) normal: innodb_log_file_write_through=OFF, innodb_data_file_write_through=OFF, and innodb_data_file_buffering=ON. Note: fsync() or fdatasync() will only be disabled if the separate parameter debug_no_sync (in the code, my_disable_sync) is set. In mariadb-backup, the parameter innodb_flush_method will be ignored. The Boolean parameters can be modified by SET GLOBAL while the server is running. This will require reopening the ib_logfile0 or all currently open InnoDB data files. We will open files straight in O_DSYNC or O_SYNC mode when applicable. Data files we will try to open straight in O_DIRECT mode when the page size is at least 4096 bytes. For atomically creating data files, we will invoke os_file_set_nocache() to enable O_DIRECT afterwards, because O_DIRECT is not supported on some file systems. We will also continue to invoke os_file_set_nocache() on ib_logfile0 when innodb_log_file_buffering=OFF can be fulfilled. For reopening the ib_logfile0, we use the same logic that was developed for online log resizing and reused for updates of innodb_log_file_buffering. Reopening all data files is implemented in the new function fil_space_t::reopen_all(). Reviewed by: Vladislav Vaintroub Tested by: Matthias Leich --- extra/mariabackup/fil_cur.cc | 6 - extra/mariabackup/xtrabackup.cc | 26 ++- mysql-test/lib/My/Debugger.pm | 2 +- .../suite/sys_vars/r/sysvars_innodb.result | 36 ++++ storage/innobase/buf/buf0flu.cc | 20 +- storage/innobase/fil/fil0fil.cc | 139 ++++++++++-- storage/innobase/handler/ha_innodb.cc | 115 ++++++---- storage/innobase/include/fil0fil.h | 52 ++--- storage/innobase/include/log0log.h | 4 + storage/innobase/log/log0log.cc | 27 ++- storage/innobase/os/os0file.cc | 198 +++++++----------- storage/innobase/srv/srv0srv.cc | 3 - storage/innobase/trx/trx0trx.cc | 2 +- 13 files changed, 379 insertions(+), 251 deletions(-) diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index e0a4711a2aac5..2932fa6d5a630 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -199,12 +199,6 @@ xb_fil_cur_open( return(XB_FIL_CUR_SKIP); } - if (srv_file_flush_method == SRV_O_DIRECT - || srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC) { - - os_file_set_nocache(cursor->file, node->name, "OPEN"); - } - posix_fadvise(cursor->file, 0, 0, POSIX_FADV_SEQUENTIAL); cursor->page_size = node->space->physical_size(); diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 67560ec03aa02..27bb10bf82e24 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -311,6 +311,8 @@ extern const char *innodb_checksum_algorithm_names[]; extern TYPELIB innodb_checksum_algorithm_typelib; extern const char *innodb_flush_method_names[]; extern TYPELIB innodb_flush_method_typelib; +/** Ignored option */ +static ulong innodb_flush_method; static const char *binlog_info_values[] = {"off", "lockless", "on", "auto", NullS}; @@ -1032,6 +1034,8 @@ enum options_xtrabackup #if defined __linux__ || defined _WIN32 OPT_INNODB_LOG_FILE_BUFFERING, #endif + OPT_INNODB_DATA_FILE_BUFFERING, + OPT_INNODB_DATA_FILE_WRITE_THROUGH, OPT_INNODB_LOG_FILE_SIZE, OPT_INNODB_OPEN_FILES, OPT_XTRA_DEBUG_SYNC, @@ -1583,10 +1587,10 @@ struct my_option xb_server_options[] = FALSE, 0, 0, 0, 0, 0}, {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD, - "With which method to flush data.", - &srv_file_flush_method, &srv_file_flush_method, + "Ignored parameter with no effect", + &innodb_flush_method, &innodb_flush_method, &innodb_flush_method_typelib, GET_ENUM, REQUIRED_ARG, - IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_O_DIRECT), 0, 0, 0, 0, 0}, + 4/* O_DIRECT */, 0, 0, 0, 0, 0}, {"innodb_log_buffer_size", OPT_INNODB_LOG_BUFFER_SIZE, "Redo log buffer size in bytes.", @@ -1600,6 +1604,16 @@ struct my_option xb_server_options[] = (G_PTR*) &log_sys.log_buffered, 0, GET_BOOL, NO_ARG, TRUE, 0, 0, 0, 0, 0}, #endif + {"innodb_data_file_buffering", OPT_INNODB_DATA_FILE_BUFFERING, + "Whether the file system cache for data files is enabled during --backup", + (G_PTR*) &fil_system.buffered, + (G_PTR*) &fil_system.buffered, 0, GET_BOOL, NO_ARG, + FALSE, 0, 0, 0, 0, 0}, + {"innodb_data_file_write_through", OPT_INNODB_DATA_FILE_WRITE_THROUGH, + "Whether each write to data files writes through", + (G_PTR*) &fil_system.write_through, + (G_PTR*) &fil_system.write_through, 0, GET_BOOL, NO_ARG, + FALSE, 0, 0, 0, 0, 0}, {"innodb_log_file_size", OPT_INNODB_LOG_FILE_SIZE, "Ignored for mysqld option compatibility", (G_PTR*) &srv_log_file_size, (G_PTR*) &srv_log_file_size, 0, @@ -1917,12 +1931,6 @@ xb_get_one_option(const struct my_option *opt, ADD_PRINT_PARAM_OPT(srv_log_group_home_dir); break; - case OPT_INNODB_FLUSH_METHOD: - ut_a(srv_file_flush_method - <= IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_O_DIRECT_NO_FSYNC)); - ADD_PRINT_PARAM_OPT(innodb_flush_method_names[srv_file_flush_method]); - break; - case OPT_INNODB_PAGE_SIZE: ADD_PRINT_PARAM_OPT(innobase_page_size); diff --git a/mysql-test/lib/My/Debugger.pm b/mysql-test/lib/My/Debugger.pm index c2062c2eaba13..412c028cfc52c 100644 --- a/mysql-test/lib/My/Debugger.pm +++ b/mysql-test/lib/My/Debugger.pm @@ -78,7 +78,7 @@ my %debuggers = ( options => '-f -o {log} {exe} {args}', }, rr => { - options => '_RR_TRACE_DIR={log} rr record {exe} {args} --loose-skip-innodb-use-native-aio --loose-innodb-flush-method=fsync', + options => '_RR_TRACE_DIR={log} rr record {exe} {args}', run => 'env', pre => sub { ::mtr_error('rr requires kernel.perf_event_paranoid <= 1') diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 6eface8c09769..998d82587b6a0 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -355,6 +355,18 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_DATA_FILE_BUFFERING +SESSION_VALUE NULL +DEFAULT_VALUE OFF +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Whether the file system cache for data files is enabled +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_DATA_FILE_PATH SESSION_VALUE NULL DEFAULT_VALUE ibdata1:12M:autoextend @@ -379,6 +391,18 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME INNODB_DATA_FILE_WRITE_THROUGH +SESSION_VALUE NULL +DEFAULT_VALUE OFF +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Whether each write to data files writes through +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_DATA_HOME_DIR SESSION_VALUE NULL DEFAULT_VALUE @@ -1015,6 +1039,18 @@ NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME INNODB_LOG_FILE_WRITE_THROUGH +SESSION_VALUE NULL +DEFAULT_VALUE OFF +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Whether each write to ib_logfile0 is write through +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_GROUP_HOME_DIR SESSION_VALUE NULL DEFAULT_VALUE diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 6bf03d3e72a48..d71cbfbf7435d 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1724,7 +1724,7 @@ inline void log_t::write_checkpoint(lsn_t end_lsn) noexcept resize_log.write(CHECKPOINT_1, {c, get_block_size()}); } - if (srv_file_flush_method != SRV_O_DSYNC) + if (!log_write_through) ut_a(log.flush()); latch.wr_lock(SRW_LOCK_CALL); ut_ad(checkpoint_pending); @@ -1756,7 +1756,7 @@ inline void log_t::write_checkpoint(lsn_t end_lsn) noexcept if (!is_pmem()) { - if (srv_file_flush_method != SRV_O_DSYNC) + if (!log_write_through) ut_a(resize_log.flush()); IF_WIN(log.close(),); } @@ -1902,13 +1902,7 @@ static bool log_checkpoint() if (recv_recovery_is_on()) recv_sys.apply(true); - switch (srv_file_flush_method) { - case SRV_NOSYNC: - case SRV_O_DIRECT_NO_FSYNC: - break; - default: - fil_flush_file_spaces(); - } + fil_flush_file_spaces(); log_sys.latch.wr_lock(SRW_LOCK_CALL); const lsn_t end_lsn= log_sys.get_lsn(); @@ -2060,13 +2054,7 @@ ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn) MONITOR_FLUSH_SYNC_PAGES, n_flushed); } - switch (srv_file_flush_method) { - case SRV_NOSYNC: - case SRV_O_DIRECT_NO_FSYNC: - break; - default: - fil_flush_file_spaces(); - } + fil_flush_file_spaces(); log_sys.latch.wr_lock(SRW_LOCK_CALL); const lsn_t newest_lsn= log_sys.get_lsn(); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 481a2dbce5318..cecda94cac476 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -499,6 +499,9 @@ void fil_space_t::flush_low() break; } + if (fil_system.is_write_through()) + goto skip_flush; + fil_n_pending_tablespace_flushes++; for (fil_node_t *node= UT_LIST_GET_FIRST(chain); node; node= UT_LIST_GET_NEXT(chain, node)) @@ -523,8 +526,9 @@ void fil_space_t::flush_low() mysql_mutex_unlock(&fil_system.mutex); } - clear_flush(); fil_n_pending_tablespace_flushes--; +skip_flush: + clear_flush(); } /** Try to extend a tablespace. @@ -753,7 +757,6 @@ inline pfs_os_file_t fil_node_t::close_to_free(bool detach_handle) { if (space->is_in_unflushed_spaces) { - ut_ad(srv_file_flush_method != SRV_O_DIRECT_NO_FSYNC); space->is_in_unflushed_spaces= false; fil_system.unflushed_spaces.remove(*space); } @@ -786,7 +789,6 @@ pfs_os_file_t fil_system_t::detach(fil_space_t *space, bool detach_handle) if (space->is_in_unflushed_spaces) { - ut_ad(srv_file_flush_method != SRV_O_DIRECT_NO_FSYNC); space->is_in_unflushed_spaces= false; unflushed_spaces.remove(*space); } @@ -1320,6 +1322,120 @@ ATTRIBUTE_COLD void fil_system_t::extend_to_recv_size() mysql_mutex_unlock(&mutex); } +ATTRIBUTE_COLD void fil_space_t::reopen_all() +{ + mysql_mutex_assert_owner(&fil_system.mutex); + fil_system.freeze_space_list++; + + for (fil_space_t &space : fil_system.space_list) + { + for (fil_node_t *node= UT_LIST_GET_FIRST(space.chain); node; + node= UT_LIST_GET_NEXT(chain, node)) + if (node->is_open()) + goto need_to_close; + continue; + + need_to_close: + uint32_t p= space.n_pending.fetch_or(CLOSING, std::memory_order_acquire); + if (p & (STOPPING | CLOSING)) + continue; + + for (fil_node_t *node= UT_LIST_GET_FIRST(space.chain); node; + node= UT_LIST_GET_NEXT(chain, node)) + { + if (!node->is_open()) + continue; + + ulint type= OS_DATA_FILE; + + switch (FSP_FLAGS_GET_ZIP_SSIZE(space.flags)) { + case 1: case 2: + type= OS_DATA_FILE_NO_O_DIRECT; + } + + for (ulint count= 10000; count--;) + { + p= space.pending(); + + if (!(p & CLOSING) || (p & STOPPING)) + break; + + if (!(p & PENDING) && !node->being_extended) + { + space.reacquire(); + mysql_mutex_unlock(&fil_system.mutex); + /* Unconditionally flush the file, because + fil_system.write_through was updated prematurely, + potentially causing some flushes to be lost. */ + os_file_flush(node->handle); + mysql_mutex_lock(&fil_system.mutex); + p= space.n_pending.fetch_sub(1, std::memory_order_relaxed) - 1; + + if (!(p & CLOSING) || (p & STOPPING)) + break; + + if (!(p & PENDING) && !node->being_extended) + { + ut_a(os_file_close(node->handle)); + bool success; + node->handle= os_file_create(innodb_data_file_key, node->name, + node->is_raw_disk + ? OS_FILE_OPEN_RAW : OS_FILE_OPEN, + OS_FILE_AIO, type, + srv_read_only_mode, &success); + ut_a(success); + goto next_file; + } + } + + space.reacquire(); + mysql_mutex_unlock(&fil_system.mutex); + std::this_thread::sleep_for(std::chrono::microseconds(100)); + mysql_mutex_lock(&fil_system.mutex); + space.release(); + + if (!node->is_open()) + goto next_file; + } + + if (!(p & CLOSING) || (p & STOPPING)) + next_file: + continue; + + sql_print_error("InnoDB: Failed to reopen file '%s' due to " UINT32PF + " operations", node->name, p & PENDING); + } + } + + fil_system.freeze_space_list--; +} + +void fil_system_t::set_write_through(bool write_through) +{ + mysql_mutex_lock(&mutex); + + if (write_through != this->write_through) + { + this->write_through= write_through; + fil_space_t::reopen_all(); + } + + mysql_mutex_unlock(&mutex); +} + +void fil_system_t::set_buffered(bool buffered) +{ + mysql_mutex_lock(&mutex); + + if (buffered != this->buffered) + { + this->buffered= buffered; + fil_space_t::reopen_all(); + } + + mysql_mutex_unlock(&mutex); +} + /** Close all tablespace files at shutdown */ void fil_space_t::close_all() { @@ -1340,12 +1456,9 @@ void fil_space_t::close_all() for (fil_node_t *node= UT_LIST_GET_FIRST(space.chain); node != NULL; node= UT_LIST_GET_NEXT(chain, node)) { - if (!node->is_open()) - { next: continue; - } for (ulint count= 10000; count--;) { @@ -1361,8 +1474,8 @@ void fil_space_t::close_all() goto next; } - ib::error() << "File '" << node->name << "' has " << space.referenced() - << " operations"; + sql_print_error("InnoDB: File '%s' has " UINT32PF " operations", + node->name, space.referenced()); } fil_system.detach(&space); @@ -2598,7 +2711,7 @@ inline void fil_node_t::complete_write() mysql_mutex_assert_not_owner(&fil_system.mutex); if (space->purpose != FIL_TYPE_TEMPORARY && - srv_file_flush_method != SRV_O_DIRECT_NO_FSYNC && + (!fil_system.is_write_through() && !my_disable_sync) && space->set_needs_flush()) { mysql_mutex_lock(&fil_system.mutex); @@ -2774,14 +2887,6 @@ void fil_aio_callback(const IORequest &request) possibly cached by the OS. */ void fil_flush_file_spaces() { - if (srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC) - { - ut_d(mysql_mutex_lock(&fil_system.mutex)); - ut_ad(fil_system.unflushed_spaces.empty()); - ut_d(mysql_mutex_unlock(&fil_system.mutex)); - return; - } - rescan: mysql_mutex_lock(&fil_system.mutex); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 86fc747faedec..a51e30e28ced8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -366,6 +366,8 @@ const char* innodb_flush_method_names[] = { NullS }; +static constexpr ulong innodb_flush_method_default = IF_WIN(6,4); + /** Enumeration of innodb_flush_method */ TYPELIB innodb_flush_method_typelib = { array_elements(innodb_flush_method_names) - 1, @@ -374,6 +376,9 @@ TYPELIB innodb_flush_method_typelib = { NULL }; +/** Deprecated parameter */ +static ulong innodb_flush_method; + /** Names of allowed values of innodb_deadlock_report */ static const char *innodb_deadlock_report_names[]= { "off", /* Do not report any details of deadlocks */ @@ -4005,22 +4010,27 @@ static int innodb_init_params() data_mysql_default_charset_coll = (ulint) default_charset_info->number; + if (innodb_flush_method == 1 /* O_DSYNC */) { + log_sys.log_write_through = true; + fil_system.write_through = true; + fil_system.buffered = false; +#if defined __linux__ || defined _WIN32 + log_sys.log_buffered = false; + goto skip_buffering_tweak; +#endif + } else if (innodb_flush_method >= 4 /* O_DIRECT */ + IF_WIN(&& innodb_flush_method < 8 /* normal */,)) { + /* O_DIRECT and similar settings do nothing */ #ifndef _WIN32 - if (srv_use_atomic_writes && my_may_have_atomic_write) { - /* - Force O_DIRECT on Unixes (on Windows writes are always - unbuffered) - */ - switch (srv_file_flush_method) { - case SRV_O_DIRECT: - case SRV_O_DIRECT_NO_FSYNC: - break; - default: - srv_file_flush_method = SRV_O_DIRECT; - fprintf(stderr, "InnoDB: using O_DIRECT due to atomic writes.\n"); - } - } + } else if (srv_use_atomic_writes && my_may_have_atomic_write) { + /* If atomic writes are enabled, do the same as with + innodb_flush_method=O_DIRECT: retain the default settings */ #endif + } else { + log_sys.log_write_through = false; + fil_system.write_through = false; + fil_system.buffered = true; + } #if defined __linux__ || defined _WIN32 if (srv_flush_log_at_trx_commit == 2) { @@ -4028,6 +4038,7 @@ static int innodb_init_params() innodb_flush_log_at_trx_commit=2. */ log_sys.log_buffered = true; } +skip_buffering_tweak: #endif if (srv_read_only_mode) { @@ -4035,12 +4046,6 @@ static int innodb_init_params() srv_use_doublewrite_buf = FALSE; } -#if !defined LINUX_NATIVE_AIO && !defined HAVE_URING && !defined _WIN32 - /* Currently native AIO is supported only on windows and linux - and that also when the support is compiled in. In all other - cases, we ignore the setting of innodb_use_native_aio. */ - srv_use_native_aio = FALSE; -#endif #ifdef HAVE_URING if (srv_use_native_aio && io_uring_may_be_unsafe) { sql_print_warning("innodb_use_native_aio may cause " @@ -4048,22 +4053,13 @@ static int innodb_init_params() "https://jira.mariadb.org/browse/MDEV-26674", io_uring_may_be_unsafe); } +#elif !defined LINUX_NATIVE_AIO && !defined _WIN32 + /* Currently native AIO is supported only on windows and linux + and that also when the support is compiled in. In all other + cases, we ignore the setting of innodb_use_native_aio. */ + srv_use_native_aio = FALSE; #endif -#ifndef _WIN32 - ut_ad(srv_file_flush_method <= SRV_O_DIRECT_NO_FSYNC); -#else - switch (srv_file_flush_method) { - case SRV_ALL_O_DIRECT_FSYNC + 1 /* "async_unbuffered"="unbuffered" */: - srv_file_flush_method = SRV_ALL_O_DIRECT_FSYNC; - break; - case SRV_ALL_O_DIRECT_FSYNC + 2 /* "normal"="fsync" */: - srv_file_flush_method = SRV_FSYNC; - break; - default: - ut_ad(srv_file_flush_method <= SRV_ALL_O_DIRECT_FSYNC); - } -#endif innodb_buffer_pool_size_init(); srv_lock_table_size = 5 * (srv_buf_pool_size >> srv_page_size_shift); @@ -18409,7 +18405,7 @@ buffer_pool_load_abort( } #if defined __linux__ || defined _WIN32 -static void innodb_log_file_buffering_update(THD *thd, st_mysql_sys_var*, +static void innodb_log_file_buffering_update(THD *, st_mysql_sys_var*, void *, const void *save) { mysql_mutex_unlock(&LOCK_global_system_variables); @@ -18418,6 +18414,30 @@ static void innodb_log_file_buffering_update(THD *thd, st_mysql_sys_var*, } #endif +static void innodb_log_file_write_through_update(THD *, st_mysql_sys_var*, + void *, const void *save) +{ + mysql_mutex_unlock(&LOCK_global_system_variables); + log_sys.set_write_through(*static_cast(save)); + mysql_mutex_lock(&LOCK_global_system_variables); +} + +static void innodb_data_file_buffering_update(THD *, st_mysql_sys_var*, + void *, const void *save) +{ + mysql_mutex_unlock(&LOCK_global_system_variables); + fil_system.set_buffered(*static_cast(save)); + mysql_mutex_lock(&LOCK_global_system_variables); +} + +static void innodb_data_file_write_through_update(THD *, st_mysql_sys_var*, + void *, const void *save) +{ + mysql_mutex_unlock(&LOCK_global_system_variables); + fil_system.set_write_through(*static_cast(save)); + mysql_mutex_lock(&LOCK_global_system_variables); +} + static void innodb_log_file_size_update(THD *thd, st_mysql_sys_var*, void *var, const void *save) { @@ -18876,11 +18896,10 @@ static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit, " guarantees in case of crash. 0 and 2 can be faster than 1 or 3.", NULL, NULL, 1, 0, 3, 0); -static MYSQL_SYSVAR_ENUM(flush_method, srv_file_flush_method, - PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, +static MYSQL_SYSVAR_ENUM(flush_method, innodb_flush_method, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY | PLUGIN_VAR_DEPRECATED, "With which method to flush data.", - NULL, NULL, IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_O_DIRECT), - &innodb_flush_method_typelib); + NULL, NULL, innodb_flush_method_default, &innodb_flush_method_typelib); static MYSQL_SYSVAR_STR(log_group_home_dir, srv_log_group_home_dir, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, @@ -19312,6 +19331,21 @@ static MYSQL_SYSVAR_BOOL(log_file_buffering, log_sys.log_buffered, nullptr, innodb_log_file_buffering_update, FALSE); #endif +static MYSQL_SYSVAR_BOOL(log_file_write_through, log_sys.log_write_through, + PLUGIN_VAR_OPCMDARG, + "Whether each write to ib_logfile0 is write through", + nullptr, innodb_log_file_write_through_update, FALSE); + +static MYSQL_SYSVAR_BOOL(data_file_buffering, fil_system.buffered, + PLUGIN_VAR_OPCMDARG, + "Whether the file system cache for data files is enabled", + nullptr, innodb_data_file_buffering_update, FALSE); + +static MYSQL_SYSVAR_BOOL(data_file_write_through, fil_system.write_through, + PLUGIN_VAR_OPCMDARG, + "Whether each write to data files writes through", + nullptr, innodb_data_file_write_through_update, FALSE); + static MYSQL_SYSVAR_ULONGLONG(log_file_size, srv_log_file_size, PLUGIN_VAR_RQCMDARG, "Redo log size in bytes.", @@ -19756,6 +19790,9 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { #if defined __linux__ || defined _WIN32 MYSQL_SYSVAR(log_file_buffering), #endif + MYSQL_SYSVAR(log_file_write_through), + MYSQL_SYSVAR(data_file_buffering), + MYSQL_SYSVAR(data_file_write_through), MYSQL_SYSVAR(log_file_size), MYSQL_SYSVAR(log_group_home_dir), MYSQL_SYSVAR(max_dirty_pages_pct), diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 940e1b6845850..210f365ddd826 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -51,35 +51,6 @@ using space_list_t= ilist; // Forward declaration extern my_bool srv_use_doublewrite_buf; -/** Possible values of innodb_flush_method */ -enum srv_flush_t -{ - /** fsync, the default */ - SRV_FSYNC= 0, - /** open log files in O_DSYNC mode */ - SRV_O_DSYNC, - /** do not call os_file_flush() when writing data files, but do flush - after writing to log files */ - SRV_LITTLESYNC, - /** do not flush after writing */ - SRV_NOSYNC, - /** invoke os_file_set_nocache() on data files. This implies using - unbuffered I/O but still fdatasync(), because some filesystems might - not flush meta-data on write completion */ - SRV_O_DIRECT, - /** Like O_DIRECT, but skip fdatasync(), assuming that the data is - durable on write completion */ - SRV_O_DIRECT_NO_FSYNC -#ifdef _WIN32 - /** Traditional Windows appoach to open all files without caching, - and do FileFlushBuffers() */ - ,SRV_ALL_O_DIRECT_FSYNC -#endif -}; - -/** innodb_flush_method */ -extern ulong srv_file_flush_method; - /** Undo tablespaces starts with space_id. */ extern uint32_t srv_undo_space_id_start; /** The number of UNDO tablespaces that are open and ready to use. */ @@ -631,6 +602,8 @@ struct fil_space_t final } public: + /** Reopen all files on set_write_through() or set_buffered(). */ + static void reopen_all(); /** Try to close a file to adhere to the innodb_open_files limit. @param print_info whether to diagnose why a file cannot be closed @return whether a file was closed */ @@ -1414,6 +1387,20 @@ struct fil_system_t fil_space_t* temp_space; /*!< The innodb_temporary tablespace */ /** Map of fil_space_t::id to fil_space_t* */ hash_table_t spaces; + + /** whether each write to data files is durable (O_DSYNC) */ + my_bool write_through; + /** whether data files are buffered (not O_DIRECT) */ + my_bool buffered; + + /** Try to enable or disable write-through of data files */ + void set_write_through(bool write_through); + /** Try to enable or disable file system caching of data files */ + void set_buffered(bool buffered); + + TPOOL_SUPPRESS_TSAN bool is_write_through() const { return write_through; } + TPOOL_SUPPRESS_TSAN bool is_buffered() const { return buffered; } + /** tablespaces for which fil_space_t::needs_flush() holds */ sized_ilist unflushed_spaces; /** number of currently open files; protected by mutex */ @@ -1527,12 +1514,7 @@ template inline void fil_space_t::flush() mysql_mutex_assert_not_owner(&fil_system.mutex); ut_ad(!have_reference || (pending() & PENDING)); ut_ad(purpose == FIL_TYPE_TABLESPACE || purpose == FIL_TYPE_IMPORT); - if (srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC) - { - ut_ad(!is_in_unflushed_spaces); - ut_ad(!needs_flush()); - } - else if (have_reference) + if (have_reference) flush_low(); else { diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 09e4ece88943c..8afa92abc93ca 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -275,6 +275,8 @@ typedef srw_lock log_rwlock_t; bool log_maybe_unbuffered; # endif #endif + /** whether each write to ib_logfile0 is durable (O_DSYNC) */ + my_bool log_write_through; /** Fields involved in checkpoints @{ */ lsn_t log_capacity; /*!< capacity of the log; if @@ -362,6 +364,8 @@ typedef srw_lock log_rwlock_t; /** Try to enable or disable file system caching (update log_buffered) */ void set_buffered(bool buffered); #endif + /** Try to enable or disable durable writes (update log_write_through) */ + void set_write_through(bool write_through); void attach(log_file_t file, os_offset_t size); diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 2804143721c12..4e9ed1263f6a7 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -401,6 +401,31 @@ void log_t::set_buffered(bool buffered) } #endif + /** Try to enable or disable durable writes (update log_write_through) */ +void log_t::set_write_through(bool write_through) +{ + if (is_pmem() || high_level_read_only) + return; + log_resize_acquire(); + if (!resize_in_progress() && is_opened() && + bool(log_write_through) != write_through) + { + os_file_close_func(log.m_file); + log.m_file= OS_FILE_CLOSED; + std::string path{get_log_file_path()}; + log_write_through= write_through; + bool success; + log.m_file= os_file_create_func(path.c_str(), + OS_FILE_OPEN, OS_FILE_NORMAL, OS_LOG_FILE, + false, &success); + ut_a(log.m_file != OS_FILE_CLOSED); + sql_print_information(log_write_through + ? "InnoDB: Log writes write through" + : "InnoDB: Log writes may be cached"); + } + log_resize_release(); +} + /** Start resizing the log and release the exclusive latch. @param size requested new file_size @return whether the resizing was started successfully */ @@ -852,7 +877,7 @@ bool log_t::flush(lsn_t lsn) noexcept { ut_ad(lsn >= get_flushed_lsn()); flush_lock.set_pending(lsn); - const bool success{srv_file_flush_method == SRV_O_DSYNC || log.flush()}; + const bool success{log_write_through || log.flush()}; if (UNIV_LIKELY(success)) { flushed_to_disk_lsn.store(lsn, std::memory_order_release); diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index d4cfb6207bfce..6141c9dcc374a 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -65,7 +65,9 @@ Created 10/21/1995 Heikki Tuuri #endif /* HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE */ #ifdef _WIN32 -#include +# include +#elif !defined O_DSYNC +# define O_DSYNC O_SYNC #endif // my_test_if_atomic_write() , my_win_secattr() @@ -931,6 +933,8 @@ bool os_file_flush_func( os_file_t file) { + if (UNIV_UNLIKELY(my_disable_sync)) return true; + int ret; ret = os_file_sync_posix(file); @@ -981,40 +985,19 @@ os_file_create_simple_func( *success = false; - int create_flag; - const char* mode_str = NULL; + int create_flag = O_RDONLY; ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT)); ut_a(!(create_mode & OS_FILE_ON_ERROR_NO_EXIT)); - if (create_mode == OS_FILE_OPEN) { - mode_str = "OPEN"; - - if (access_type == OS_FILE_READ_ONLY) { - - create_flag = O_RDONLY; - - } else if (read_only) { - - create_flag = O_RDONLY; - - } else { + if (read_only) { + } else if (create_mode == OS_FILE_OPEN) { + if (access_type != OS_FILE_READ_ONLY) { create_flag = O_RDWR; } - - } else if (read_only) { - - mode_str = "OPEN"; - create_flag = O_RDONLY; - } else if (create_mode == OS_FILE_CREATE) { - - mode_str = "CREATE"; create_flag = O_RDWR | O_CREAT | O_EXCL; - } else if (create_mode == OS_FILE_CREATE_PATH) { - - mode_str = "CREATE PATH"; /* Create subdirs along the path if needed. */ *success = os_file_create_subdirs_if_needed(name); @@ -1040,40 +1023,32 @@ os_file_create_simple_func( return(OS_FILE_CLOSED); } - bool retry; + create_flag |= O_CLOEXEC; + if (fil_system.is_write_through()) create_flag |= O_DSYNC; + int direct_flag = fil_system.is_buffered() ? 0 : O_DIRECT; - do { - file = open(name, create_flag | O_CLOEXEC, os_innodb_umask); + for (;;) { + file = open(name, create_flag | direct_flag, os_innodb_umask); if (file == -1) { + if (direct_flag && errno == EINVAL) { + direct_flag = 0; + continue; + } + *success = false; - retry = os_file_handle_error( + if (!os_file_handle_error( name, create_mode == OS_FILE_OPEN - ? "open" : "create"); + ? "open" : "create")) { + break; + } } else { *success = true; - retry = false; - } - - } while (retry); - - /* This function is always called for data files, we should disable - OS caching (O_DIRECT) here as we do in os_file_create_func(), so - we open the same file in the same mode, see man page of open(2). */ - if (!srv_read_only_mode && *success) { - switch (srv_file_flush_method) { - case SRV_O_DSYNC: - case SRV_O_DIRECT: - case SRV_O_DIRECT_NO_FSYNC: - os_file_set_nocache(file, name, mode_str); - break; - default: break; } } -#ifndef _WIN32 if (!read_only && *success && access_type == OS_FILE_READ_WRITE @@ -1084,7 +1059,6 @@ os_file_create_simple_func( close(file); file = -1; } -#endif /* !_WIN32 */ return(file); } @@ -1156,8 +1130,8 @@ os_file_create_func( return(OS_FILE_CLOSED); ); - int create_flag; - const char* mode_str = NULL; + int create_flag = O_RDONLY | O_CLOEXEC; + const char* mode_str = "OPEN"; on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT ? true : false; @@ -1167,30 +1141,17 @@ os_file_create_func( create_mode &= ulint(~(OS_FILE_ON_ERROR_NO_EXIT | OS_FILE_ON_ERROR_SILENT)); - if (create_mode == OS_FILE_OPEN - || create_mode == OS_FILE_OPEN_RAW - || create_mode == OS_FILE_OPEN_RETRY) { - - mode_str = "OPEN"; - - create_flag = read_only ? O_RDONLY : O_RDWR; - - } else if (read_only) { - - mode_str = "OPEN"; - - create_flag = O_RDONLY; - + if (read_only) { + } else if (create_mode == OS_FILE_OPEN + || create_mode == OS_FILE_OPEN_RAW + || create_mode == OS_FILE_OPEN_RETRY) { + create_flag = O_RDWR | O_CLOEXEC; } else if (create_mode == OS_FILE_CREATE) { - mode_str = "CREATE"; - create_flag = O_RDWR | O_CREAT | O_EXCL; - + create_flag = O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC; } else if (create_mode == OS_FILE_OVERWRITE) { - mode_str = "OVERWRITE"; - create_flag = O_RDWR | O_CREAT | O_TRUNC; - + create_flag = O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC; } else { ib::error() << "Unknown file create mode (" << create_mode << ")" @@ -1205,25 +1166,30 @@ os_file_create_func( ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL); - /* We let O_DSYNC only affect log files */ + create_flag |= O_CLOEXEC; - if (!read_only - && type == OS_LOG_FILE - && srv_file_flush_method == SRV_O_DSYNC) { -#ifdef O_DSYNC + int direct_flag = type == OS_DATA_FILE && create_mode != OS_FILE_CREATE + && !fil_system.is_buffered() + ? O_DIRECT : 0; + + if (read_only) { + } else if ((type == OS_LOG_FILE) + ? log_sys.log_write_through + : fil_system.is_write_through()) { create_flag |= O_DSYNC; -#else - create_flag |= O_SYNC; -#endif } os_file_t file; - bool retry; - do { - file = open(name, create_flag | O_CLOEXEC, os_innodb_umask); + for (;;) { + file = open(name, create_flag | direct_flag, os_innodb_umask); if (file == -1) { + if (direct_flag && errno == EINVAL) { + direct_flag = 0; + continue; + } + const char* operation; operation = (create_mode == OS_FILE_CREATE @@ -1232,39 +1198,30 @@ os_file_create_func( *success = false; if (on_error_no_exit) { - retry = os_file_handle_error_no_exit( - name, operation, on_error_silent); + if (os_file_handle_error_no_exit( + name, operation, on_error_silent)) + continue; } else { - retry = os_file_handle_error(name, operation); + if (os_file_handle_error(name, operation)) + continue; } + + return file; } else { *success = true; - retry = false; + break; } - - } while (retry); - - if (!*success) { - return file; } #if (defined __sun__ && defined DIRECTIO_ON) || defined O_DIRECT - if (type == OS_DATA_FILE) { - switch (srv_file_flush_method) { - case SRV_O_DSYNC: - case SRV_O_DIRECT: - case SRV_O_DIRECT_NO_FSYNC: + if (type == OS_DATA_FILE && create_mode == OS_FILE_CREATE + && !fil_system.is_buffered()) { # ifdef __linux__ use_o_direct: # endif - os_file_set_nocache(file, name, mode_str); - break; - default: - break; - } - } + os_file_set_nocache(file, name, mode_str); # ifdef __linux__ - else if (type == OS_LOG_FILE && !log_sys.is_opened()) { + } else if (type == OS_LOG_FILE && !log_sys.is_opened()) { struct stat st; char b[20 + sizeof "/sys/dev/block/" ":" "/../queue/physical_block_size"]; @@ -1316,11 +1273,10 @@ os_file_create_func( log_sys.log_buffered= true; log_sys.set_block_size(512); } - } # endif + } #endif -#ifndef _WIN32 if (!read_only && create_mode != OS_FILE_OPEN_RAW && !my_disable_locking @@ -1348,7 +1304,6 @@ os_file_create_func( close(file); file = -1; } -#endif /* !_WIN32 */ return(file); } @@ -1786,6 +1741,9 @@ Flushes the write buffers of a given file to the disk. @return true if success */ bool os_file_flush_func(os_file_t file) { + if (UNIV_UNLIKELY(my_disable_sync)) + return true; + ++os_n_fsyncs; static bool disable_datasync; @@ -2011,6 +1969,11 @@ os_file_create_simple_func( return(OS_FILE_CLOSED); } + if (fil_system.is_write_through()) + attributes |= FILE_FLAG_WRITE_THROUGH; + if (!fil_system.is_buffered()) + attributes |= FILE_FLAG_NO_BUFFERING; + bool retry; do { @@ -2182,27 +2145,16 @@ os_file_create_func( if (!log_sys.is_opened() && !log_sys.log_buffered) { attributes|= FILE_FLAG_NO_BUFFERING; } - if (srv_file_flush_method == SRV_O_DSYNC) + if (log_sys.log_write_through) attributes|= FILE_FLAG_WRITE_THROUGH; - } - else if (type == OS_DATA_FILE) - { - switch (srv_file_flush_method) - { - case SRV_FSYNC: - case SRV_LITTLESYNC: - case SRV_NOSYNC: - break; - default: + } else { + if (type == OS_DATA_FILE && !fil_system.is_buffered()) attributes|= FILE_FLAG_NO_BUFFERING; - } + if (fil_system.is_write_through()) + attributes|= FILE_FLAG_WRITE_THROUGH; } - DWORD access = GENERIC_READ; - - if (!read_only) { - access |= GENERIC_WRITE; - } + DWORD access = read_only ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE; for (;;) { const char *operation; diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index ffb7f53c15cd6..02c7367cc937f 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -223,9 +223,6 @@ ulong srv_read_ahead_threshold; buffer in terms of percentage of the buffer pool. */ uint srv_change_buffer_max_size; -ulong srv_file_flush_method; - - /** copy of innodb_open_files; @see innodb_init_params() */ ulint srv_max_n_open_files; diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 475ae887d23e4..0ff20b31771b5 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1168,7 +1168,7 @@ static void trx_flush_log_if_needed_low(lsn_t lsn, const trx_t *trx) callback= &cb; } - log_write_up_to(lsn, srv_file_flush_method != SRV_NOSYNC && + log_write_up_to(lsn, !my_disable_sync && (srv_flush_log_at_trx_commit & 1), callback); } From f27e9c894779a4c7ebe6446ba9aa408f1771c114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 11 Jan 2023 17:59:36 +0200 Subject: [PATCH 109/113] MDEV-29694 Remove the InnoDB change buffer The purpose of the change buffer was to reduce random disk access, which could be useful on rotational storage, but maybe less so on solid-state storage. When we wished to (1) insert a record into a non-unique secondary index, (2) delete-mark a secondary index record, (3) delete a secondary index record as part of purge (but not ROLLBACK), and the B-tree leaf page where the record belongs to is not in the buffer pool, we inserted a record into the change buffer B-tree, indexed by the page identifier. When the page was eventually read into the buffer pool, we looked up the change buffer B-tree for any modifications to the page, applied these upon the completion of the read operation. This was called the insert buffer merge. We remove the change buffer, because it has been the source of various hard-to-reproduce corruption bugs, including those fixed in commit 5b9ee8d8193a8c7a8ebdd35eedcadc3ae78e7fc1 and commit 165564d3c33ae3d677d70644a83afcb744bdbf65 but not limited to them. A downgrade will fail with a clear message starting with commit db14eb16f9977453467ec4765f481bb2f71814ba (MDEV-30106). buf_page_t::state: Merge IBUF_EXIST to UNFIXED and WRITE_FIX_IBUF to WRITE_FIX. buf_pool_t::watch[]: Remove. trx_t: Move isolation_level, check_foreigns, check_unique_secondary, bulk_insert into the same bit-field. The only purpose of trx_t::check_unique_secondary is to enable bulk insert into an empty table. It no longer enables insert buffering for UNIQUE INDEX. btr_cur_t::thr: Remove. This field was originally needed for change buffering. Later, its use was extended to cover SPATIAL INDEX. Much of the time, rtr_info::thr holds this field. When it does not, we will add parameters to SPATIAL INDEX specific functions. ibuf_upgrade_needed(): Check if the change buffer needs to be updated. ibuf_upgrade(): Merge and upgrade the change buffer after all redo log has been applied. Free any pages consumed by the change buffer, and zero out the change buffer root page to mark the upgrade completed, and to prevent a downgrade to an earlier version. dict_load_tablespaces(): Renamed from dict_check_tablespaces_and_store_max_id(). This needs to be invoked before ibuf_upgrade(). btr_cur_open_at_rnd_pos(): Specialize for use in persistent statistics. The change buffer merge does not need this function anymore. btr_page_alloc(): Renamed from btr_page_alloc_low(). We no longer allocate any change buffer pages. btr_cur_open_at_rnd_pos(): Specialize for use in persistent statistics. The change buffer merge does not need this function anymore. row_search_index_entry(), btr_lift_page_up(): Add a parameter thr for the SPATIAL INDEX case. rtr_page_split_and_insert(): Specialized from btr_page_split_and_insert(). rtr_root_raise_and_insert(): Specialized from btr_root_raise_and_insert(). Note: The support for upgrading from the MySQL 3.23 or MySQL 4.0 change buffer format that predates the MySQL 4.1 introduction of the option innodb_file_per_table was removed in MySQL 5.6.5 as part of mysql/mysql-server@69b6241a79876ae98bb0c9dce7c8d8799d6ad273 and MariaDB 10.0.11 as part of 1d0f70c2f894b27e98773a282871d32802f67964. In the tests innodb.log_upgrade and innodb.log_corruption, we create valid (upgraded) change buffer pages. Tested by: Matthias Leich --- extra/mariabackup/xtrabackup.cc | 6 - .../suite/encryption/t/innodb-redo-badkey.opt | 1 - .../suite/encryption/t/innodb-redo-nokeys.opt | 1 - mysql-test/suite/innodb/r/ibuf_delete.result | 53 - .../suite/innodb/r/ibuf_not_empty.result | 20 - .../r/innodb-change-buffer-recovery.result | 51 - .../suite/innodb/r/innodb-wl5522-debug.result | 5 - .../suite/innodb/r/innodb_bug59733.result | 18 - .../r/innodb_skip_innodb_is_tables.result | 16 - .../innodb/r/innodb_status_variables.result | 10 - mysql-test/suite/innodb/r/insert_debug.result | 2 - mysql-test/suite/innodb/r/mdev-15707.result | 24 - mysql-test/suite/innodb/r/monitor.result | 16 - .../innodb/r/row_format_redundant.result | 3 +- mysql-test/suite/innodb/t/ibuf_delete.test | 67 - .../innodb/t/ibuf_not_empty.combinations | 9 - mysql-test/suite/innodb/t/ibuf_not_empty.test | 117 - .../innodb-change-buffer-recovery-master.opt | 1 - .../t/innodb-change-buffer-recovery.test | 78 - .../suite/innodb/t/innodb-wl5522-debug.test | 15 - .../innodb/t/innodb_buffer_pool_load_now.test | 2 +- .../suite/innodb/t/innodb_bug59733.test | 53 - mysql-test/suite/innodb/t/insert_debug.test | 2 - mysql-test/suite/innodb/t/log_corruption.test | 26 +- mysql-test/suite/innodb/t/log_upgrade.test | 19 +- mysql-test/suite/innodb/t/mdev-15707.opt | 1 - mysql-test/suite/innodb/t/mdev-15707.test | 30 - .../suite/innodb/t/row_format_redundant.test | 5 +- .../innodb_zip/r/wl5522_debug_zip.result | 5 - .../suite/innodb_zip/t/wl5522_debug_zip.test | 15 - ...innodb_change_buffer_max_size_basic.result | 77 - .../r/innodb_change_buffering_basic.result | 73 - ...innodb_change_buffering_debug_basic.result | 67 - .../suite/sys_vars/r/sysvars_innodb.result | 48 - .../innodb_change_buffer_max_size_basic.test | 71 - .../t/innodb_change_buffering_basic.test | 65 - .../innodb_change_buffering_debug_basic.test | 59 - sql/mysqld.cc | 6 +- storage/innobase/CMakeLists.txt | 3 +- storage/innobase/btr/btr0btr.cc | 511 +- storage/innobase/btr/btr0bulk.cc | 12 +- storage/innobase/btr/btr0cur.cc | 541 +- storage/innobase/btr/btr0defragment.cc | 44 +- storage/innobase/btr/btr0pcur.cc | 27 +- storage/innobase/btr/btr0sea.cc | 17 +- storage/innobase/buf/buf0buf.cc | 498 +- storage/innobase/buf/buf0flu.cc | 9 +- storage/innobase/buf/buf0rea.cc | 164 +- storage/innobase/data/data0type.cc | 9 +- storage/innobase/dict/dict0boot.cc | 14 +- storage/innobase/dict/dict0defrag_bg.cc | 7 +- storage/innobase/dict/dict0dict.cc | 39 +- storage/innobase/dict/dict0load.cc | 14 +- storage/innobase/dict/dict0stats.cc | 35 +- storage/innobase/fil/fil0fil.cc | 12 +- storage/innobase/fil/fil0pagecompress.cc | 3 +- storage/innobase/fsp/fsp0fsp.cc | 17 +- storage/innobase/gis/gis0rtree.cc | 274 +- storage/innobase/gis/gis0sea.cc | 49 +- storage/innobase/handler/ha_innodb.cc | 102 +- storage/innobase/handler/handler0alter.cc | 3 +- storage/innobase/handler/i_s.cc | 42 +- storage/innobase/ibuf/ibuf0ibuf.cc | 4699 ++--------------- storage/innobase/include/btr0btr.h | 42 +- storage/innobase/include/btr0cur.h | 40 +- storage/innobase/include/btr0types.h | 45 +- storage/innobase/include/buf0buf.h | 146 +- storage/innobase/include/buf0rea.h | 36 +- storage/innobase/include/data0type.h | 57 +- storage/innobase/include/data0type.inl | 122 +- storage/innobase/include/dict0dict.h | 4 +- storage/innobase/include/dict0load.h | 8 +- storage/innobase/include/dict0mem.h | 18 +- storage/innobase/include/dict0types.h | 13 +- storage/innobase/include/fil0fil.h | 6 +- storage/innobase/include/fsp0types.h | 16 +- storage/innobase/include/gis0rtree.h | 41 +- storage/innobase/include/gis0rtree.inl | 5 +- storage/innobase/include/ibuf0ibuf.h | 457 +- storage/innobase/include/ibuf0ibuf.inl | 282 - storage/innobase/include/log0recv.h | 12 +- storage/innobase/include/mtr0mtr.h | 15 +- storage/innobase/include/page0cur.h | 12 +- storage/innobase/include/page0cur.inl | 7 +- storage/innobase/include/page0page.h | 19 +- storage/innobase/include/page0zip.h | 10 +- storage/innobase/include/page0zip.inl | 4 +- storage/innobase/include/rem0rec.inl | 6 +- storage/innobase/include/row0purge.h | 35 +- storage/innobase/include/row0row.h | 38 +- storage/innobase/include/srv0mon.h | 21 +- storage/innobase/include/srv0srv.h | 11 +- storage/innobase/include/sux_lock.h | 4 +- storage/innobase/include/trx0trx.h | 25 +- storage/innobase/include/univ.i | 6 +- storage/innobase/log/log0log.cc | 21 +- storage/innobase/log/log0recv.cc | 77 +- storage/innobase/mtr/mtr0mtr.cc | 7 +- storage/innobase/page/page0cur.cc | 16 +- storage/innobase/page/page0page.cc | 42 +- storage/innobase/page/page0zip.cc | 14 +- storage/innobase/rem/rem0cmp.cc | 46 +- storage/innobase/rem/rem0rec.cc | 9 +- storage/innobase/row/row0import.cc | 12 +- storage/innobase/row/row0ins.cc | 34 +- storage/innobase/row/row0log.cc | 64 +- storage/innobase/row/row0merge.cc | 4 +- storage/innobase/row/row0mysql.cc | 15 +- storage/innobase/row/row0purge.cc | 96 +- storage/innobase/row/row0quiesce.cc | 15 +- storage/innobase/row/row0row.cc | 85 +- storage/innobase/row/row0sel.cc | 7 +- storage/innobase/row/row0uins.cc | 17 +- storage/innobase/row/row0umod.cc | 51 +- storage/innobase/row/row0upd.cc | 31 +- storage/innobase/srv/srv0mon.cc | 112 +- storage/innobase/srv/srv0srv.cc | 69 +- storage/innobase/srv/srv0start.cc | 244 +- storage/innobase/trx/trx0rseg.cc | 6 +- storage/innobase/trx/trx0sys.cc | 10 +- storage/innobase/trx/trx0trx.cc | 10 +- .../r/innodb_i_s_tables_disabled.result | 16 - 122 files changed, 1669 insertions(+), 9306 deletions(-) delete mode 100644 mysql-test/suite/innodb/r/ibuf_delete.result delete mode 100644 mysql-test/suite/innodb/r/ibuf_not_empty.result delete mode 100644 mysql-test/suite/innodb/r/innodb-change-buffer-recovery.result delete mode 100644 mysql-test/suite/innodb/r/innodb_bug59733.result delete mode 100644 mysql-test/suite/innodb/r/mdev-15707.result delete mode 100644 mysql-test/suite/innodb/t/ibuf_delete.test delete mode 100644 mysql-test/suite/innodb/t/ibuf_not_empty.combinations delete mode 100644 mysql-test/suite/innodb/t/ibuf_not_empty.test delete mode 100644 mysql-test/suite/innodb/t/innodb-change-buffer-recovery-master.opt delete mode 100644 mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test delete mode 100644 mysql-test/suite/innodb/t/innodb_bug59733.test delete mode 100644 mysql-test/suite/innodb/t/mdev-15707.opt delete mode 100644 mysql-test/suite/innodb/t/mdev-15707.test delete mode 100644 mysql-test/suite/sys_vars/r/innodb_change_buffer_max_size_basic.result delete mode 100644 mysql-test/suite/sys_vars/r/innodb_change_buffering_basic.result delete mode 100644 mysql-test/suite/sys_vars/r/innodb_change_buffering_debug_basic.result delete mode 100644 mysql-test/suite/sys_vars/t/innodb_change_buffer_max_size_basic.test delete mode 100644 mysql-test/suite/sys_vars/t/innodb_change_buffering_basic.test delete mode 100644 mysql-test/suite/sys_vars/t/innodb_change_buffering_debug_basic.test delete mode 100644 storage/innobase/include/ibuf0ibuf.inl diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 27bb10bf82e24..9d86ae100afbb 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2169,12 +2169,6 @@ static bool innodb_init_param() srv_print_verbose_log = verbose ? 2 : 1; - /* Store the default charset-collation number of this MySQL - installation */ - - /* We cannot treat characterset here for now!! */ - data_mysql_default_charset_coll = (ulint)default_charset_info->number; - ut_ad(DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number); #ifdef _WIN32 diff --git a/mysql-test/suite/encryption/t/innodb-redo-badkey.opt b/mysql-test/suite/encryption/t/innodb-redo-badkey.opt index 2de0bdb32416d..60d43648e0087 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-badkey.opt +++ b/mysql-test/suite/encryption/t/innodb-redo-badkey.opt @@ -1,4 +1,3 @@ ---innodb-change-buffering=all --innodb-encrypt-tables=on --innodb-tablespaces-encryption --innodb-encryption-threads=2 diff --git a/mysql-test/suite/encryption/t/innodb-redo-nokeys.opt b/mysql-test/suite/encryption/t/innodb-redo-nokeys.opt index 6190ad24ed338..4e7b22902a443 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-nokeys.opt +++ b/mysql-test/suite/encryption/t/innodb-redo-nokeys.opt @@ -1,2 +1 @@ ---innodb-change-buffering=none --innodb-default-encryption-key-id=20 diff --git a/mysql-test/suite/innodb/r/ibuf_delete.result b/mysql-test/suite/innodb/r/ibuf_delete.result deleted file mode 100644 index 7423d3cfa3e16..0000000000000 --- a/mysql-test/suite/innodb/r/ibuf_delete.result +++ /dev/null @@ -1,53 +0,0 @@ -SET @buffering= @@innodb_change_buffering; -SET GLOBAL innodb_change_buffering= deletes; -Warnings: -Warning 1287 '@@innodb_change_buffering' is deprecated and will be removed in a future release -SET @flush= @@innodb_flush_log_at_trx_commit; -SET GLOBAL innodb_flush_log_at_trx_commit= 0; -CREATE TABLE t1 ( -a varchar(1024), -b varchar(1024), -c varchar(1024), -d varchar(1024), -e varchar(1024), -f varchar(1024), -g varchar(1024), -h varchar(1024), -key (a), -key (b), -key (c), -key (d) -) ENGINE=InnoDB; -INSERT INTO t1 -SELECT REPEAT('x',10), REPEAT('x',13), REPEAT('x',427), REPEAT('x',244), -REPEAT('x',9), REPEAT('x',112), REPEAT('x',814), REPEAT('x',633) -FROM seq_1_to_1024; -CREATE TEMPORARY TABLE t2 ( -a varchar(1024), -b varchar(1024), -c varchar(1024), -d varchar(1024), -e varchar(1024), -f varchar(1024), -g varchar(1024), -h varchar(1024), -i varchar(1024), -j varchar(1024), -k varchar(1024), -l varchar(1024), -m varchar(1024), -key (a), -key (b), -key (c), -key (d), -key (e), -key (f) -) ENGINE=InnoDB; -SET @x=REPEAT('x',512); -INSERT INTO t2 SELECT @x, @x, @x, @x, @x, @x, @x, @x, @x, @x, @x, @x, @x -FROM seq_1_to_768; -DROP TABLE t1, t2; -SET GLOBAL innodb_change_buffering= @buffering; -Warnings: -Warning 1287 '@@innodb_change_buffering' is deprecated and will be removed in a future release -SET GLOBAL innodb_flush_log_at_trx_commit= @flush; diff --git a/mysql-test/suite/innodb/r/ibuf_not_empty.result b/mysql-test/suite/innodb/r/ibuf_not_empty.result deleted file mode 100644 index 1dc7f0324d316..0000000000000 --- a/mysql-test/suite/innodb/r/ibuf_not_empty.result +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE t1( -a INT AUTO_INCREMENT PRIMARY KEY, -b CHAR(1), -c INT, -INDEX(b)) -ENGINE=InnoDB STATS_PERSISTENT=0; -SET GLOBAL innodb_change_buffering_debug = 1; -SET GLOBAL innodb_change_buffering=all; -Warnings: -Warning 1287 '@@innodb_change_buffering' is deprecated and will be removed in a future release -INSERT INTO t1 SELECT 0,'x',1 FROM seq_1_to_1024; -# restart: --innodb-force-recovery=6 --innodb-change-buffer-dump -check table t1; -Table Op Msg_type Msg_text -test.t1 check Warning InnoDB: Index 'b' contains 990 entries, should be 1024. -test.t1 check error Corrupt -# restart: --innodb-force_recovery=0 -SET GLOBAL innodb_fast_shutdown=0; -# restart: --innodb-force_recovery=0 -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-change-buffer-recovery.result b/mysql-test/suite/innodb/r/innodb-change-buffer-recovery.result deleted file mode 100644 index 42fdf680f2e84..0000000000000 --- a/mysql-test/suite/innodb/r/innodb-change-buffer-recovery.result +++ /dev/null @@ -1,51 +0,0 @@ -# -# Bug#69122 - INNODB DOESN'T REDO-LOG INSERT BUFFER MERGE -# OPERATION IF IT IS DONE IN-PLACE -# -call mtr.add_suppression("InnoDB: innodb_read_only prevents crash recovery"); -call mtr.add_suppression("Plugin initialization aborted at srv0start\\.cc"); -call mtr.add_suppression("Plugin 'InnoDB'"); -FLUSH TABLES; -CREATE TABLE t1( -a INT AUTO_INCREMENT PRIMARY KEY, -b CHAR(1), -c INT, -INDEX(b)) -ENGINE=InnoDB STATS_PERSISTENT=0; -SET GLOBAL innodb_change_buffering_debug = 1; -SET GLOBAL innodb_change_buffering = all; -Warnings: -Warning 1287 '@@innodb_change_buffering' is deprecated and will be removed in a future release -INSERT INTO t1 SELECT 0,'x',1 FROM seq_1_to_8192; -BEGIN; -SELECT b FROM t1 LIMIT 3; -b -x -x -x -connect con1,localhost,root,,; -BEGIN; -DELETE FROM t1 WHERE a=1; -INSERT INTO t1 VALUES(1,'X',1); -SET DEBUG_DBUG='+d,crash_after_log_ibuf_upd_inplace'; -SELECT b FROM t1 LIMIT 3; -ERROR HY000: Lost connection to server during query -disconnect con1; -connection default; -FOUND 1 /Wrote log record for ibuf update in place operation/ in mysqld.1.err -# restart: --innodb-read-only -CHECK TABLE t1; -Table Op Msg_type Msg_text -test.t1 check Error Unknown storage engine 'InnoDB' -test.t1 check error Corrupt -FOUND 1 /innodb_read_only prevents crash recovery/ in mysqld.1.err -# restart: --innodb-force-recovery=5 --debug-dbug=d,crash_after_log_ibuf_upd_inplace -SELECT * FROM t1 LIMIT 1; -a b c -1 X 1 -SET GLOBAL innodb_fast_shutdown=0; -# restart -CHECK TABLE t1; -Table Op Msg_type Msg_text -test.t1 check status OK -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result index ff0f8b2acc8a5..1c3b10c05974e 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result +++ b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result @@ -454,11 +454,6 @@ ALTER TABLE t1 IMPORT TABLESPACE; ERROR HY000: Got error 42 'Tablespace not found' from ./test/t1.ibd SET SESSION debug_dbug=@saved_debug_dbug; restore: t1 .ibd and .cfg files -SET SESSION debug_dbug="+d,ib_import_check_bitmap_failure"; -ALTER TABLE t1 IMPORT TABLESPACE; -ERROR HY000: Index for table 't1' is corrupt; try to repair it -SET SESSION debug_dbug=@saved_debug_dbug; -restore: t1 .ibd and .cfg files SET SESSION debug_dbug="+d,ib_import_cluster_root_adjust_failure"; ALTER TABLE t1 IMPORT TABLESPACE; ERROR HY000: Index for table 't1' is corrupt; try to repair it diff --git a/mysql-test/suite/innodb/r/innodb_bug59733.result b/mysql-test/suite/innodb/r/innodb_bug59733.result deleted file mode 100644 index c962cdfd67779..0000000000000 --- a/mysql-test/suite/innodb/r/innodb_bug59733.result +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE bug59733(a INT AUTO_INCREMENT PRIMARY KEY,b CHAR(1))ENGINE=InnoDB; -INSERT INTO bug59733 VALUES(0,'x'); -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -CREATE INDEX b ON bug59733 (b); -DELETE FROM bug59733 WHERE (a%100)=0; -DROP INDEX b ON bug59733; -CREATE INDEX b ON bug59733 (b); -DROP TABLE bug59733; diff --git a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result index bc5051b1442d5..ede6241765254 100644 --- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result +++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result @@ -116,12 +116,8 @@ buffer_LRU_unzip_search_num_scan buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL N buffer_LRU_unzip_search_scanned_per_call buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Page scanned per single LRU unzip search buffer_page_read_index_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Leaf Pages read buffer_page_read_index_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Non-leaf Pages read -buffer_page_read_index_ibuf_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Leaf Pages read -buffer_page_read_index_ibuf_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Non-Leaf Pages read buffer_page_read_undo_log buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Undo Log Pages read buffer_page_read_index_inode buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Inode Pages read -buffer_page_read_ibuf_free_list buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Free List Pages read -buffer_page_read_ibuf_bitmap buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Bitmap Pages read buffer_page_read_system_page buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of System Pages read buffer_page_read_trx_system buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Transaction System Pages read buffer_page_read_fsp_hdr buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of File Space Header Pages read @@ -132,12 +128,8 @@ buffer_page_read_zblob2 buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NU buffer_page_read_other buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of other/unknown (old version of InnoDB) Pages read buffer_page_written_index_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Leaf Pages written buffer_page_written_index_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Non-leaf Pages written -buffer_page_written_index_ibuf_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Leaf Pages written -buffer_page_written_index_ibuf_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Non-Leaf Pages written buffer_page_written_undo_log buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Undo Log Pages written buffer_page_written_index_inode buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Inode Pages written -buffer_page_written_ibuf_free_list buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Free List Pages written -buffer_page_written_ibuf_bitmap buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Bitmap Pages written buffer_page_written_system_page buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of System Pages written buffer_page_written_trx_system buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Transaction System Pages written buffer_page_written_fsp_hdr buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of File Space Header Pages written @@ -205,14 +197,6 @@ adaptive_hash_rows_removed adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL adaptive_hash_rows_deleted_no_hash_entry adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of rows deleted that did not have corresponding Adaptive Hash Index entries adaptive_hash_rows_updated adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Adaptive Hash Index rows updated file_num_open_files file_system 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of files currently open (innodb_num_open_files) -ibuf_merges_insert change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of inserted records merged by change buffering -ibuf_merges_delete_mark change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of deleted records merged by change buffering -ibuf_merges_delete change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of purge records merged by change buffering -ibuf_merges_discard_insert change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of insert merged operations discarded -ibuf_merges_discard_delete_mark change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of deleted merged operations discarded -ibuf_merges_discard_delete change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of purge merged operations discarded -ibuf_merges change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of change buffer merges -ibuf_size change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Change buffer size in pages innodb_master_thread_sleeps server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times (seconds) master thread sleeps innodb_activity_count server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Current server activity count innodb_master_active_loops server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times master thread performs its tasks when server is active diff --git a/mysql-test/suite/innodb/r/innodb_status_variables.result b/mysql-test/suite/innodb/r/innodb_status_variables.result index 2271cf48b1460..2e8272f444bf8 100644 --- a/mysql-test/suite/innodb/r/innodb_status_variables.result +++ b/mysql-test/suite/innodb/r/innodb_status_variables.result @@ -44,16 +44,6 @@ INNODB_DBLWR_PAGES_WRITTEN INNODB_DBLWR_WRITES INNODB_DEADLOCKS INNODB_HISTORY_LIST_LENGTH -INNODB_IBUF_DISCARDED_DELETE_MARKS -INNODB_IBUF_DISCARDED_DELETES -INNODB_IBUF_DISCARDED_INSERTS -INNODB_IBUF_FREE_LIST -INNODB_IBUF_MERGED_DELETE_MARKS -INNODB_IBUF_MERGED_DELETES -INNODB_IBUF_MERGED_INSERTS -INNODB_IBUF_MERGES -INNODB_IBUF_SEGMENT_SIZE -INNODB_IBUF_SIZE INNODB_LOG_WAITS INNODB_LOG_WRITE_REQUESTS INNODB_LOG_WRITES diff --git a/mysql-test/suite/innodb/r/insert_debug.result b/mysql-test/suite/innodb/r/insert_debug.result index 3ac9df58c169d..cafab4aa978cb 100644 --- a/mysql-test/suite/innodb/r/insert_debug.result +++ b/mysql-test/suite/innodb/r/insert_debug.result @@ -2,12 +2,10 @@ # Bug#19904003 INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG=1 # CAUSES INFINITE PAGE SPLIT # -SET GLOBAL innodb_change_buffering_debug=1; SET GLOBAL innodb_limit_optimistic_insert_debug=1; CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=InnoDB PARTITION BY HASH (c1) PARTITIONS 15; DROP TABLE t1; -SET GLOBAL innodb_change_buffering_debug=0; SET GLOBAL innodb_limit_optimistic_insert_debug=0; # # Bug#25082593 FOREIGN KEY VALIDATION DOESN'T NEED diff --git a/mysql-test/suite/innodb/r/mdev-15707.result b/mysql-test/suite/innodb/r/mdev-15707.result deleted file mode 100644 index 3967ce48b625d..0000000000000 --- a/mysql-test/suite/innodb/r/mdev-15707.result +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE t1( -a INT AUTO_INCREMENT PRIMARY KEY, -b CHAR(255), -INDEX(b)) -ENGINE=InnoDB; -INSERT INTO t1(b) SELECT UUID(); -BEGIN; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -INSERT INTO t1(b) SELECT UUID() FROM t1; -COMMIT; -UPDATE t1 SET b=UUID(); -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/monitor.result b/mysql-test/suite/innodb/r/monitor.result index 63f78752276a5..57f10731ed6ad 100644 --- a/mysql-test/suite/innodb/r/monitor.result +++ b/mysql-test/suite/innodb/r/monitor.result @@ -82,12 +82,8 @@ buffer_LRU_unzip_search_num_scan disabled buffer_LRU_unzip_search_scanned_per_call disabled buffer_page_read_index_leaf disabled buffer_page_read_index_non_leaf disabled -buffer_page_read_index_ibuf_leaf disabled -buffer_page_read_index_ibuf_non_leaf disabled buffer_page_read_undo_log disabled buffer_page_read_index_inode disabled -buffer_page_read_ibuf_free_list disabled -buffer_page_read_ibuf_bitmap disabled buffer_page_read_system_page disabled buffer_page_read_trx_system disabled buffer_page_read_fsp_hdr disabled @@ -98,12 +94,8 @@ buffer_page_read_zblob2 disabled buffer_page_read_other disabled buffer_page_written_index_leaf disabled buffer_page_written_index_non_leaf disabled -buffer_page_written_index_ibuf_leaf disabled -buffer_page_written_index_ibuf_non_leaf disabled buffer_page_written_undo_log disabled buffer_page_written_index_inode disabled -buffer_page_written_ibuf_free_list disabled -buffer_page_written_ibuf_bitmap disabled buffer_page_written_system_page disabled buffer_page_written_trx_system disabled buffer_page_written_fsp_hdr disabled @@ -171,14 +163,6 @@ adaptive_hash_rows_removed disabled adaptive_hash_rows_deleted_no_hash_entry disabled adaptive_hash_rows_updated disabled file_num_open_files disabled -ibuf_merges_insert disabled -ibuf_merges_delete_mark disabled -ibuf_merges_delete disabled -ibuf_merges_discard_insert disabled -ibuf_merges_discard_delete_mark disabled -ibuf_merges_discard_delete disabled -ibuf_merges disabled -ibuf_size disabled innodb_master_thread_sleeps disabled innodb_activity_count disabled innodb_master_active_loops disabled diff --git a/mysql-test/suite/innodb/r/row_format_redundant.result b/mysql-test/suite/innodb/r/row_format_redundant.result index e7e15983dfd3e..f028638180955 100644 --- a/mysql-test/suite/innodb/r/row_format_redundant.result +++ b/mysql-test/suite/innodb/r/row_format_redundant.result @@ -25,7 +25,6 @@ c varchar(150), index k1(c(99), b(56)), index k2(b(5), c(10))) engine=InnoDB row_format=redundant; insert into t3 values(444, 'dddd', 'bbbbb', 'aaaaa'); insert into t3 values(555, 'eeee', 'ccccc', 'aaaaa'); -SET GLOBAL innodb_fast_shutdown=0; # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-data-file-path=ibdata1:1M:autoextend --innodb-undo-tablespaces=0 --innodb-stats-persistent=0 --innodb-read-only SELECT COUNT(*) FROM t1; COUNT(*) @@ -68,7 +67,7 @@ DROP TABLE t1; Warnings: Warning 1932 Table 'test.t1' doesn't exist in engine DROP TABLE t2,t3; -FOUND 6 /\[ERROR\] InnoDB: Table test/t1 in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b/ in mysqld.1.err +FOUND 1 /\[ERROR\] InnoDB: Table test/t1 in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b.*/ in mysqld.1.err # restart ib_buffer_pool ib_logfile0 diff --git a/mysql-test/suite/innodb/t/ibuf_delete.test b/mysql-test/suite/innodb/t/ibuf_delete.test deleted file mode 100644 index 82b740b6aa1cf..0000000000000 --- a/mysql-test/suite/innodb/t/ibuf_delete.test +++ /dev/null @@ -1,67 +0,0 @@ ---source include/have_innodb.inc ---source include/have_sequence.inc - -SET @buffering= @@innodb_change_buffering; -SET GLOBAL innodb_change_buffering= deletes; -SET @flush= @@innodb_flush_log_at_trx_commit; -SET GLOBAL innodb_flush_log_at_trx_commit= 0; - -CREATE TABLE t1 ( - a varchar(1024), - b varchar(1024), - c varchar(1024), - d varchar(1024), - e varchar(1024), - f varchar(1024), - g varchar(1024), - h varchar(1024), - key (a), - key (b), - key (c), - key (d) -) ENGINE=InnoDB; - -INSERT INTO t1 -SELECT REPEAT('x',10), REPEAT('x',13), REPEAT('x',427), REPEAT('x',244), -REPEAT('x',9), REPEAT('x',112), REPEAT('x',814), REPEAT('x',633) -FROM seq_1_to_1024; - -CREATE TEMPORARY TABLE t2 ( - a varchar(1024), - b varchar(1024), - c varchar(1024), - d varchar(1024), - e varchar(1024), - f varchar(1024), - g varchar(1024), - h varchar(1024), - i varchar(1024), - j varchar(1024), - k varchar(1024), - l varchar(1024), - m varchar(1024), - key (a), - key (b), - key (c), - key (d), - key (e), - key (f) -) ENGINE=InnoDB; - -SET @x=REPEAT('x',512); -INSERT INTO t2 SELECT @x, @x, @x, @x, @x, @x, @x, @x, @x, @x, @x, @x, @x -FROM seq_1_to_768; - ---disable_query_log ---let $run=1024 -while ($run) -{ - eval DELETE FROM t1 LIMIT 1 /* $run */; - --dec $run -} ---enable_query_log - -# Cleanup -DROP TABLE t1, t2; -SET GLOBAL innodb_change_buffering= @buffering; -SET GLOBAL innodb_flush_log_at_trx_commit= @flush; diff --git a/mysql-test/suite/innodb/t/ibuf_not_empty.combinations b/mysql-test/suite/innodb/t/ibuf_not_empty.combinations deleted file mode 100644 index c4b45dcca32c8..0000000000000 --- a/mysql-test/suite/innodb/t/ibuf_not_empty.combinations +++ /dev/null @@ -1,9 +0,0 @@ -[strict_crc32] ---innodb-checksum-algorithm=strict_crc32 ---innodb-page-size=4k ---innodb-force-recovery=2 - -[strict_full_crc32] ---innodb-checksum-algorithm=strict_full_crc32 ---innodb-page-size=4k ---innodb-force-recovery=2 diff --git a/mysql-test/suite/innodb/t/ibuf_not_empty.test b/mysql-test/suite/innodb/t/ibuf_not_empty.test deleted file mode 100644 index 9362f8daffa63..0000000000000 --- a/mysql-test/suite/innodb/t/ibuf_not_empty.test +++ /dev/null @@ -1,117 +0,0 @@ ---source include/have_innodb.inc ---source include/no_valgrind_without_big.inc -# innodb_change_buffering_debug option is debug only ---source include/have_debug.inc -# Embedded server tests do not support restarting ---source include/not_embedded.inc ---source include/have_sequence.inc - ---disable_query_log -call mtr.add_suppression("InnoDB: Failed to find tablespace for table `test`\\.`t1` in the cache\\. Attempting to load the tablespace with space id"); -call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for test.t1, old maximum was"); -call mtr.add_suppression("InnoDB: Failed to find tablespace for table `mysql`\\.`transaction_registry` in the cache\\. Attempting to load the tablespace with space id"); -call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for mysql.transaction_registry, old maximum was"); -call mtr.add_suppression("InnoDB: Trying to read 4096 bytes"); -call mtr.add_suppression("InnoDB: File './test/t1.ibd' is corrupted"); ---enable_query_log - -CREATE TABLE t1( - a INT AUTO_INCREMENT PRIMARY KEY, - b CHAR(1), - c INT, - INDEX(b)) -ENGINE=InnoDB STATS_PERSISTENT=0; - -# The flag innodb_change_buffering_debug is only available in debug builds. -# It instructs InnoDB to try to evict pages from the buffer pool when -# change buffering is possible, so that the change buffer will be used -# whenever possible. -SET GLOBAL innodb_change_buffering_debug = 1; -SET GLOBAL innodb_change_buffering=all; - -# Create enough rows for the table, so that the change buffer will be -# used for modifying the secondary index page. There must be multiple -# index pages, because changes to the root page are never buffered. -INSERT INTO t1 SELECT 0,'x',1 FROM seq_1_to_1024; -let MYSQLD_DATADIR=`select @@datadir`; -let PAGE_SIZE=`select @@innodb_page_size`; - ---source include/shutdown_mysqld.inc - -# Corrupt the change buffer bitmap, to claim that pages are clean -perl; -do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; -my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; -open(FILE, "+<$file") || die "Unable to open $file"; -binmode FILE; -my $ps= $ENV{PAGE_SIZE}; -my $page; -die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; -my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS -die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; -# Clean the change buffer bitmap. -substr($page,38,$ps - 38 - 8) = chr(0) x ($ps - 38 - 8); -my $polynomial = 0x82f63b78; # CRC-32C -if ($full_crc32) -{ - my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial); - substr($page, $ps-4, 4) = pack("N", $ck); -} -else -{ - my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ - mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); - substr($page,0,4)=$ck; - substr($page,$ps-8,4)=$ck; -} -sysseek(FILE, $ps, 0) || die "Unable to rewind $file\n"; -syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; -close(FILE) || die "Unable to close $file"; -EOF - ---let $restart_parameters= --innodb-force-recovery=6 --innodb-change-buffer-dump ---source include/start_mysqld.inc - ---replace_regex /contains \d+ entries/contains 990 entries/ -check table t1; - ---source include/shutdown_mysqld.inc - -# Truncate the file to 5 pages, as if it were empty -perl; -do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; -my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; -open(FILE, "+<$file") || die "Unable to open $file"; -binmode FILE; -my $ps= $ENV{PAGE_SIZE}; -my $pages=5; -my $page; -die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; -my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS -substr($page,46,4)=pack("N", $pages); -my $polynomial = 0x82f63b78; # CRC-32C -if ($full_crc32) -{ - my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial); - substr($page, $ps-4, 4) = pack("N", $ck); -} -else -{ - my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ - mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); - substr($page,0,4)=$ck; - substr($page,$ps-8,4)=$ck; -} -sysseek(FILE, 0, 0) || die "Unable to rewind $file\n"; -syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; -truncate(FILE, $ps * $pages); -close(FILE) || die "Unable to close $file"; -EOF - ---let $restart_parameters=--innodb-force_recovery=0 ---source include/start_mysqld.inc -SET GLOBAL innodb_fast_shutdown=0; ---source include/restart_mysqld.inc - -# Cleanup -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery-master.opt b/mysql-test/suite/innodb/t/innodb-change-buffer-recovery-master.opt deleted file mode 100644 index e5d7090c88353..0000000000000 --- a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery-master.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb_buffer_pool_size=24M diff --git a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test b/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test deleted file mode 100644 index dbce2f91948fe..0000000000000 --- a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test +++ /dev/null @@ -1,78 +0,0 @@ ---echo # ---echo # Bug#69122 - INNODB DOESN'T REDO-LOG INSERT BUFFER MERGE ---echo # OPERATION IF IT IS DONE IN-PLACE ---echo # ---source include/have_innodb.inc -# innodb_change_buffering_debug option is debug only ---source include/have_debug.inc -# Embedded server does not support crashing ---source include/not_embedded.inc -# DBUG_SUICIDE() hangs under valgrind ---source include/not_valgrind.inc -# This test is slow on buildbot. ---source include/big_test.inc ---source include/have_sequence.inc - -call mtr.add_suppression("InnoDB: innodb_read_only prevents crash recovery"); -call mtr.add_suppression("Plugin initialization aborted at srv0start\\.cc"); -call mtr.add_suppression("Plugin 'InnoDB'"); -FLUSH TABLES; - -CREATE TABLE t1( - a INT AUTO_INCREMENT PRIMARY KEY, - b CHAR(1), - c INT, - INDEX(b)) -ENGINE=InnoDB STATS_PERSISTENT=0; - ---let $_server_id= `SELECT @@server_id` ---let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect - -# The flag innodb_change_buffering_debug is only available in debug builds. -# It instructs InnoDB to try to evict pages from the buffer pool when -# change buffering is possible, so that the change buffer will be used -# whenever possible. -SET GLOBAL innodb_change_buffering_debug = 1; -SET GLOBAL innodb_change_buffering = all; -let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err; - -# Create enough rows for the table, so that the change buffer will be -# used for modifying the secondary index page. There must be multiple -# index pages, because changes to the root page are never buffered. -INSERT INTO t1 SELECT 0,'x',1 FROM seq_1_to_8192; - -BEGIN; -SELECT b FROM t1 LIMIT 3; - -connect (con1,localhost,root,,); -BEGIN; -DELETE FROM t1 WHERE a=1; -# This should be buffered, if innodb_change_buffering_debug = 1 is in effect. -INSERT INTO t1 VALUES(1,'X',1); - -SET DEBUG_DBUG='+d,crash_after_log_ibuf_upd_inplace'; ---exec echo "wait" > $_expect_file_name ---error 2013 -# This should force a change buffer merge -SELECT b FROM t1 LIMIT 3; -disconnect con1; -connection default; -let SEARCH_PATTERN=Wrote log record for ibuf update in place operation; ---source include/search_pattern_in_file.inc - ---let $restart_parameters= --innodb-read-only ---source include/start_mysqld.inc -CHECK TABLE t1; ---source include/shutdown_mysqld.inc -let SEARCH_PATTERN=innodb_read_only prevents crash recovery; ---source include/search_pattern_in_file.inc - ---let $restart_parameters= --innodb-force-recovery=5 --debug-dbug=d,crash_after_log_ibuf_upd_inplace ---source include/start_mysqld.inc -SELECT * FROM t1 LIMIT 1; -# Slow shutdown will not merge the changes due to innodb_force_recovery=5. -SET GLOBAL innodb_fast_shutdown=0; ---let $restart_parameters= ---source include/restart_mysqld.inc -CHECK TABLE t1; -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test index 16c5713cc7ba6..e970bd842e2df 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test @@ -952,21 +952,6 @@ do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; ib_restore_tablespaces("test", "t1"); EOF -# Test failure after ibuf check -SET SESSION debug_dbug="+d,ib_import_check_bitmap_failure"; - -# Need proper mapping of error codes :-( ---error ER_NOT_KEYFILE -ALTER TABLE t1 IMPORT TABLESPACE; - -SET SESSION debug_dbug=@saved_debug_dbug; - -# Restore files -perl; -do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; -ib_restore_tablespaces("test", "t1"); -EOF - # Test failure after adjusting the cluster index root page SET SESSION debug_dbug="+d,ib_import_cluster_root_adjust_failure"; diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_load_now.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_load_now.test index baced6e9e117d..c9e4dc25e7fce 100644 --- a/mysql-test/suite/innodb/t/innodb_buffer_pool_load_now.test +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_load_now.test @@ -69,7 +69,7 @@ EOF --move_file $file $file.now -# Complete purge (and change buffer merge). +# Complete purge. SET GLOBAL innodb_fast_shutdown=0; --source include/shutdown_mysqld.inc diff --git a/mysql-test/suite/innodb/t/innodb_bug59733.test b/mysql-test/suite/innodb/t/innodb_bug59733.test deleted file mode 100644 index 0b1bff5193298..0000000000000 --- a/mysql-test/suite/innodb/t/innodb_bug59733.test +++ /dev/null @@ -1,53 +0,0 @@ -# -# Bug #59733 Possible deadlock when buffered changes are to be discarded -# in buf_page_create -# --- source include/have_innodb.inc - --- disable_query_log -# The flag innodb_change_buffering_debug is only available in debug builds. -# It instructs InnoDB to try to evict pages from the buffer pool when -# change buffering is possible, so that the change buffer will be used -# whenever possible. --- error 0,ER_UNKNOWN_SYSTEM_VARIABLE -SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug; --- error 0,ER_UNKNOWN_SYSTEM_VARIABLE -SET GLOBAL innodb_change_buffering_debug = 1; --- enable_query_log - -CREATE TABLE bug59733(a INT AUTO_INCREMENT PRIMARY KEY,b CHAR(1))ENGINE=InnoDB; - -# Create enough rows for the table, so that the insert buffer will be -# used. There must be multiple index pages, because changes to the -# root page are never buffered. - -INSERT INTO bug59733 VALUES(0,'x'); -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; -INSERT INTO bug59733 SELECT 0,b FROM bug59733; - -# Create the secondary index for which changes will be buffered. -CREATE INDEX b ON bug59733 (b); - -# This should be buffered, if innodb_change_buffering_debug = 1 is in effect. -DELETE FROM bug59733 WHERE (a%100)=0; - -# Drop the index in order to get free pages with orphaned buffered changes. -DROP INDEX b ON bug59733; - -# Create the index and attempt to reuse pages for which buffered changes exist. -CREATE INDEX b ON bug59733 (b); - -DROP TABLE bug59733; - --- disable_query_log --- error 0, ER_UNKNOWN_SYSTEM_VARIABLE -SET GLOBAL innodb_change_buffering_debug = @innodb_change_buffering_debug_orig; diff --git a/mysql-test/suite/innodb/t/insert_debug.test b/mysql-test/suite/innodb/t/insert_debug.test index c370c402ac7c9..7fe584a8ff7f5 100644 --- a/mysql-test/suite/innodb/t/insert_debug.test +++ b/mysql-test/suite/innodb/t/insert_debug.test @@ -7,13 +7,11 @@ --echo # CAUSES INFINITE PAGE SPLIT --echo # -SET GLOBAL innodb_change_buffering_debug=1; SET GLOBAL innodb_limit_optimistic_insert_debug=1; CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=InnoDB PARTITION BY HASH (c1) PARTITIONS 15; DROP TABLE t1; -SET GLOBAL innodb_change_buffering_debug=0; SET GLOBAL innodb_limit_optimistic_insert_debug=0; --echo # diff --git a/mysql-test/suite/innodb/t/log_corruption.test b/mysql-test/suite/innodb/t/log_corruption.test index 6f7080f5b502e..f54aebf317edd 100644 --- a/mysql-test/suite/innodb/t/log_corruption.test +++ b/mysql-test/suite/innodb/t/log_corruption.test @@ -57,16 +57,24 @@ my $head = pack("Nx[18]", 0); my $body = pack("x[8]Nx[10]Nx[16312]", 768, 97937874); my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); -# Dummy pages 1..6. -$body = pack("x[16338]"); -for (my($page) = 1; $page < 7; $page++) -{ - ## FIL_PAGE_OFFSET - $head = pack("Nx[18]", $page); - $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); - print OUT pack("N",$ck).$head.pack("x[16350]Nx[4]",$ck); -} + +# Dummy change buffer header page (page 3). +die unless seek(OUT, 3 * 16384, 0); +## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT, FIL_PAGE_TYPE +my $head = pack("NNNx[8]n", 3, 0xffffffff, 0xffffffff, 6); +my $body = pack("x[62]nnx[16272]", 2, 50); +my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); +print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); + +# Dummy change buffer root page (page 4). +## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT +my $head = pack("NNNx[10]", 4, 0xffffffff, 0xffffffff); +my $body = chr(0) x 16338; +my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); +print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); + # Dictionary header page (page 7). +die unless seek(OUT, 7 * 16384, 0); ## FIL_PAGE_OFFSET $head = pack("Nx[18]", 7); ## DICT_HDR_TABLES,DICT_HDR_INDEXES diff --git a/mysql-test/suite/innodb/t/log_upgrade.test b/mysql-test/suite/innodb/t/log_upgrade.test index faf88c41bef23..a3d237875feac 100644 --- a/mysql-test/suite/innodb/t/log_upgrade.test +++ b/mysql-test/suite/innodb/t/log_upgrade.test @@ -45,9 +45,24 @@ my $head = pack("Nx[18]", 0); my $body = pack("x[8]Nx[10]Nx[16312]", 768, 97937874); my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); -# Dummy pages 1..6. -print OUT chr(0) x (6 * 16384); + +# Dummy change buffer header page (page 3). +die unless seek(OUT, 3 * 16384, 0); +## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT, FIL_PAGE_TYPE +my $head = pack("NNNx[8]n", 3, 0xffffffff, 0xffffffff, 6); +my $body = pack("x[62]nnx[16272]", 2, 50); +my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); +print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); + +# Dummy change buffer root page (page 4). +## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT +my $head = pack("NNNx[10]", 4, 0xffffffff, 0xffffffff); +my $body = chr(0) x 16338; +my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); +print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); + # Dictionary header page (page 7). +die unless seek(OUT, 7 * 16384, 0); ## FIL_PAGE_OFFSET $head = pack("Nx[18]", 7); ## DICT_HDR_TABLES,DICT_HDR_INDEXES diff --git a/mysql-test/suite/innodb/t/mdev-15707.opt b/mysql-test/suite/innodb/t/mdev-15707.opt deleted file mode 100644 index fec3463c6d084..0000000000000 --- a/mysql-test/suite/innodb/t/mdev-15707.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb --innodb-buffer-pool-size=5MB --innodb-read-io-threads=1 --innodb-doublewrite=0 --innodb-flush-log-at-trx-commit=0 \ No newline at end of file diff --git a/mysql-test/suite/innodb/t/mdev-15707.test b/mysql-test/suite/innodb/t/mdev-15707.test deleted file mode 100644 index a0446ef4f811a..0000000000000 --- a/mysql-test/suite/innodb/t/mdev-15707.test +++ /dev/null @@ -1,30 +0,0 @@ ---source include/windows.inc -# This test is slow on buildbot. ---source include/big_test.inc - -# Deadlock in conjunction with the innodb change buffering. - -# When innodb change buffering kicks in, i.e secondary non-unique index -# does not fit into the bufferpool, then, on Windows, innodb -# background threads could deadlock whenever index page is -# read, and the page needs load/merge change buffer. -# The test tries to reproduce this situation, by creating index -# that does not fit into bufferpool, and doing a large update. - -CREATE TABLE t1( -a INT AUTO_INCREMENT PRIMARY KEY, -b CHAR(255), -INDEX(b)) -ENGINE=InnoDB; - -INSERT INTO t1(b) SELECT UUID(); -BEGIN; -let $i=`select cast(log2(@@innodb_buffer_pool_size/255) as int)`; -while ($i) -{ - INSERT INTO t1(b) SELECT UUID() FROM t1; - dec $i; -} -COMMIT; -UPDATE t1 SET b=UUID(); -DROP TABLE t1; \ No newline at end of file diff --git a/mysql-test/suite/innodb/t/row_format_redundant.test b/mysql-test/suite/innodb/t/row_format_redundant.test index 6ab1eabe15b7b..6b5a559fc189a 100644 --- a/mysql-test/suite/innodb/t/row_format_redundant.test +++ b/mysql-test/suite/innodb/t/row_format_redundant.test @@ -58,9 +58,6 @@ row_format=redundant; insert into t3 values(444, 'dddd', 'bbbbb', 'aaaaa'); insert into t3 values(555, 'eeee', 'ccccc', 'aaaaa'); -# read-only restart requires the change buffer to be empty; therefore we -# do a slow shutdown. -SET GLOBAL innodb_fast_shutdown=0; --let $restart_parameters= $d --innodb-read-only --source include/restart_mysqld.inc @@ -147,7 +144,7 @@ RENAME TABLE t1 TO tee_one; DROP TABLE t1; DROP TABLE t2,t3; ---let SEARCH_PATTERN= \[ERROR\] InnoDB: Table test/t1 in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b +--let SEARCH_PATTERN= \[ERROR\] InnoDB: Table test/t1 in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b.* --source include/search_pattern_in_file.inc --let $restart_parameters= diff --git a/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result b/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result index 62a28a981cdb3..f44190680c095 100644 --- a/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result +++ b/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result @@ -94,11 +94,6 @@ ALTER TABLE t1 IMPORT TABLESPACE; ERROR HY000: Got error 42 'Tablespace not found' from ./test/t1.ibd SET SESSION debug_dbug=@saved_debug_dbug; restore: t1 .ibd and .cfg files -SET SESSION debug_dbug="+d,ib_import_check_bitmap_failure"; -ALTER TABLE t1 IMPORT TABLESPACE; -ERROR HY000: Index for table 't1' is corrupt; try to repair it -SET SESSION debug_dbug=@saved_debug_dbug; -restore: t1 .ibd and .cfg files SET SESSION debug_dbug="+d,ib_import_cluster_root_adjust_failure"; ALTER TABLE t1 IMPORT TABLESPACE; ERROR HY000: Index for table 't1' is corrupt; try to repair it diff --git a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test index 36dcd1e454be9..b5bc2a94f0153 100644 --- a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test +++ b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test @@ -226,21 +226,6 @@ do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; ib_restore_tablespaces("test", "t1"); EOF -# Test failure after ibuf check -SET SESSION debug_dbug="+d,ib_import_check_bitmap_failure"; - -# Need proper mapping of error codes :-( ---error ER_NOT_KEYFILE -ALTER TABLE t1 IMPORT TABLESPACE; - -SET SESSION debug_dbug=@saved_debug_dbug; - -# Restore files -perl; -do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; -ib_restore_tablespaces("test", "t1"); -EOF - # Test failure after adjusting the cluster index root page SET SESSION debug_dbug="+d,ib_import_cluster_root_adjust_failure"; diff --git a/mysql-test/suite/sys_vars/r/innodb_change_buffer_max_size_basic.result b/mysql-test/suite/sys_vars/r/innodb_change_buffer_max_size_basic.result deleted file mode 100644 index 03f11ece3582e..0000000000000 --- a/mysql-test/suite/sys_vars/r/innodb_change_buffer_max_size_basic.result +++ /dev/null @@ -1,77 +0,0 @@ -SET @start_global_value = @@global.innodb_change_buffer_max_size; -SELECT @start_global_value; -@start_global_value -25 -Valid values are between 0 and 50 -select @@global.innodb_change_buffer_max_size between 0 and 50; -@@global.innodb_change_buffer_max_size between 0 and 50 -1 -select @@global.innodb_change_buffer_max_size; -@@global.innodb_change_buffer_max_size -25 -select @@session.innodb_change_buffer_max_size; -ERROR HY000: Variable 'innodb_change_buffer_max_size' is a GLOBAL variable -show global variables like 'innodb_change_buffer_max_size'; -Variable_name Value -innodb_change_buffer_max_size 25 -show session variables like 'innodb_change_buffer_max_size'; -Variable_name Value -innodb_change_buffer_max_size 25 -select * from information_schema.global_variables where variable_name='innodb_change_buffer_max_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFER_MAX_SIZE 25 -select * from information_schema.session_variables where variable_name='innodb_change_buffer_max_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFER_MAX_SIZE 25 -set global innodb_change_buffer_max_size=10; -select @@global.innodb_change_buffer_max_size; -@@global.innodb_change_buffer_max_size -10 -select * from information_schema.global_variables where variable_name='innodb_change_buffer_max_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFER_MAX_SIZE 10 -select * from information_schema.session_variables where variable_name='innodb_change_buffer_max_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFER_MAX_SIZE 10 -set session innodb_change_buffer_max_size=1; -ERROR HY000: Variable 'innodb_change_buffer_max_size' is a GLOBAL variable and should be set with SET GLOBAL -set global innodb_change_buffer_max_size=1.1; -ERROR 42000: Incorrect argument type to variable 'innodb_change_buffer_max_size' -set global innodb_change_buffer_max_size=1e1; -ERROR 42000: Incorrect argument type to variable 'innodb_change_buffer_max_size' -set global innodb_change_buffer_max_size="foo"; -ERROR 42000: Incorrect argument type to variable 'innodb_change_buffer_max_size' -set global innodb_change_buffer_max_size=-7; -Warnings: -Warning 1292 Truncated incorrect innodb_change_buffer_max_size value: '-7' -select @@global.innodb_change_buffer_max_size; -@@global.innodb_change_buffer_max_size -0 -select * from information_schema.global_variables where variable_name='innodb_change_buffer_max_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFER_MAX_SIZE 0 -set global innodb_change_buffer_max_size=56; -Warnings: -Warning 1292 Truncated incorrect innodb_change_buffer_max_size value: '56' -select @@global.innodb_change_buffer_max_size; -@@global.innodb_change_buffer_max_size -50 -select * from information_schema.global_variables where variable_name='innodb_change_buffer_max_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFER_MAX_SIZE 50 -set global innodb_change_buffer_max_size=0; -select @@global.innodb_change_buffer_max_size; -@@global.innodb_change_buffer_max_size -0 -set global innodb_change_buffer_max_size=50; -select @@global.innodb_change_buffer_max_size; -@@global.innodb_change_buffer_max_size -50 -set global innodb_change_buffer_max_size=DEFAULT; -select @@global.innodb_change_buffer_max_size; -@@global.innodb_change_buffer_max_size -25 -SET @@global.innodb_change_buffer_max_size = @start_global_value; -SELECT @@global.innodb_change_buffer_max_size; -@@global.innodb_change_buffer_max_size -25 diff --git a/mysql-test/suite/sys_vars/r/innodb_change_buffering_basic.result b/mysql-test/suite/sys_vars/r/innodb_change_buffering_basic.result deleted file mode 100644 index f3b7ac80523a2..0000000000000 --- a/mysql-test/suite/sys_vars/r/innodb_change_buffering_basic.result +++ /dev/null @@ -1,73 +0,0 @@ -SET @start_global_value = @@global.innodb_change_buffering; -SELECT @start_global_value; -@start_global_value -none -Valid values are 'all', 'deletes', 'changes', 'inserts', 'none', 'purges' -select @@global.innodb_change_buffering in ('all', 'deletes', 'changes', 'inserts', 'none', 'purges'); -@@global.innodb_change_buffering in ('all', 'deletes', 'changes', 'inserts', 'none', 'purges') -1 -select @@global.innodb_change_buffering; -@@global.innodb_change_buffering -none -select @@session.innodb_change_buffering; -ERROR HY000: Variable 'innodb_change_buffering' is a GLOBAL variable -show global variables like 'innodb_change_buffering'; -Variable_name Value -innodb_change_buffering none -show session variables like 'innodb_change_buffering'; -Variable_name Value -innodb_change_buffering none -select * from information_schema.global_variables where variable_name='innodb_change_buffering'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING none -select * from information_schema.session_variables where variable_name='innodb_change_buffering'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING none -set global innodb_change_buffering='none'; -Warnings: -Warning 1287 '@@innodb_change_buffering' is deprecated and will be removed in a future release -select @@global.innodb_change_buffering; -@@global.innodb_change_buffering -none -select * from information_schema.global_variables where variable_name='innodb_change_buffering'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING none -select * from information_schema.session_variables where variable_name='innodb_change_buffering'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING none -set @@global.innodb_change_buffering='inserts'; -Warnings: -Warning 1287 '@@innodb_change_buffering' is deprecated and will be removed in a future release -select @@global.innodb_change_buffering; -@@global.innodb_change_buffering -inserts -select * from information_schema.global_variables where variable_name='innodb_change_buffering'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING inserts -select * from information_schema.session_variables where variable_name='innodb_change_buffering'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING inserts -set session innodb_change_buffering='some'; -ERROR HY000: Variable 'innodb_change_buffering' is a GLOBAL variable and should be set with SET GLOBAL -set @@session.innodb_change_buffering='some'; -ERROR HY000: Variable 'innodb_change_buffering' is a GLOBAL variable and should be set with SET GLOBAL -set global innodb_change_buffering=1.1; -ERROR 42000: Incorrect argument type to variable 'innodb_change_buffering' -set global innodb_change_buffering=1; -Warnings: -Warning 1287 '@@innodb_change_buffering' is deprecated and will be removed in a future release -SELECT @@global.innodb_change_buffering; -@@global.innodb_change_buffering -inserts -set global innodb_change_buffering=-2; -ERROR 42000: Variable 'innodb_change_buffering' can't be set to the value of '-2' -set global innodb_change_buffering=1e1; -ERROR 42000: Incorrect argument type to variable 'innodb_change_buffering' -set global innodb_change_buffering='some'; -ERROR 42000: Variable 'innodb_change_buffering' can't be set to the value of 'some' -SET @@global.innodb_change_buffering = @start_global_value; -Warnings: -Warning 1287 '@@innodb_change_buffering' is deprecated and will be removed in a future release -SELECT @@global.innodb_change_buffering; -@@global.innodb_change_buffering -none diff --git a/mysql-test/suite/sys_vars/r/innodb_change_buffering_debug_basic.result b/mysql-test/suite/sys_vars/r/innodb_change_buffering_debug_basic.result deleted file mode 100644 index 2cb3fc76e3071..0000000000000 --- a/mysql-test/suite/sys_vars/r/innodb_change_buffering_debug_basic.result +++ /dev/null @@ -1,67 +0,0 @@ -SET @start_global_value = @@global.innodb_change_buffering_debug; -SELECT @start_global_value; -@start_global_value -0 -select @@global.innodb_change_buffering_debug in (0, 1); -@@global.innodb_change_buffering_debug in (0, 1) -1 -select @@global.innodb_change_buffering_debug; -@@global.innodb_change_buffering_debug -0 -select @@session.innodb_change_buffering_debug; -ERROR HY000: Variable 'innodb_change_buffering_debug' is a GLOBAL variable -show global variables like 'innodb_change_buffering_debug'; -Variable_name Value -innodb_change_buffering_debug 0 -show session variables like 'innodb_change_buffering_debug'; -Variable_name Value -innodb_change_buffering_debug 0 -select * from information_schema.global_variables where variable_name='innodb_change_buffering_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING_DEBUG 0 -select * from information_schema.session_variables where variable_name='innodb_change_buffering_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING_DEBUG 0 -set global innodb_change_buffering_debug=1; -select @@global.innodb_change_buffering_debug; -@@global.innodb_change_buffering_debug -1 -select * from information_schema.global_variables where variable_name='innodb_change_buffering_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING_DEBUG 1 -select * from information_schema.session_variables where variable_name='innodb_change_buffering_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING_DEBUG 1 -set @@global.innodb_change_buffering_debug=0; -select @@global.innodb_change_buffering_debug; -@@global.innodb_change_buffering_debug -0 -select * from information_schema.global_variables where variable_name='innodb_change_buffering_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING_DEBUG 0 -select * from information_schema.session_variables where variable_name='innodb_change_buffering_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_CHANGE_BUFFERING_DEBUG 0 -set session innodb_change_buffering_debug='some'; -ERROR HY000: Variable 'innodb_change_buffering_debug' is a GLOBAL variable and should be set with SET GLOBAL -set @@session.innodb_change_buffering_debug='some'; -ERROR HY000: Variable 'innodb_change_buffering_debug' is a GLOBAL variable and should be set with SET GLOBAL -set global innodb_change_buffering_debug=1.1; -ERROR 42000: Incorrect argument type to variable 'innodb_change_buffering_debug' -set global innodb_change_buffering_debug='foo'; -ERROR 42000: Incorrect argument type to variable 'innodb_change_buffering_debug' -set global innodb_change_buffering_debug=-2; -Warnings: -Warning 1292 Truncated incorrect innodb_change_buffering_debug value: '-2' -set global innodb_change_buffering_debug=1e1; -ERROR 42000: Incorrect argument type to variable 'innodb_change_buffering_debug' -set global innodb_change_buffering_debug=2; -Warnings: -Warning 1292 Truncated incorrect innodb_change_buffering_debug value: '2' -select @@global.innodb_change_buffering_debug; -@@global.innodb_change_buffering_debug -1 -SET @@global.innodb_change_buffering_debug = @start_global_value; -SELECT @@global.innodb_change_buffering_debug; -@@global.innodb_change_buffering_debug -0 diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 998d82587b6a0..53c02d962067d 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -223,54 +223,6 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL -VARIABLE_NAME INNODB_CHANGE_BUFFERING -SESSION_VALUE NULL -DEFAULT_VALUE none -VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE ENUM -VARIABLE_COMMENT Buffer changes to secondary indexes. -NUMERIC_MIN_VALUE NULL -NUMERIC_MAX_VALUE NULL -NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST none,inserts,deletes,changes,purges,all -READ_ONLY NO -COMMAND_LINE_ARGUMENT REQUIRED -VARIABLE_NAME INNODB_CHANGE_BUFFERING_DEBUG -SESSION_VALUE NULL -DEFAULT_VALUE 0 -VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE INT UNSIGNED -VARIABLE_COMMENT Debug flags for InnoDB change buffering (0=none, 1=try to buffer) -NUMERIC_MIN_VALUE 0 -NUMERIC_MAX_VALUE 1 -NUMERIC_BLOCK_SIZE 0 -ENUM_VALUE_LIST NULL -READ_ONLY NO -COMMAND_LINE_ARGUMENT REQUIRED -VARIABLE_NAME INNODB_CHANGE_BUFFER_DUMP -SESSION_VALUE NULL -DEFAULT_VALUE OFF -VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Dump the change buffer at startup. -NUMERIC_MIN_VALUE NULL -NUMERIC_MAX_VALUE NULL -NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST OFF,ON -READ_ONLY YES -COMMAND_LINE_ARGUMENT NONE -VARIABLE_NAME INNODB_CHANGE_BUFFER_MAX_SIZE -SESSION_VALUE NULL -DEFAULT_VALUE 25 -VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE INT UNSIGNED -VARIABLE_COMMENT Maximum on-disk size of change buffer in terms of percentage of the buffer pool. -NUMERIC_MIN_VALUE 0 -NUMERIC_MAX_VALUE 50 -NUMERIC_BLOCK_SIZE 0 -ENUM_VALUE_LIST NULL -READ_ONLY NO -COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_CHECKSUM_ALGORITHM SESSION_VALUE NULL DEFAULT_VALUE full_crc32 diff --git a/mysql-test/suite/sys_vars/t/innodb_change_buffer_max_size_basic.test b/mysql-test/suite/sys_vars/t/innodb_change_buffer_max_size_basic.test deleted file mode 100644 index 2094ef3dc0bb4..0000000000000 --- a/mysql-test/suite/sys_vars/t/innodb_change_buffer_max_size_basic.test +++ /dev/null @@ -1,71 +0,0 @@ - - -# 2011-02-09 - Added -# - ---source include/have_innodb.inc - -SET @start_global_value = @@global.innodb_change_buffer_max_size; -SELECT @start_global_value; - -# -# exists as global only -# ---echo Valid values are between 0 and 50 -select @@global.innodb_change_buffer_max_size between 0 and 50; -select @@global.innodb_change_buffer_max_size; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -select @@session.innodb_change_buffer_max_size; -show global variables like 'innodb_change_buffer_max_size'; -show session variables like 'innodb_change_buffer_max_size'; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffer_max_size'; -select * from information_schema.session_variables where variable_name='innodb_change_buffer_max_size'; ---enable_warnings - -# -# show that it's writable -# -set global innodb_change_buffer_max_size=10; -select @@global.innodb_change_buffer_max_size; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffer_max_size'; -select * from information_schema.session_variables where variable_name='innodb_change_buffer_max_size'; ---enable_warnings ---error ER_GLOBAL_VARIABLE -set session innodb_change_buffer_max_size=1; - -# -# incorrect types -# ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_change_buffer_max_size=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_change_buffer_max_size=1e1; ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_change_buffer_max_size="foo"; - -set global innodb_change_buffer_max_size=-7; -select @@global.innodb_change_buffer_max_size; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffer_max_size'; ---enable_warnings -set global innodb_change_buffer_max_size=56; -select @@global.innodb_change_buffer_max_size; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffer_max_size'; ---enable_warnings - -# -# min/max/DEFAULT values -# -set global innodb_change_buffer_max_size=0; -select @@global.innodb_change_buffer_max_size; -set global innodb_change_buffer_max_size=50; -select @@global.innodb_change_buffer_max_size; -set global innodb_change_buffer_max_size=DEFAULT; -select @@global.innodb_change_buffer_max_size; - - -SET @@global.innodb_change_buffer_max_size = @start_global_value; -SELECT @@global.innodb_change_buffer_max_size; diff --git a/mysql-test/suite/sys_vars/t/innodb_change_buffering_basic.test b/mysql-test/suite/sys_vars/t/innodb_change_buffering_basic.test deleted file mode 100644 index 19f0890feff4d..0000000000000 --- a/mysql-test/suite/sys_vars/t/innodb_change_buffering_basic.test +++ /dev/null @@ -1,65 +0,0 @@ - - -# 2010-01-25 - Added -# - ---source include/have_innodb.inc - -SET @start_global_value = @@global.innodb_change_buffering; -SELECT @start_global_value; - -# -# exists as global only -# ---echo Valid values are 'all', 'deletes', 'changes', 'inserts', 'none', 'purges' -select @@global.innodb_change_buffering in ('all', 'deletes', 'changes', 'inserts', 'none', 'purges'); -select @@global.innodb_change_buffering; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -select @@session.innodb_change_buffering; -show global variables like 'innodb_change_buffering'; -show session variables like 'innodb_change_buffering'; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffering'; -select * from information_schema.session_variables where variable_name='innodb_change_buffering'; ---enable_warnings - -# -# show that it's writable -# -set global innodb_change_buffering='none'; -select @@global.innodb_change_buffering; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffering'; -select * from information_schema.session_variables where variable_name='innodb_change_buffering'; ---enable_warnings -set @@global.innodb_change_buffering='inserts'; -select @@global.innodb_change_buffering; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffering'; -select * from information_schema.session_variables where variable_name='innodb_change_buffering'; ---enable_warnings ---error ER_GLOBAL_VARIABLE -set session innodb_change_buffering='some'; ---error ER_GLOBAL_VARIABLE -set @@session.innodb_change_buffering='some'; - -# -# incorrect types -# ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_change_buffering=1.1; -set global innodb_change_buffering=1; -SELECT @@global.innodb_change_buffering; ---error ER_WRONG_VALUE_FOR_VAR -set global innodb_change_buffering=-2; ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_change_buffering=1e1; ---error ER_WRONG_VALUE_FOR_VAR -set global innodb_change_buffering='some'; - -# -# Cleanup -# - -SET @@global.innodb_change_buffering = @start_global_value; -SELECT @@global.innodb_change_buffering; diff --git a/mysql-test/suite/sys_vars/t/innodb_change_buffering_debug_basic.test b/mysql-test/suite/sys_vars/t/innodb_change_buffering_debug_basic.test deleted file mode 100644 index 70f8bee152356..0000000000000 --- a/mysql-test/suite/sys_vars/t/innodb_change_buffering_debug_basic.test +++ /dev/null @@ -1,59 +0,0 @@ ---source include/have_innodb.inc ---source include/have_debug.inc - -SET @start_global_value = @@global.innodb_change_buffering_debug; -SELECT @start_global_value; - -# -# exists as global only -# -select @@global.innodb_change_buffering_debug in (0, 1); -select @@global.innodb_change_buffering_debug; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -select @@session.innodb_change_buffering_debug; -show global variables like 'innodb_change_buffering_debug'; -show session variables like 'innodb_change_buffering_debug'; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffering_debug'; -select * from information_schema.session_variables where variable_name='innodb_change_buffering_debug'; ---enable_warnings - -# -# show that it's writable -# -set global innodb_change_buffering_debug=1; -select @@global.innodb_change_buffering_debug; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffering_debug'; -select * from information_schema.session_variables where variable_name='innodb_change_buffering_debug'; ---enable_warnings -set @@global.innodb_change_buffering_debug=0; -select @@global.innodb_change_buffering_debug; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_change_buffering_debug'; -select * from information_schema.session_variables where variable_name='innodb_change_buffering_debug'; ---enable_warnings ---error ER_GLOBAL_VARIABLE -set session innodb_change_buffering_debug='some'; ---error ER_GLOBAL_VARIABLE -set @@session.innodb_change_buffering_debug='some'; - -# -# incorrect types -# ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_change_buffering_debug=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_change_buffering_debug='foo'; -set global innodb_change_buffering_debug=-2; ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_change_buffering_debug=1e1; -set global innodb_change_buffering_debug=2; -select @@global.innodb_change_buffering_debug; - -# -# Cleanup -# - -SET @@global.innodb_change_buffering_debug = @start_global_value; -SELECT @@global.innodb_change_buffering_debug; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index afc1ec543c224..93aa7380ad54e 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, 2022, MariaDB + Copyright (c) 2008, 2023, 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 @@ -5324,6 +5324,10 @@ static int init_server_components() MARIADB_REMOVED_OPTION("innodb-thread-concurrency"), MARIADB_REMOVED_OPTION("innodb-thread-sleep-delay"), MARIADB_REMOVED_OPTION("innodb-undo-logs"), + + /* The following options were deprecated in 10.9 */ + MARIADB_REMOVED_OPTION("innodb-change-buffering"), + {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; /* diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 49b363b76d359..848855b41e551 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -1,6 +1,6 @@ # Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2014, 2022, MariaDB Corporation. +# Copyright (c) 2014, 2023, 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 @@ -270,7 +270,6 @@ SET(INNOBASE_SOURCES include/handler0alter.h include/hash0hash.h include/ibuf0ibuf.h - include/ibuf0ibuf.inl include/lock0iter.h include/lock0lock.h include/lock0lock.inl diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 73d88596743f9..99cb135e019b7 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -2,7 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2014, 2022, MariaDB Corporation. +Copyright (c) 2014, 2023, 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 @@ -37,7 +37,6 @@ Created 6/2/1994 Heikki Tuuri #include "btr0defragment.h" #include "rem0cmp.h" #include "lock0lock.h" -#include "ibuf0ibuf.h" #include "trx0trx.h" #include "srv0mon.h" #include "gis0geo.h" @@ -181,9 +180,8 @@ we allocate pages for the non-leaf levels of the tree. @param block B-tree root page @param space tablespace @return whether the segment header is valid */ -static bool btr_root_fseg_validate(ulint offset, - const buf_block_t &block, - const fil_space_t &space) +bool btr_root_fseg_validate(ulint offset, const buf_block_t &block, + const fil_space_t &space) { ut_ad(block.page.id().space() == space.id); const uint16_t hdr= mach_read_from_2(offset + FSEG_HDR_OFFSET + @@ -213,12 +211,11 @@ ATTRIBUTE_COLD void btr_decryption_failed(const dict_index_t &index) @param[in] index index tree @param[in] page page number @param[in] mode latch mode -@param[in] merge whether change buffer merge should be attempted @param[in,out] mtr mini-transaction @param[out] err error code @return block */ buf_block_t *btr_block_get(const dict_index_t &index, - uint32_t page, ulint mode, bool merge, + uint32_t page, ulint mode, mtr_t *mtr, dberr_t *err) { dberr_t local_err; @@ -227,7 +224,7 @@ buf_block_t *btr_block_get(const dict_index_t &index, buf_block_t *block= buf_page_get_gen(page_id_t{index.table->space->id, page}, index.table->space->zip_size(), mode, nullptr, BUF_GET, - mtr, err, merge && !index.is_clust()); + mtr, err); ut_ad(!block == (*err != DB_SUCCESS)); if (UNIV_LIKELY(block != nullptr)) @@ -266,15 +263,13 @@ btr_root_block_get( return nullptr; } - buf_block_t *block = btr_block_get(*index, index->page, mode, false, mtr, - err); + buf_block_t *block = btr_block_get(*index, index->page, mode, mtr, err); if (block) { - if (index->is_ibuf()); - else if (!btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF, - *block, *index->table->space) || - !btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP, - *block, *index->table->space)) + if (!btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF, + *block, *index->table->space) || + !btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP, + *block, *index->table->space)) { *err= DB_CORRUPTION; block= nullptr; @@ -460,46 +455,13 @@ btr_page_create( } } -/**************************************************************//** -Allocates a new file page to be used in an ibuf tree. Takes the page from -the free list of the tree, which must contain pages! -@return new allocated block, x-latched */ -static -buf_block_t* -btr_page_alloc_for_ibuf( -/*====================*/ - dict_index_t* index, /*!< in: index tree */ - mtr_t* mtr, /*!< in: mtr */ - dberr_t* err) /*!< out: error code */ -{ - buf_block_t *root= btr_root_block_get(index, RW_SX_LATCH, mtr, err); - if (UNIV_UNLIKELY(!root)) - return root; - - buf_block_t *new_block= - buf_page_get_gen(page_id_t(index->table->space_id, - mach_read_from_4(PAGE_HEADER + - PAGE_BTR_IBUF_FREE_LIST + - FLST_FIRST + FIL_ADDR_PAGE + - root->page.frame)), - index->table->space->zip_size(), RW_X_LATCH, nullptr, - BUF_GET, mtr, err); - if (new_block) - *err= flst_remove(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, new_block, - PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, mtr); - ut_d(if (*err == DB_SUCCESS) - flst_validate(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, mtr)); - return new_block; -} - /**************************************************************//** Allocates a new file page to be used in an index tree. NOTE: we assume that the caller has made the reservation for free extents! @retval NULL if no page could be allocated */ -static MY_ATTRIBUTE((nonnull, warn_unused_result)) +MY_ATTRIBUTE((nonnull, warn_unused_result)) buf_block_t* -btr_page_alloc_low( -/*===============*/ +btr_page_alloc( dict_index_t* index, /*!< in: index */ uint32_t hint_page_no, /*!< in: hint of a good page */ byte file_direction, /*!< in: direction where a possible @@ -513,6 +475,8 @@ btr_page_alloc_low( page should be initialized. */ dberr_t* err) /*!< out: error code */ { + ut_ad(level < BTR_MAX_NODE_LEVEL); + const auto savepoint= mtr->get_savepoint(); buf_block_t *root= btr_root_block_get(index, RW_NO_LATCH, mtr, err); if (UNIV_UNLIKELY(!root)) @@ -540,57 +504,6 @@ btr_page_alloc_low( true, mtr, init_mtr, err); } -/**************************************************************//** -Allocates a new file page to be used in an index tree. NOTE: we assume -that the caller has made the reservation for free extents! -@retval NULL if no page could be allocated */ -buf_block_t* -btr_page_alloc( -/*===========*/ - dict_index_t* index, /*!< in: index */ - uint32_t hint_page_no, /*!< in: hint of a good page */ - byte file_direction, /*!< in: direction where a possible - page split is made */ - ulint level, /*!< in: level where the page is placed - in the tree */ - mtr_t* mtr, /*!< in/out: mini-transaction - for the allocation */ - mtr_t* init_mtr, /*!< in/out: mini-transaction - for x-latching and initializing - the page */ - dberr_t* err) /*!< out: error code */ -{ - ut_ad(level < BTR_MAX_NODE_LEVEL); - return index->is_ibuf() - ? btr_page_alloc_for_ibuf(index, mtr, err) - : btr_page_alloc_low(index, hint_page_no, file_direction, level, - mtr, init_mtr, err); -} - -/**************************************************************//** -Frees a page used in an ibuf tree. Puts the page to the free list of the -ibuf tree. */ -static -dberr_t -btr_page_free_for_ibuf( -/*===================*/ - dict_index_t* index, /*!< in: index tree */ - buf_block_t* block, /*!< in: block to be freed, x-latched */ - mtr_t* mtr) /*!< in: mtr */ -{ - ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); - - dberr_t err; - if (buf_block_t *root= btr_root_block_get(index, RW_SX_LATCH, mtr, &err)) - { - err= flst_add_first(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - block, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, mtr); - ut_d(if (err == DB_SUCCESS) - flst_validate(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, mtr)); - } - return err; -} - /** Free an index page. @param[in,out] index index tree @param[in,out] block block to be freed @@ -623,9 +536,6 @@ dberr_t btr_page_free(dict_index_t* index, buf_block_t* block, mtr_t* mtr, The page will be freed, so previous changes to it by this mini-transaction should not matter. */ - if (index->is_ibuf()) - return btr_page_free_for_ibuf(index, block, mtr); - fil_space_t *space= index->table->space; dberr_t err; @@ -708,8 +618,7 @@ btr_node_ptr_get_child( return btr_block_get( *index, btr_node_ptr_get_child_page_no(node_ptr, offsets), - RW_SX_LATCH, btr_page_get_level(page_align(node_ptr)) == 1, - mtr, err); + RW_SX_LATCH, mtr, err); } MY_ATTRIBUTE((nonnull(2,3,5), warn_unused_result)) @@ -930,77 +839,32 @@ btr_create( mtr_t* mtr, dberr_t* err) { - buf_block_t* block; - ut_ad(mtr->is_named_space(space)); ut_ad(index_id != BTR_FREED_INDEX_ID); ut_ad(index || space == fil_system.sys_space); - /* Create the two new segments (one, in the case of an ibuf tree) for - the index tree; the segment headers are put on the allocated root page - (for an ibuf tree, not in the root, but on a separate ibuf header - page) */ + /* Create the two new segments for the index tree; + the segment headers are put on the allocated root page */ - if (UNIV_UNLIKELY(type & DICT_IBUF)) { - /* Allocate first the ibuf header page */ - buf_block_t* ibuf_hdr_block = fseg_create( - space, IBUF_HEADER + IBUF_TREE_SEG_HEADER, mtr, err); + buf_block_t *block = fseg_create(space, PAGE_HEADER + PAGE_BTR_SEG_TOP, + mtr, err); - if (ibuf_hdr_block == NULL) { - return(FIL_NULL); - } - - ut_ad(ibuf_hdr_block->page.id().page_no() - == IBUF_HEADER_PAGE_NO); - /* Allocate then the next page to the segment: it will be the - tree root page */ - - block = fseg_alloc_free_page_general( - buf_block_get_frame(ibuf_hdr_block) - + IBUF_HEADER + IBUF_TREE_SEG_HEADER, - IBUF_TREE_ROOT_PAGE_NO, - FSP_UP, false, mtr, mtr, err); - - if (block == NULL) { - return(FIL_NULL); - } - - ut_ad(block->page.id() == page_id_t(0,IBUF_TREE_ROOT_PAGE_NO)); - - flst_init(block, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, mtr); - } else { - block = fseg_create(space, PAGE_HEADER + PAGE_BTR_SEG_TOP, - mtr, err); - - if (block == NULL) { - return(FIL_NULL); - } + if (!block) { + return FIL_NULL; + } - if (!fseg_create(space, PAGE_HEADER + PAGE_BTR_SEG_LEAF, mtr, - err, false, block)) { - /* Not enough space for new segment, free root - segment before return. */ - btr_free_root(block, *space, mtr); - return(FIL_NULL); - } + if (!fseg_create(space, PAGE_HEADER + PAGE_BTR_SEG_LEAF, mtr, + err, false, block)) { + /* Not enough space for new segment, free root + segment before return. */ + btr_free_root(block, *space, mtr); + return FIL_NULL; } ut_ad(!page_has_siblings(block->page.frame)); btr_root_page_init(block, index_id, index, mtr); - /* We reset the free bits for the page in a separate - mini-transaction to allow creation of several trees in the - same mtr, otherwise the latch on a bitmap page would prevent - it because of the latching order. - - Note: Insert Buffering is disabled for temporary tables given that - most temporary tables are smaller in size and short-lived. */ - if (!(type & DICT_CLUSTERED) - && (!index || !index->table->is_temporary())) { - ibuf_reset_free_bits(block); - } - /* In the following assertion we test that two records of maximum allowed size fit on the root page: this fact is needed to ensure correctness of split algorithms */ @@ -1152,7 +1016,7 @@ void btr_drop_temporary_table(const dict_table_t &table) { if (buf_block_t *block= buf_page_get_low({SRV_TMP_SPACE_ID, index->page}, 0, RW_X_LATCH, nullptr, BUF_GET, &mtr, - nullptr, false)) + nullptr)) { btr_free_but_not_root(block, MTR_LOG_NO_REDO); mtr.set_log_mode(MTR_LOG_NO_REDO); @@ -1323,18 +1187,18 @@ static dberr_t btr_page_reorganize_low(page_cur_t *cursor, mtr_t *mtr) if (page_get_max_trx_id(block->page.frame)) /* PAGE_MAX_TRX_ID must be zero on non-leaf pages other than clustered index root pages. */ - ut_ad(dict_index_is_sec_or_ibuf(cursor->index) + ut_ad(!cursor->index->is_primary() ? page_is_leaf(block->page.frame) : block->page.id().page_no() == cursor->index->page); else /* PAGE_MAX_TRX_ID is unused in clustered index pages (other than the root where it is repurposed as PAGE_ROOT_AUTO_INC), non-leaf pages, and in temporary tables. It was always zero-initialized in - page_create(). PAGE_MAX_TRX_ID must be nonzero on - dict_index_is_sec_or_ibuf() leaf pages. */ + page_create(). PAGE_MAX_TRX_ID must be nonzero on secondary index + leaf pages. */ ut_ad(cursor->index->table->is_temporary() || !page_is_leaf(block->page.frame) || - !dict_index_is_sec_or_ibuf(cursor->index)); + cursor->index->is_primary()); #endif const uint16_t data_size1= page_get_data_size(old->page.frame); @@ -1534,15 +1398,7 @@ static dberr_t btr_page_reorganize_low(page_cur_t *cursor, mtr_t *mtr) return DB_SUCCESS; } -/*************************************************************//** -Reorganizes an index page. - -IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE -if this is a compressed leaf page in a secondary index. This has to -be done either within the same mini-transaction, or by invoking -ibuf_reset_free_bits() before mtr_commit(). On uncompressed pages, -IBUF_BITMAP_FREE is unaffected by reorganization. - +/** Reorganize an index page. @return error code @retval DB_FAIL if reorganizing a ROW_FORMAT=COMPRESSED page failed */ dberr_t @@ -1561,15 +1417,7 @@ btr_page_reorganize_block( return btr_page_reorganize_low(&cur, mtr); } -/*************************************************************//** -Reorganizes an index page. - -IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE -if this is a compressed leaf page in a secondary index. This has to -be done either within the same mini-transaction, or by invoking -ibuf_reset_free_bits() before mtr_commit(). On uncompressed pages, -IBUF_BITMAP_FREE is unaffected by reorganization. - +/** Reorganize an index page. @param cursor page cursor @param mtr mini-transaction @return error code @@ -1800,6 +1648,7 @@ btr_root_raise_and_insert( ut_ad(!page_is_empty(root->page.frame)); index = btr_cur_get_index(cursor); ut_ad(index->n_core_null_bytes <= UT_BITS_IN_BYTES(index->n_nullable)); + ut_ad(!index->is_spatial()); #ifdef UNIV_ZIP_DEBUG ut_a(!root_page_zip || page_zip_validate(root_page_zip, root->page.frame, index)); @@ -1815,12 +1664,11 @@ btr_root_raise_and_insert( return nullptr; } - if (index->is_ibuf()) { - } else if (!btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF, - *root, *index->table->space) - || !btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP, - *root, *index->table->space)) { - return nullptr; + if (!btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF, + *root, *index->table->space) + || !btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP, + *root, *index->table->space)) { + return nullptr; } /* Allocate a new page to the tree. Root splitting is done by first @@ -1891,18 +1739,12 @@ btr_root_raise_and_insert( page_get_infimum_rec(root->page.frame)); } - /* Move any existing predicate locks */ - if (dict_index_is_spatial(index)) { - lock_prdt_rec_move(new_block, root_id); - } else { - btr_search_move_or_delete_hash_entries( - new_block, root); - } + btr_search_move_or_delete_hash_entries(new_block, root); } constexpr uint16_t max_trx_id = PAGE_HEADER + PAGE_MAX_TRX_ID; - if (dict_index_is_sec_or_ibuf(index)) { - /* In secondary indexes and the change buffer, + if (!index->is_primary()) { + /* In secondary indexes, PAGE_MAX_TRX_ID can be reset on the root page, because the field only matters on leaf pages, and the root no longer is a leaf page. (Older versions of InnoDB did @@ -1952,16 +1794,8 @@ btr_root_raise_and_insert( /* Build the node pointer (= node key and page address) for the child */ - if (dict_index_is_spatial(index)) { - rtr_mbr_t new_mbr; - - rtr_page_cal_mbr(index, new_block, &new_mbr, *heap); - node_ptr = rtr_index_build_node_ptr( - index, &new_mbr, rec, new_page_no, *heap); - } else { - node_ptr = dict_index_build_node_ptr( - index, rec, new_page_no, *heap, level); - } + node_ptr = dict_index_build_node_ptr(index, rec, new_page_no, *heap, + level); /* The node pointer must be marked as the predefined minimum record, as there is no lower alphabetical limit to records in the leftmost node of a level: */ @@ -1994,13 +1828,6 @@ btr_root_raise_and_insert( to new_block at this point. Thus, the data should fit. */ ut_a(node_ptr_rec); - /* We play safe and reset the free bits for the new page */ - - if (!dict_index_is_clust(index) - && !index->table->is_temporary()) { - ibuf_reset_free_bits(new_block); - } - page_cursor->block = new_block; page_cursor->index = index; @@ -2479,11 +2306,11 @@ btr_attach_half_pages( /* for consistency, both blocks should be locked, before change */ if (prev_page_no != FIL_NULL && direction == FSP_DOWN) { prev_block = btr_block_get(*index, prev_page_no, RW_X_LATCH, - !level, mtr); + mtr); } if (next_page_no != FIL_NULL && direction != FSP_DOWN) { next_block = btr_block_get(*index, next_page_no, RW_X_LATCH, - !level, mtr); + mtr); } /* Build the node pointer (= node key and page address) for the upper @@ -2629,10 +2456,9 @@ btr_insert_into_right_sibling( page_t* next_page; btr_cur_t next_father_cursor; rec_t* rec = nullptr; - ulint max_size; next_block = btr_block_get(*cursor->index(), next_page_no, RW_X_LATCH, - page_is_leaf(page), mtr); + mtr); if (UNIV_UNLIKELY(!next_block)) { return nullptr; } @@ -2655,8 +2481,6 @@ btr_insert_into_right_sibling( return nullptr; } - max_size = page_get_max_insert_size_after_reorganize(next_page, 1); - /* Extends gap lock for the next page */ if (is_leaf && cursor->index()->has_locking()) { lock_update_node_pointer(block, next_block); @@ -2666,15 +2490,6 @@ btr_insert_into_right_sibling( n_ext, mtr); if (!rec) { - if (is_leaf - && next_block->page.zip.ssize - && !dict_index_is_clust(cursor->index()) - && !cursor->index()->table->is_temporary()) { - /* Reset the IBUF_BITMAP_FREE bits, because - page_cur_tuple_insert() will have attempted page - reorganize before failing. */ - ibuf_reset_free_bits(next_block); - } return nullptr; } @@ -2712,34 +2527,12 @@ btr_insert_into_right_sibling( } ut_ad(rec_offs_validate(rec, cursor->index(), *offsets)); - - if (is_leaf - && !dict_index_is_clust(cursor->index()) - && !cursor->index()->table->is_temporary()) { - /* Update the free bits of the B-tree page in the - insert buffer bitmap. */ - - if (next_block->page.zip.ssize) { - ibuf_update_free_bits_zip(next_block, mtr); - } else { - ibuf_update_free_bits_if_full( - next_block, max_size, - rec_offs_size(*offsets) + PAGE_DIR_SLOT_SIZE); - } - } - return(rec); } /*************************************************************//** Moves record list end to another page. Moved records include split_rec. - -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if new_block is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return error code */ static dberr_t @@ -2795,12 +2588,6 @@ page_move_rec_list_end( /*************************************************************//** Moves record list start to another page. Moved records do not include split_rec. - -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if new_block is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return error code */ static dberr_t @@ -2858,12 +2645,7 @@ btr_page_split_and_insert( ut_ad(*err == DB_SUCCESS); ut_ad(dtuple_check_typed(tuple)); - - if (cursor->index()->is_spatial()) { - /* Split rtree page and update parent */ - return rtr_page_split_and_insert(flags, cursor, offsets, heap, - tuple, n_ext, mtr, err); - } + ut_ad(!cursor->index()->is_spatial()); if (!*heap) { *heap = mem_heap_create(1024); @@ -3228,13 +3010,6 @@ btr_page_split_and_insert( /* The insert did not fit on the page: loop back to the start of the function for a new split */ insert_failed: - /* We play safe and reset the free bits for new_page */ - if (!dict_index_is_clust(page_cursor->index) - && !page_cursor->index->table->is_temporary()) { - ibuf_reset_free_bits(new_block); - ibuf_reset_free_bits(block); - } - n_iterations++; ut_ad(n_iterations < 2 || buf_block_get_page_zip(insert_block)); @@ -3244,17 +3019,6 @@ btr_page_split_and_insert( } func_exit: - /* Insert fit on the page: update the free bits for the - left and right pages in the same mtr */ - - if (!dict_index_is_clust(page_cursor->index) - && !page_cursor->index->table->is_temporary() - && page_is_leaf(page)) { - - ibuf_update_free_bits_for_two_pages_low( - left_block, right_block, mtr); - } - MONITOR_INC(MONITOR_INDEX_SPLIT); ut_ad(page_validate(buf_block_get_frame(left_block), @@ -3287,8 +3051,7 @@ dberr_t btr_level_list_remove(const buf_block_t& block, if (prev_page_no != FIL_NULL) { buf_block_t* prev_block = btr_block_get( - index, prev_page_no, RW_X_LATCH, page_is_leaf(page), - mtr, &err); + index, prev_page_no, RW_X_LATCH, mtr, &err); if (UNIV_UNLIKELY(!prev_block)) { return err; } @@ -3303,8 +3066,7 @@ dberr_t btr_level_list_remove(const buf_block_t& block, if (next_page_no != FIL_NULL) { buf_block_t* next_block = btr_block_get( - index, next_page_no, RW_X_LATCH, page_is_leaf(page), - mtr, &err); + index, next_page_no, RW_X_LATCH, mtr, &err); if (UNIV_UNLIKELY(!next_block)) { return err; @@ -3332,6 +3094,7 @@ btr_lift_page_up( must not be empty: use btr_discard_only_page_on_level if the last record from the page should be removed */ + que_thr_t* thr, /*!< in/out: query thread */ mtr_t* mtr, /*!< in/out: mini-transaction */ dberr_t* err) /*!< out: error code */ { @@ -3366,7 +3129,8 @@ btr_lift_page_up( if (index->is_spatial()) { offsets = rtr_page_get_father_block( - nullptr, heap, mtr, nullptr, &cursor); + nullptr, heap, nullptr, &cursor, + thr, mtr); } else { offsets = btr_page_get_father_block(offsets, heap, mtr, &cursor); @@ -3387,7 +3151,8 @@ btr_lift_page_up( if (index->is_spatial()) { offsets = rtr_page_get_father_block( - nullptr, heap, mtr, nullptr, &cursor); + nullptr, heap, nullptr, &cursor, thr, + mtr); } else { offsets = btr_page_get_father_block(offsets, heap, @@ -3518,13 +3283,8 @@ btr_lift_page_up( /* Free the file page */ btr_page_free(index, block, mtr); - /* We play it safe and reset the free bits for the father */ - if (!dict_index_is_clust(index) - && !index->table->is_temporary()) { - ibuf_reset_free_bits(father_block); - } ut_ad(page_validate(father_block->page.frame, index)); - ut_ad(btr_check_node_ptr(index, father_block, mtr)); + ut_ad(btr_check_node_ptr(index, father_block, thr, mtr)); return(lift_father_up ? block_orig : father_block); } @@ -3591,8 +3351,10 @@ btr_compress( father_cursor.page_cur.block = block; if (index->is_spatial()) { + ut_ad(cursor->rtr_info); offsets = rtr_page_get_father_block( - NULL, heap, mtr, cursor, &father_cursor); + nullptr, heap, cursor, &father_cursor, + cursor->rtr_info->thr, mtr); ut_ad(cursor->page_cur.block->page.id() == block->page.id()); rec_t* my_rec = father_cursor.page_cur.rec; @@ -3602,10 +3364,10 @@ btr_compress( ib::info() << "father positioned on page " << page_no << "instead of " << block->page.id().page_no(); - offsets = btr_page_get_father_block( - NULL, heap, mtr, &father_cursor); + goto get_offsets; } } else { +get_offsets: offsets = btr_page_get_father_block( NULL, heap, mtr, &father_cursor); } @@ -3615,14 +3377,7 @@ btr_compress( if (UNIV_UNLIKELY(!nth_rec || nth_rec == ULINT_UNDEFINED)) { corrupted: err = DB_CORRUPTION; - err_exit: - /* We play it safe and reset the free bits. */ - if (merge_block && merge_block->zip_size() - && page_is_leaf(merge_block->page.frame) - && !index->is_clust()) { - ibuf_reset_free_bits(merge_block); - } - goto func_exit; + goto err_exit; } } @@ -3630,7 +3385,10 @@ btr_compress( /* The page is the only one on the level, lift the records to the father */ - merge_block = btr_lift_page_up(index, block, mtr, &err); + merge_block = btr_lift_page_up(index, block, + cursor->rtr_info + ? cursor->rtr_info->thr + : nullptr, mtr, &err); success: if (adjust) { ut_ad(nth_rec > 0); @@ -3645,7 +3403,7 @@ btr_compress( } MONITOR_INC(MONITOR_INDEX_MERGE_SUCCESSFUL); -func_exit: +err_exit: mem_heap_free(heap); DBUG_RETURN(err); } @@ -3945,49 +3703,6 @@ btr_compress( } } - if (!dict_index_is_clust(index) - && !index->table->is_temporary() - && page_is_leaf(merge_page)) { - /* Update the free bits of the B-tree page in the - insert buffer bitmap. This has to be done in a - separate mini-transaction that is committed before the - main mini-transaction. We cannot update the insert - buffer bitmap in this mini-transaction, because - btr_compress() can be invoked recursively without - committing the mini-transaction in between. Since - insert buffer bitmap pages have a lower rank than - B-tree pages, we must not access other pages in the - same mini-transaction after accessing an insert buffer - bitmap page. */ - - /* The free bits in the insert buffer bitmap must - never exceed the free space on a page. It is safe to - decrement or reset the bits in the bitmap in a - mini-transaction that is committed before the - mini-transaction that affects the free space. */ - - /* It is unsafe to increment the bits in a separately - committed mini-transaction, because in crash recovery, - the free bits could momentarily be set too high. */ - - if (merge_block->zip_size()) { - /* Because the free bits may be incremented - and we cannot update the insert buffer bitmap - in the same mini-transaction, the only safe - thing we can do here is the pessimistic - approach: reset the free bits. */ - ibuf_reset_free_bits(merge_block); - } else { - /* On uncompressed pages, the free bits will - never increase here. Thus, it is safe to - write the bits accurately in a separate - mini-transaction. */ - ibuf_update_free_bits_if_full(merge_block, - srv_page_size, - ULINT_UNDEFINED); - } - } - ut_ad(page_validate(merge_page, index)); #ifdef UNIV_ZIP_DEBUG ut_a(!merge_page_zip || page_zip_validate(merge_page_zip, merge_page, @@ -4002,7 +3717,10 @@ btr_compress( err = btr_page_free(index, block, mtr); if (err == DB_SUCCESS) { ut_ad(leftmost_child - || btr_check_node_ptr(index, merge_block, mtr)); + || btr_check_node_ptr(index, merge_block, + cursor->rtr_info + ? cursor->rtr_info->thr + : nullptr, mtr)); goto success; } else { goto err_exit; @@ -4019,11 +3737,13 @@ static void btr_discard_only_page_on_level( /*===========================*/ - dict_index_t* index, /*!< in: index tree */ - buf_block_t* block, /*!< in: page which is the only on its level */ + btr_cur_t* cur, /*!< in: cursor on a page which is the + only on its level */ mtr_t* mtr) /*!< in: mtr */ { - ulint page_level = 0; + dict_index_t* index = cur->index(); + buf_block_t* block = btr_cur_get_block(cur); + ulint page_level = 0; ut_ad(!index->is_dummy); @@ -4054,7 +3774,8 @@ btr_discard_only_page_on_level( if (index->is_spatial()) { /* Check any concurrent search having this page */ rtr_check_discard_page(index, NULL, block); - if (!rtr_page_get_father(mtr, nullptr, &cursor)) { + if (!rtr_page_get_father(mtr, nullptr, &cursor, + cur->rtr_info->thr)) { return; } } else { @@ -4120,9 +3841,6 @@ btr_discard_only_page_on_level( index->clear_instant_add(); } } else if (!index->table->is_temporary()) { - /* We play it safe and reset the free bits for the root */ - ibuf_reset_free_bits(block); - ut_a(max_trx_id); page_set_max_trx_id(block, buf_block_get_page_zip(block), @@ -4159,7 +3877,8 @@ btr_discard_page( MONITOR_INC(MONITOR_INDEX_DISCARD); if (index->is_spatial() - ? !rtr_page_get_father(mtr, cursor, &parent_cursor) + ? !rtr_page_get_father(mtr, cursor, &parent_cursor, + cursor->rtr_info->thr) : !btr_page_get_father(mtr, &parent_cursor)) { return DB_CORRUPTION; } @@ -4173,7 +3892,7 @@ btr_discard_page( if (left_page_no != FIL_NULL) { dberr_t err; merge_block = btr_block_get(*index, left_page_no, RW_X_LATCH, - true, mtr, &err); + mtr, &err); if (UNIV_UNLIKELY(!merge_block)) { return err; } @@ -4194,7 +3913,7 @@ btr_discard_page( } else if (right_page_no != FIL_NULL) { dberr_t err; merge_block = btr_block_get(*index, right_page_no, RW_X_LATCH, - true, mtr, &err); + mtr, &err); if (UNIV_UNLIKELY(!merge_block)) { return err; } @@ -4220,7 +3939,7 @@ btr_discard_page( return DB_CORRUPTION; } } else { - btr_discard_only_page_on_level(index, block, mtr); + btr_discard_only_page_on_level(cursor, mtr); return DB_SUCCESS; } @@ -4278,14 +3997,20 @@ btr_discard_page( If the merge_block's parent block is not same, we cannot use btr_check_node_ptr() */ ut_ad(parent_is_different - || btr_check_node_ptr(index, merge_block, mtr)); + || btr_check_node_ptr(index, merge_block, + cursor->rtr_info + ? cursor->rtr_info->thr + : nullptr, mtr)); if (btr_cur_get_block(&parent_cursor)->page.id().page_no() == index->page && !page_has_siblings(btr_cur_get_page(&parent_cursor)) && page_get_n_recs(btr_cur_get_page(&parent_cursor)) == 1) { - btr_lift_page_up(index, merge_block, mtr, &err); + btr_lift_page_up(index, merge_block, + cursor->rtr_info + ? cursor->rtr_info->thr + : nullptr, mtr, &err); } } @@ -4304,13 +4029,6 @@ btr_print_size( fseg_header_t* seg; mtr_t mtr; - if (dict_index_is_ibuf(index)) { - fputs("Sorry, cannot print info of an ibuf tree:" - " use ibuf functions\n", stderr); - - return; - } - mtr_start(&mtr); root = btr_root_get(index, &mtr); @@ -4320,13 +4038,10 @@ btr_print_size( fputs("INFO OF THE NON-LEAF PAGE SEGMENT\n", stderr); fseg_print(seg, &mtr); - if (!dict_index_is_ibuf(index)) { - - seg = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; + seg = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; - fputs("INFO OF THE LEAF PAGE SEGMENT\n", stderr); - fseg_print(seg, &mtr); - } + fputs("INFO OF THE LEAF PAGE SEGMENT\n", stderr); + fseg_print(seg, &mtr); mtr_commit(&mtr); } @@ -4437,6 +4152,7 @@ btr_check_node_ptr( /*===============*/ dict_index_t* index, /*!< in: index tree */ buf_block_t* block, /*!< in: index page */ + que_thr_t* thr, /*!< in/out: query thread */ mtr_t* mtr) /*!< in: mtr */ { mem_heap_t* heap; @@ -4458,8 +4174,8 @@ btr_check_node_ptr( heap = mem_heap_create(256); if (dict_index_is_spatial(index)) { - offsets = rtr_page_get_father_block(NULL, heap, mtr, - NULL, &cursor); + offsets = rtr_page_get_father_block(NULL, heap, + NULL, &cursor, thr, mtr); } else { offsets = btr_page_get_father_block(NULL, heap, mtr, &cursor); } @@ -4532,14 +4248,6 @@ btr_index_rec_validate( ut_ad(index->n_core_fields); - if (index->is_ibuf()) { - /* The insert buffer index tree can contain records from any - other index: we cannot check the number of fields or - their length */ - - return(TRUE); - } - #ifdef VIRTUAL_INDEX_DEBUG if (dict_index_has_virtual(index)) { fprintf(stderr, "index name is %s\n", index->name()); @@ -4882,8 +4590,7 @@ btr_validate_level( savepoint2 = mtr_set_savepoint(&mtr); block = btr_block_get(*index, left_page_no, - RW_SX_LATCH, false, - &mtr, &err); + RW_SX_LATCH, &mtr, &err); if (!block) { goto invalid_page; } @@ -4961,7 +4668,7 @@ btr_validate_level( savepoint = mtr_set_savepoint(&mtr); right_block = btr_block_get(*index, right_page_no, RW_SX_LATCH, - !level, &mtr, &err); + &mtr, &err); if (!right_block) { btr_validate_report1(index, level, block); fputs("InnoDB: broken FIL_PAGE_NEXT link\n", stderr); @@ -5158,15 +4865,13 @@ btr_validate_level( if (parent_right_page_no != FIL_NULL) { btr_block_get(*index, parent_right_page_no, - RW_SX_LATCH, false, - &mtr); + RW_SX_LATCH, &mtr); } right_block = btr_block_get(*index, right_page_no, RW_SX_LATCH, - !level, &mtr, - &err); + &mtr, &err); if (!right_block) { btr_validate_report1(index, level, block); @@ -5252,17 +4957,16 @@ btr_validate_level( if (parent_right_page_no != FIL_NULL) { btr_block_get(*index, parent_right_page_no, - RW_SX_LATCH, false, - &mtr); + RW_SX_LATCH, &mtr); } } else if (parent_page_no != FIL_NULL) { btr_block_get(*index, parent_page_no, - RW_SX_LATCH, false, &mtr); + RW_SX_LATCH, &mtr); } } block = btr_block_get(*index, right_page_no, RW_SX_LATCH, - !level, &mtr, &err); + &mtr, &err); goto loop; } @@ -5334,8 +5038,7 @@ btr_can_merge_with_page( index = btr_cur_get_index(cursor); page = btr_cur_get_page(cursor); - mblock = btr_block_get(*index, page_no, RW_X_LATCH, page_is_leaf(page), - mtr); + mblock = btr_block_get(*index, page_no, RW_X_LATCH, mtr); if (!mblock) { goto error; } diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index 013cd13102cd8..3c5b4b293f20c 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2014, 2019, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -28,7 +28,6 @@ Created 03/11/2014 Shaohua Wang #include "btr0btr.h" #include "btr0cur.h" #include "btr0pcur.h" -#include "ibuf0ibuf.h" #include "page0page.h" #include "trx0trx.h" @@ -107,7 +106,7 @@ PageBulk::init() } } else { new_block = btr_block_get(*m_index, m_page_no, RW_X_LATCH, - false, &m_mtr); + &m_mtr); if (!new_block) { m_mtr.commit(); return(DB_CORRUPTION); @@ -122,7 +121,7 @@ PageBulk::init() m_page_zip = buf_block_get_page_zip(new_block); - if (!m_level && dict_index_is_sec_or_ibuf(m_index)) { + if (!m_level && !m_index->is_primary()) { page_update_max_trx_id(new_block, m_page_zip, m_trx_id, &m_mtr); } @@ -563,9 +562,6 @@ inline void PageBulk::finish() void PageBulk::commit(bool success) { finish(); - if (success && !m_index->is_clust() && page_is_leaf(m_page)) - ibuf_set_bitmap_for_bulk_load(m_block, &m_mtr, - innobase_fill_factor == 100); m_mtr.commit(); } @@ -1194,7 +1190,7 @@ BtrBulk::finish(dberr_t err) ut_ad(last_page_no != FIL_NULL); last_block = btr_block_get(*m_index, last_page_no, RW_X_LATCH, - false, &mtr); + &mtr); if (!last_block) { err = DB_CORRUPTION; err_exit: diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 2f237bb595725..a4260c7f11120 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -3,7 +3,7 @@ Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2015, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -61,7 +61,6 @@ Created 10/16/1994 Heikki Tuuri #include "que0que.h" #include "row0row.h" #include "srv0srv.h" -#include "ibuf0ibuf.h" #include "lock0lock.h" #include "zlib.h" #include "srv0start.h" @@ -73,15 +72,6 @@ Created 10/16/1994 Heikki Tuuri #endif /* WITH_WSREP */ #include "log.h" -/** Buffered B-tree operation types, introduced as part of delete buffering. */ -enum btr_op_t { - BTR_NO_OP = 0, /*!< Not buffered */ - BTR_INSERT_OP, /*!< Insert, do not ignore UNIQUE */ - BTR_INSERT_IGNORE_UNIQUE_OP, /*!< Insert, ignoring UNIQUE */ - BTR_DELETE_OP, /*!< Purge a delete-marked record */ - BTR_DELMARK_OP /*!< Mark a record for deletion */ -}; - /** Modification types for the B-tree operation. Note that the order must be DELETE, BOTH, INSERT !! */ @@ -259,7 +249,7 @@ btr_cur_latch_leaves( if (left_page_no != FIL_NULL) { buf_block_t *b = btr_block_get( *cursor->index(), left_page_no, RW_X_LATCH, - true, mtr); + mtr); if (latch_leaves) { latch_leaves->savepoints[0] = save; @@ -300,7 +290,7 @@ btr_cur_latch_leaves( buf_block_t* b = btr_block_get( *cursor->index(), right_page_no, RW_X_LATCH, - true, mtr); + mtr); if (latch_leaves) { latch_leaves->savepoints[2] = save; latch_leaves->blocks[2] = b; @@ -331,8 +321,7 @@ btr_cur_latch_leaves( if (left_page_no != FIL_NULL) { save = mtr->get_savepoint(); cursor->left_block = btr_block_get( - *cursor->index(), left_page_no, - mode, true, mtr); + *cursor->index(), left_page_no, mode, mtr); if (latch_leaves) { latch_leaves->savepoints[0] = save; latch_leaves->blocks[0] = cursor->left_block; @@ -341,7 +330,8 @@ btr_cur_latch_leaves( goto latch_block; case BTR_CONT_MODIFY_TREE: - ut_ad(cursor->index()->is_spatial()); + ut_ad(cursor->index()->is_dummy + || cursor->index()->is_spatial()); return; } @@ -758,7 +748,7 @@ btr_cur_optimistic_latch_leaves( return(buf_page_optimistic_get(*latch_mode, block, modify_clock, mtr)); case BTR_SEARCH_PREV: /* btr_pcur_move_backward_from_page() */ - case BTR_MODIFY_PREV: /* Ditto, or ibuf_insert() */ + case BTR_MODIFY_PREV: /* Ditto */ uint32_t curr_page_no, left_page_no; { transactional_shared_lock_guard g{ @@ -1063,20 +1053,6 @@ btr_cur_need_opposite_intention( @return maximum size of a node pointer record in bytes */ static ulint btr_node_ptr_max_size(const dict_index_t* index) { - if (dict_index_is_ibuf(index)) { - /* cannot estimate accurately */ - /* This is universal index for change buffer. - The max size of the entry is about max key length * 2. - (index key + primary key to be inserted to the index) - (The max key length is UNIV_PAGE_SIZE / 16 * 3 at - ha_innobase::max_supported_key_length(), - considering MAX_KEY_LENGTH = 3072 at MySQL imposes - the 3500 historical InnoDB value for 16K page size case.) - For the universal index, node_ptr contains most of the entry. - And 512 is enough to contain ibuf columns and meta-data */ - return srv_page_size / 8 * 3 + 512; - } - /* Each record has page_no, length of page_no and header. */ ulint comp = dict_table_is_comp(index->table); ulint rec_max_size = comp @@ -1245,10 +1221,8 @@ dberr_t btr_cur_search_to_nth_level(ulint level, ulint rw_latch; page_cur_mode_t page_mode; page_cur_mode_t search_mode = PAGE_CUR_UNSUPP; - ulint buf_mode; ulint node_ptr_max_size = srv_page_size / 2; page_cur_t* page_cursor; - btr_op_t btr_op; ulint root_height = 0; /* remove warning */ btr_intention_t lock_intention; @@ -1287,7 +1261,6 @@ dberr_t btr_cur_search_to_nth_level(ulint level, ut_ad(level == 0 || mode == PAGE_CUR_LE || RTREE_SEARCH_MODE(mode)); ut_ad(dict_index_check_search_tuple(index, tuple)); - ut_ad(!dict_index_is_ibuf(index) || ibuf_inside(mtr)); ut_ad(dtuple_check_typed(tuple)); ut_ad(!(index->type & DICT_FTS)); ut_ad(index->page != FIL_NULL); @@ -1308,36 +1281,6 @@ dberr_t btr_cur_search_to_nth_level(ulint level, || mtr->memo_contains_flagged(&index->lock, MTR_MEMO_S_LOCK | MTR_MEMO_SX_LOCK)); - /* These flags are mutually exclusive, they are lumped together - with the latch mode for historical reasons. It's possible for - none of the flags to be set. */ - switch (UNIV_EXPECT(latch_mode & BTR_DELETE, 0)) { - default: - btr_op = BTR_NO_OP; - break; - case BTR_INSERT: - btr_op = (latch_mode & BTR_IGNORE_SEC_UNIQUE) - ? BTR_INSERT_IGNORE_UNIQUE_OP - : BTR_INSERT_OP; - break; - case BTR_DELETE: - btr_op = BTR_DELETE_OP; - ut_a(cursor->purge_node); - break; - case BTR_DELETE_MARK: - btr_op = BTR_DELMARK_OP; - break; - } - - /* Operations on the insert buffer tree cannot be buffered. */ - ut_ad(btr_op == BTR_NO_OP || !dict_index_is_ibuf(index)); - /* Operations on the clustered index cannot be buffered. */ - ut_ad(btr_op == BTR_NO_OP || !dict_index_is_clust(index)); - /* Operations on the temporary table(indexes) cannot be buffered. */ - ut_ad(btr_op == BTR_NO_OP || !index->table->is_temporary()); - /* Operation on the spatial index cannot be buffered. */ - ut_ad(btr_op == BTR_NO_OP || !dict_index_is_spatial(index)); - lock_intention = btr_cur_get_and_clear_intention(&latch_mode); /* Turn the flags unrelated to the latch mode off. */ @@ -1512,7 +1455,6 @@ dberr_t btr_cur_search_to_nth_level(ulint level, btr_latch_leaves_t latch_leaves = {{NULL, NULL, NULL}, {0, 0, 0}}; search_loop: - buf_mode = BUF_GET; rw_latch = RW_NO_LATCH; rtree_parent_modified = false; @@ -1534,108 +1476,16 @@ dberr_t btr_cur_search_to_nth_level(ulint level, } } else if (latch_mode <= BTR_MODIFY_LEAF) { rw_latch = latch_mode; - - if (btr_op != BTR_NO_OP - && ibuf_should_try(index, btr_op != BTR_INSERT_OP)) { - - /* Try to buffer the operation if the leaf - page is not in the buffer pool. */ - - buf_mode = btr_op == BTR_DELETE_OP - ? BUF_GET_IF_IN_POOL_OR_WATCH - : BUF_GET_IF_IN_POOL; - } } -retry_page_get: ut_ad(n_blocks < BTR_MAX_LEVELS); tree_savepoints[n_blocks] = mtr_set_savepoint(mtr); dberr_t err; block = buf_page_get_gen(page_id, zip_size, rw_latch, guess, - buf_mode, mtr, &err, - height == 0 && !index->is_clust()); - if (!block) { - switch (err) { - case DB_SUCCESS: - /* change buffering */ - break; - case DB_DECRYPTION_FAILED: - btr_decryption_failed(*index); - /* fall through */ - default: - goto func_exit; - } - - /* This must be a search to perform an insert/delete - mark/ delete; try using the insert/delete buffer */ - - ut_ad(height == 0); - ut_ad(cursor->thr); - - switch (btr_op) { - default: - MY_ASSERT_UNREACHABLE(); - break; - case BTR_INSERT_OP: - case BTR_INSERT_IGNORE_UNIQUE_OP: - ut_ad(buf_mode == BUF_GET_IF_IN_POOL); - - if (ibuf_insert(IBUF_OP_INSERT, tuple, index, - page_id, zip_size, cursor->thr)) { - - cursor->flag = BTR_CUR_INSERT_TO_IBUF; - - goto func_exit; - } - break; - - case BTR_DELMARK_OP: - ut_ad(buf_mode == BUF_GET_IF_IN_POOL); - - if (ibuf_insert(IBUF_OP_DELETE_MARK, tuple, - index, page_id, zip_size, - cursor->thr)) { - - cursor->flag = BTR_CUR_DEL_MARK_IBUF; + BUF_GET, mtr, &err); - goto func_exit; - } - - break; - - case BTR_DELETE_OP: - ut_ad(buf_mode == BUF_GET_IF_IN_POOL_OR_WATCH); - ut_ad(index->is_btree()); - auto& chain = buf_pool.page_hash.cell_get( - page_id.fold()); - - if (!row_purge_poss_sec(cursor->purge_node, - index, tuple)) { - - /* The record cannot be purged yet. */ - cursor->flag = BTR_CUR_DELETE_REF; - } else if (ibuf_insert(IBUF_OP_DELETE, tuple, - index, page_id, zip_size, - cursor->thr)) { - - /* The purge was buffered. */ - cursor->flag = BTR_CUR_DELETE_IBUF; - } else { - /* The purge could not be buffered. */ - buf_pool.watch_unset(page_id, chain); - break; - } - - buf_pool.watch_unset(page_id, chain); - goto func_exit; - } - - /* Insert to the insert/delete buffer did not succeed, we - must read the page from disk. */ - - buf_mode = BUF_GET; - - goto retry_page_get; + if (!block) { + goto func_exit; } tree_blocks[n_blocks] = block; @@ -1658,7 +1508,7 @@ dberr_t btr_cur_search_to_nth_level(ulint level, = mtr_set_savepoint(mtr); buf_block_t* get_block = buf_page_get_gen( page_id_t(page_id.space(), left_page_no), - zip_size, rw_latch, NULL, buf_mode, + zip_size, rw_latch, NULL, BUF_GET, mtr, &err); if (!get_block) { if (err == DB_DECRYPTION_FAILED) { @@ -1729,7 +1579,6 @@ dberr_t btr_cur_search_to_nth_level(ulint level, } /* Save the MBR */ - cursor->rtr_info->thr = cursor->thr; rtr_get_mbr_from_tuple(tuple, &cursor->rtr_info->mbr); } @@ -1902,15 +1751,16 @@ dberr_t btr_cur_search_to_nth_level(ulint level, /* Add Predicate lock if it is serializable isolation and only if it is in the search case */ - if (dict_index_is_spatial(index) + if (index->is_spatial() && cursor->rtr_info->need_prdt_lock + && mode >= PAGE_CUR_CONTAIN && mode != PAGE_CUR_RTREE_INSERT - && mode != PAGE_CUR_RTREE_LOCATE - && mode >= PAGE_CUR_CONTAIN) { + && mode != PAGE_CUR_RTREE_LOCATE) { lock_prdt_t prdt; + que_thr_t* thr = cursor->rtr_info->thr; { - trx_t* trx = thr_get_trx(cursor->thr); + trx_t* trx = thr_get_trx(thr); TMLockTrxGuard g{TMLockTrxArgs(*trx)}; lock_init_prdt_from_mbr( &prdt, &cursor->rtr_info->mbr, mode, @@ -1922,7 +1772,7 @@ dberr_t btr_cur_search_to_nth_level(ulint level, } lock_prdt_lock(block, &prdt, index, LOCK_S, - LOCK_PREDICATE, cursor->thr); + LOCK_PREDICATE, thr); if (rw_latch == RW_NO_LATCH && height != 0) { block->page.lock.s_unlock(); @@ -2230,17 +2080,6 @@ dberr_t btr_cur_search_to_nth_level(ulint level, n_blocks++; - if (UNIV_UNLIKELY(height == 0 && dict_index_is_ibuf(index))) { - /* We're doing a search on an ibuf tree and we're one - level above the leaf page. */ - - ut_ad(level == 0); - - buf_mode = BUF_GET; - rw_latch = RW_NO_LATCH; - goto retry_page_get; - } - if (dict_index_is_spatial(index) && page_mode >= PAGE_CUR_CONTAIN && page_mode != PAGE_CUR_RTREE_INSERT) { @@ -2311,7 +2150,7 @@ dberr_t btr_cur_search_to_nth_level(ulint level, btr_block_get( *index, page_id.page_no(), latch_mode == BTR_CONT_MODIFY_TREE - ? RW_X_LATCH : RW_SX_LATCH, false, mtr, &err); + ? RW_X_LATCH : RW_SX_LATCH, mtr, &err); } else { ut_ad(mtr->memo_contains_flagged(block, upper_rw_latch)); @@ -2440,10 +2279,12 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index, rw_lock_type_t upper_rw_latch= RW_X_LATCH; switch (latch_mode) { - case BTR_CONT_MODIFY_TREE: case BTR_CONT_SEARCH_TREE: - abort(); - break; + ut_ad("invalid mode" == 0); + /* fall through */ + case BTR_CONT_MODIFY_TREE: + ut_ad(index->is_dummy); + /* fall through */ case BTR_MODIFY_TREE: /* Most of delete-intended operations are purging. Free blocks and read IO bandwidth should be prioritized for them, when the @@ -2489,9 +2330,7 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index, const rw_lock_type_t rw_latch= height && latch_mode != BTR_MODIFY_TREE ? upper_rw_latch : RW_NO_LATCH; - buf_block_t* block= - btr_block_get(*index, page, rw_latch, !height && !index->is_clust(), mtr, - &err); + buf_block_t* block= btr_block_get(*index, page, rw_latch, mtr, &err); ut_ad(!block == (err != DB_SUCCESS)); @@ -2514,7 +2353,9 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index, /* We are in the root node */ height= l; if (height); - else if (upper_rw_latch != root_leaf_rw_latch) + else if (upper_rw_latch != root_leaf_rw_latch && + /* ibuf_upgrade() needs the following condition */ + UNIV_LIKELY(root_leaf_rw_latch != RW_NO_LATCH)) { /* We should retry to get the page, because the root page is latched with different level as a leaf page. */ @@ -2635,11 +2476,6 @@ be freed by reorganizing. Differs from btr_cur_optimistic_insert because no heuristics is applied to whether it pays to use CPU time for reorganizing the page or not. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if this is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return pointer to inserted record if succeed, else NULL */ static MY_ATTRIBUTE((nonnull, warn_unused_result)) rec_t* @@ -2808,9 +2644,6 @@ static void btr_cur_prefetch_siblings(const buf_block_t *block, { ut_ad(page_is_leaf(block->page.frame)); - if (index->is_ibuf()) - return; - const page_t *page= block->page.frame; uint32_t prev= mach_read_from_4(my_assume_aligned<4>(page + FIL_PAGE_PREV)); uint32_t next= mach_read_from_4(my_assume_aligned<4>(page + FIL_PAGE_NEXT)); @@ -3046,14 +2879,6 @@ btr_cur_optimistic_insert( if (*rec) { } else if (block->page.zip.data) { ut_ad(!index->table->is_temporary()); - /* Reset the IBUF_BITMAP_FREE bits, because - page_cur_tuple_insert() will have attempted page - reorganize before failing. */ - if (leaf - && !dict_index_is_clust(index)) { - ibuf_reset_free_bits(block); - } - goto fail; } else { ut_ad(!reorg); @@ -3094,34 +2919,6 @@ btr_cur_optimistic_insert( lock_update_insert(block, *rec); } - if (leaf - && !dict_index_is_clust(index) - && !index->table->is_temporary()) { - /* Update the free bits of the B-tree page in the - insert buffer bitmap. */ - - /* The free bits in the insert buffer bitmap must - never exceed the free space on a page. It is safe to - decrement or reset the bits in the bitmap in a - mini-transaction that is committed before the - mini-transaction that affects the free space. */ - - /* It is unsafe to increment the bits in a separately - committed mini-transaction, because in crash recovery, - the free bits could momentarily be set too high. */ - - if (block->page.zip.data) { - /* Update the bits in the same mini-transaction. */ - ibuf_update_free_bits_zip(block, mtr); - } else { - /* Decrement the bits in a separate - mini-transaction. */ - ibuf_update_free_bits_if_full( - block, max_size, - rec_size + PAGE_DIR_SLOT_SIZE); - } - } - *big_rec = big_rec_vec; return(DB_SUCCESS); @@ -3192,12 +2989,10 @@ btr_cur_pessimistic_insert( the index tree, so that the insert will not fail because of lack of space */ - if (!index->is_ibuf() - && (err = fsp_reserve_free_extents(&n_reserved, index->table->space, - uint32_t(cursor->tree_height / 16 - + 3), - FSP_NORMAL, mtr)) - != DB_SUCCESS) { + err = fsp_reserve_free_extents(&n_reserved, index->table->space, + uint32_t(cursor->tree_height / 16 + 3), + FSP_NORMAL, mtr); + if (err != DB_SUCCESS) { return err; } @@ -3229,11 +3024,21 @@ btr_cur_pessimistic_insert( } } - *rec = index->page == btr_cur_get_block(cursor)->page.id().page_no() - ? btr_root_raise_and_insert(flags, cursor, offsets, heap, - entry, n_ext, mtr, &err) - : btr_page_split_and_insert(flags, cursor, offsets, heap, - entry, n_ext, mtr, &err); + if (index->page == btr_cur_get_block(cursor)->page.id().page_no()) { + *rec = index->is_spatial() + ? rtr_root_raise_and_insert(flags, cursor, offsets, + heap, entry, n_ext, mtr, + &err, thr) + : btr_root_raise_and_insert(flags, cursor, offsets, + heap, entry, n_ext, mtr, + &err); + } else if (index->is_spatial()) { + *rec = rtr_page_split_and_insert(flags, cursor, offsets, heap, + entry, n_ext, mtr, &err, thr); + } else { + *rec = btr_page_split_and_insert(flags, cursor, offsets, heap, + entry, n_ext, mtr, &err); + } if (!*rec) { goto func_exit; @@ -3477,14 +3282,8 @@ static dberr_t btr_cur_upd_rec_sys(buf_block_t *block, rec_t *rec, See if there is enough place in the page modification log to log an update-in-place. -@retval false if out of space; IBUF_BITMAP_FREE will be reset -outside mtr if the page was recompressed -@retval true if enough place; - -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if this is -a secondary index leaf page. This has to be done either within the -same mini-transaction, or by invoking ibuf_reset_free_bits() before -mtr_commit(mtr). */ +@retval false if out of space +@retval true if enough place */ bool btr_cur_update_alloc_zip_func( /*==========================*/ @@ -3505,7 +3304,6 @@ btr_cur_update_alloc_zip_func( const page_t* page = page_cur_get_page(cursor); ut_ad(page_zip == page_cur_get_page_zip(cursor)); - ut_ad(!dict_index_is_ibuf(index)); ut_ad(rec_offs_validate(page_cur_get_rec(cursor), index, offsets)); if (page_zip_available(page_zip, dict_index_is_clust(index), @@ -3529,26 +3327,8 @@ btr_cur_update_alloc_zip_func( rec_offs_make_valid(page_cur_get_rec(cursor), index, page_is_leaf(page), offsets); - /* After recompressing a page, we must make sure that the free - bits in the insert buffer bitmap will not exceed the free - space on the page. Because this function will not attempt - recompression unless page_zip_available() fails above, it is - safe to reset the free bits if page_zip_available() fails - again, below. The free bits can safely be reset in a separate - mini-transaction. If page_zip_available() succeeds below, we - can be sure that the btr_page_reorganize() above did not reduce - the free space available on the page. */ - - if (page_zip_available(page_zip, dict_index_is_clust(index), - length, create)) { - return true; - } - } - - if (!dict_index_is_clust(index) - && !index->table->is_temporary() - && page_is_leaf(page)) { - ibuf_reset_free_bits(page_cur_get_block(cursor)); + return page_zip_available(page_zip, dict_index_is_clust(index), + length, create); } return(false); @@ -3697,7 +3477,7 @@ We assume here that the ordering fields of the record do not change. @return locking or undo log related error code, or @retval DB_SUCCESS on success @retval DB_ZIP_OVERFLOW if there is not enough space left -on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) */ +on a ROW_FORMAT=COMPRESSED page */ dberr_t btr_cur_update_in_place( /*====================*/ @@ -3717,7 +3497,6 @@ btr_cur_update_in_place( further pages */ { dict_index_t* index; - dberr_t err; rec_t* rec; roll_ptr_t roll_ptr = 0; ulint was_delete_marked; @@ -3725,17 +3504,14 @@ btr_cur_update_in_place( ut_ad(page_is_leaf(cursor->page_cur.block->page.frame)); rec = btr_cur_get_rec(cursor); index = cursor->index(); - ut_ad(!index->is_ibuf()); ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG) || index->table->is_temporary()); - /* The insert buffer tree should never be updated in place. */ - ut_ad(!dict_index_is_ibuf(index)); ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) - || dict_index_is_clust(index)); + || index->is_primary()); ut_ad(thr_get_trx(thr)->id == trx_id - || (flags & ulint(~(BTR_KEEP_POS_FLAG | BTR_KEEP_IBUF_BITMAP))) + || (flags & ulint(~BTR_KEEP_POS_FLAG)) == (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG)); ut_ad(fil_page_index_page_check(btr_cur_get_page(cursor))); @@ -3765,22 +3541,17 @@ btr_cur_update_in_place( } /* Do lock checking and undo logging */ - err = btr_cur_upd_lock_and_undo(flags, cursor, offsets, - update, cmpl_info, - thr, mtr, &roll_ptr); - if (UNIV_UNLIKELY(err != DB_SUCCESS)) { - /* We may need to update the IBUF_BITMAP_FREE - bits after a reorganize that was done in - btr_cur_update_alloc_zip(). */ - goto func_exit; + if (dberr_t err = btr_cur_upd_lock_and_undo(flags, cursor, offsets, + update, cmpl_info, + thr, mtr, &roll_ptr)) { + return err; } - if (!(flags & BTR_KEEP_SYS_FLAG)) { - err = btr_cur_upd_rec_sys(block, rec, index, offsets, - thr_get_trx(thr), roll_ptr, mtr); - if (UNIV_UNLIKELY(err != DB_SUCCESS)) { - goto func_exit; - } + if (flags & BTR_KEEP_SYS_FLAG) { + } else if (dberr_t err = btr_cur_upd_rec_sys(block, rec, index, offsets, + thr_get_trx(thr), + roll_ptr, mtr)) { + return err; } was_delete_marked = rec_get_deleted_flag( @@ -3838,19 +3609,7 @@ btr_cur_update_in_place( btr_cur_unmark_extern_fields(block, rec, index, offsets, mtr); } - ut_ad(err == DB_SUCCESS); - -func_exit: - if (page_zip - && !(flags & BTR_KEEP_IBUF_BITMAP) - && !dict_index_is_clust(index) - && page_is_leaf(buf_block_get_frame(block))) { - /* Update the free bits in the insert buffer. */ - ut_ad(!index->table->is_temporary()); - ibuf_update_free_bits_zip(block, mtr); - } - - return(err); + return DB_SUCCESS; } /** Trim a metadata record during the rollback of instant ALTER TABLE. @@ -3994,7 +3753,7 @@ fields of the record do not change. @retval DB_OVERFLOW if the updated record does not fit @retval DB_UNDERFLOW if the page would become too empty @retval DB_ZIP_OVERFLOW if there is not enough space left -on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) */ +on a ROW_FORMAT=COMPRESSED page */ dberr_t btr_cur_optimistic_update( /*======================*/ @@ -4025,7 +3784,6 @@ btr_cur_optimistic_update( ulint max_size; ulint new_rec_size; ulint old_rec_size; - ulint max_ins_size = 0; dtuple_t* new_entry; roll_ptr_t roll_ptr; ulint i; @@ -4034,19 +3792,16 @@ btr_cur_optimistic_update( page = buf_block_get_frame(block); rec = btr_cur_get_rec(cursor); index = cursor->index(); - ut_ad(index->has_locking()); ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG) || index->table->is_temporary()); ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); /* This is intended only for leaf page updates */ ut_ad(page_is_leaf(page)); - /* The insert buffer tree should never be updated in place. */ - ut_ad(!dict_index_is_ibuf(index)); ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) || dict_index_is_clust(index)); ut_ad(thr_get_trx(thr)->id == trx_id - || (flags & ulint(~(BTR_KEEP_POS_FLAG | BTR_KEEP_IBUF_BITMAP))) + || (flags & ulint(~BTR_KEEP_POS_FLAG)) == (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG)); ut_ad(fil_page_index_page_check(page)); @@ -4075,7 +3830,6 @@ btr_cur_optimistic_update( if (rec_offs_any_extern(*offsets)) { any_extern: - ut_ad(!index->is_ibuf()); /* Externally stored fields are treated in pessimistic update */ @@ -4156,9 +3910,6 @@ btr_cur_optimistic_update( if (UNIV_UNLIKELY(new_rec_size >= (page_get_free_space_of_empty(page_is_comp(page)) / 2))) { - /* We may need to update the IBUF_BITMAP_FREE - bits after a reorganize that was done in - btr_cur_update_alloc_zip(). */ err = DB_OVERFLOW; goto func_exit; } @@ -4166,10 +3917,6 @@ btr_cur_optimistic_update( if (UNIV_UNLIKELY(page_get_data_size(page) - old_rec_size + new_rec_size < BTR_CUR_PAGE_COMPRESS_LIMIT(index))) { - /* We may need to update the IBUF_BITMAP_FREE - bits after a reorganize that was done in - btr_cur_update_alloc_zip(). */ - /* The page would become too empty */ err = DB_UNDERFLOW; goto func_exit; @@ -4182,19 +3929,9 @@ btr_cur_optimistic_update( : (old_rec_size + page_get_max_insert_size_after_reorganize(page, 1)); - if (!page_zip) { - max_ins_size = page_get_max_insert_size_after_reorganize( - page, 1); - } - if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT) && (max_size >= new_rec_size)) || (page_get_n_recs(page) <= 1))) { - - /* We may need to update the IBUF_BITMAP_FREE - bits after a reorganize that was done in - btr_cur_update_alloc_zip(). */ - /* There was not enough space, or it did not pay to reorganize: for simplicity, we decide what to do assuming a reorganization is needed, though it might not be necessary */ @@ -4208,9 +3945,6 @@ btr_cur_optimistic_update( update, cmpl_info, thr, mtr, &roll_ptr); if (err != DB_SUCCESS) { - /* We may need to update the IBUF_BITMAP_FREE - bits after a reorganize that was done in - btr_cur_update_alloc_zip(). */ goto func_exit; } @@ -4266,22 +4000,11 @@ btr_cur_optimistic_update( ut_ad(err == DB_SUCCESS); if (!page_cur_move_to_next(page_cursor)) { corrupted: - err = DB_CORRUPTION; - } - -func_exit: - if (!(flags & BTR_KEEP_IBUF_BITMAP) - && !dict_index_is_clust(index)) { - /* Update the free bits in the insert buffer. */ - if (page_zip) { - ut_ad(!index->table->is_temporary()); - ibuf_update_free_bits_zip(block, mtr); - } else if (!index->table->is_temporary()) { - ibuf_update_free_bits_low(block, max_ins_size, mtr); - } + return DB_CORRUPTION; } if (err != DB_SUCCESS) { +func_exit: /* prefetch siblings of the leaf for the pessimistic operation. */ btr_cur_prefetch_siblings(block, index); @@ -4378,7 +4101,6 @@ btr_cur_pessimistic_update( big_rec_t* dummy_big_rec; dict_index_t* index; buf_block_t* block; - page_zip_des_t* page_zip; rec_t* rec; page_cur_t* page_cursor; dberr_t err; @@ -4391,20 +4113,19 @@ btr_cur_pessimistic_update( *big_rec = NULL; block = btr_cur_get_block(cursor); - page_zip = buf_block_get_page_zip(block); index = cursor->index(); - ut_ad(index->has_locking()); ut_ad(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK)); ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); +#if defined UNIV_ZIP_DEBUG || defined UNIV_DEBUG + page_zip_des_t* page_zip = buf_block_get_page_zip(block); +#endif #ifdef UNIV_ZIP_DEBUG ut_a(!page_zip || page_zip_validate(page_zip, block->page.frame, index)); #endif /* UNIV_ZIP_DEBUG */ ut_ad(!page_zip || !index->table->is_temporary()); - /* The insert buffer tree should never be updated in place. */ - ut_ad(!dict_index_is_ibuf(index)); ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG) || index->table->is_temporary()); ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) @@ -4415,7 +4136,7 @@ btr_cur_pessimistic_update( | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG)); err = optim_err = btr_cur_optimistic_update( - flags | BTR_KEEP_IBUF_BITMAP, + flags, cursor, offsets, offsets_heap, update, cmpl_info, thr, trx_id, mtr); @@ -4426,18 +4147,6 @@ btr_cur_pessimistic_update( break; default: err_exit: - /* We suppressed this with BTR_KEEP_IBUF_BITMAP. - For DB_ZIP_OVERFLOW, the IBUF_BITMAP_FREE bits were - already reset by btr_cur_update_alloc_zip() if the - page was recompressed. */ - if (page_zip - && optim_err != DB_ZIP_OVERFLOW - && !dict_index_is_clust(index) - && page_is_leaf(block->page.frame)) { - ut_ad(!index->table->is_temporary()); - ibuf_update_free_bits_zip(block, mtr); - } - if (big_rec_vec != NULL) { dtuple_big_rec_free(big_rec_vec); } @@ -4515,11 +4224,6 @@ btr_cur_pessimistic_update( index->first_user_field())))) { big_rec_vec = dtuple_convert_big_rec(index, update, new_entry, &n_ext); if (UNIV_UNLIKELY(big_rec_vec == NULL)) { - - /* We cannot goto return_after_reservations, - because we may need to update the - IBUF_BITMAP_FREE bits, which was suppressed by - BTR_KEEP_IBUF_BITMAP. */ #ifdef UNIV_ZIP_DEBUG ut_a(!page_zip || page_zip_validate(page_zip, block->page.frame, @@ -4564,11 +4268,6 @@ btr_cur_pessimistic_update( btr_cur_write_sys(new_entry, index, trx_id, roll_ptr); } - const ulint max_ins_size = page_zip - ? 0 - : page_get_max_insert_size_after_reorganize(block->page.frame, - 1); - if (UNIV_UNLIKELY(is_metadata)) { ut_ad(new_entry->is_metadata()); ut_ad(index->is_instant()); @@ -4653,18 +4352,6 @@ btr_cur_pessimistic_update( rec_offs_make_valid(page_cursor->rec, index, true, *offsets); } - } else if (!dict_index_is_clust(index) - && page_is_leaf(block->page.frame)) { - /* Update the free bits in the insert buffer. - This is the same block which was skipped by - BTR_KEEP_IBUF_BITMAP. */ - if (page_zip) { - ut_ad(!index->table->is_temporary()); - ibuf_update_free_bits_zip(block, mtr); - } else if (!index->table->is_temporary()) { - ibuf_update_free_bits_low(block, max_ins_size, - mtr); - } } if (!srv_read_only_mode @@ -4686,16 +4373,7 @@ btr_cur_pessimistic_update( of a badly-compressing record, it is possible for btr_cur_optimistic_update() to return DB_UNDERFLOW and btr_cur_insert_if_possible() to return FALSE. */ - ut_a(page_zip || optim_err != DB_UNDERFLOW); - - /* Out of space: reset the free bits. - This is the same block which was skipped by - BTR_KEEP_IBUF_BITMAP. */ - if (!dict_index_is_clust(index) - && !index->table->is_temporary() - && page_is_leaf(block->page.frame)) { - ibuf_reset_free_bits(block); - } + ut_ad(page_zip || optim_err != DB_UNDERFLOW); } if (big_rec_vec != NULL) { @@ -4740,8 +4418,7 @@ btr_cur_pessimistic_update( same temp-table in parallel. max_trx_id is ignored for temp tables because it not required for MVCC. */ - if (dict_index_is_sec_or_ibuf(index) - && !index->table->is_temporary()) { + if (!index->is_primary() && !index->table->is_temporary()) { /* Update PAGE_MAX_TRX_ID in the index page header. It was not updated by btr_cur_pessimistic_insert() because of BTR_NO_LOCKING_FLAG. */ @@ -5052,9 +4729,6 @@ btr_cur_optimistic_delete( } { - page_t* page = buf_block_get_frame(block); - page_zip_des_t* page_zip= buf_block_get_page_zip(block); - if (UNIV_UNLIKELY(rec_get_info_bits(rec, page_rec_is_comp(rec)) & REC_INFO_MIN_REC_FLAG)) { /* This should be rolling back instant ADD COLUMN. @@ -5063,7 +4737,7 @@ btr_cur_optimistic_delete( insert into SYS_COLUMNS is rolled back. */ ut_ad(cursor->index()->table->supports_instant()); ut_ad(cursor->index()->is_primary()); - ut_ad(!page_zip); + ut_ad(!buf_block_get_page_zip(block)); page_cur_delete_rec(btr_cur_get_page_cur(cursor), offsets, mtr); /* We must empty the PAGE_FREE list, because @@ -5081,40 +4755,8 @@ btr_cur_optimistic_delete( btr_search_update_hash_on_delete(cursor); } - if (page_zip) { -#ifdef UNIV_ZIP_DEBUG - ut_a(page_zip_validate(page_zip, page, - cursor->index())); -#endif /* UNIV_ZIP_DEBUG */ - page_cur_delete_rec(btr_cur_get_page_cur(cursor), - offsets, mtr); -#ifdef UNIV_ZIP_DEBUG - ut_a(page_zip_validate(page_zip, page, - cursor->index())); -#endif /* UNIV_ZIP_DEBUG */ - - /* On compressed pages, the IBUF_BITMAP_FREE - space is not affected by deleting (purging) - records, because it is defined as the minimum - of space available *without* reorganize, and - space available in the modification log. */ - } else { - const ulint max_ins - = page_get_max_insert_size_after_reorganize( - page, 1); - - page_cur_delete_rec(btr_cur_get_page_cur(cursor), - offsets, mtr); - - /* The change buffer does not handle inserts - into non-leaf pages, into clustered indexes, - or into the change buffer. */ - if (!cursor->index()->is_clust() - && !cursor->index()->table->is_temporary() - && !dict_index_is_ibuf(cursor->index())) { - ibuf_update_free_bits_low(block, max_ins, mtr); - } - } + page_cur_delete_rec(btr_cur_get_page_cur(cursor), + offsets, mtr); } func_exit: @@ -5310,9 +4952,9 @@ btr_cur_pessimistic_delete( goto err_exit; } - btr_cur_t cursor; - cursor.page_cur.index = index; - cursor.page_cur.block = block; + btr_cur_t cur; + cur.page_cur.index = index; + cur.page_cur.block = block; if (!page_has_prev(page)) { /* If we delete the leftmost node pointer on a @@ -5328,16 +4970,17 @@ btr_cur_pessimistic_delete( rec_offs* offsets; ulint len; - rtr_page_get_father_block(NULL, heap, mtr, NULL, - &cursor); - father_rec = btr_cur_get_rec(&cursor); + rtr_page_get_father_block(nullptr, heap, nullptr, + &cur, + cursor->rtr_info->thr, mtr); + father_rec = btr_cur_get_rec(&cur); offsets = rec_get_offsets(father_rec, index, NULL, 0, ULINT_UNDEFINED, &heap); rtr_read_mbr(rec_get_nth_field( father_rec, offsets, 0, &len), &father_mbr); - rtr_update_mbr_field(&cursor, offsets, NULL, + rtr_update_mbr_field(&cur, offsets, NULL, page, &father_mbr, next_rec, mtr); ut_d(parent_latched = true); } else { @@ -5345,12 +4988,12 @@ btr_cur_pessimistic_delete( on a page, we have to change the parent node pointer so that it is equal to the new leftmost node pointer on the page */ - ret = btr_page_get_father(mtr, &cursor); + ret = btr_page_get_father(mtr, &cur); if (!ret) { *err = DB_CORRUPTION; goto err_exit; } - *err = btr_cur_node_ptr_delete(&cursor, mtr); + *err = btr_cur_node_ptr_delete(&cur, mtr); if (*err != DB_SUCCESS) { got_err: ret = FALSE; @@ -5397,7 +5040,10 @@ btr_cur_pessimistic_delete( #endif /* UNIV_ZIP_DEBUG */ ut_ad(!parent_latched - || btr_check_node_ptr(index, block, mtr)); + || btr_check_node_ptr(index, block, + cursor->rtr_info + ? cursor->rtr_info->thr + : nullptr, mtr)); if (!ret && btr_cur_compress_recommendation(cursor, mtr)) { if (UNIV_LIKELY(allow_merge)) { @@ -5544,7 +5190,7 @@ class btr_est_cur_t ulint parent_savepoint= m_savepoint; m_savepoint= mtr_set_savepoint(&mtr); - m_block= btr_block_get(*index(), m_page_id.page_no(), RW_S_LATCH, !level, + m_block= btr_block_get(*index(), m_page_id.page_no(), RW_S_LATCH, &mtr, nullptr); if (parent_block && parent_block != right_parent) @@ -5762,8 +5408,7 @@ static ha_rows btr_estimate_n_rows_in_range_on_level( savepoint= mtr_set_savepoint(&mtr); /* Fetch the page. */ - block= btr_block_get(*index, page_id.page_no(), RW_S_LATCH, !level, &mtr, - nullptr); + block= btr_block_get(*index, page_id.page_no(), RW_S_LATCH, &mtr, nullptr); if (prev_block) mtr_release_block_at_savepoint(&mtr, prev_savepoint, prev_block); @@ -6378,7 +6023,7 @@ struct btr_blob_log_check_t { if (UNIV_UNLIKELY(page_no != FIL_NULL)) { m_pcur->btr_cur.page_cur.block = btr_block_get( - *index, page_no, RW_X_LATCH, false, m_mtr); + *index, page_no, RW_X_LATCH, m_mtr); /* The page should not be evicted or corrupted while we are holding a buffer-fix on it. */ m_pcur->btr_cur.page_cur.block->page.unfix(); diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc index 76b173359dacd..bd2f4e0cbfc71 100644 --- a/storage/innobase/btr/btr0defragment.cc +++ b/storage/innobase/btr/btr0defragment.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (C) 2012, 2014 Facebook, Inc. All Rights Reserved. -Copyright (C) 2014, 2022, MariaDB Corporation. +Copyright (C) 2014, 2023, 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 @@ -33,7 +33,6 @@ Modified 30/07/2014 Jan Lindström jan.lindstrom@mariadb.com #include "dict0stats.h" #include "dict0stats_bg.h" #include "dict0defrag_bg.h" -#include "ibuf0ibuf.h" #include "lock0lock.h" #include "srv0start.h" #include "mysqld.h" @@ -330,20 +329,16 @@ btr_defragment_merge_pages( // If max_ins_size >= move_size, we can move the records without // reorganizing the page, otherwise we need to reorganize the page // first to release more space. - if (move_size > max_ins_size) { - dberr_t err = btr_page_reorganize_block(page_zip_level, - to_block, index, mtr); - if (err != DB_SUCCESS) { - if (!dict_index_is_clust(index) - && page_is_leaf(to_page)) { - ibuf_reset_free_bits(to_block); - } - // If reorganization fails, that means page is - // not compressable. There's no point to try - // merging into this page. Continue to the - // next page. - return err == DB_FAIL ? from_block : nullptr; - } + if (move_size <= max_ins_size) { + } else if (dberr_t err = btr_page_reorganize_block(page_zip_level, + to_block, index, + mtr)) { + // If reorganization fails, that means page is + // not compressable. There's no point to try + // merging into this page. Continue to the + // next page. + return err == DB_FAIL ? from_block : nullptr; + } else { ut_ad(page_validate(to_page, index)); max_ins_size = page_get_max_insert_size(to_page, n_recs); if (max_ins_size < move_size) { @@ -392,18 +387,6 @@ btr_defragment_merge_pages( && *max_data_size > new_data_size + move_size) { *max_data_size = new_data_size + move_size; } - // Set ibuf free bits if necessary. - if (!dict_index_is_clust(index) - && page_is_leaf(to_page)) { - if (zip_size) { - ibuf_reset_free_bits(to_block); - } else { - ibuf_update_free_bits_if_full( - to_block, - srv_page_size, - ULINT_UNDEFINED); - } - } btr_cur_t parent; parent.page_cur.index = index; parent.page_cur.block = from_block; @@ -526,8 +509,7 @@ btr_defragment_n_pages( break; } - blocks[i] = btr_block_get(*index, page_no, RW_X_LATCH, true, - mtr); + blocks[i] = btr_block_get(*index, page_no, RW_X_LATCH, mtr); if (!blocks[i]) { return nullptr; } @@ -542,7 +524,7 @@ btr_defragment_n_pages( /* given page is the last page. Lift the records to father. */ dberr_t err; - btr_lift_page_up(index, block, mtr, &err); + btr_lift_page_up(index, block, nullptr, mtr, &err); } return NULL; } diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index 46b8d48785005..640b1b4ea2ab7 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2022, MariaDB Corporation. +Copyright (c) 2016, 2023, 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 @@ -157,20 +157,14 @@ btr_pcur_store_position( cursor->rel_pos = BTR_PCUR_ON; } - if (index->is_ibuf()) { - ut_ad(!index->table->not_redundant()); - cursor->old_n_fields = uint16_t(rec_get_n_fields_old(rec)); - } else { - cursor->old_n_fields = static_cast( - dict_index_get_n_unique_in_tree(index)); - if (index->is_spatial() && !page_rec_is_leaf(rec)) { - ut_ad(dict_index_get_n_unique_in_tree_nonleaf(index) - == DICT_INDEX_SPATIAL_NODEPTR_SIZE); - /* For R-tree, we have to compare - the child page numbers as well. */ - cursor->old_n_fields - = DICT_INDEX_SPATIAL_NODEPTR_SIZE + 1; - } + cursor->old_n_fields = static_cast( + dict_index_get_n_unique_in_tree(index)); + if (index->is_spatial() && !page_rec_is_leaf(rec)) { + ut_ad(dict_index_get_n_unique_in_tree_nonleaf(index) + == DICT_INDEX_SPATIAL_NODEPTR_SIZE); + /* For R-tree, we have to compare + the child page numbers as well. */ + cursor->old_n_fields = DICT_INDEX_SPATIAL_NODEPTR_SIZE + 1; } cursor->old_n_core_fields = index->n_core_fields; @@ -476,8 +470,7 @@ btr_pcur_move_to_next_page( dberr_t err; buf_block_t* next_block = btr_block_get( - *cursor->index(), next_page_no, mode, - page_is_leaf(page), mtr, &err); + *cursor->index(), next_page_no, mode, mtr, &err); if (UNIV_UNLIKELY(!next_block)) { return err; diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index c61cdd9f6042d..93bb4825a3d25 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -2,7 +2,7 @@ Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -305,13 +305,6 @@ static void btr_search_info_update_hash(btr_search_t *info, btr_cur_t *cursor) dict_index_t* index = cursor->index(); int cmp; - if (dict_index_is_ibuf(index)) { - /* So many deletes are performed on an insert buffer tree - that we do not consider a hash index useful on it: */ - - return; - } - uint16_t n_unique = dict_index_get_n_unique_in_tree(index); if (info->n_hash_potential == 0) { @@ -712,7 +705,6 @@ btr_search_update_hash_ref( ut_ad(block->page.id().space() == index->table->space_id); ut_ad(index == cursor->index()); - ut_ad(!dict_index_is_ibuf(index)); auto part = btr_search_sys.get_part(*index); part->latch.wr_lock(SRW_LOCK_CALL); ut_ad(!block->index || block->index == index); @@ -1062,7 +1054,6 @@ btr_search_guess_on_hash( return false; } - ut_ad(!index->is_ibuf()); ut_ad(latch_mode == BTR_SEARCH_LEAF || latch_mode == BTR_MODIFY_LEAF); compile_time_assert(ulint{BTR_SEARCH_LEAF} == ulint{RW_S_LATCH}); compile_time_assert(ulint{BTR_MODIFY_LEAF} == ulint{RW_X_LATCH}); @@ -1269,7 +1260,6 @@ void btr_search_drop_page_hash_index(buf_block_t* block, ut_ad(block->page.id().space() == index->table->space_id); ut_a(index_id == index->id); - ut_ad(!dict_index_is_ibuf(index)); n_fields = block->curr_n_fields; n_bytes = block->curr_n_bytes; @@ -1472,7 +1462,6 @@ btr_search_build_page_hash_index( ut_ad(ahi_latch == &btr_search_sys.get_part(*index)->latch); ut_ad(index); ut_ad(block->page.id().space() == index->table->space_id); - ut_ad(!dict_index_is_ibuf(index)); ut_ad(page_is_leaf(block->page.frame)); ut_ad(block->page.lock.have_x() || block->page.lock.have_s()); @@ -1798,7 +1787,6 @@ void btr_search_update_hash_on_delete(btr_cur_t *cursor) ut_ad(block->page.id().space() == index->table->space_id); ut_a(index == cursor->index()); ut_a(block->curr_n_fields > 0 || block->curr_n_bytes > 0); - ut_ad(!dict_index_is_ibuf(index)); rec = btr_cur_get_rec(cursor); @@ -1871,7 +1859,6 @@ void btr_search_update_hash_node_on_insert(btr_cur_t *cursor, } ut_a(cursor->index() == index); - ut_ad(!dict_index_is_ibuf(index)); ahi_latch->wr_lock(SRW_LOCK_CALL); if (!block->index || !btr_search_enabled) { @@ -1964,7 +1951,6 @@ void btr_search_update_hash_on_insert(btr_cur_t *cursor, } ut_a(index == cursor->index()); - ut_ad(!dict_index_is_ibuf(index)); n_fields = block->curr_n_fields; n_bytes = block->curr_n_bytes; @@ -2213,7 +2199,6 @@ btr_search_hash_table_validate(ulint hash_table_id) invokes btr_search_drop_page_hash_index(). */ ut_a(block->page.state() == buf_page_t::REMOVE_HASH); state_ok: - ut_ad(!dict_index_is_ibuf(block->index)); ut_ad(block->page.id().space() == block->index->table->space_id); diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index ce6a525d0802b..e48538545f00c 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -50,7 +50,6 @@ Created 11/5/1995 Heikki Tuuri #include "buf0dblwr.h" #include "lock0lock.h" #include "btr0sea.h" -#include "ibuf0ibuf.h" #include "trx0undo.h" #include "trx0purge.h" #include "log0log.h" @@ -1820,9 +1819,6 @@ inline void buf_pool_t::resize() " and dictionary."; } - /* normalize ibuf.max_size */ - ibuf_max_size_update(srv_change_buffer_max_size); - if (srv_buf_pool_old_size != srv_buf_pool_size) { buf_resize_status("Completed resizing buffer pool from %zu to %zu bytes." @@ -1896,7 +1892,6 @@ static void buf_relocate(buf_page_t *bpage, buf_page_t *dpage) mysql_mutex_assert_owner(&buf_pool.mutex); ut_ad(buf_pool.page_hash.lock_get(chain).is_write_locked()); ut_ad(bpage == buf_pool.page_hash.get(id, chain)); - ut_ad(!buf_pool.watch_is_sentinel(*bpage)); ut_d(const auto state= bpage->state()); ut_ad(state >= buf_page_t::FREED); ut_ad(state <= buf_page_t::READ_FIX); @@ -1940,135 +1935,6 @@ static void buf_relocate(buf_page_t *bpage, buf_page_t *dpage) buf_pool.page_hash.replace(chain, bpage, dpage); } -/** Register a watch for a page identifier. The caller must hold an -exclusive page hash latch. The *hash_lock may be released, -relocated, and reacquired. -@param id page identifier -@param chain hash table chain with exclusively held page_hash -@return a buffer pool block corresponding to id -@retval nullptr if the block was not present, and a watch was installed */ -inline buf_page_t *buf_pool_t::watch_set(const page_id_t id, - buf_pool_t::hash_chain &chain) -{ - ut_ad(&chain == &page_hash.cell_get(id.fold())); - ut_ad(page_hash.lock_get(chain).is_write_locked()); - -retry: - if (buf_page_t *bpage= page_hash.get(id, chain)) - { - if (!watch_is_sentinel(*bpage)) - /* The page was loaded meanwhile. */ - return bpage; - /* Add to an existing watch. */ - bpage->fix(); - return nullptr; - } - - page_hash.lock_get(chain).unlock(); - /* Allocate a watch[] and then try to insert it into the page_hash. */ - mysql_mutex_lock(&mutex); - - /* The maximum number of purge tasks should never exceed - the UT_ARR_SIZE(watch) - 1, and there is no way for a purge task to hold a - watch when setting another watch. */ - for (buf_page_t *w= &watch[UT_ARR_SIZE(watch)]; w-- >= watch; ) - { - ut_ad(w->access_time == 0); - ut_ad(!w->oldest_modification()); - ut_ad(!w->zip.data); - ut_ad(!w->in_zip_hash); - static_assert(buf_page_t::NOT_USED == 0, "efficiency"); - if (ut_d(auto s=) w->state()) - { - /* This watch may be in use for some other page. */ - ut_ad(s >= buf_page_t::UNFIXED); - continue; - } - /* w is pointing to watch[], which is protected by mutex. - Normally, buf_page_t::id for objects that are reachable by - page_hash.get(id, chain) are protected by hash_lock. */ - w->set_state(buf_page_t::UNFIXED + 1); - w->id_= id; - - buf_page_t *bpage= page_hash.get(id, chain); - if (UNIV_LIKELY_NULL(bpage)) - { - w->set_state(buf_page_t::NOT_USED); - page_hash.lock_get(chain).lock(); - mysql_mutex_unlock(&mutex); - goto retry; - } - - page_hash.lock_get(chain).lock(); - ut_ad(w->state() == buf_page_t::UNFIXED + 1); - buf_pool.page_hash.append(chain, w); - mysql_mutex_unlock(&mutex); - return nullptr; - } - - ut_error; - mysql_mutex_unlock(&mutex); - return nullptr; -} - -/** Stop watching whether a page has been read in. -watch_set(id) must have returned nullptr before. -@param id page identifier -@param chain unlocked hash table chain */ -TRANSACTIONAL_TARGET -void buf_pool_t::watch_unset(const page_id_t id, buf_pool_t::hash_chain &chain) -{ - mysql_mutex_assert_not_owner(&mutex); - buf_page_t *w; - { - transactional_lock_guard g{page_hash.lock_get(chain)}; - /* The page must exist because watch_set() did fix(). */ - w= page_hash.get(id, chain); - ut_ad(w->in_page_hash); - if (!watch_is_sentinel(*w)) - { - no_watch: - w->unfix(); - w= nullptr; - } - else - { - const auto state= w->state(); - ut_ad(~buf_page_t::LRU_MASK & state); - ut_ad(state >= buf_page_t::UNFIXED + 1); - if (state != buf_page_t::UNFIXED + 1) - goto no_watch; - } - } - - if (!w) - return; - - const auto old= w; - /* The following is based on buf_pool_t::watch_remove(). */ - mysql_mutex_lock(&mutex); - w= page_hash.get(id, chain); - - { - transactional_lock_guard g - {buf_pool.page_hash.lock_get(chain)}; - auto f= w->unfix(); - ut_ad(f < buf_page_t::READ_FIX || w != old); - - if (f == buf_page_t::UNFIXED && w == old) - { - page_hash.remove(chain, w); - // Now that w is detached from page_hash, release it to watch[]. - ut_ad(w->id_ == id); - ut_ad(!w->frame); - ut_ad(!w->zip.data); - w->set_state(buf_page_t::NOT_USED); - } - } - - mysql_mutex_unlock(&mutex); -} - /** Mark the page status as FREED for the given tablespace and page number. @param[in,out] space tablespace @param[in] page page number @@ -2150,7 +2016,7 @@ buf_page_t* buf_page_get_zip(const page_id_t page_id, ulint zip_size) if (hash_lock.is_locked()) xabort(); bpage= buf_pool.page_hash.get(page_id, chain); - if (!bpage || buf_pool.watch_is_sentinel(*bpage)) + if (!bpage) { xend(); goto must_read_page; @@ -2175,7 +2041,7 @@ buf_page_t* buf_page_get_zip(const page_id_t page_id, ulint zip_size) { hash_lock.lock_shared(); bpage= buf_pool.page_hash.get(page_id, chain); - if (!bpage || buf_pool.watch_is_sentinel(*bpage)) + if (!bpage) { hash_lock.unlock_shared(); goto must_read_page; @@ -2348,13 +2214,9 @@ buf_zip_decompress( @param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH @param[in] guess guessed block or NULL @param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, -BUF_PEEK_IF_IN_POOL, or BUF_GET_IF_IN_POOL_OR_WATCH +or BUF_PEEK_IF_IN_POOL @param[in] mtr mini-transaction @param[out] err DB_SUCCESS or error code -@param[in] allow_ibuf_merge Allow change buffer merge to happen -while reading the page from file -then it makes sure that it does merging of change buffer changes while -reading the page from file. @return pointer to the block or NULL */ TRANSACTIONAL_TARGET buf_block_t* @@ -2365,10 +2227,8 @@ buf_page_get_low( buf_block_t* guess, ulint mode, mtr_t* mtr, - dberr_t* err, - bool allow_ibuf_merge) + dberr_t* err) { - unsigned access_time; ulint retries = 0; ut_ad(!mtr || mtr->is_active()); @@ -2377,11 +2237,6 @@ buf_page_get_low( || (rw_latch == RW_X_LATCH) || (rw_latch == RW_SX_LATCH) || (rw_latch == RW_NO_LATCH)); - ut_ad(!allow_ibuf_merge - || mode == BUF_GET - || mode == BUF_GET_POSSIBLY_FREED - || mode == BUF_GET_IF_IN_POOL - || mode == BUF_GET_IF_IN_POOL_OR_WATCH); if (err) { *err = DB_SUCCESS; @@ -2399,7 +2254,6 @@ buf_page_get_low( case BUF_GET_POSSIBLY_FREED: break; case BUF_GET: - case BUF_GET_IF_IN_POOL_OR_WATCH: ut_ad(!mtr->is_freeing_tree()); fil_space_t* s = fil_space_get(page_id.space()); ut_ad(s); @@ -2407,9 +2261,6 @@ buf_page_get_low( } #endif /* UNIV_DEBUG */ - ut_ad(!mtr || !ibuf_inside(mtr) - || ibuf_page_low(page_id, zip_size, FALSE, NULL)); - ++buf_pool.stat.n_page_gets; auto& chain= buf_pool.page_hash.cell_get(page_id.fold()); @@ -2442,8 +2293,7 @@ buf_page_get_low( hash_lock.lock_shared(); block = reinterpret_cast( buf_pool.page_hash.get(page_id, chain)); - if (UNIV_LIKELY(block - && !buf_pool.watch_is_sentinel(block->page))) { + if (UNIV_LIKELY(block != nullptr)) { state = block->page.fix(); hash_lock.unlock_shared(); goto got_block; @@ -2454,20 +2304,6 @@ buf_page_get_low( switch (mode) { case BUF_GET_IF_IN_POOL: case BUF_PEEK_IF_IN_POOL: - return nullptr; - case BUF_GET_IF_IN_POOL_OR_WATCH: - /* We cannot easily use a memory transaction here. */ - hash_lock.lock(); - block = reinterpret_cast - (buf_pool.watch_set(page_id, chain)); - /* buffer-fixing will prevent eviction */ - state = block ? block->page.fix() : 0; - hash_lock.unlock(); - - if (block) { - goto got_block; - } - return nullptr; } @@ -2495,7 +2331,7 @@ buf_page_get_low( return nullptr; } } else { - buf_read_ahead_random(page_id, zip_size, ibuf_inside(mtr)); + buf_read_ahead_random(page_id, zip_size); } ut_d(if (!(++buf_dbg_counter % 5771)) buf_pool.validate()); @@ -2603,7 +2439,6 @@ buf_page_get_low( switch (state) { case buf_page_t::UNFIXED + 1: - case buf_page_t::IBUF_EXIST + 1: case buf_page_t::REINIT + 1: break; default: @@ -2657,13 +2492,6 @@ buf_page_get_low( buf_pool.n_pend_unzip++; - access_time = block->page.is_accessed(); - - if (!access_time && !recv_no_ibuf_operations - && ibuf_page_exists(block->page.id(), block->zip_size())) { - state = buf_page_t::IBUF_EXIST + 1; - } - /* Decompress the page while not holding buf_pool.mutex. */ auto ok = buf_zip_decompress(block, false); @@ -2683,55 +2511,6 @@ buf_page_get_low( } } -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG -re_evict: - if (mode != BUF_GET_IF_IN_POOL - && mode != BUF_GET_IF_IN_POOL_OR_WATCH) { - } else if (!ibuf_debug || recv_recovery_is_on()) { - } else if (fil_space_t* space = fil_space_t::get(page_id.space())) { - /* Try to evict the block from the buffer pool, to use the - insert buffer (change buffer) as much as possible. */ - - mysql_mutex_lock(&buf_pool.mutex); - - block->unfix(); - - /* Blocks cannot be relocated or enter or exit the - buf_pool while we are holding the buf_pool.mutex. */ - const bool evicted = buf_LRU_free_page(&block->page, true); - space->release(); - - if (evicted) { - page_hash_latch& hash_lock - = buf_pool.page_hash.lock_get(chain); - hash_lock.lock(); - mysql_mutex_unlock(&buf_pool.mutex); - /* We may set the watch, as it would have - been set if the page were not in the - buffer pool in the first place. */ - block= reinterpret_cast( - mode == BUF_GET_IF_IN_POOL_OR_WATCH - ? buf_pool.watch_set(page_id, chain) - : buf_pool.page_hash.get(page_id, chain)); - hash_lock.unlock(); - return(NULL); - } - - block->fix(); - mysql_mutex_unlock(&buf_pool.mutex); - buf_flush_sync(); - - state = block->page.state(); - - if (state == buf_page_t::UNFIXED + 1 - && !block->page.oldest_modification()) { - goto re_evict; - } - - /* Failed to evict the page; change it directly */ - } -#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ - ut_ad(state > buf_page_t::FREED); if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED)) { goto ignore_block; @@ -2744,118 +2523,69 @@ buf_page_get_low( #endif /* UNIV_DEBUG */ ut_ad(block->page.frame); - if (state >= buf_page_t::UNFIXED - && allow_ibuf_merge - && fil_page_get_type(block->page.frame) == FIL_PAGE_INDEX - && page_is_leaf(block->page.frame)) { - block->page.lock.x_lock(); - ut_ad(block->page.id() == page_id - || (state >= buf_page_t::READ_FIX - && state < buf_page_t::WRITE_FIX)); - -#ifdef BTR_CUR_HASH_ADAPT - btr_search_drop_page_hash_index(block, true); -#endif /* BTR_CUR_HASH_ADAPT */ - - dberr_t e; + mtr_memo_type_t fix_type; + switch (rw_latch) { + case RW_NO_LATCH: + mtr->memo_push(block, MTR_MEMO_BUF_FIX); + return block; + case RW_S_LATCH: + fix_type = MTR_MEMO_PAGE_S_FIX; + block->page.lock.s_lock(); + ut_ad(!block->page.is_read_fixed()); if (UNIV_UNLIKELY(block->page.id() != page_id)) { + block->page.lock.s_unlock(); + block->page.lock.x_lock(); page_id_mismatch: - state = block->page.state(); - e = DB_CORRUPTION; -ibuf_merge_corrupted: - if (err) { - *err = e; - } - if (block->page.id().is_corrupted()) { - buf_pool.corrupted_evict(&block->page, state); + buf_pool.corrupted_evict(&block->page, + block->page.state()); } - return nullptr; - } - - state = block->page.state(); - ut_ad(state < buf_page_t::READ_FIX); - - if (state >= buf_page_t::IBUF_EXIST - && state < buf_page_t::REINIT) { - block->page.clear_ibuf_exist(); - e = ibuf_merge_or_delete_for_page(block, page_id, - block->zip_size()); - if (UNIV_UNLIKELY(e != DB_SUCCESS)) { - goto ibuf_merge_corrupted; + if (err) { + *err = DB_CORRUPTION; } + return nullptr; } - - if (rw_latch == RW_X_LATCH) { - mtr->memo_push(block, MTR_MEMO_PAGE_X_FIX); - goto got_latch; - } else { - block->page.lock.x_unlock(); - goto get_latch; + break; + case RW_SX_LATCH: + fix_type = MTR_MEMO_PAGE_SX_FIX; + block->page.lock.u_lock(); + ut_ad(!block->page.is_io_fixed()); + if (UNIV_UNLIKELY(block->page.id() != page_id)) { + block->page.lock.u_x_upgrade(); + goto page_id_mismatch; } - } else { -get_latch: - switch (rw_latch) { - mtr_memo_type_t fix_type; - case RW_NO_LATCH: - mtr->memo_push(block, MTR_MEMO_BUF_FIX); + break; + default: + ut_ad(rw_latch == RW_X_LATCH); + fix_type = MTR_MEMO_PAGE_X_FIX; + if (block->page.lock.x_lock_upgraded()) { + ut_ad(block->page.id() == page_id); + block->unfix(); + mtr->page_lock_upgrade(*block); return block; - case RW_S_LATCH: - fix_type = MTR_MEMO_PAGE_S_FIX; - block->page.lock.s_lock(); - ut_ad(!block->page.is_read_fixed()); - if (UNIV_UNLIKELY(block->page.id() != page_id)) { - block->page.lock.s_unlock(); - block->page.lock.x_lock(); - goto page_id_mismatch; - } -get_latch_valid: - mtr->memo_push(block, fix_type); + } + if (UNIV_UNLIKELY(block->page.id() != page_id)) { + goto page_id_mismatch; + } + } + + mtr->memo_push(block, fix_type); #ifdef BTR_CUR_HASH_ADAPT - btr_search_drop_page_hash_index(block, true); + btr_search_drop_page_hash_index(block, true); #endif /* BTR_CUR_HASH_ADAPT */ - break; - case RW_SX_LATCH: - fix_type = MTR_MEMO_PAGE_SX_FIX; - block->page.lock.u_lock(); - ut_ad(!block->page.is_io_fixed()); - if (UNIV_UNLIKELY(block->page.id() != page_id)) { - block->page.lock.u_x_upgrade(); - goto page_id_mismatch; - } - goto get_latch_valid; - default: - ut_ad(rw_latch == RW_X_LATCH); - fix_type = MTR_MEMO_PAGE_X_FIX; - if (block->page.lock.x_lock_upgraded()) { - ut_ad(block->page.id() == page_id); - block->unfix(); - mtr->page_lock_upgrade(*block); - return block; - } - if (UNIV_UNLIKELY(block->page.id() != page_id)) { - goto page_id_mismatch; - } - goto get_latch_valid; - } -got_latch: - ut_ad(page_id_t(page_get_space_id(block->page.frame), - page_get_page_no(block->page.frame)) - == page_id); + ut_ad(page_id_t(page_get_space_id(block->page.frame), + page_get_page_no(block->page.frame)) == page_id); - if (mode == BUF_GET_POSSIBLY_FREED - || mode == BUF_PEEK_IF_IN_POOL) { - return block; - } + if (mode == BUF_GET_POSSIBLY_FREED || mode == BUF_PEEK_IF_IN_POOL) { + return block; + } - const bool not_first_access{block->page.set_accessed()}; - buf_page_make_young_if_needed(&block->page); - if (!not_first_access) { - buf_read_ahead_linear(page_id, block->zip_size(), - ibuf_inside(mtr)); - } + const bool not_first_access{block->page.set_accessed()}; + buf_page_make_young_if_needed(&block->page); + if (!not_first_access) { + buf_read_ahead_linear(page_id, block->zip_size()); } return block; @@ -2867,11 +2597,9 @@ buf_page_get_low( @param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH @param[in] guess guessed block or NULL @param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, -BUF_PEEK_IF_IN_POOL, or BUF_GET_IF_IN_POOL_OR_WATCH +or BUF_PEEK_IF_IN_POOL @param[in,out] mtr mini-transaction, or NULL @param[out] err DB_SUCCESS or error code -@param[in] allow_ibuf_merge Allow change buffer merge while -reading the pages from file. @return pointer to the block or NULL */ buf_block_t* buf_page_get_gen( @@ -2881,8 +2609,7 @@ buf_page_get_gen( buf_block_t* guess, ulint mode, mtr_t* mtr, - dberr_t* err, - bool allow_ibuf_merge) + dberr_t* err) { if (buf_block_t *block= recv_sys.recover(page_id)) { @@ -2899,57 +2626,20 @@ buf_page_get_gen( /* The block may be write-fixed at this point because we are not holding a lock, but it must not be read-fixed. */ ut_ad(s < buf_page_t::READ_FIX || s >= buf_page_t::WRITE_FIX); - if (err) - *err= DB_SUCCESS; - const bool must_merge= allow_ibuf_merge && - ibuf_page_exists(page_id, block->zip_size()); if (s < buf_page_t::UNFIXED) { - got_freed_page: ut_ad(mode == BUF_GET_POSSIBLY_FREED || mode == BUF_PEEK_IF_IN_POOL); block->page.unfix(); goto corrupted; } - else if (must_merge && - fil_page_get_type(block->page.frame) == FIL_PAGE_INDEX && - page_is_leaf(block->page.frame)) - { - block->page.lock.x_lock(); - s= block->page.state(); - ut_ad(s > buf_page_t::FREED); - ut_ad(s < buf_page_t::READ_FIX); - if (s < buf_page_t::UNFIXED) - { - block->page.lock.x_unlock(); - goto got_freed_page; - } - else - { - if (block->page.is_ibuf_exist()) - block->page.clear_ibuf_exist(); - if (dberr_t e= - ibuf_merge_or_delete_for_page(block, page_id, block->zip_size())) - { - if (err) - *err= e; - buf_pool.corrupted_evict(&block->page, s); - return nullptr; - } - } - - if (rw_latch == RW_X_LATCH) - { - mtr->memo_push(block, MTR_MEMO_PAGE_X_FIX); - return block; - } - block->page.lock.x_unlock(); - } + if (err) + *err= DB_SUCCESS; mtr->page_lock(block, rw_latch); return block; } return buf_page_get_low(page_id, zip_size, rw_latch, - guess, mode, mtr, err, allow_ibuf_merge); + guess, mode, mtr, err); } /********************************************************************//** @@ -3014,7 +2704,6 @@ bool buf_page_optimistic_get(ulint rw_latch, buf_block_t *block, { ut_ad(rw_latch == RW_S_LATCH || !block->page.is_io_fixed()); ut_ad(id == block->page.id()); - ut_ad(!ibuf_inside(mtr) || ibuf_page(id, block->zip_size(), nullptr)); if (modify_clock != block->modify_clock || block->page.is_freed()) { @@ -3110,12 +2799,11 @@ static buf_block_t *buf_page_create_low(page_id_t page_id, ulint zip_size, buf_page_t *bpage= buf_pool.page_hash.get(page_id, chain); - if (bpage && !buf_pool.watch_is_sentinel(*bpage)) + if (bpage) { #ifdef BTR_CUR_HASH_ADAPT const dict_index_t *drop_hash_entry= nullptr; #endif - bool ibuf_exist= false; if (!mtr->have_x_latch(reinterpret_cast(*bpage))) { @@ -3141,10 +2829,7 @@ static buf_block_t *buf_page_create_low(page_id_t page_id, ulint zip_size, if (state < buf_page_t::UNFIXED) bpage->set_reinit(buf_page_t::FREED); else - { bpage->set_reinit(state & buf_page_t::LRU_MASK); - ibuf_exist= (state & buf_page_t::LRU_MASK) == buf_page_t::IBUF_EXIST; - } if (UNIV_LIKELY(bpage->frame != nullptr)) { @@ -3170,10 +2855,7 @@ static buf_block_t *buf_page_create_low(page_id_t page_id, ulint zip_size, if (state < buf_page_t::UNFIXED) bpage->set_reinit(buf_page_t::FREED); else - { bpage->set_reinit(state & buf_page_t::LRU_MASK); - ibuf_exist= (state & buf_page_t::LRU_MASK) == buf_page_t::IBUF_EXIST; - } mysql_mutex_lock(&buf_pool.flush_list_mutex); buf_relocate(bpage, &free_block->page); @@ -3213,9 +2895,6 @@ static buf_block_t *buf_page_create_low(page_id_t page_id, ulint zip_size, false); #endif /* BTR_CUR_HASH_ADAPT */ - if (ibuf_exist && !recv_recovery_is_on()) - ibuf_merge_or_delete_for_page(nullptr, page_id, zip_size); - return reinterpret_cast(bpage); } @@ -3256,13 +2935,6 @@ static buf_block_t *buf_page_create_low(page_id_t page_id, ulint zip_size, bpage->set_accessed(); buf_pool.stat.n_pages_created++; - /* Delete possible entries for the page from the insert buffer: - such can exist if the page belonged to an index which was dropped */ - if (page_id < page_id_t{SRV_SPACE_ID_UPPER_BOUND, 0} && - !srv_is_undo_tablespace(page_id.space()) && - !recv_recovery_is_on()) - ibuf_merge_or_delete_for_page(nullptr, page_id, zip_size); - static_assert(FIL_PAGE_PREV + 4 == FIL_PAGE_NEXT, "adjacent"); memset_aligned<8>(bpage->frame + FIL_PAGE_PREV, 0xff, 8); mach_write_to_2(bpage->frame + FIL_PAGE_TYPE, FIL_PAGE_TYPE_ALLOCATED); @@ -3326,32 +2998,15 @@ ATTRIBUTE_COLD void buf_page_monitor(const buf_page_t &bpage, bool read) const byte* frame = bpage.zip.data ? bpage.zip.data : bpage.frame; switch (fil_page_get_type(frame)) { - ulint level; case FIL_PAGE_TYPE_INSTANT: case FIL_PAGE_INDEX: case FIL_PAGE_RTREE: - level = btr_page_get_level(frame); - - /* Check if it is an index page for insert buffer */ - if (fil_page_get_type(frame) == FIL_PAGE_INDEX - && btr_page_get_index_id(frame) - == (index_id_t)(DICT_IBUF_ID_MIN + IBUF_SPACE_ID)) { - if (level == 0) { - counter = MONITOR_RW_COUNTER( - read, MONITOR_INDEX_IBUF_LEAF_PAGE); - } else { - counter = MONITOR_RW_COUNTER( - read, - MONITOR_INDEX_IBUF_NON_LEAF_PAGE); - } + if (page_is_leaf(frame)) { + counter = MONITOR_RW_COUNTER( + read, MONITOR_INDEX_LEAF_PAGE); } else { - if (level == 0) { - counter = MONITOR_RW_COUNTER( - read, MONITOR_INDEX_LEAF_PAGE); - } else { - counter = MONITOR_RW_COUNTER( - read, MONITOR_INDEX_NON_LEAF_PAGE); - } + counter = MONITOR_RW_COUNTER( + read, MONITOR_INDEX_NON_LEAF_PAGE); } break; @@ -3363,14 +3018,6 @@ ATTRIBUTE_COLD void buf_page_monitor(const buf_page_t &bpage, bool read) counter = MONITOR_RW_COUNTER(read, MONITOR_INODE_PAGE); break; - case FIL_PAGE_IBUF_FREE_LIST: - counter = MONITOR_RW_COUNTER(read, MONITOR_IBUF_FREELIST_PAGE); - break; - - case FIL_PAGE_IBUF_BITMAP: - counter = MONITOR_RW_COUNTER(read, MONITOR_IBUF_BITMAP_PAGE); - break; - case FIL_PAGE_TYPE_SYS: counter = MONITOR_RW_COUNTER(read, MONITOR_SYSTEM_PAGE); break; @@ -3603,25 +3250,16 @@ dberr_t buf_page_t::read_complete(const fil_node_t &node) if (recovery && !recv_recover_page(node.space, this)) return DB_PAGE_CORRUPTED; - const bool ibuf_may_exist= frame && !recv_no_ibuf_operations && - (!expected_id.space() || !is_predefined_tablespace(expected_id.space())) && - fil_page_get_type(read_frame) == FIL_PAGE_INDEX && - page_is_leaf(read_frame); - if (UNIV_UNLIKELY(MONITOR_IS_ON(MONITOR_MODULE_BUF_PAGE))) buf_page_monitor(*this, true); DBUG_PRINT("ib_buf", ("read page %u:%u", id().space(), id().page_no())); if (!recovery) { - ut_d(auto f=) zip.fix.fetch_sub(ibuf_may_exist - ? READ_FIX - IBUF_EXIST - : READ_FIX - UNFIXED); + ut_d(auto f=) zip.fix.fetch_sub(READ_FIX - UNFIXED); ut_ad(f >= READ_FIX); ut_ad(f < WRITE_FIX); } - else if (ibuf_may_exist) - set_ibuf_exist(); lock.x_unlock(true); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index d71cbfbf7435d..99b44c0d06e36 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, MariaDB Corporation. Copyright (c) 2013, 2014, Fusion-io This program is free software; you can redistribute it and/or modify it under @@ -889,7 +889,7 @@ static bool buf_flush_check_neighbor(const page_id_t id, ulint fold, bool lru) const buf_page_t *bpage= buf_pool.page_hash.get(id, buf_pool.page_hash.cell_get(fold)); - if (!bpage || buf_pool.watch_is_sentinel(*bpage)) + if (!bpage) return false; /* We avoid flushing 'non-old' blocks in an LRU flush, because the @@ -1066,8 +1066,7 @@ static ulint buf_flush_try_neighbors(fil_space_t *space, because the flushed blocks are soon freed */ if (!lru || id == page_id || bpage->is_old()) { - if (!buf_pool.watch_is_sentinel(*bpage) && - bpage->oldest_modification() > 1 && bpage->ready_for_flush() && + if (bpage->oldest_modification() > 1 && bpage->ready_for_flush() && bpage->flush(lru, space)) { ++count; @@ -1174,7 +1173,7 @@ static void buf_flush_discard_page(buf_page_t *bpage) ut_d(const auto state= bpage->state()); ut_ad(state == buf_page_t::FREED || state == buf_page_t::UNFIXED || - state == buf_page_t::IBUF_EXIST || state == buf_page_t::REINIT); + state == buf_page_t::REINIT); bpage->lock.u_unlock(); buf_LRU_free_page(bpage, true); diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 4a2ac88d97c0e..731f8a6c7e7ba 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, 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 @@ -35,7 +35,7 @@ Created 11/5/1995 Heikki Tuuri #include "buf0lru.h" #include "buf0buddy.h" #include "buf0dblwr.h" -#include "ibuf0ibuf.h" +#include "page0zip.h" #include "log0recv.h" #include "trx0sys.h" #include "os0file.h" @@ -48,74 +48,24 @@ read-ahead is not done: this is to prevent flooding the buffer pool with i/o-fixed buffer blocks */ #define BUF_READ_AHEAD_PEND_LIMIT 2 -/** Remove the sentinel block for the watch before replacing it with a -real block. watch_unset() or watch_occurred() will notice -that the block has been replaced with the real block. -@param w sentinel -@param chain locked hash table chain -@return w->state() */ -inline uint32_t buf_pool_t::watch_remove(buf_page_t *w, - buf_pool_t::hash_chain &chain) -{ - mysql_mutex_assert_owner(&buf_pool.mutex); - ut_ad(xtest() || page_hash.lock_get(chain).is_write_locked()); - ut_ad(w >= &watch[0]); - ut_ad(w < &watch[array_elements(watch)]); - ut_ad(!w->in_zip_hash); - ut_ad(!w->zip.data); - - uint32_t s{w->state()}; - w->set_state(buf_page_t::NOT_USED); - ut_ad(s >= buf_page_t::UNFIXED); - ut_ad(s < buf_page_t::READ_FIX); - - if (~buf_page_t::LRU_MASK & s) - page_hash.remove(chain, w); - - ut_ad(!w->in_page_hash); - w->id_= page_id_t(~0ULL); - return s; -} - /** Initialize a page for read to the buffer buf_pool. If the page is (1) already in buf_pool, or -(2) if we specify to read only ibuf pages and the page is not an ibuf page, or -(3) if the space is deleted or being deleted, +(2) if the tablespace has been or is being deleted, then this function does nothing. Sets the io_fix flag to BUF_IO_READ and sets a non-recursive exclusive lock on the buffer frame. The io-handler must take care that the flag is cleared and the lock released later. -@param[in] mode BUF_READ_IBUF_PAGES_ONLY, ... @param[in] page_id page id @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] unzip whether the uncompressed page is - requested (for ROW_FORMAT=COMPRESSED) @return pointer to the block @retval NULL in case of an error */ TRANSACTIONAL_TARGET -static buf_page_t* buf_page_init_for_read(ulint mode, const page_id_t page_id, - ulint zip_size, bool unzip) +static buf_page_t* buf_page_init_for_read(const page_id_t page_id, + ulint zip_size) { - mtr_t mtr; - - if (mode == BUF_READ_IBUF_PAGES_ONLY) - { - /* It is a read-ahead within an ibuf routine */ - ut_ad(!ibuf_bitmap_page(page_id, zip_size)); - ibuf_mtr_start(&mtr); - - if (!recv_no_ibuf_operations && !ibuf_page(page_id, zip_size, &mtr)) - { - ibuf_mtr_commit(&mtr); - return nullptr; - } - } - else - ut_ad(mode == BUF_READ_ANY_PAGE); - buf_page_t *bpage= nullptr; buf_block_t *block= nullptr; - if (!zip_size || unzip || recv_recovery_is_on()) + if (!zip_size || recv_recovery_is_on()) { block= buf_LRU_get_free_block(false); block->initialise(page_id, zip_size, buf_page_t::READ_FIX); @@ -128,8 +78,7 @@ static buf_page_t* buf_page_init_for_read(ulint mode, const page_id_t page_id, mysql_mutex_lock(&buf_pool.mutex); - buf_page_t *hash_page= buf_pool.page_hash.get(page_id, chain); - if (hash_page && !buf_pool.watch_is_sentinel(*hash_page)) + if (buf_pool.page_hash.get(page_id, chain)) { /* The page is already in the buffer pool. */ if (block) @@ -149,11 +98,6 @@ static buf_page_t* buf_page_init_for_read(ulint mode, const page_id_t page_id, { transactional_lock_guard g {buf_pool.page_hash.lock_get(chain)}; - - if (hash_page) - bpage->set_state(buf_pool.watch_remove(hash_page, chain) + - (buf_page_t::READ_FIX - buf_page_t::UNFIXED)); - buf_pool.page_hash.append(chain, &block->page); } @@ -191,9 +135,7 @@ static buf_page_t* buf_page_init_for_read(ulint mode, const page_id_t page_id, check the page_hash again, as it may have been modified. */ if (UNIV_UNLIKELY(lru)) { - hash_page= buf_pool.page_hash.get(page_id, chain); - - if (UNIV_UNLIKELY(hash_page && !buf_pool.watch_is_sentinel(*hash_page))) + if (UNIV_LIKELY_NULL(buf_pool.page_hash.get(page_id, chain))) { /* The block was added by some other thread. */ buf_buddy_free(data, zip_size); @@ -213,11 +155,6 @@ static buf_page_t* buf_page_init_for_read(ulint mode, const page_id_t page_id, { transactional_lock_guard g {buf_pool.page_hash.lock_get(chain)}; - - if (hash_page) - bpage->set_state(buf_pool.watch_remove(hash_page, chain) + - (buf_page_t::READ_FIX - buf_page_t::UNFIXED)); - buf_pool.page_hash.append(chain, bpage); } @@ -228,13 +165,9 @@ static buf_page_t* buf_page_init_for_read(ulint mode, const page_id_t page_id, mysql_mutex_unlock(&buf_pool.mutex); buf_pool.n_pend_reads++; - goto func_exit_no_mutex; + return bpage; func_exit: mysql_mutex_unlock(&buf_pool.mutex); -func_exit_no_mutex: - if (mode == BUF_READ_IBUF_PAGES_ONLY) - ibuf_mtr_commit(&mtr); - ut_ad(!bpage || bpage->in_file()); return bpage; @@ -250,10 +183,8 @@ flag is cleared and the x-lock released by an i/o-handler thread. to read from a non-existent tablespace @param[in,out] space tablespace @param[in] sync true if synchronous aio is desired -@param[in] mode BUF_READ_IBUF_PAGES_ONLY, ..., @param[in] page_id page id @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] unzip true=request uncompressed page @return whether a read request was queued */ static bool @@ -261,10 +192,8 @@ buf_read_page_low( dberr_t* err, fil_space_t* space, bool sync, - ulint mode, const page_id_t page_id, - ulint zip_size, - bool unzip) + ulint zip_size) { buf_page_t* bpage; @@ -279,25 +208,11 @@ buf_read_page_low( return false; } - if (sync) { - } else if (trx_sys_hdr_page(page_id) - || ibuf_bitmap_page(page_id, zip_size) - || (!recv_no_ibuf_operations - && ibuf_page(page_id, zip_size, nullptr))) { - - /* Trx sys header is so low in the latching order that we play - safe and do not leave the i/o-completion to an asynchronous - i/o-thread. Change buffer pages must always be read with - synchronous i/o, to make sure they do not get involved in - thread deadlocks. */ - sync = true; - } - /* The following call will also check if the tablespace does not exist or is being dropped; if we succeed in initing the page in the buffer pool for read, then DISCARD cannot proceed until the read has completed */ - bpage = buf_page_init_for_read(mode, page_id, zip_size, unzip); + bpage = buf_page_init_for_read(page_id, zip_size); if (bpage == NULL) { goto nothing_read; @@ -311,7 +226,7 @@ buf_read_page_low( DBUG_LOG("ib_buf", "read page " << page_id << " zip_size=" << zip_size - << " unzip=" << unzip << ',' << (sync ? "sync" : "async")); + << (sync ? " sync" : " async")); void* dst = zip_size ? bpage->zip.data : bpage->frame; const ulint len = zip_size ? zip_size : srv_page_size; @@ -339,22 +254,15 @@ buf_read_page_low( /** Applies a random read-ahead in buf_pool if there are at least a threshold value of accessed pages from the random read-ahead area. Does not read any page, not even the one at the position (space, offset), if the read-ahead -mechanism is not activated. NOTE 1: the calling thread may own latches on +mechanism is not activated. NOTE: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot -end up waiting for these latches! NOTE 2: the calling thread must want -access to the page given: this rule is set to prevent unintended read-aheads -performed by ibuf routines, a situation which could result in a deadlock if -the OS does not support asynchronous i/o. +end up waiting for these latches! @param[in] page_id page id of a page which the current thread wants to access @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] ibuf whether we are inside ibuf routine -@return number of page read requests issued; NOTE that if we read ibuf -pages, it may happen that the page at the given page number does not -get read even if we return a positive value! */ +@return number of page read requests issued */ TRANSACTIONAL_TARGET -ulint -buf_read_ahead_random(const page_id_t page_id, ulint zip_size, bool ibuf) +ulint buf_read_ahead_random(const page_id_t page_id, ulint zip_size) { if (!srv_random_read_ahead) return 0; @@ -363,11 +271,6 @@ buf_read_ahead_random(const page_id_t page_id, ulint zip_size, bool ibuf) /* No read-ahead to avoid thread deadlocks */ return 0; - if (ibuf_bitmap_page(page_id, zip_size) || trx_sys_hdr_page(page_id)) - /* If it is an ibuf bitmap page or trx sys hdr, we do no - read-ahead, as that could break the ibuf page access order */ - return 0; - if (buf_pool.n_pend_reads > buf_pool.curr_size / BUF_READ_AHEAD_PEND_LIMIT) return 0; @@ -403,17 +306,14 @@ buf_read_ahead_random(const page_id_t page_id, ulint zip_size, bool ibuf) goto no_read_ahead; /* Read all the suitable blocks within the area */ - const ulint ibuf_mode= ibuf ? BUF_READ_IBUF_PAGES_ONLY : BUF_READ_ANY_PAGE; for (page_id_t i= low; i < high; ++i) { - if (ibuf_bitmap_page(i, zip_size)) - continue; if (space->is_stopping()) break; dberr_t err; space->reacquire(); - if (buf_read_page_low(&err, space, false, ibuf_mode, i, zip_size, false)) + if (buf_read_page_low(&err, space, false, i, zip_size)) count++; } @@ -454,8 +354,7 @@ dberr_t buf_read_page(const page_id_t page_id, ulint zip_size) } dberr_t err; - if (buf_read_page_low(&err, space, true, BUF_READ_ANY_PAGE, - page_id, zip_size, false)) + if (buf_read_page_low(&err, space, true, page_id, zip_size)) srv_stats.buf_pool_reads.add(1); buf_LRU_stat_inc_io(); @@ -474,8 +373,7 @@ void buf_read_page_background(fil_space_t *space, const page_id_t page_id, { dberr_t err; - if (buf_read_page_low(&err, space, false, BUF_READ_ANY_PAGE, - page_id, zip_size, false)) { + if (buf_read_page_low(&err, space, false, page_id, zip_size)) { srv_stats.buf_pool_reads.add(1); } @@ -506,16 +404,11 @@ only very improbably. NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! -NOTE 3: the calling thread must want access to the page given: this rule is -set to prevent unintended read-aheads performed by ibuf routines, a situation -which could result in a deadlock if the OS does not support asynchronous io. @param[in] page_id page id; see NOTE 3 above @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] ibuf whether if we are inside ibuf routine @return number of page read requests issued */ TRANSACTIONAL_TARGET -ulint -buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf) +ulint buf_read_ahead_linear(const page_id_t page_id, ulint zip_size) { /* check if readahead is disabled */ if (!srv_read_ahead_threshold) @@ -540,11 +433,6 @@ buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf) /* This is not a border page of the area */ return 0; - if (ibuf_bitmap_page(page_id, zip_size) || trx_sys_hdr_page(page_id)) - /* If it is an ibuf bitmap page or trx sys hdr, we do no - read-ahead, as that could break the ibuf page access order */ - return 0; - fil_space_t *space= fil_space_t::get(page_id.space()); if (!space) return 0; @@ -628,17 +516,13 @@ buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf) /* If we got this far, read-ahead can be sensible: do it */ count= 0; - for (ulint ibuf_mode= ibuf ? BUF_READ_IBUF_PAGES_ONLY : BUF_READ_ANY_PAGE; - new_low != new_high_1; ++new_low) + for (; new_low != new_high_1; ++new_low) { - if (ibuf_bitmap_page(new_low, zip_size)) - continue; if (space->is_stopping()) break; dberr_t err; space->reacquire(); - count+= buf_read_page_low(&err, space, false, ibuf_mode, new_low, zip_size, - false); + count+= buf_read_page_low(&err, space, false, new_low, zip_size); } if (count) @@ -706,9 +590,7 @@ void buf_read_recv_pages(uint32_t space_id, st_::span page_nos) dberr_t err; space->reacquire(); - buf_read_page_low(&err, space, false, - BUF_READ_ANY_PAGE, cur_page_id, zip_size, - true); + buf_read_page_low(&err, space, false, cur_page_id, zip_size); if (err != DB_SUCCESS) { sql_print_error("InnoDB: Recovery failed to read page " diff --git a/storage/innobase/data/data0type.cc b/storage/innobase/data/data0type.cc index b1952bcc2a4a4..dc1c4b9a04add 100644 --- a/storage/innobase/data/data0type.cc +++ b/storage/innobase/data/data0type.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -33,13 +33,6 @@ const byte reset_trx_id[DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN] = { 0x80, 0, 0, 0, 0, 0, 0 }; -/* At the database startup we store the default-charset collation number of -this MySQL installation to this global variable. If we have < 4.1.2 format -column definitions, or records in the insert buffer, we use this -charset-collation code for them. */ - -ulint data_mysql_default_charset_coll; - /*********************************************************************//** Determine how many bytes the first n characters of the given string occupy. If the string is shorter than n characters, returns the number of bytes diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc index 5516bce920bca..8d18b37f132d2 100644 --- a/storage/innobase/dict/dict0boot.cc +++ b/storage/innobase/dict/dict0boot.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2022, MariaDB Corporation. +Copyright (c) 2016, 2023, 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,7 +30,6 @@ Created 4/18/1996 Heikki Tuuri #include "dict0load.h" #include "trx0trx.h" #include "srv0srv.h" -#include "ibuf0ibuf.h" #include "buf0flu.h" #include "log0recv.h" #include "os0file.h" @@ -233,12 +232,12 @@ dberr_t dict_boot() dict_sys.create(); dberr_t err; - const buf_block_t *d = buf_page_get_gen(hdr_page_id, 0, RW_X_LATCH, + const buf_block_t *d = buf_page_get_gen(hdr_page_id, 0, RW_S_LATCH, nullptr, BUF_GET, &mtr, &err); - if (!d) { + if (!d) { mtr.commit(); return err; - } + } heap = mem_heap_create(450); @@ -420,10 +419,7 @@ dberr_t dict_boot() mtr.commit(); - err = ibuf_init_at_db_start(); - - if (err == DB_SUCCESS || srv_force_recovery >= SRV_FORCE_NO_DDL_UNDO) { - err = DB_SUCCESS; + if (err == DB_SUCCESS) { /* Load definitions of other indexes on system tables */ dict_load_sys_table(dict_sys.sys_tables); diff --git a/storage/innobase/dict/dict0defrag_bg.cc b/storage/innobase/dict/dict0defrag_bg.cc index ea2914e52dc52..964e75aacc143 100644 --- a/storage/innobase/dict/dict0defrag_bg.cc +++ b/storage/innobase/dict/dict0defrag_bg.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2016, 2022, MariaDB Corporation. +Copyright (c) 2016, 2023, 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 @@ -214,9 +214,6 @@ Save defragmentation result. @return DB_SUCCESS or error code */ dberr_t dict_stats_save_defrag_summary(dict_index_t *index, THD *thd) { - if (index->is_ibuf()) - return DB_SUCCESS; - MDL_ticket *mdl_table= nullptr, *mdl_index= nullptr; dict_table_t *table_stats= dict_table_open_on_name(TABLE_STATS_NAME, false, DICT_ERR_IGNORE_NONE); @@ -336,8 +333,6 @@ dict_stats_save_defrag_stats( /*============================*/ dict_index_t* index) /*!< in: index */ { - if (index->is_ibuf()) - return DB_SUCCESS; if (!index->is_readable()) return dict_stats_report_error(index->table, true); diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index e90dff03e16a1..c1c911480dd5a 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, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -1999,7 +1999,6 @@ dict_index_add_to_cache( ut_ad(index->n_def == index->n_fields); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); ut_ad(!dict_index_is_online_ddl(index)); - ut_ad(!dict_index_is_ibuf(index)); ut_d(mem_heap_validate(index->heap)); ut_a(!dict_index_is_clust(index) @@ -2381,15 +2380,7 @@ dict_index_copy_types( ulint n_fields) /*!< in: number of field types to copy */ { - ulint i; - - if (dict_index_is_ibuf(index)) { - dtuple_set_types_binary(tuple, n_fields); - - return; - } - - for (i = 0; i < n_fields; i++) { + for (ulint i = 0; i < n_fields; i++) { const dict_field_t* ifield; dtype_t* dfield_type; @@ -2628,17 +2619,14 @@ dict_index_build_internal_non_clust( ulint i; ibool* indexed; - ut_ad(table && index); - ut_ad(!dict_index_is_clust(index)); - ut_ad(!dict_index_is_ibuf(index)); + ut_ad(!index->is_primary()); ut_ad(dict_sys.locked()); /* The clustered index should be the first in the list of indexes */ clust_index = UT_LIST_GET_FIRST(table->indexes); ut_ad(clust_index); - ut_ad(dict_index_is_clust(clust_index)); - ut_ad(!dict_index_is_ibuf(clust_index)); + ut_ad(clust_index->is_clust()); /* Create a new index */ new_index = dict_mem_index_create( @@ -3769,24 +3757,7 @@ dict_index_build_node_ptr( dtuple_t* tuple; dfield_t* field; byte* buf; - ulint n_unique; - - if (dict_index_is_ibuf(index)) { - /* In a universal index tree, we take the whole record as - the node pointer if the record is on the leaf level, - on non-leaf levels we remove the last field, which - contains the page number of the child page */ - - ut_a(!dict_table_is_comp(index->table)); - n_unique = rec_get_n_fields_old(rec); - - if (level > 0) { - ut_a(n_unique > 1); - n_unique--; - } - } else { - n_unique = dict_index_get_n_unique_in_tree_nonleaf(index); - } + ulint n_unique = dict_index_get_n_unique_in_tree_nonleaf(index); tuple = dtuple_create(heap, n_unique + 1); diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 1ee10ec8232dd..b442e92664822 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, 2022, MariaDB Corporation. +Copyright (c) 2016, 2023, 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 @@ -865,9 +865,7 @@ dict_sys_tables_rec_read( return READ_OK; } -/** Check each tablespace found in the data dictionary. -Then look at each table defined in SYS_TABLES that has a space_id > 0 -to find all the file-per-table tablespaces. +/** Open each tablespace found in the data dictionary. In a crash recovery we already have some tablespace objects created from processing the REDO log. We will compare the @@ -876,14 +874,12 @@ tablespace file. In addition, more validation will be done if recovery was needed and force_recovery is not set. We also scan the biggest space id, and store it to fil_system. */ -void dict_check_tablespaces_and_store_max_id() +void dict_load_tablespaces() { uint32_t max_space_id = 0; btr_pcur_t pcur; mtr_t mtr; - DBUG_ENTER("dict_check_tablespaces_and_store_max_id"); - mtr.start(); dict_sys.lock(SRW_LOCK_CALL); @@ -976,8 +972,6 @@ void dict_check_tablespaces_and_store_max_id() fil_set_max_space_id_if_bigger(max_space_id); dict_sys.unlock(); - - DBUG_VOID_RETURN; } /** Error message for a delete-marked record in dict_load_column_low() */ @@ -1125,7 +1119,7 @@ static const char *dict_load_column_low(dict_table_t *table, prtype = dtype_form_prtype( prtype, - data_mysql_default_charset_coll); + default_charset_info->number); } } diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 06d3051522971..ce02d9513d171 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2009, 2019, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, 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 @@ -584,8 +584,6 @@ dict_stats_table_clone_create( continue; } - ut_ad(!dict_index_is_ibuf(index)); - ulint n_uniq = dict_index_get_n_unique(index); heap_size += sizeof(dict_index_t); @@ -634,8 +632,6 @@ dict_stats_table_clone_create( continue; } - ut_ad(!dict_index_is_ibuf(index)); - dict_index_t* idx; idx = (dict_index_t*) mem_heap_zalloc(heap, sizeof(*idx)); @@ -714,7 +710,6 @@ dict_stats_empty_index( /*!< in: whether to empty defrag stats */ { ut_ad(!(index->type & DICT_FTS)); - ut_ad(!dict_index_is_ibuf(index)); ut_ad(index->table->stats_mutex_is_owner()); ulint n_uniq = index->n_uniq; @@ -767,8 +762,6 @@ dict_stats_empty_table( continue; } - ut_ad(!dict_index_is_ibuf(index)); - dict_stats_empty_index(index, empty_defrag_stats); } @@ -901,8 +894,6 @@ dict_stats_copy( } } - ut_ad(!dict_index_is_ibuf(dst_idx)); - if (!INDEX_EQ(src_idx, dst_idx)) { for (src_idx = dict_table_get_first_index(src); src_idx != NULL; @@ -1094,11 +1085,10 @@ btr_cur_t::open_random_leaf(rec_offs *&offsets, mem_heap_t *&heap, mtr_t &mtr) dberr_t err; auto offset= index()->page; - bool merge= false; ulint height= ULINT_UNDEFINED; while (buf_block_t *block= - btr_block_get(*index(), offset, RW_S_LATCH, merge, &mtr, &err)) + btr_block_get(*index(), offset, RW_S_LATCH, &mtr, &err)) { page_cur.block= block; @@ -1120,8 +1110,7 @@ btr_cur_t::open_random_leaf(rec_offs *&offsets, mem_heap_t *&heap, mtr_t &mtr) return DB_SUCCESS; } - if (!--height) - merge= !index()->is_clust(); + height--; page_cur_open_on_rnd_user_rec(&page_cur); @@ -1462,10 +1451,6 @@ dict_stats_update_transient_for_index( dict_stats_empty_index(index, false); index->table->stats_mutex_unlock(); return err; -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG - } else if (ibuf_debug && !dict_index_is_clust(index)) { - goto dummy_empty; -#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ } else if (dict_index_is_online_ddl(index) || !index->is_committed() || !index->table->space) { goto dummy_empty; @@ -1571,9 +1556,6 @@ dict_stats_update_transient( } for (; index != NULL; index = dict_table_get_next_index(index)) { - - ut_ad(!dict_index_is_ibuf(index)); - if (!index->is_btree()) { continue; } @@ -1638,9 +1620,7 @@ static dberr_t page_cur_open_level(page_cur_t *page_cur, ulint level, for (ulint height = ULINT_UNDEFINED;; height--) { - buf_block_t* block= - btr_block_get(*index, page, RW_S_LATCH, - !height && !index->is_clust(), mtr, &err); + buf_block_t* block= btr_block_get(*index, page, RW_S_LATCH, mtr, &err); if (!block) break; @@ -2258,9 +2238,7 @@ dict_stats_analyze_index_below_cur( block = buf_page_get_gen(page_id, zip_size, RW_S_LATCH, NULL, BUF_GET, - &mtr, &err, - !index->is_clust() - && 1 == btr_page_get_level(page)); + &mtr, &err); if (!block) { goto func_exit; } @@ -2999,7 +2977,6 @@ dict_stats_update_persistent( return(DB_CORRUPTION); } - ut_ad(!dict_index_is_ibuf(index)); table->stats_mutex_lock(); dict_stats_empty_index(index, false); table->stats_mutex_unlock(); @@ -3373,8 +3350,6 @@ dict_stats_save( continue; } - ut_ad(!dict_index_is_ibuf(index)); - for (unsigned i = 0; i < index->n_uniq; i++) { char stat_name[16]; diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index cecda94cac476..bde04c84de635 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2021, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2022, MariaDB Corporation. +Copyright (c) 2014, 2023, 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 @@ -45,7 +45,6 @@ Created 10/25/1995 Heikki Tuuri #include "srv0start.h" #include "trx0purge.h" #include "buf0lru.h" -#include "ibuf0ibuf.h" #include "buf0flu.h" #include "log.h" #ifdef __linux__ @@ -1414,7 +1413,7 @@ void fil_system_t::set_write_through(bool write_through) { mysql_mutex_lock(&mutex); - if (write_through != this->write_through) + if (write_through != is_write_through()) { this->write_through= write_through; fil_space_t::reopen_all(); @@ -1427,7 +1426,7 @@ void fil_system_t::set_buffered(bool buffered) { mysql_mutex_lock(&mutex); - if (buffered != this->buffered) + if (buffered != is_buffered()) { this->buffered= buffered; fil_space_t::reopen_all(); @@ -1718,7 +1717,6 @@ pfs_os_file_t fil_delete_tablespace(uint32_t id) fil_space_free_low(space); } - ibuf_delete_for_discarded_space(id); return handle; } @@ -2859,10 +2857,6 @@ void fil_aio_callback(const IORequest &request) { ut_ad(request.is_read()); - /* IMPORTANT: since i/o handling for reads will read also the insert - buffer in fil_system.sys_space, we have to be very careful not to - introduce deadlocks. We never close fil_system.sys_space data - files and never issue asynchronous reads of change buffer pages. */ const page_id_t id(request.bpage->id()); if (dberr_t err= request.bpage->read_complete(*request.node)) diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index b6971558201b9..bdc08b22f3abb 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2021, MariaDB Corporation. +Copyright (C) 2013, 2023, 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 @@ -47,7 +47,6 @@ Updated 14/02/2015 #include "trx0sys.h" #include "row0mysql.h" #include "buf0lru.h" -#include "ibuf0ibuf.h" #include "zlib.h" #ifdef __linux__ #include diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 09583e157b7ec..a7b98e159cb2d 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, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -33,7 +33,6 @@ Created 11/29/1995 Heikki Tuuri #include "page0page.h" #include "srv0srv.h" #include "srv0start.h" -#include "ibuf0ibuf.h" #include "btr0btr.h" #include "btr0sea.h" #include "dict0boot.h" @@ -848,11 +847,17 @@ fsp_fill_free_list( { buf_block_t *f= buf_LRU_get_free_block(false); buf_block_t *block= - buf_page_create(space, - static_cast(i + FSP_IBUF_BITMAP_OFFSET), + buf_page_create(space, static_cast(i + 1), zip_size, mtr, f); if (UNIV_UNLIKELY(block != f)) buf_pool.free_block(f); + /* The zero-initialization will reset the change buffer bitmap bits + to safe values for possible import to an earlier version that + supports change buffering: + + IBUF_BITMAP_FREE = 0 (no space left for buffering inserts) + IBUF_BITMAP_BUFFERED = 0 (no changes have been buffered) + IBUF_BITMAP_IBUF = 0 (not part of the change buffer) */ fsp_init_file_page(space, block, mtr); mtr->write<2>(*block, FIL_PAGE_TYPE + block->page.frame, FIL_PAGE_IBUF_BITMAP); @@ -877,9 +882,9 @@ fsp_fill_free_list( if (UNIV_UNLIKELY(init_xdes)) { /* The first page in the extent is a descriptor page and the - second is an ibuf bitmap page: mark them used */ + second was reserved for change buffer bitmap: mark them used */ xdes_set_free(*xdes, descr, 0, mtr); - xdes_set_free(*xdes, descr, FSP_IBUF_BITMAP_OFFSET, mtr); + xdes_set_free(*xdes, descr, 1, mtr); xdes_set_state(*xdes, descr, XDES_FREE_FRAG, mtr); if (dberr_t err= flst_add_last(header, FSP_HEADER_OFFSET + FSP_FREE_FRAG, xdes, xoffset, mtr)) diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index 59d77c9c5fc12..28e8359cab43d 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, 2022, MariaDB Corporation. +Copyright (c) 2018, 2023, 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,7 +34,6 @@ Created 2013/03/27 Allen Lai and Jimmy Yang #include "btr0pcur.h" #include "rem0cmp.h" #include "lock0lock.h" -#include "ibuf0ibuf.h" #include "trx0undo.h" #include "srv0mon.h" #include "gis0geo.h" @@ -538,7 +537,7 @@ rtr_update_mbr_field( mem_heap_free(heap); } -MY_ATTRIBUTE((nonnull, warn_unused_result)) +MY_ATTRIBUTE((nonnull(1,3,4,5,6,8), warn_unused_result)) /**************************************************************//** Update parent page's MBR and Predicate lock information during a split */ static @@ -552,6 +551,7 @@ rtr_adjust_upper_level( buf_block_t* new_block, /*!< in/out: the new half page */ rtr_mbr_t* mbr, /*!< in: MBR on the old page */ rtr_mbr_t* new_mbr, /*!< in: MBR on the new page */ + que_thr_t* thr, /*!< in/out: query thread */ mtr_t* mtr) /*!< in: mtr */ { ulint page_no; @@ -570,7 +570,6 @@ rtr_adjust_upper_level( /* Create a memory heap where the data tuple is stored */ heap = mem_heap_create(1024); - cursor.thr = sea_cur->thr; cursor.page_cur.index = sea_cur->index(); cursor.page_cur.block = block; @@ -584,7 +583,8 @@ rtr_adjust_upper_level( /* Set new mbr for the old page on the upper level. */ /* Look up the index for the node pointer to page */ - offsets = rtr_page_get_father_block(NULL, heap, mtr, sea_cur, &cursor); + offsets = rtr_page_get_father_block(nullptr, heap, sea_cur, &cursor, + thr, mtr); page_cursor = btr_cur_get_page_cur(&cursor); @@ -669,7 +669,7 @@ rtr_adjust_upper_level( if (next_page_no == FIL_NULL) { } else if (buf_block_t* next_block = btr_block_get(*sea_cur->index(), next_page_no, RW_X_LATCH, - false, mtr, &err)) { + mtr, &err)) { if (UNIV_UNLIKELY(memcmp_aligned<4>(next_block->page.frame + FIL_PAGE_PREV, block->page.frame @@ -691,11 +691,6 @@ rtr_adjust_upper_level( /*************************************************************//** Moves record list to another page for rtree splitting. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if new_block is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return error code @retval DB_FAIL on ROW_FORMAT=COMPRESSED compression failure */ static @@ -731,8 +726,7 @@ rtr_split_page_move_rec_list( ulint max_to_move = 0; rtr_rec_move_t* rec_move = NULL; - ut_ad(!dict_index_is_ibuf(index)); - ut_ad(dict_index_is_spatial(index)); + ut_ad(index->is_spatial()); rec_offs_init(offsets_); @@ -867,7 +861,8 @@ rtr_page_split_and_insert( const dtuple_t* tuple, /*!< in: tuple to insert */ ulint n_ext, /*!< in: number of externally stored columns */ mtr_t* mtr, /*!< in: mtr */ - dberr_t* err) /*!< out: error code */ + dberr_t* err, /*!< out: error code */ + que_thr_t* thr) /*!< in: query thread */ { buf_block_t* block; page_t* page; @@ -1159,7 +1154,7 @@ rtr_page_split_and_insert( /* Adjust the upper level. */ *err = rtr_adjust_upper_level(cursor, flags, block, new_block, - &mbr, &new_mbr, mtr); + &mbr, &new_mbr, thr, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) { return nullptr; } @@ -1179,13 +1174,6 @@ rtr_page_split_and_insert( /* If the new res insert fail, we need to do another split again. */ if (!rec) { - /* We play safe and reset the free bits for new_page */ - if (!dict_index_is_clust(cursor->index()) - && !cursor->index()->table->is_temporary()) { - ibuf_reset_free_bits(new_block); - ibuf_reset_free_bits(block); - } - /* We need to clean the parent path here and search father node later, otherwise, it's possible that find a wrong parent. */ @@ -1214,6 +1202,244 @@ rtr_page_split_and_insert( return(rec); } +/*************************************************************//** +Makes tree one level higher by splitting the root, and inserts the tuple. +NOTE that the operation of this function must always succeed, +we cannot reverse it: therefore enough free disk space must be +guaranteed to be available before this function is called. +@return inserted record */ +rec_t* +rtr_root_raise_and_insert( +/*======================*/ + ulint flags, /*!< in: undo logging and locking flags */ + btr_cur_t* cursor, /*!< in: cursor at which to insert: must be + on the root page; when the function returns, + the cursor is positioned on the predecessor + of the inserted record */ + rec_offs** offsets,/*!< out: offsets on inserted record */ + mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */ + const dtuple_t* tuple, /*!< in: tuple to insert */ + ulint n_ext, /*!< in: number of externally stored columns */ + mtr_t* mtr, /*!< in: mtr */ + dberr_t* err, /*!< out: error code */ + que_thr_t* thr) /*!< in: query thread */ +{ + dict_index_t* index; + rec_t* rec; + dtuple_t* node_ptr; + ulint level; + rec_t* node_ptr_rec; + page_cur_t* page_cursor; + page_zip_des_t* root_page_zip; + page_zip_des_t* new_page_zip; + buf_block_t* root; + buf_block_t* new_block; + + root = btr_cur_get_block(cursor); + root_page_zip = buf_block_get_page_zip(root); + ut_ad(!page_is_empty(root->page.frame)); + index = btr_cur_get_index(cursor); + ut_ad(index->is_spatial()); +#ifdef UNIV_ZIP_DEBUG + ut_a(!root_page_zip + || page_zip_validate(root_page_zip, root->page.frame, index)); +#endif /* UNIV_ZIP_DEBUG */ + + const page_id_t root_id{root->page.id()}; + + ut_ad(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK + | MTR_MEMO_SX_LOCK)); + ut_ad(mtr->memo_contains_flagged(root, MTR_MEMO_PAGE_X_FIX)); + + if (index->page != root_id.page_no()) { + ut_ad("corrupted root page number" == 0); + return nullptr; + } + + if (!btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF, + *root, *index->table->space) + || !btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP, + *root, *index->table->space)) { + return nullptr; + } + + /* Allocate a new page to the tree. Root splitting is done by first + moving the root records to the new page, emptying the root, putting + a node pointer to the new page, and then splitting the new page. */ + + level = btr_page_get_level(root->page.frame); + + new_block = btr_page_alloc(index, 0, FSP_NO_DIR, level, mtr, mtr, err); + + if (!new_block) { + return nullptr; + } + + new_page_zip = buf_block_get_page_zip(new_block); + ut_a(!new_page_zip == !root_page_zip); + ut_a(!new_page_zip + || page_zip_get_size(new_page_zip) + == page_zip_get_size(root_page_zip)); + + btr_page_create(new_block, new_page_zip, index, level, mtr); + if (page_has_siblings(new_block->page.frame)) { + compile_time_assert(FIL_PAGE_NEXT == FIL_PAGE_PREV + 4); + compile_time_assert(FIL_NULL == 0xffffffff); + static_assert(FIL_PAGE_PREV % 8 == 0, "alignment"); + memset_aligned<8>(new_block->page.frame + FIL_PAGE_PREV, + 0xff, 8); + mtr->memset(new_block, FIL_PAGE_PREV, 8, 0xff); + if (UNIV_LIKELY_NULL(new_page_zip)) { + memset_aligned<8>(new_page_zip->data + FIL_PAGE_PREV, + 0xff, 8); + } + } + + /* Copy the records from root to the new page one by one. */ + dberr_t e; + if (!err) { + err = &e; + } + + if (0 +#ifdef UNIV_ZIP_COPY + || new_page_zip +#endif /* UNIV_ZIP_COPY */ + || !page_copy_rec_list_end(new_block, root, + page_get_infimum_rec(root->page.frame), + index, mtr, err)) { + switch (*err) { + case DB_SUCCESS: + break; + case DB_FAIL: + *err = DB_SUCCESS; + break; + default: + return nullptr; + } + + ut_a(new_page_zip); + + /* Copy the page byte for byte. */ + page_zip_copy_recs(new_block, root_page_zip, + root->page.frame, index, mtr); + + /* Update the lock table and possible hash index. */ + if (index->has_locking()) { + lock_move_rec_list_end( + new_block, root, + page_get_infimum_rec(root->page.frame)); + } + + /* Move any existing predicate locks */ + lock_prdt_rec_move(new_block, root_id); + } + + constexpr uint16_t max_trx_id = PAGE_HEADER + PAGE_MAX_TRX_ID; + if (!index->is_primary()) { + /* In secondary indexes, + PAGE_MAX_TRX_ID can be reset on the root page, because + the field only matters on leaf pages, and the root no + longer is a leaf page. (Older versions of InnoDB did + set PAGE_MAX_TRX_ID on all secondary index pages.) */ + byte* p = my_assume_aligned<8>( + PAGE_HEADER + PAGE_MAX_TRX_ID + root->page.frame); + if (mach_read_from_8(p)) { + mtr->memset(root, max_trx_id, 8, 0); + if (UNIV_LIKELY_NULL(root->page.zip.data)) { + memset_aligned<8>(max_trx_id + + root->page.zip.data, 0, 8); + } + } + } else { + /* PAGE_ROOT_AUTO_INC is only present in the clustered index + root page; on other clustered index pages, we want to reserve + the field PAGE_MAX_TRX_ID for future use. */ + byte* p = my_assume_aligned<8>( + PAGE_HEADER + PAGE_MAX_TRX_ID + new_block->page.frame); + if (mach_read_from_8(p)) { + mtr->memset(new_block, max_trx_id, 8, 0); + if (UNIV_LIKELY_NULL(new_block->page.zip.data)) { + memset_aligned<8>(max_trx_id + + new_block->page.zip.data, + 0, 8); + } + } + } + + /* If this is a pessimistic insert which is actually done to + perform a pessimistic update then we have stored the lock + information of the record to be inserted on the infimum of the + root page: we cannot discard the lock structs on the root page */ + + if (index->has_locking()) { + lock_update_root_raise(*new_block, root_id); + } + + /* Create a memory heap where the node pointer is stored */ + if (!*heap) { + *heap = mem_heap_create(1000); + } + + const uint32_t new_page_no = new_block->page.id().page_no(); + rec = page_rec_get_next(page_get_infimum_rec(new_block->page.frame)); + ut_ad(rec); /* We just created the page. */ + + /* Build the node pointer (= node key and page address) for the + child */ + rtr_mbr_t new_mbr; + rtr_page_cal_mbr(index, new_block, &new_mbr, *heap); + node_ptr = rtr_index_build_node_ptr(index, &new_mbr, rec, new_page_no, + *heap); + /* The node pointer must be marked as the predefined minimum record, + as there is no lower alphabetical limit to records in the leftmost + node of a level: */ + dtuple_set_info_bits(node_ptr, + dtuple_get_info_bits(node_ptr) + | REC_INFO_MIN_REC_FLAG); + + /* Rebuild the root page to get free space */ + btr_page_empty(root, root_page_zip, index, level + 1, mtr); + ut_ad(!page_has_siblings(root->page.frame)); + + page_cursor = btr_cur_get_page_cur(cursor); + + /* Insert node pointer to the root */ + + page_cur_set_before_first(root, page_cursor); + + node_ptr_rec = page_cur_tuple_insert(page_cursor, node_ptr, + offsets, heap, 0, mtr); + + /* The root page should only contain the node pointer + to new_block at this point. Thus, the data should fit. */ + ut_a(node_ptr_rec); + + page_cursor->block = new_block; + page_cursor->index = index; + + if (tuple) { + ut_ad(dtuple_check_typed(tuple)); + /* Reposition the cursor to the child node */ + ulint low_match = 0, up_match = 0; + + if (page_cur_search_with_match(tuple, PAGE_CUR_LE, + &up_match, &low_match, + page_cursor, nullptr)) { + if (err) { + *err = DB_CORRUPTION; + } + return nullptr; + } + } else { + page_cursor->rec = page_get_infimum_rec(new_block->page.frame); + } + + /* Split the child and insert tuple */ + return rtr_page_split_and_insert(flags, cursor, offsets, heap, + tuple, n_ext, mtr, err, thr); +} + /****************************************************************//** Following the right link to find the proper block for insert. @return the proper block.*/ @@ -1242,6 +1468,7 @@ rtr_ins_enlarge_mbr( /* Check path info is not empty. */ ut_ad(!btr_cur->rtr_info->parent_path->empty()); + ut_ad(btr_cur->rtr_info->thr || !btr_cur->index()->is_committed()); /* Create a memory heap. */ heap = mem_heap_create(1024); @@ -1267,7 +1494,8 @@ rtr_ins_enlarge_mbr( cursor.page_cur.index = page_cursor->index; cursor.page_cur.block = block; offsets = rtr_page_get_father_block( - NULL, heap, mtr, btr_cur, &cursor); + nullptr, heap, btr_cur, &cursor, + btr_cur->rtr_info->thr, mtr); page = buf_block_get_frame(block); diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index 207d49abebaf5..d3f991bb67703 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2016, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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,7 +34,6 @@ Created 2014/01/16 Jimmy Yang #include "btr0pcur.h" #include "rem0cmp.h" #include "lock0lock.h" -#include "ibuf0ibuf.h" #include "trx0trx.h" #include "srv0mon.h" #include "que0que.h" @@ -511,13 +510,13 @@ static void rtr_compare_cursor_rec(const rec_t *rec, dict_index_t *index, /**************************************************************//** Initializes and opens a persistent cursor to an index tree. It should be -closed with btr_pcur_close. Mainly called by row_search_index_entry() */ +closed with btr_pcur_close. */ bool rtr_pcur_open( - dict_index_t* index, /*!< in: index */ const dtuple_t* tuple, /*!< in: tuple on which search done */ btr_latch_mode latch_mode,/*!< in: BTR_SEARCH_LEAF, ... */ btr_pcur_t* cursor, /*!< in: memory buffer for persistent cursor */ + que_thr_t* thr, /*!< in/out; query thread */ mtr_t* mtr) /*!< in: mtr */ { static_assert(BTR_MODIFY_TREE == (8 | BTR_MODIFY_LEAF), ""); @@ -534,15 +533,16 @@ rtr_pcur_open( /* Search with the tree cursor */ btr_cur_t* btr_cursor = btr_pcur_get_btr_cur(cursor); - btr_cursor->page_cur.index = index; + dict_index_t* const index = cursor->index(); - btr_cursor->rtr_info = rtr_create_rtr_info(false, false, - btr_cursor, index); + btr_cursor->rtr_info = rtr_create_rtr_info(false, false, thr, + btr_cursor); - /* Purge will SX lock the tree instead of take Page Locks */ - if (btr_cursor->thr) { + if (!thr) { + /* Purge will U lock the tree instead of take Page Locks */ + } else { btr_cursor->rtr_info->need_page_lock = true; - btr_cursor->rtr_info->thr = btr_cursor->thr; + btr_cursor->rtr_info->thr = thr; } if ((latch_mode & 8) && index->lock.have_u_not_x()) { @@ -607,12 +607,14 @@ rtr_pcur_open( about parent nodes in search @param[out] cursor cursor on node pointer record, its page x-latched +@param[in,out] thr query thread @return whether the cursor was successfully positioned */ -bool rtr_page_get_father(mtr_t *mtr, btr_cur_t *sea_cur, btr_cur_t *cursor) +bool rtr_page_get_father(mtr_t *mtr, btr_cur_t *sea_cur, btr_cur_t *cursor, + que_thr_t *thr) { mem_heap_t *heap = mem_heap_create(100); rec_offs *offsets= rtr_page_get_father_block(nullptr, heap, - mtr, sea_cur, cursor); + sea_cur, cursor, thr, mtr); mem_heap_free(heap); return offsets != nullptr; } @@ -629,12 +631,13 @@ static const rec_t* rtr_get_father_node( btr_cur_t* sea_cur,/*!< in: search cursor */ btr_cur_t* btr_cur,/*!< in/out: tree cursor; the cursor page is s- or x-latched, but see also above! */ + que_thr_t* thr, /*!< in/out: query thread */ ulint page_no,/*!< Current page no */ mtr_t* mtr) /*!< in: mtr */ { const rec_t* rec = nullptr; auto had_rtr = btr_cur->rtr_info; - dict_index_t* const index = btr_cur->index(); + ut_d(dict_index_t* const index = btr_cur->index()); /* Try to optimally locate the parent node. Level should always less than sea_cur->tree_height unless the root is splitting */ @@ -666,7 +669,7 @@ static const rec_t* rtr_get_father_node( rtr_clean_rtr_info(btr_cur->rtr_info, true); } - btr_cur->rtr_info = rtr_create_rtr_info(false, false, btr_cur, index); + btr_cur->rtr_info = rtr_create_rtr_info(false, false, thr, btr_cur); if (btr_cur_search_to_nth_level(level, tuple, PAGE_CUR_RTREE_LOCATE, @@ -718,6 +721,7 @@ rtr_page_get_father_node_ptr( btr_cur_t* cursor, /*!< in: cursor pointing to user record, out: cursor on node pointer record, its page x-latched */ + que_thr_t* thr, /*!< in/out: query thread */ mtr_t* mtr) /*!< in: mtr */ { dtuple_t* tuple; @@ -754,7 +758,7 @@ rtr_page_get_father_node_ptr( const rec_t* node_ptr = rtr_get_father_node(level + 1, tuple, sea_cur, cursor, - page_no, mtr); + thr, page_no, mtr); if (!node_ptr) { return nullptr; } @@ -780,18 +784,20 @@ rtr_page_get_father_block( /*======================*/ rec_offs* offsets,/*!< in: work area for the return value */ mem_heap_t* heap, /*!< in: memory heap to use */ - mtr_t* mtr, /*!< in: mtr */ btr_cur_t* sea_cur,/*!< in: search cursor, contains information about parent nodes in search */ - btr_cur_t* cursor) /*!< out: cursor on node pointer record, + btr_cur_t* cursor, /*!< out: cursor on node pointer record, its page x-latched */ + que_thr_t* thr, /*!< in/out: query thread */ + mtr_t* mtr) /*!< in/out: mtr */ { rec_t *rec= page_rec_get_next(page_get_infimum_rec(cursor->block()->page.frame)); if (!rec) return nullptr; cursor->page_cur.rec= rec; - return rtr_page_get_father_node_ptr(offsets, heap, sea_cur, cursor, mtr); + return rtr_page_get_father_node_ptr(offsets, heap, sea_cur, cursor, + thr, mtr); } /*******************************************************************//** @@ -804,12 +810,12 @@ rtr_create_rtr_info( bool init_matches, /*!< in: Whether to initiate the "matches" structure for collecting matched leaf records */ - btr_cur_t* cursor, /*!< in: tree search cursor */ - dict_index_t* index) /*!< in: index struct */ + que_thr_t* thr, /*!< in/out: query thread */ + btr_cur_t* cursor) /*!< in: tree search cursor */ { rtr_info_t* rtr_info; - index = index ? index : cursor->index(); + dict_index_t* index = cursor->index(); ut_ad(index); rtr_info = static_cast(ut_zalloc_nokey(sizeof(*rtr_info))); @@ -817,6 +823,7 @@ rtr_create_rtr_info( rtr_info->allocated = true; rtr_info->cursor = cursor; rtr_info->index = index; + rtr_info->thr = thr; if (init_matches) { rtr_info->heap = mem_heap_create(sizeof(*(rtr_info->matches))); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a51e30e28ced8..d7e495ff3d75f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -87,7 +87,6 @@ this program; if not, write to the Free Software Foundation, Inc., #include "fts0plugin.h" #include "fts0priv.h" #include "fts0types.h" -#include "ibuf0ibuf.h" #include "lock0lock.h" #include "log0crypt.h" #include "mtr0mtr.h" @@ -399,25 +398,6 @@ static TYPELIB innodb_deadlock_report_typelib = { NULL }; -/** Allowed values of innodb_change_buffering */ -static const char* innodb_change_buffering_names[] = { - "none", /* IBUF_USE_NONE */ - "inserts", /* IBUF_USE_INSERT */ - "deletes", /* IBUF_USE_DELETE_MARK */ - "changes", /* IBUF_USE_INSERT_DELETE_MARK */ - "purges", /* IBUF_USE_DELETE */ - "all", /* IBUF_USE_ALL */ - NullS -}; - -/** Enumeration of innodb_change_buffering */ -static TYPELIB innodb_change_buffering_typelib = { - array_elements(innodb_change_buffering_names) - 1, - "innodb_change_buffering_typelib", - innodb_change_buffering_names, - NULL -}; - /** Allowed values of innodb_instant_alter_column_allowed */ const char* innodb_instant_alter_column_allowed_names[] = { "never", /* compatible with MariaDB 5.5 to 10.2 */ @@ -531,9 +511,6 @@ mysql_pfs_key_t fts_cache_mutex_key; mysql_pfs_key_t fts_cache_init_mutex_key; mysql_pfs_key_t fts_delete_mutex_key; mysql_pfs_key_t fts_doc_id_mutex_key; -mysql_pfs_key_t ibuf_bitmap_mutex_key; -mysql_pfs_key_t ibuf_mutex_key; -mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key; mysql_pfs_key_t recalc_pool_mutex_key; mysql_pfs_key_t purge_sys_pq_mutex_key; mysql_pfs_key_t recv_sys_mutex_key; @@ -565,8 +542,6 @@ static PSI_mutex_info all_innodb_mutexes[] = { PSI_KEY(fts_cache_init_mutex), PSI_KEY(fts_delete_mutex), PSI_KEY(fts_doc_id_mutex), - PSI_KEY(ibuf_mutex), - PSI_KEY(ibuf_pessimistic_insert_mutex), PSI_KEY(index_online_log), PSI_KEY(page_zip_stat_per_index_mutex), PSI_KEY(purge_sys_pq_mutex), @@ -973,20 +948,6 @@ static SHOW_VAR innodb_status_variables[]= { {"dblwr_writes", &export_vars.innodb_dblwr_writes, SHOW_SIZE_T}, {"deadlocks", &lock_sys.deadlocks, SHOW_SIZE_T}, {"history_list_length", &export_vars.innodb_history_list_length,SHOW_SIZE_T}, - {"ibuf_discarded_delete_marks", &ibuf.n_discarded_ops[IBUF_OP_DELETE_MARK], - SHOW_SIZE_T}, - {"ibuf_discarded_deletes", &ibuf.n_discarded_ops[IBUF_OP_DELETE], - SHOW_SIZE_T}, - {"ibuf_discarded_inserts", &ibuf.n_discarded_ops[IBUF_OP_INSERT], - SHOW_SIZE_T}, - {"ibuf_free_list", &ibuf.free_list_len, SHOW_SIZE_T}, - {"ibuf_merged_delete_marks", &ibuf.n_merged_ops[IBUF_OP_DELETE_MARK], - SHOW_SIZE_T}, - {"ibuf_merged_deletes", &ibuf.n_merged_ops[IBUF_OP_DELETE], SHOW_SIZE_T}, - {"ibuf_merged_inserts", &ibuf.n_merged_ops[IBUF_OP_INSERT], SHOW_SIZE_T}, - {"ibuf_merges", &ibuf.n_merges, SHOW_SIZE_T}, - {"ibuf_segment_size", &ibuf.seg_size, SHOW_SIZE_T}, - {"ibuf_size", &ibuf.size, SHOW_SIZE_T}, {"log_waits", &log_sys.waits, SHOW_SIZE_T}, {"log_write_requests", &log_sys.write_to_buf, SHOW_SIZE_T}, {"log_writes", &log_sys.write_to_log, SHOW_SIZE_T}, @@ -3927,8 +3888,6 @@ static int innodb_init_params() DBUG_RETURN(HA_ERR_INITIALIZATION); } - DBUG_ASSERT(innodb_change_buffering <= IBUF_USE_ALL); - /* Check that interdependent parameters have sane values. */ if (srv_max_buf_pool_modified_pct < srv_max_dirty_pages_pct_lwm) { sql_print_warning("InnoDB: innodb_max_dirty_pages_pct_lwm" @@ -4005,11 +3964,6 @@ static int innodb_init_params() fts_sort_pll_degree = num_pll_degree; - /* Store the default charset-collation number of this MySQL - installation */ - - data_mysql_default_charset_coll = (ulint) default_charset_info->number; - if (innodb_flush_method == 1 /* O_DSYNC */) { log_sys.log_write_through = true; fil_system.write_through = true; @@ -4213,8 +4167,6 @@ static int innodb_init(void* p) innobase_old_blocks_pct = buf_LRU_old_ratio_update( innobase_old_blocks_pct, true); - ibuf_max_size_update(srv_change_buffer_max_size); - mysql_mutex_init(pending_checkpoint_mutex_key, &log_requests.mutex, MY_MUTEX_INIT_FAST); @@ -4345,7 +4297,7 @@ innobase_start_trx_and_assign_read_view( Do this only if transaction is using REPEATABLE READ isolation level. */ trx->isolation_level = innobase_map_isolation_level( - thd_get_trx_isolation(thd)); + thd_get_trx_isolation(thd)) & 3; if (trx->isolation_level == TRX_ISO_REPEATABLE_READ) { trx->read_view.open(trx); @@ -6593,8 +6545,7 @@ uint8_t get_innobase_type_from_mysql_type(unsigned *unsigned_flag, const Field *field) { /* The following asserts try to check that the MySQL type code fits in - 8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to - the type */ + 8 bits: this is used when DATA_NOT_NULL is ORed to the type */ static_assert(MYSQL_TYPE_STRING < 256, "compatibility"); static_assert(MYSQL_TYPE_VAR_STRING < 256, "compatibility"); @@ -15264,7 +15215,7 @@ ha_innobase::check( } /* Restore the original isolation level */ - m_prebuilt->trx->isolation_level = old_isolation_level; + m_prebuilt->trx->isolation_level = old_isolation_level & 3; #ifdef BTR_CUR_HASH_ADAPT # if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG /* We validate the whole adaptive hash index for all tables @@ -16297,7 +16248,7 @@ ha_innobase::store_lock( if (lock_type != TL_IGNORE && trx->n_mysql_tables_in_use == 0) { trx->isolation_level = innobase_map_isolation_level( - (enum_tx_isolation) thd_tx_isolation(thd)); + (enum_tx_isolation) thd_tx_isolation(thd)) & 3; if (trx->isolation_level <= TRX_ISO_READ_COMMITTED) { @@ -17438,20 +17389,6 @@ innodb_old_blocks_pct_update(THD*, st_mysql_sys_var*, void*, const void* save) innobase_old_blocks_pct = ratio; } -/****************************************************************//** -Update the system variable innodb_old_blocks_pct using the "saved" -value. This function is registered as a callback with MySQL. */ -static -void -innodb_change_buffer_max_size_update(THD*, st_mysql_sys_var*, void*, - const void* save) -{ - srv_change_buffer_max_size = *static_cast(save); - mysql_mutex_unlock(&LOCK_global_system_variables); - ibuf_max_size_update(srv_change_buffer_max_size); - mysql_mutex_lock(&LOCK_global_system_variables); -} - #ifdef UNIV_DEBUG static uint srv_fil_make_page_dirty_debug = 0; static uint srv_saved_page_number_debug; @@ -19479,19 +19416,6 @@ static MYSQL_SYSVAR_BOOL(numa_interleave, srv_numa_interleave, NULL, NULL, FALSE); #endif /* HAVE_LIBNUMA */ -static MYSQL_SYSVAR_ENUM(change_buffering, innodb_change_buffering, - PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_DEPRECATED, - "Buffer changes to secondary indexes.", - nullptr, nullptr, IBUF_USE_NONE, &innodb_change_buffering_typelib); - -static MYSQL_SYSVAR_UINT(change_buffer_max_size, - srv_change_buffer_max_size, - PLUGIN_VAR_RQCMDARG, - "Maximum on-disk size of change buffer in terms of percentage" - " of the buffer pool.", - NULL, innodb_change_buffer_max_size_update, - CHANGE_BUFFER_DEFAULT_SIZE, 0, 50, 0); - static MYSQL_SYSVAR_ENUM(stats_method, srv_innodb_stats_method, PLUGIN_VAR_RQCMDARG, "Specifies how InnoDB index statistics collection code should" @@ -19499,18 +19423,6 @@ static MYSQL_SYSVAR_ENUM(stats_method, srv_innodb_stats_method, " NULLS_UNEQUAL and NULLS_IGNORED", NULL, NULL, SRV_STATS_NULLS_EQUAL, &innodb_stats_method_typelib); -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG -static MYSQL_SYSVAR_BOOL(change_buffer_dump, ibuf_dump, - PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, - "Dump the change buffer at startup.", - NULL, NULL, FALSE); - -static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug, - PLUGIN_VAR_RQCMDARG, - "Debug flags for InnoDB change buffering (0=none, 1=try to buffer)", - NULL, NULL, 0, 0, 1, 0); -#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ - static MYSQL_SYSVAR_ULONG(buf_dump_status_frequency, srv_buf_dump_status_frequency, PLUGIN_VAR_RQCMDARG, "A number between [0, 100] that tells how oftern buffer pool dump status " @@ -19840,12 +19752,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { #ifdef HAVE_LIBNUMA MYSQL_SYSVAR(numa_interleave), #endif /* HAVE_LIBNUMA */ - MYSQL_SYSVAR(change_buffering), - MYSQL_SYSVAR(change_buffer_max_size), -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG - MYSQL_SYSVAR(change_buffer_dump), - MYSQL_SYSVAR(change_buffering_debug), -#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ MYSQL_SYSVAR(random_read_ahead), MYSQL_SYSVAR(read_ahead_threshold), MYSQL_SYSVAR(read_only), diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 91c1ff53d2d3b..abca00323e012 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -2154,8 +2154,7 @@ static bool innobase_table_is_empty(const dict_table_t *table, } next_page= false; - block= btr_block_get(*clust_index, next_page_no, BTR_SEARCH_LEAF, false, - &mtr); + block= btr_block_get(*clust_index, next_page_no, BTR_SEARCH_LEAF, &mtr); if (!block) goto non_empty; page_cur_set_before_first(block, cur); diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 9510a4a8bfcfd..2a26f4f5ac26c 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, 2022, MariaDB Corporation. +Copyright (c) 2014, 2023, 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,7 +39,6 @@ Created July 18, 2007 Vasil Dimov #include "dict0load.h" #include "buf0buddy.h" #include "buf0buf.h" -#include "ibuf0ibuf.h" #include "dict0mem.h" #include "dict0types.h" #include "srv0start.h" @@ -80,10 +79,7 @@ in i_s_page_type[] array */ /** R-tree index page */ #define I_S_PAGE_TYPE_RTREE (FIL_PAGE_TYPE_LAST + 1) -/** Change buffer B-tree page */ -#define I_S_PAGE_TYPE_IBUF (FIL_PAGE_TYPE_LAST + 2) - -#define I_S_PAGE_TYPE_LAST I_S_PAGE_TYPE_IBUF +#define I_S_PAGE_TYPE_LAST I_S_PAGE_TYPE_RTREE #define I_S_PAGE_TYPE_BITS 4 @@ -104,9 +100,6 @@ static buf_page_desc_t i_s_page_type[] = { {"COMPRESSED_BLOB2", FIL_PAGE_TYPE_ZBLOB2}, {"UNKNOWN", I_S_PAGE_TYPE_UNKNOWN}, {"RTREE_INDEX", I_S_PAGE_TYPE_RTREE}, - {"IBUF_INDEX", I_S_PAGE_TYPE_IBUF}, - {"PAGE COMPRESSED", FIL_PAGE_PAGE_COMPRESSED}, - {"PAGE COMPRESSED AND ENCRYPTED", FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED}, }; /** This structure defines information we will fetch from pages @@ -3776,17 +3769,17 @@ i_s_innodb_buffer_page_fill( OK(fields[IDX_BUFFER_PAGE_STATE]->store( std::min(3, page_info->state) + 1, true)); - static_assert(buf_page_t::UNFIXED == 1U << 29, "comp."); + static_assert(buf_page_t::UNFIXED == 2U << 29, "comp."); static_assert(buf_page_t::READ_FIX == 4U << 29, "comp."); - static_assert(buf_page_t::WRITE_FIX == 5U << 29, "comp."); + static_assert(buf_page_t::WRITE_FIX == 6U << 29, "comp."); unsigned io_fix = page_info->state >> 29; if (io_fix < 4) { io_fix = 1; - } else if (io_fix > 5) { - io_fix = 3; + } else if (io_fix == 4) { + io_fix = 2; } else { - io_fix -= 2; + io_fix = 3; } OK(fields[IDX_BUFFER_PAGE_IO_FIX]->store(io_fix, true)); @@ -3824,14 +3817,9 @@ i_s_innodb_set_page_type( their values are defined as 17855 and 17854, so we cannot use them to index into i_s_page_type[] array, its array index in the i_s_page_type[] array is I_S_PAGE_TYPE_INDEX - (1) for index pages or I_S_PAGE_TYPE_IBUF for - change buffer index pages */ + (1) for index pages */ if (page_type == FIL_PAGE_RTREE) { page_info->page_type = I_S_PAGE_TYPE_RTREE; - } else if (page_info->index_id - == static_cast(DICT_IBUF_ID_MIN - + IBUF_SPACE_ID)) { - page_info->page_type = I_S_PAGE_TYPE_IBUF; } else { ut_ad(page_type == FIL_PAGE_INDEX || page_type == FIL_PAGE_TYPE_INSTANT); @@ -3876,9 +3864,9 @@ i_s_innodb_buffer_page_get_info( static_assert(buf_page_t::NOT_USED == 0, "compatibility"); static_assert(buf_page_t::MEMORY == 1, "compatibility"); static_assert(buf_page_t::REMOVE_HASH == 2, "compatibility"); - static_assert(buf_page_t::UNFIXED == 1U << 29, "compatibility"); + static_assert(buf_page_t::UNFIXED == 2U << 29, "compatibility"); static_assert(buf_page_t::READ_FIX == 4U << 29, "compatibility"); - static_assert(buf_page_t::WRITE_FIX == 5U << 29, "compatibility"); + static_assert(buf_page_t::WRITE_FIX == 6U << 29, "compatibility"); page_info->state = bpage->state(); @@ -4268,17 +4256,17 @@ i_s_innodb_buf_page_lru_fill( OK(fields[IDX_BUF_LRU_PAGE_STATE]->store( page_info->compressed_only, true)); - static_assert(buf_page_t::UNFIXED == 1U << 29, "comp."); + static_assert(buf_page_t::UNFIXED == 2U << 29, "comp."); static_assert(buf_page_t::READ_FIX == 4U << 29, "comp."); - static_assert(buf_page_t::WRITE_FIX == 5U << 29, "comp."); + static_assert(buf_page_t::WRITE_FIX == 6U << 29, "comp."); unsigned io_fix = page_info->state >> 29; if (io_fix < 4) { io_fix = 1; - } else if (io_fix > 5) { - io_fix = 3; + } else if (io_fix == 4) { + io_fix = 2; } else { - io_fix -= 2; + io_fix = 3; } OK(fields[IDX_BUF_LRU_PAGE_IO_FIX]->store(io_fix, true)); diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 2512232c7ca64..dcee5a7b0ef8d 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2022, MariaDB Corporation. +Copyright (c) 2023, 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 @@ -17,3583 +17,283 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************//** +/** @file ibuf/ibuf0ibuf.cc -Insert buffer - -Created 7/19/1997 Heikki Tuuri -*******************************************************/ +Upgrade and removal of the InnoDB change buffer +*/ #include "ibuf0ibuf.h" #include "btr0sea.h" - -/** Number of bits describing a single page */ -#define IBUF_BITS_PER_PAGE 4 -/** The start address for an insert buffer bitmap page bitmap */ -#define IBUF_BITMAP PAGE_DATA - -#include "buf0buf.h" -#include "buf0rea.h" -#include "fsp0fsp.h" -#include "trx0sys.h" -#include "fil0fil.h" -#include "rem0rec.h" -#include "btr0cur.h" #include "btr0pcur.h" -#include "btr0btr.h" #include "row0upd.h" -#include "dict0boot.h" -#include "fut0lst.h" -#include "lock0lock.h" -#include "log0recv.h" -#include "que0que.h" -#include "srv0start.h" /* srv_shutdown_state */ -#include "rem0cmp.h" +#include "my_service_manager.h" #include "log.h" -/* STRUCTURE OF AN INSERT BUFFER RECORD +/** Possible operations buffered in the change buffer. */ +enum ibuf_op +{ + IBUF_OP_INSERT= 0, + IBUF_OP_DELETE_MARK= 1, + IBUF_OP_DELETE= 2, +}; + +constexpr const page_id_t ibuf_root{0, FSP_IBUF_TREE_ROOT_PAGE_NO}; +constexpr const page_id_t ibuf_header{0, FSP_IBUF_HEADER_PAGE_NO}; +constexpr const index_id_t ibuf_index_id{0xFFFFFFFF00000000ULL}; -In versions < 4.1.x: +/* Format of the change buffer records: + +MySQL 3.23 and MySQL 4.0 (not supported since MySQL 5.6.5 and MariaDB 10.0.11): 1. The first field is the page number. 2. The second field is an array which stores type info for each subsequent - field. We store the information which affects the ordering of records, and + field (4 bytes per column). + We store the information which affects the ordering of records, and also the physical storage size of an SQL NULL value. E.g., for CHAR(10) it is 10 bytes. 3. Next we have the fields of the actual index record. -In versions >= 4.1.x: - -Note that contary to what we planned in the 1990's, there will only be one -insert buffer tree, and that is in the system tablespace of InnoDB. +MySQL 4.1: 1. The first field is the space id. 2. The second field is a one-byte marker (0) which differentiates records from the < 4.1.x storage format. 3. The third field is the page number. -4. The fourth field contains the type info, where we have also added 2 bytes to - store the charset. In the compressed table format of 5.0.x we must add more - information here so that we can build a dummy 'index' struct which 5.0.x - can use in the binary search on the index page in the ibuf merge phase. +4. The fourth field contains the type info + (6 bytes per index field, 16-bit collation information added). + Unless ROW_FORMAT=REDUNDANT, we add more metadata here so that + we can access records in the index page. 5. The rest of the fields contain the fields of the actual index record. -In versions >= 5.0.3: +MySQL 5.0 (starting with MySQL 5.0.3) and MySQL 5.1: The first byte of the fourth field is an additional marker (0) if the record -is in the compact format. The presence of this marker can be detected by -looking at the length of the field modulo DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE. +is not in ROW_FORMAT=REDUNDANT. The presence of this marker can be detected by +looking at the length of the field modulo 6. The high-order bit of the character set field in the type info is the "nullable" flag for the field. -In versions >= 5.5: +MySQL 5.5 and MariaDB 5.5 and later: -The optional marker byte at the start of the fourth field is replaced by -mandatory 3 fields, totaling 4 bytes: +Unless innodb_change_buffering=inserts, the optional marker byte at +the start of the fourth field may be replaced by mandatory 3 fields, +comprising 4 bytes: 1. 2 bytes: Counter field, used to sort records within a (space id, page no) in the order they were added. This is needed so that for example the sequence of operations "INSERT x, DEL MARK x, INSERT x" is handled correctly. - 2. 1 byte: Operation type (see ibuf_op_t). + 2. 1 byte: Operation type (see ibuf_op). - 3. 1 byte: Flags. Currently only one flag exists, IBUF_REC_COMPACT. - -To ensure older records, which do not have counters to enforce correct -sorting, are merged before any new records, ibuf_insert checks if we're -trying to insert to a position that contains old-style records, and if so, -refuses the insert. Thus, ibuf pages are gradually converted to the new -format as their corresponding buffer pool pages are read into memory. + 3. 1 byte: 0=ROW_FORMAT=REDUNDANT, 1=other */ - -/* PREVENTING DEADLOCKS IN THE INSERT BUFFER SYSTEM - -If an OS thread performs any operation that brings in disk pages from -non-system tablespaces into the buffer pool, or creates such a page there, -then the operation may have as a side effect an insert buffer index tree -compression. Thus, the tree latch of the insert buffer tree may be acquired -in the x-mode, and also the file space latch of the system tablespace may -be acquired in the x-mode. - -Also, an insert to an index in a non-system tablespace can have the same -effect. How do we know this cannot lead to a deadlock of OS threads? There -is a problem with the i\o-handler threads: they break the latching order -because they own x-latches to pages which are on a lower level than the -insert buffer tree latch, its page latches, and the tablespace latch an -insert buffer operation can reserve. - -The solution is the following: Let all the tree and page latches connected -with the insert buffer be later in the latching order than the fsp latch and -fsp page latches. - -Insert buffer pages must be such that the insert buffer is never invoked -when these pages are accessed as this would result in a recursion violating -the latching order. We let a special i/o-handler thread take care of i/o to -the insert buffer pages and the ibuf bitmap pages, as well as the fsp bitmap -pages and the first inode page, which contains the inode of the ibuf tree: let -us call all these ibuf pages. To prevent deadlocks, we do not let a read-ahead -access both non-ibuf and ibuf pages. - -Then an i/o-handler for the insert buffer never needs to access recursively the -insert buffer tree and thus obeys the latching order. On the other hand, other -i/o-handlers for other tablespaces may require access to the insert buffer, -but because all kinds of latches they need to access there are later in the -latching order, no violation of the latching order occurs in this case, -either. - -A problem is how to grow and contract an insert buffer tree. As it is later -in the latching order than the fsp management, we have to reserve the fsp -latch first, before adding or removing pages from the insert buffer tree. -We let the insert buffer tree have its own file space management: a free -list of pages linked to the tree root. To prevent recursive using of the -insert buffer when adding pages to the tree, we must first load these pages -to memory, obtaining a latch on them, and only after that add them to the -free list of the insert buffer tree. More difficult is removing of pages -from the free list. If there is an excess of pages in the free list of the -ibuf tree, they might be needed if some thread reserves the fsp latch, -intending to allocate more file space. So we do the following: if a thread -reserves the fsp latch, we check the writer count field of the latch. If -this field has value 1, it means that the thread did not own the latch -before entering the fsp system, and the mtr of the thread contains no -modifications to the fsp pages. Now we are free to reserve the ibuf latch, -and check if there is an excess of pages in the free list. We can then, in a -separate mini-transaction, take them out of the free list and free them to -the fsp system. - -To avoid deadlocks in the ibuf system, we divide file pages into three levels: - -(1) non-ibuf pages, -(2) ibuf tree pages and the pages in the ibuf tree free list, and -(3) ibuf bitmap pages. - -No OS thread is allowed to access higher level pages if it has latches to -lower level pages; even if the thread owns a B-tree latch it must not access -the B-tree non-leaf pages if it has latches on lower level pages. Read-ahead -is only allowed for level 1 and 2 pages. Dedicated i/o-handler threads handle -exclusively level 1 i/o. A dedicated i/o handler thread handles exclusively -level 2 i/o. However, if an OS thread does the i/o handling for itself, i.e., -it uses synchronous aio, it can access any pages, as long as it obeys the -access order rules. */ - -/** Operations that can currently be buffered. */ -ulong innodb_change_buffering; - -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG -/** Dump the change buffer at startup */ -my_bool ibuf_dump; -/** Flag to control insert buffer debugging. */ -uint ibuf_debug; -#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ - -/** The insert buffer control structure */ -ibuf_t ibuf; - -/** @name Offsets to the per-page bits in the insert buffer bitmap */ -/* @{ */ -#define IBUF_BITMAP_FREE 0 /*!< Bits indicating the - amount of free space */ -#define IBUF_BITMAP_BUFFERED 2 /*!< TRUE if there are buffered - changes for the page */ -#define IBUF_BITMAP_IBUF 3 /*!< TRUE if page is a part of - the ibuf tree, excluding the - root page, or is in the free - list of the ibuf */ -/* @} */ - -#define IBUF_REC_FIELD_SPACE 0 /*!< in the pre-4.1 format, - the page number. later, the space_id */ -#define IBUF_REC_FIELD_MARKER 1 /*!< starting with 4.1, a marker - consisting of 1 byte that is 0 */ -#define IBUF_REC_FIELD_PAGE 2 /*!< starting with 4.1, the - page number */ -#define IBUF_REC_FIELD_METADATA 3 /* the metadata field */ -#define IBUF_REC_FIELD_USER 4 /* first user field */ - -/* Various constants for checking the type of an ibuf record and extracting -data from it. For details, see the description of the record format at the -top of this file. */ - -/** @name Format of the IBUF_REC_FIELD_METADATA of an insert buffer record -The fourth column in the MySQL 5.5 format contains an operation -type, counter, and some flags. */ -/* @{ */ -#define IBUF_REC_INFO_SIZE 4 /*!< Combined size of info fields at - the beginning of the fourth field */ - -/* Offsets for the fields at the beginning of the fourth field */ -#define IBUF_REC_OFFSET_COUNTER 0 /*!< Operation counter */ -#define IBUF_REC_OFFSET_TYPE 2 /*!< Type of operation */ -#define IBUF_REC_OFFSET_FLAGS 3 /*!< Additional flags */ - -/* Record flag masks */ -#define IBUF_REC_COMPACT 0x1 /*!< Set in - IBUF_REC_OFFSET_FLAGS if the - user index is in COMPACT - format or later */ - - -#ifndef SAFE_MUTEX -static -#endif /* SAFE_MUTEX */ -/** The mutex protecting the insert buffer */ -mysql_mutex_t ibuf_mutex, - /** The mutex covering pessimistic inserts into the change buffer */ - ibuf_pessimistic_insert_mutex; - -/** The area in pages from which contract looks for page numbers for merge */ -const ulint IBUF_MERGE_AREA = 8; - -/** Inside the merge area, pages which have at most 1 per this number less -buffered entries compared to maximum volume that can buffered for a single -page are merged along with the page whose buffer became full */ -const ulint IBUF_MERGE_THRESHOLD = 4; - -/** In ibuf_contract at most this number of pages is read to memory in one -batch, in order to merge the entries for them in the insert buffer */ -const ulint IBUF_MAX_N_PAGES_MERGED = IBUF_MERGE_AREA; - -/** If the combined size of the ibuf trees exceeds ibuf.max_size by -this many pages, we start to contract it synchronous contract, but do -not insert */ -const ulint IBUF_CONTRACT_DO_NOT_INSERT = 10; - -/* TODO: how to cope with drop table if there are records in the insert -buffer for the indexes of the table? Is there actually any problem, -because ibuf merge is done to a page when it is read in, and it is -still physically like the index page even if the index would have been -dropped! So, there seems to be no problem. */ - -/******************************************************************//** -Sets the flag in the current mini-transaction record indicating we're -inside an insert buffer routine. */ -UNIV_INLINE -void -ibuf_enter( -/*=======*/ - mtr_t* mtr) /*!< in/out: mini-transaction */ -{ - ut_ad(!mtr->is_inside_ibuf()); - mtr->enter_ibuf(); -} - -/******************************************************************//** -Sets the flag in the current mini-transaction record indicating we're -exiting an insert buffer routine. */ -UNIV_INLINE -void -ibuf_exit( -/*======*/ - mtr_t* mtr) /*!< in/out: mini-transaction */ -{ - ut_ad(mtr->is_inside_ibuf()); - mtr->exit_ibuf(); -} - -/**************************************************************//** -Commits an insert buffer mini-transaction and sets the persistent -cursor latch mode to BTR_NO_LATCHES, that is, detaches the cursor. */ -UNIV_INLINE -void -ibuf_btr_pcur_commit_specify_mtr( -/*=============================*/ - btr_pcur_t* pcur, /*!< in/out: persistent cursor */ - mtr_t* mtr) /*!< in/out: mini-transaction */ -{ - ut_d(ibuf_exit(mtr)); - btr_pcur_commit_specify_mtr(pcur, mtr); -} - -/******************************************************************//** -Gets the ibuf header page and x-latches it. -@return insert buffer header page */ -static -page_t* -ibuf_header_page_get( -/*=================*/ - mtr_t* mtr) /*!< in/out: mini-transaction */ -{ - ut_ad(!ibuf_inside(mtr)); - - buf_block_t* block = buf_page_get( - page_id_t(IBUF_SPACE_ID, FSP_IBUF_HEADER_PAGE_NO), - 0, RW_X_LATCH, mtr); - - return block ? block->page.frame : nullptr; -} - -/** Acquire the change buffer root page. -@param[in,out] mtr mini-transaction -@return change buffer root page, SX-latched */ -static buf_block_t *ibuf_tree_root_get(mtr_t *mtr, dberr_t *err= nullptr) -{ - ut_ad(ibuf_inside(mtr)); - mysql_mutex_assert_owner(&ibuf_mutex); - - mtr_sx_lock_index(ibuf.index, mtr); - - buf_block_t *block= - buf_page_get_gen(page_id_t{IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO}, - 0, RW_SX_LATCH, nullptr, BUF_GET, mtr, err); - ut_ad(!block || ibuf.empty == page_is_empty(block->page.frame)); - return block; -} - -/******************************************************************//** -Closes insert buffer and frees the data structures. */ -void -ibuf_close(void) -/*============*/ -{ - if (!ibuf.index) { - return; - } - - mysql_mutex_destroy(&ibuf_pessimistic_insert_mutex); - mysql_mutex_destroy(&ibuf_mutex); - - dict_table_t* ibuf_table = ibuf.index->table; - ibuf.index->lock.free(); - dict_mem_index_free(ibuf.index); - dict_mem_table_free(ibuf_table); - ibuf.index = NULL; -} - -/******************************************************************//** -Updates the size information of the ibuf, assuming the segment size has not -changed. */ -static -void -ibuf_size_update( -/*=============*/ - const page_t* root) /*!< in: ibuf tree root */ -{ - mysql_mutex_assert_owner(&ibuf_mutex); - - ibuf.free_list_len = flst_get_len(root + PAGE_HEADER - + PAGE_BTR_IBUF_FREE_LIST); - - ibuf.height = 1 + btr_page_get_level(root); - - /* the '1 +' is the ibuf header page */ - ibuf.size = ibuf.seg_size - (1 + ibuf.free_list_len); -} - -/******************************************************************//** -Creates the insert buffer data structure at a database startup and initializes -the data structures for the insert buffer. -@return DB_SUCCESS or failure */ -dberr_t -ibuf_init_at_db_start(void) -/*=======================*/ -{ - page_t* root; - - ut_ad(!ibuf.index); - mtr_t mtr; - mtr.start(); - compile_time_assert(IBUF_SPACE_ID == TRX_SYS_SPACE); - compile_time_assert(IBUF_SPACE_ID == 0); - mtr.x_lock_space(fil_system.sys_space); - dberr_t err; - buf_block_t* header_page = buf_page_get_gen( - page_id_t(IBUF_SPACE_ID, FSP_IBUF_HEADER_PAGE_NO), - 0, RW_X_LATCH, nullptr, BUF_GET, &mtr, &err); - - if (!header_page) { -err_exit: - sql_print_error("InnoDB: The change buffer is corrupted"); - mtr.commit(); - return err; - } - - fseg_n_reserved_pages(*header_page, - IBUF_HEADER + IBUF_TREE_SEG_HEADER - + header_page->page.frame, &ibuf.seg_size, &mtr); - - do { - DBUG_EXECUTE_IF("intermittent_read_failure", continue;); - ut_ad(ibuf.seg_size >= 2); - } while (0); - - if (buf_block_t* block = - buf_page_get_gen(page_id_t(IBUF_SPACE_ID, - FSP_IBUF_TREE_ROOT_PAGE_NO), - 0, RW_X_LATCH, nullptr, BUF_GET, &mtr, &err)) { - root = buf_block_get_frame(block); - } else { - goto err_exit; - } - - if (page_is_comp(root) || fil_page_get_type(root) != FIL_PAGE_INDEX - || btr_page_get_index_id(root) != DICT_IBUF_ID_MIN) { - err = DB_CORRUPTION; - goto err_exit; - } - - /* At startup we intialize ibuf to have a maximum of - CHANGE_BUFFER_DEFAULT_SIZE in terms of percentage of the - buffer pool size. Once ibuf struct is initialized this - value is updated with the user supplied size by calling - ibuf_max_size_update(). */ - ibuf.max_size = ((buf_pool_get_curr_size() >> srv_page_size_shift) - * CHANGE_BUFFER_DEFAULT_SIZE) / 100; - - mysql_mutex_init(ibuf_mutex_key, &ibuf_mutex, nullptr); - mysql_mutex_init(ibuf_pessimistic_insert_mutex_key, - &ibuf_pessimistic_insert_mutex, nullptr); - - mysql_mutex_lock(&ibuf_mutex); - ibuf_size_update(root); - mysql_mutex_unlock(&ibuf_mutex); - - ibuf.empty = page_is_empty(root); - mtr.commit(); - - ibuf.index = dict_mem_index_create( - dict_table_t::create( - {C_STRING_WITH_LEN("innodb_change_buffer")}, - fil_system.sys_space, 1, 0, 0, 0), - "CLUST_IND", - DICT_CLUSTERED | DICT_IBUF, 1); - ibuf.index->id = DICT_IBUF_ID_MIN + IBUF_SPACE_ID; - ibuf.index->n_uniq = REC_MAX_N_FIELDS; - ibuf.index->lock.SRW_LOCK_INIT(index_tree_rw_lock_key); -#ifdef BTR_CUR_ADAPT - ibuf.index->search_info = btr_search_info_create(ibuf.index->heap); -#endif /* BTR_CUR_ADAPT */ - ibuf.index->page = FSP_IBUF_TREE_ROOT_PAGE_NO; - ut_d(ibuf.index->cached = TRUE); - -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG - if (!ibuf_dump) { - return DB_SUCCESS; - } - ib::info() << "Dumping the change buffer"; - ibuf_mtr_start(&mtr); - btr_pcur_t pcur; - if (DB_SUCCESS - == pcur.open_leaf(true, ibuf.index, BTR_SEARCH_LEAF, &mtr)) { - while (btr_pcur_move_to_next_user_rec(&pcur, &mtr)) { - rec_print_old(stderr, btr_pcur_get_rec(&pcur)); - } - } - ibuf_mtr_commit(&mtr); - ib::info() << "Dumped the change buffer"; -#endif - - return DB_SUCCESS; -} - -/*********************************************************************//** -Updates the max_size value for ibuf. */ -void -ibuf_max_size_update( -/*=================*/ - ulint new_val) /*!< in: new value in terms of - percentage of the buffer pool size */ -{ - if (UNIV_UNLIKELY(!ibuf.index)) return; - ulint new_size = ((buf_pool_get_curr_size() >> srv_page_size_shift) - * new_val) / 100; - mysql_mutex_lock(&ibuf_mutex); - ibuf.max_size = new_size; - mysql_mutex_unlock(&ibuf_mutex); -} - -# ifdef UNIV_DEBUG -/** Gets the desired bits for a given page from a bitmap page. -@param[in] page bitmap page -@param[in] page_id page id whose bits to get -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... -@param[in,out] mtr mini-transaction holding an x-latch on the -bitmap page -@return value of bits */ -# define ibuf_bitmap_page_get_bits(page, page_id, zip_size, bit, mtr) \ - ibuf_bitmap_page_get_bits_low(page, page_id, zip_size, \ - MTR_MEMO_PAGE_X_FIX, mtr, bit) -# else /* UNIV_DEBUG */ -/** Gets the desired bits for a given page from a bitmap page. -@param[in] page bitmap page -@param[in] page_id page id whose bits to get -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... -@param[in,out] mtr mini-transaction holding an x-latch on the -bitmap page -@return value of bits */ -# define ibuf_bitmap_page_get_bits(page, page_id, zip_size, bit, mtr) \ - ibuf_bitmap_page_get_bits_low(page, page_id, zip_size, bit) -# endif /* UNIV_DEBUG */ - -/** Gets the desired bits for a given page from a bitmap page. -@param[in] page bitmap page -@param[in] page_id page id whose bits to get -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] latch_type MTR_MEMO_PAGE_X_FIX, MTR_MEMO_BUF_FIX, ... -@param[in,out] mtr mini-transaction holding latch_type on the -bitmap page -@param[in] bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... -@return value of bits */ -UNIV_INLINE -ulint -ibuf_bitmap_page_get_bits_low( - const page_t* page, - const page_id_t page_id, - ulint zip_size, -#ifdef UNIV_DEBUG - ulint latch_type, - mtr_t* mtr, -#endif /* UNIV_DEBUG */ - ulint bit) -{ - ulint byte_offset; - ulint bit_offset; - ulint map_byte; - ulint value; - const ulint size = zip_size ? zip_size : srv_page_size; - - ut_ad(ut_is_2pow(zip_size)); - ut_ad(bit < IBUF_BITS_PER_PAGE); - compile_time_assert(!(IBUF_BITS_PER_PAGE % 2)); - ut_ad(mtr->memo_contains_page_flagged(page, latch_type)); - - bit_offset = (page_id.page_no() & (size - 1)) - * IBUF_BITS_PER_PAGE + bit; - - byte_offset = bit_offset / 8; - bit_offset = bit_offset % 8; - - ut_ad(byte_offset + IBUF_BITMAP < srv_page_size); - - map_byte = mach_read_from_1(page + IBUF_BITMAP + byte_offset); - - value = ut_bit_get_nth(map_byte, bit_offset); - - if (bit == IBUF_BITMAP_FREE) { - ut_ad(bit_offset + 1 < 8); - - value = value * 2 + ut_bit_get_nth(map_byte, bit_offset + 1); - } - - return(value); -} - -/** Sets the desired bit for a given page in a bitmap page. -@tparam bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... -@param[in,out] block bitmap page -@param[in] page_id page id whose bits to set -@param[in] physical_size page size -@param[in] val value to set -@param[in,out] mtr mtr containing an x-latch to the bitmap page */ -template -static void -ibuf_bitmap_page_set_bits( - buf_block_t* block, - const page_id_t page_id, - ulint physical_size, - ulint val, - mtr_t* mtr) -{ - ulint byte_offset; - ulint bit_offset; - - static_assert(bit < IBUF_BITS_PER_PAGE, "wrong bit"); - compile_time_assert(!(IBUF_BITS_PER_PAGE % 2)); - ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); - ut_ad(mtr->is_named_space(page_id.space())); - - bit_offset = (page_id.page_no() % physical_size) - * IBUF_BITS_PER_PAGE + bit; - - byte_offset = bit_offset / 8; - bit_offset = bit_offset % 8; - - ut_ad(byte_offset + IBUF_BITMAP < srv_page_size); - - byte* map_byte = &block->page.frame[IBUF_BITMAP + byte_offset]; - byte b = *map_byte; - - if (bit == IBUF_BITMAP_FREE) { - ut_ad(bit_offset + 1 < 8); - ut_ad(val <= 3); - b &= static_cast(~(3U << bit_offset)); - b |= static_cast(((val & 2) >> 1) << bit_offset - | (val & 1) << (bit_offset + 1)); - } else { - ut_ad(val <= 1); - b &= static_cast(~(1U << bit_offset)); -#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wconversion" /* GCC 5 may need this here */ -#endif - b |= static_cast(val << bit_offset); -#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6 -# pragma GCC diagnostic pop -#endif - } - - mtr->write<1,mtr_t::MAYBE_NOP>(*block, map_byte, b); -} - -/** Calculates the bitmap page number for a given page number. -@param[in] page_id page id -@param[in] size page size -@return the bitmap page id where the file page is mapped */ -inline page_id_t ibuf_bitmap_page_no_calc(const page_id_t page_id, ulint size) -{ - if (!size) - size= srv_page_size; - - return page_id_t(page_id.space(), FSP_IBUF_BITMAP_OFFSET - + uint32_t(page_id.page_no() & ~(size - 1))); -} - -/** Gets the ibuf bitmap page where the bits describing a given file page are -stored. -@param[in] page_id page id of the file page -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in,out] mtr mini-transaction -@return bitmap page where the file page is mapped, that is, the bitmap -page containing the descriptor bits for the file page; the bitmap page -is x-latched */ -static -buf_block_t* -ibuf_bitmap_get_map_page( - const page_id_t page_id, - ulint zip_size, - mtr_t* mtr) -{ - return buf_page_get_gen(ibuf_bitmap_page_no_calc(page_id, zip_size), - zip_size, RW_X_LATCH, nullptr, - BUF_GET_POSSIBLY_FREED, mtr); -} - -/************************************************************************//** -Sets the free bits of the page in the ibuf bitmap. This is done in a separate -mini-transaction, hence this operation does not restrict further work to only -ibuf bitmap operations, which would result if the latch to the bitmap page -were kept. */ -UNIV_INLINE -void -ibuf_set_free_bits_low( -/*===================*/ - const buf_block_t* block, /*!< in: index page; free bits are set if - the index is non-clustered and page - level is 0 */ - ulint val, /*!< in: value to set: < 4 */ - mtr_t* mtr) /*!< in/out: mtr */ -{ - ut_ad(mtr->is_named_space(block->page.id().space())); - if (!page_is_leaf(block->page.frame)) { - return; - } - -#ifdef UNIV_IBUF_DEBUG - ut_a(val <= ibuf_index_page_calc_free(block)); -#endif /* UNIV_IBUF_DEBUG */ - const page_id_t id(block->page.id()); - - if (buf_block_t* bitmap_page = ibuf_bitmap_get_map_page( - id, block->zip_size(), mtr)) { - ibuf_bitmap_page_set_bits( - bitmap_page, id, block->physical_size(), - val, mtr); - } -} - -/************************************************************************//** -Sets the free bit of the page in the ibuf bitmap. This is done in a separate -mini-transaction, hence this operation does not restrict further work to only -ibuf bitmap operations, which would result if the latch to the bitmap page -were kept. */ -void -ibuf_set_free_bits_func( -/*====================*/ - buf_block_t* block, /*!< in: index page of a non-clustered index; - free bit is reset if page level is 0 */ -#ifdef UNIV_IBUF_DEBUG - ulint max_val,/*!< in: ULINT_UNDEFINED or a maximum - value which the bits must have before - setting; this is for debugging */ -#endif /* UNIV_IBUF_DEBUG */ - ulint val) /*!< in: value to set: < 4 */ -{ - if (!page_is_leaf(block->page.frame)) - return; - - mtr_t mtr; - mtr.start(); - const page_id_t id(block->page.id()); - const fil_space_t *space= mtr.set_named_space_id(id.space()); - - if (buf_block_t *bitmap_page= - ibuf_bitmap_get_map_page(id, block->zip_size(), &mtr)) - { - if (space->purpose != FIL_TYPE_TABLESPACE) - mtr.set_log_mode(MTR_LOG_NO_REDO); - -#ifdef UNIV_IBUF_DEBUG - if (max_val != ULINT_UNDEFINED) - { - ulint old_val= ibuf_bitmap_page_get_bits(bitmap_page, id, - IBUF_BITMAP_FREE, &mtr); - ut_a(old_val <= max_val); - } - - ut_a(val <= ibuf_index_page_calc_free(block)); -#endif /* UNIV_IBUF_DEBUG */ - - ibuf_bitmap_page_set_bits - (bitmap_page, id, block->physical_size(), val, &mtr); - } - - mtr.commit(); -} - -/************************************************************************//** -Resets the free bits of the page in the ibuf bitmap. This is done in a -separate mini-transaction, hence this operation does not restrict -further work to only ibuf bitmap operations, which would result if the -latch to the bitmap page were kept. NOTE: The free bits in the insert -buffer bitmap must never exceed the free space on a page. It is safe -to decrement or reset the bits in the bitmap in a mini-transaction -that is committed before the mini-transaction that affects the free -space. */ -void -ibuf_reset_free_bits( -/*=================*/ - buf_block_t* block) /*!< in: index page; free bits are set to 0 - if the index is a non-clustered - non-unique, and page level is 0 */ -{ - ibuf_set_free_bits(block, 0, ULINT_UNDEFINED); -} - -/**********************************************************************//** -Updates the free bits for an uncompressed page to reflect the present -state. Does this in the mtr given, which means that the latching -order rules virtually prevent any further operations for this OS -thread until mtr is committed. NOTE: The free bits in the insert -buffer bitmap must never exceed the free space on a page. It is safe -to set the free bits in the same mini-transaction that updated the -page. */ -void -ibuf_update_free_bits_low( -/*======================*/ - const buf_block_t* block, /*!< in: index page */ - ulint max_ins_size, /*!< in: value of - maximum insert size - with reorganize before - the latest operation - performed to the page */ - mtr_t* mtr) /*!< in/out: mtr */ -{ - ulint before; - ulint after; - - ut_a(!is_buf_block_get_page_zip(block)); - ut_ad(mtr->is_named_space(block->page.id().space())); - - before = ibuf_index_page_calc_free_bits(srv_page_size, - max_ins_size); - - after = ibuf_index_page_calc_free(block); - - /* This approach cannot be used on compressed pages, since the - computed value of "before" often does not match the current - state of the bitmap. This is because the free space may - increase or decrease when a compressed page is reorganized. */ - if (before != after) { - ibuf_set_free_bits_low(block, after, mtr); - } -} - -/**********************************************************************//** -Updates the free bits for a compressed page to reflect the present -state. Does this in the mtr given, which means that the latching -order rules virtually prevent any further operations for this OS -thread until mtr is committed. NOTE: The free bits in the insert -buffer bitmap must never exceed the free space on a page. It is safe -to set the free bits in the same mini-transaction that updated the -page. */ -void -ibuf_update_free_bits_zip( -/*======================*/ - buf_block_t* block, /*!< in/out: index page */ - mtr_t* mtr) /*!< in/out: mtr */ -{ - ut_ad(page_is_leaf(block->page.frame)); - ut_ad(block->zip_size()); - - ulint after = ibuf_index_page_calc_free_zip(block); - - if (after == 0) { - /* We move the page to the front of the buffer pool LRU list: - the purpose of this is to prevent those pages to which we - cannot make inserts using the insert buffer from slipping - out of the buffer pool */ - - buf_page_make_young(&block->page); - } - - if (buf_block_t* bitmap_page = ibuf_bitmap_get_map_page( - block->page.id(), block->zip_size(), mtr)) { - - ibuf_bitmap_page_set_bits( - bitmap_page, block->page.id(), - block->physical_size(), after, mtr); - } -} - -/**********************************************************************//** -Updates the free bits for the two pages to reflect the present state. -Does this in the mtr given, which means that the latching order rules -virtually prevent any further operations until mtr is committed. -NOTE: The free bits in the insert buffer bitmap must never exceed the -free space on a page. It is safe to set the free bits in the same -mini-transaction that updated the pages. */ -void -ibuf_update_free_bits_for_two_pages_low( -/*====================================*/ - buf_block_t* block1, /*!< in: index page */ - buf_block_t* block2, /*!< in: index page */ - mtr_t* mtr) /*!< in: mtr */ -{ - ut_ad(mtr->is_named_space(block1->page.id().space())); - ut_ad(block1->page.id().space() == block2->page.id().space()); - - /* Avoid deadlocks by acquiring multiple bitmap page latches in - a consistent order (smaller pointer first). */ - if (block1 > block2) - std::swap(block1, block2); - - ibuf_set_free_bits_low(block1, ibuf_index_page_calc_free(block1), mtr); - ibuf_set_free_bits_low(block2, ibuf_index_page_calc_free(block2), mtr); -} - -/** Returns TRUE if the page is one of the fixed address ibuf pages. -@param[in] page_id page id -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@return TRUE if a fixed address ibuf i/o page */ -inline bool ibuf_fixed_addr_page(const page_id_t page_id, ulint zip_size) -{ - return(page_id == page_id_t(IBUF_SPACE_ID, IBUF_TREE_ROOT_PAGE_NO) - || ibuf_bitmap_page(page_id, zip_size)); -} - -/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. -Must not be called when recv_no_ibuf_operations==true. -@param[in] page_id page id -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] x_latch FALSE if relaxed check (avoid latching the -bitmap page) -@param[in,out] mtr mtr which will contain an x-latch to the -bitmap page if the page is not one of the fixed address ibuf pages, or NULL, -in which case a new transaction is created. -@return TRUE if level 2 or level 3 page */ -bool -ibuf_page_low( - const page_id_t page_id, - ulint zip_size, -#ifdef UNIV_DEBUG - bool x_latch, -#endif /* UNIV_DEBUG */ - mtr_t* mtr) -{ - ibool ret; - mtr_t local_mtr; - - ut_ad(!recv_no_ibuf_operations); - ut_ad(x_latch || mtr == NULL); - - if (ibuf_fixed_addr_page(page_id, zip_size)) { - return(true); - } else if (page_id.space() != IBUF_SPACE_ID) { - return(false); - } - - compile_time_assert(IBUF_SPACE_ID == 0); - ut_ad(fil_system.sys_space->purpose == FIL_TYPE_TABLESPACE); - -#ifdef UNIV_DEBUG - if (!x_latch) { - mtr_start(&local_mtr); - - /* Get the bitmap page without a page latch, so that - we will not be violating the latching order when - another bitmap page has already been latched by this - thread. The page will be buffer-fixed, and thus it - cannot be removed or relocated while we are looking at - it. The contents of the page could change, but the - IBUF_BITMAP_IBUF bit that we are interested in should - not be modified by any other thread. Nobody should be - calling ibuf_add_free_page() or ibuf_remove_free_page() - while the page is linked to the insert buffer b-tree. */ - buf_block_t* block = buf_page_get_gen( - ibuf_bitmap_page_no_calc(page_id, zip_size), - zip_size, RW_NO_LATCH, nullptr, BUF_GET, &local_mtr); - - ret = block - && ibuf_bitmap_page_get_bits_low( - block->page.frame, page_id, zip_size, - MTR_MEMO_BUF_FIX, &local_mtr, IBUF_BITMAP_IBUF); - - mtr_commit(&local_mtr); - return(ret); - } -#endif /* UNIV_DEBUG */ - - if (mtr == NULL) { - mtr = &local_mtr; - mtr_start(mtr); - } - - buf_block_t *block = ibuf_bitmap_get_map_page(page_id, zip_size, - mtr); - ret = block - && ibuf_bitmap_page_get_bits(block->page.frame, - page_id, zip_size, - IBUF_BITMAP_IBUF, mtr); - - if (mtr == &local_mtr) { - mtr_commit(mtr); - } - - return(ret); -} - -#ifdef UNIV_DEBUG -# define ibuf_rec_get_page_no(mtr,rec) ibuf_rec_get_page_no_func(mtr,rec) -#else /* UNIV_DEBUG */ -# define ibuf_rec_get_page_no(mtr,rec) ibuf_rec_get_page_no_func(rec) -#endif /* UNIV_DEBUG */ +/** first user record field */ +constexpr unsigned IBUF_REC_FIELD_USER= 4; /********************************************************************//** Returns the page number field of an ibuf record. @return page number */ -static -uint32_t -ibuf_rec_get_page_no_func( -/*======================*/ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction owning rec */ -#endif /* UNIV_DEBUG */ - const rec_t* rec) /*!< in: ibuf record */ +static uint32_t ibuf_rec_get_page_no(const rec_t *rec) { - const byte* field; - ulint len; - - ut_ad(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX - | MTR_MEMO_PAGE_S_FIX)); - ut_ad(ibuf_inside(mtr)); - ut_ad(rec_get_n_fields_old(rec) > 2); - - field = rec_get_nth_field_old(rec, IBUF_REC_FIELD_MARKER, &len); - - ut_a(len == 1); - - field = rec_get_nth_field_old(rec, IBUF_REC_FIELD_PAGE, &len); - - ut_a(len == 4); - - return(mach_read_from_4(field)); + return mach_read_from_4(rec + 5); } -#ifdef UNIV_DEBUG -# define ibuf_rec_get_space(mtr,rec) ibuf_rec_get_space_func(mtr,rec) -#else /* UNIV_DEBUG */ -# define ibuf_rec_get_space(mtr,rec) ibuf_rec_get_space_func(rec) -#endif /* UNIV_DEBUG */ - /********************************************************************//** -Returns the space id field of an ibuf record. For < 4.1.x format records -returns 0. +Returns the space id field of an ibuf record. @return space id */ -static -uint32_t -ibuf_rec_get_space_func( -/*====================*/ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction owning rec */ -#endif /* UNIV_DEBUG */ - const rec_t* rec) /*!< in: ibuf record */ +static uint32_t ibuf_rec_get_space(const rec_t *rec) { - const byte* field; - ulint len; - - ut_ad(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX - | MTR_MEMO_PAGE_S_FIX)); - ut_ad(ibuf_inside(mtr)); - ut_ad(rec_get_n_fields_old(rec) > 2); - - field = rec_get_nth_field_old(rec, IBUF_REC_FIELD_MARKER, &len); - - ut_a(len == 1); - - field = rec_get_nth_field_old(rec, IBUF_REC_FIELD_SPACE, &len); - - ut_a(len == 4); - - return(mach_read_from_4(field)); + return mach_read_from_4(rec); } -#ifdef UNIV_DEBUG -# define ibuf_rec_get_info(mtr,rec,op,comp,info_len,counter) \ - ibuf_rec_get_info_func(mtr,rec,op,comp,info_len,counter) -#else /* UNIV_DEBUG */ -# define ibuf_rec_get_info(mtr,rec,op,comp,info_len,counter) \ - ibuf_rec_get_info_func(rec,op,comp,info_len,counter) -#endif -/****************************************************************//** -Get various information about an ibuf record in >= 4.1.x format. */ +/********************************************************************//** +Add a column to the dummy index */ static void -ibuf_rec_get_info_func( -/*===================*/ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction owning rec */ -#endif /* UNIV_DEBUG */ - const rec_t* rec, /*!< in: ibuf record */ - ibuf_op_t* op, /*!< out: operation type, or NULL */ - ibool* comp, /*!< out: compact flag, or NULL */ - ulint* info_len, /*!< out: length of info fields at the - start of the fourth field, or - NULL */ - ulint* counter) /*!< in: counter value, or NULL */ -{ - const byte* types; - ulint fields; - ulint len; - - /* Local variables to shadow arguments. */ - ibuf_op_t op_local; - ibool comp_local; - ulint info_len_local; - ulint counter_local; - - ut_ad(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX - | MTR_MEMO_PAGE_S_FIX)); - ut_ad(ibuf_inside(mtr)); - fields = rec_get_n_fields_old(rec); - ut_a(fields > IBUF_REC_FIELD_USER); - - types = rec_get_nth_field_old(rec, IBUF_REC_FIELD_METADATA, &len); - - info_len_local = len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE; - compile_time_assert(IBUF_REC_INFO_SIZE - < DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); - - switch (info_len_local) { - case 0: - case 1: - op_local = IBUF_OP_INSERT; - comp_local = info_len_local; - ut_ad(!counter); - counter_local = ULINT_UNDEFINED; - break; - - case IBUF_REC_INFO_SIZE: - op_local = (ibuf_op_t) types[IBUF_REC_OFFSET_TYPE]; - comp_local = types[IBUF_REC_OFFSET_FLAGS] & IBUF_REC_COMPACT; - counter_local = mach_read_from_2( - types + IBUF_REC_OFFSET_COUNTER); - break; - - default: - ut_error; - } - - ut_a(op_local < IBUF_OP_COUNT); - ut_a((len - info_len_local) == - (fields - IBUF_REC_FIELD_USER) - * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); - - if (op) { - *op = op_local; - } - - if (comp) { - *comp = comp_local; - } - - if (info_len) { - *info_len = info_len_local; - } - - if (counter) { - *counter = counter_local; - } -} - -#ifdef UNIV_DEBUG -# define ibuf_rec_get_op_type(mtr,rec) ibuf_rec_get_op_type_func(mtr,rec) -#else /* UNIV_DEBUG */ -# define ibuf_rec_get_op_type(mtr,rec) ibuf_rec_get_op_type_func(rec) -#endif - -/****************************************************************//** -Returns the operation type field of an ibuf record. -@return operation type */ -static -ibuf_op_t -ibuf_rec_get_op_type_func( -/*======================*/ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction owning rec */ -#endif /* UNIV_DEBUG */ - const rec_t* rec) /*!< in: ibuf record */ -{ - ulint len; - - ut_ad(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX - | MTR_MEMO_PAGE_S_FIX)); - ut_ad(ibuf_inside(mtr)); - ut_ad(rec_get_n_fields_old(rec) > 2); - - (void) rec_get_nth_field_old(rec, IBUF_REC_FIELD_MARKER, &len); - - if (len > 1) { - /* This is a < 4.1.x format record */ - - return(IBUF_OP_INSERT); - } else { - ibuf_op_t op; - - ibuf_rec_get_info(mtr, rec, &op, NULL, NULL, NULL); - - return(op); - } -} - -/****************************************************************//** -Read the first two bytes from a record's fourth field (counter field in new -records; something else in older records). -@return "counter" field, or ULINT_UNDEFINED if for some reason it -can't be read */ -ulint -ibuf_rec_get_counter( -/*=================*/ - const rec_t* rec) /*!< in: ibuf record */ -{ - const byte* ptr; - ulint len; - - if (rec_get_n_fields_old(rec) <= IBUF_REC_FIELD_METADATA) { - - return(ULINT_UNDEFINED); - } - - ptr = rec_get_nth_field_old(rec, IBUF_REC_FIELD_METADATA, &len); - - if (len >= 2) { - - return(mach_read_from_2(ptr)); - } else { - - return(ULINT_UNDEFINED); - } -} - - -/** - Add accumulated operation counts to a permanent array. - Both arrays must be of size IBUF_OP_COUNT. -*/ -static void ibuf_add_ops(Atomic_counter *out, const ulint *in) -{ - for (auto i = 0; i < IBUF_OP_COUNT; i++) - out[i]+= in[i]; -} - - -/****************************************************************//** -Print operation counts. The array must be of size IBUF_OP_COUNT. */ -static -void -ibuf_print_ops( -/*===========*/ - const char* op_name,/*!< in: operation name */ - const Atomic_counter* ops, /*!< in: operation counts */ - FILE* file) /*!< in: file where to print */ -{ - static const char* op_names[] = { - "insert", - "delete mark", - "delete" - }; - - static_assert(array_elements(op_names) == IBUF_OP_COUNT, ""); - fputs(op_name, file); - - for (ulint i = 0; i < IBUF_OP_COUNT; i++) { - fprintf(file, "%s " ULINTPF "%s", op_names[i], - ulint{ops[i]}, (i < (IBUF_OP_COUNT - 1)) ? ", " : ""); - } - - putc('\n', file); -} - -/********************************************************************//** -Creates a dummy index for inserting a record to a non-clustered index. -@return dummy index */ -static -dict_index_t* -ibuf_dummy_index_create( -/*====================*/ - ulint n, /*!< in: number of fields */ - ibool comp) /*!< in: TRUE=use compact record format */ -{ - dict_table_t* table; - dict_index_t* index; - - table = dict_table_t::create({C_STRING_WITH_LEN("IBUF_DUMMY")}, - nullptr, n, 0, - comp ? DICT_TF_COMPACT : 0, 0); - - index = dict_mem_index_create(table, "IBUF_DUMMY", 0, n); - - /* avoid ut_ad(index->cached) in dict_index_get_n_unique_in_tree */ - index->cached = TRUE; - ut_d(index->is_dummy = true); - - return(index); -} -/********************************************************************//** -Add a column to the dummy index */ -static -void -ibuf_dummy_index_add_col( -/*=====================*/ - dict_index_t* index, /*!< in: dummy index */ - const dtype_t* type, /*!< in: the data type of the column */ - ulint len) /*!< in: length of the column */ +ibuf_dummy_index_add_col( +/*=====================*/ + dict_index_t* index, /*!< in: dummy index */ + const dtype_t* type, /*!< in: the data type of the column */ + ulint len) /*!< in: length of the column */ { ulint i = index->table->n_def; dict_mem_table_add_col(index->table, NULL, NULL, dtype_get_mtype(type), dtype_get_prtype(type), - dtype_get_len(type)); - dict_index_add_col(index, index->table, - dict_table_get_nth_col(index->table, i), len); -} -/********************************************************************//** -Deallocates a dummy index for inserting a record to a non-clustered index. */ -static -void -ibuf_dummy_index_free( -/*==================*/ - dict_index_t* index) /*!< in, own: dummy index */ -{ - dict_table_t* table = index->table; - - dict_mem_index_free(index); - dict_mem_table_free(table); -} - -#ifdef UNIV_DEBUG -# define ibuf_build_entry_from_ibuf_rec(mtr,ibuf_rec,heap,pindex) \ - ibuf_build_entry_from_ibuf_rec_func(mtr,ibuf_rec,heap,pindex) -#else /* UNIV_DEBUG */ -# define ibuf_build_entry_from_ibuf_rec(mtr,ibuf_rec,heap,pindex) \ - ibuf_build_entry_from_ibuf_rec_func(ibuf_rec,heap,pindex) -#endif - -/*********************************************************************//** -Builds the entry used to - -1) IBUF_OP_INSERT: insert into a non-clustered index - -2) IBUF_OP_DELETE_MARK: find the record whose delete-mark flag we need to - activate - -3) IBUF_OP_DELETE: find the record we need to delete - -when we have the corresponding record in an ibuf index. - -NOTE that as we copy pointers to fields in ibuf_rec, the caller must -hold a latch to the ibuf_rec page as long as the entry is used! - -@return own: entry to insert to a non-clustered index */ -static -dtuple_t* -ibuf_build_entry_from_ibuf_rec_func( -/*================================*/ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction owning rec */ -#endif /* UNIV_DEBUG */ - const rec_t* ibuf_rec, /*!< in: record in an insert buffer */ - mem_heap_t* heap, /*!< in: heap where built */ - dict_index_t** pindex) /*!< out, own: dummy index that - describes the entry */ -{ - dtuple_t* tuple; - dfield_t* field; - ulint n_fields; - const byte* types; - const byte* data; - ulint len; - ulint info_len; - ulint i; - ulint comp; - dict_index_t* index; - - ut_ad(mtr->memo_contains_page_flagged(ibuf_rec, MTR_MEMO_PAGE_X_FIX - | MTR_MEMO_PAGE_S_FIX)); - ut_ad(ibuf_inside(mtr)); - - data = rec_get_nth_field_old(ibuf_rec, IBUF_REC_FIELD_MARKER, &len); - - ut_a(len == 1); - ut_a(*data == 0); - ut_a(rec_get_n_fields_old(ibuf_rec) > IBUF_REC_FIELD_USER); - - n_fields = rec_get_n_fields_old(ibuf_rec) - IBUF_REC_FIELD_USER; - - tuple = dtuple_create(heap, n_fields); - - types = rec_get_nth_field_old(ibuf_rec, IBUF_REC_FIELD_METADATA, &len); - - ibuf_rec_get_info(mtr, ibuf_rec, NULL, &comp, &info_len, NULL); - - index = ibuf_dummy_index_create(n_fields, comp); - - len -= info_len; - types += info_len; - - ut_a(len == n_fields * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); - - for (i = 0; i < n_fields; i++) { - field = dtuple_get_nth_field(tuple, i); - - data = rec_get_nth_field_old( - ibuf_rec, i + IBUF_REC_FIELD_USER, &len); - - dfield_set_data(field, data, len); - - dtype_new_read_for_order_and_null_size( - dfield_get_type(field), - types + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); - - ibuf_dummy_index_add_col(index, dfield_get_type(field), len); - } - - index->n_core_null_bytes = static_cast( - UT_BITS_IN_BYTES(unsigned(index->n_nullable))); - - /* Prevent an ut_ad() failure in page_zip_write_rec() by - adding system columns to the dummy table pointed to by the - dummy secondary index. The insert buffer is only used for - secondary indexes, whose records never contain any system - columns, such as DB_TRX_ID. */ - ut_d(dict_table_add_system_columns(index->table, index->table->heap)); - - *pindex = index; - - return(tuple); -} - -/******************************************************************//** -Get the data size. -@return size of fields */ -UNIV_INLINE -ulint -ibuf_rec_get_size( -/*==============*/ - const rec_t* rec, /*!< in: ibuf record */ - const byte* types, /*!< in: fields */ - ulint n_fields, /*!< in: number of fields */ - ulint comp) /*!< in: 0=ROW_FORMAT=REDUNDANT, - nonzero=ROW_FORMAT=COMPACT */ -{ - ulint i; - ulint field_offset; - ulint types_offset; - ulint size = 0; - - field_offset = IBUF_REC_FIELD_USER; - types_offset = DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE; - - for (i = 0; i < n_fields; i++) { - ulint len; - dtype_t dtype; - - rec_get_nth_field_offs_old(rec, i + field_offset, &len); - - if (len != UNIV_SQL_NULL) { - size += len; - } else { - dtype_new_read_for_order_and_null_size(&dtype, types); - - size += dtype_get_sql_null_size(&dtype, comp); - } - - types += types_offset; - } - - return(size); -} - -#ifdef UNIV_DEBUG -# define ibuf_rec_get_volume(mtr,rec) ibuf_rec_get_volume_func(mtr,rec) -#else /* UNIV_DEBUG */ -# define ibuf_rec_get_volume(mtr,rec) ibuf_rec_get_volume_func(rec) -#endif - -/********************************************************************//** -Returns the space taken by a stored non-clustered index entry if converted to -an index record. -@return size of index record in bytes + an upper limit of the space -taken in the page directory */ -static -ulint -ibuf_rec_get_volume_func( -/*=====================*/ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction owning rec */ -#endif /* UNIV_DEBUG */ - const rec_t* ibuf_rec)/*!< in: ibuf record */ -{ - ulint len; - const byte* data; - const byte* types; - ulint n_fields; - ulint data_size; - ulint comp; - ibuf_op_t op; - ulint info_len; - - ut_ad(mtr->memo_contains_page_flagged(ibuf_rec, MTR_MEMO_PAGE_X_FIX - | MTR_MEMO_PAGE_S_FIX)); - ut_ad(ibuf_inside(mtr)); - ut_ad(rec_get_n_fields_old(ibuf_rec) > 2); - - data = rec_get_nth_field_old(ibuf_rec, IBUF_REC_FIELD_MARKER, &len); - ut_a(len == 1); - ut_a(*data == 0); - - types = rec_get_nth_field_old( - ibuf_rec, IBUF_REC_FIELD_METADATA, &len); - - ibuf_rec_get_info(mtr, ibuf_rec, &op, &comp, &info_len, NULL); - - if (op == IBUF_OP_DELETE_MARK || op == IBUF_OP_DELETE) { - /* Delete-marking a record doesn't take any - additional space, and while deleting a record - actually frees up space, we have to play it safe and - pretend it takes no additional space (the record - might not exist, etc.). */ - - return(0); - } else if (comp) { - dtuple_t* entry; - ulint volume; - dict_index_t* dummy_index; - mem_heap_t* heap = mem_heap_create(500); - - entry = ibuf_build_entry_from_ibuf_rec(mtr, ibuf_rec, - heap, &dummy_index); - - volume = rec_get_converted_size(dummy_index, entry, 0); - - ibuf_dummy_index_free(dummy_index); - mem_heap_free(heap); - - return(volume + page_dir_calc_reserved_space(1)); - } - - types += info_len; - n_fields = rec_get_n_fields_old(ibuf_rec) - - IBUF_REC_FIELD_USER; - - data_size = ibuf_rec_get_size(ibuf_rec, types, n_fields, comp); - - return(data_size + rec_get_converted_extra_size(data_size, n_fields, 0) - + page_dir_calc_reserved_space(1)); -} - -/*********************************************************************//** -Builds the tuple to insert to an ibuf tree when we have an entry for a -non-clustered index. - -NOTE that the original entry must be kept because we copy pointers to -its fields. - -@return own: entry to insert into an ibuf index tree */ -static -dtuple_t* -ibuf_entry_build( -/*=============*/ - ibuf_op_t op, /*!< in: operation type */ - dict_index_t* index, /*!< in: non-clustered index */ - const dtuple_t* entry, /*!< in: entry for a non-clustered index */ - ulint space, /*!< in: space id */ - ulint page_no,/*!< in: index page number where entry should - be inserted */ - ulint counter,/*!< in: counter value; - ULINT_UNDEFINED=not used */ - mem_heap_t* heap) /*!< in: heap into which to build */ -{ - dtuple_t* tuple; - dfield_t* field; - const dfield_t* entry_field; - ulint n_fields; - byte* buf; - byte* ti; - byte* type_info; - ulint i; - - ut_ad(counter != ULINT_UNDEFINED || op == IBUF_OP_INSERT); - ut_ad(counter == ULINT_UNDEFINED || counter <= 0xFFFF); - ut_ad(op < IBUF_OP_COUNT); - - /* We have to build a tuple with the following fields: - - 1-4) These are described at the top of this file. - - 5) The rest of the fields are copied from the entry. - - All fields in the tuple are ordered like the type binary in our - insert buffer tree. */ - - n_fields = dtuple_get_n_fields(entry); - - tuple = dtuple_create(heap, n_fields + IBUF_REC_FIELD_USER); - - /* 1) Space Id */ - - field = dtuple_get_nth_field(tuple, IBUF_REC_FIELD_SPACE); - - buf = static_cast(mem_heap_alloc(heap, 4)); - - mach_write_to_4(buf, space); - - dfield_set_data(field, buf, 4); - - /* 2) Marker byte */ - - field = dtuple_get_nth_field(tuple, IBUF_REC_FIELD_MARKER); - - buf = static_cast(mem_heap_alloc(heap, 1)); - - /* We set the marker byte zero */ - - mach_write_to_1(buf, 0); - - dfield_set_data(field, buf, 1); - - /* 3) Page number */ - - field = dtuple_get_nth_field(tuple, IBUF_REC_FIELD_PAGE); - - buf = static_cast(mem_heap_alloc(heap, 4)); - - mach_write_to_4(buf, page_no); - - dfield_set_data(field, buf, 4); - - /* 4) Type info, part #1 */ - - if (counter == ULINT_UNDEFINED) { - i = dict_table_is_comp(index->table) ? 1 : 0; - } else { - ut_ad(counter <= 0xFFFF); - i = IBUF_REC_INFO_SIZE; - } - - ti = type_info = static_cast( - mem_heap_alloc( - heap, - i + n_fields * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE)); - - switch (i) { - default: - ut_error; - break; - case 1: - /* set the flag for ROW_FORMAT=COMPACT */ - *ti++ = 0; - /* fall through */ - case 0: - /* the old format does not allow delete buffering */ - ut_ad(op == IBUF_OP_INSERT); - break; - case IBUF_REC_INFO_SIZE: - mach_write_to_2(ti + IBUF_REC_OFFSET_COUNTER, counter); - - ti[IBUF_REC_OFFSET_TYPE] = (byte) op; - ti[IBUF_REC_OFFSET_FLAGS] = dict_table_is_comp(index->table) - ? IBUF_REC_COMPACT : 0; - ti += IBUF_REC_INFO_SIZE; - break; - } - - /* 5+) Fields from the entry */ - - for (i = 0; i < n_fields; i++) { - ulint fixed_len; - const dict_field_t* ifield; - - field = dtuple_get_nth_field(tuple, i + IBUF_REC_FIELD_USER); - entry_field = dtuple_get_nth_field(entry, i); - dfield_copy(field, entry_field); - - ifield = dict_index_get_nth_field(index, i); - ut_ad(!ifield->descending); - /* Prefix index columns of fixed-length columns are of - fixed length. However, in the function call below, - dfield_get_type(entry_field) contains the fixed length - of the column in the clustered index. Replace it with - the fixed length of the secondary index column. */ - fixed_len = ifield->fixed_len; - -#ifdef UNIV_DEBUG - if (fixed_len) { - /* dict_index_add_col() should guarantee these */ - ut_ad(fixed_len <= (ulint) - dfield_get_type(entry_field)->len); - if (ifield->prefix_len) { - ut_ad(ifield->prefix_len == fixed_len); - } else { - ut_ad(fixed_len == (ulint) - dfield_get_type(entry_field)->len); - } - } -#endif /* UNIV_DEBUG */ - - dtype_new_store_for_order_and_null_size( - ti, dfield_get_type(entry_field), fixed_len); - ti += DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE; - } - - /* 4) Type info, part #2 */ - - field = dtuple_get_nth_field(tuple, IBUF_REC_FIELD_METADATA); - - dfield_set_data(field, type_info, ulint(ti - type_info)); - - /* Set all the types in the new tuple binary */ - - dtuple_set_types_binary(tuple, n_fields + IBUF_REC_FIELD_USER); - - return(tuple); -} - -/*********************************************************************//** -Builds a search tuple used to search buffered inserts for an index page. -This is for >= 4.1.x format records. -@return own: search tuple */ -static -dtuple_t* -ibuf_search_tuple_build( -/*====================*/ - ulint space, /*!< in: space id */ - ulint page_no,/*!< in: index page number */ - mem_heap_t* heap) /*!< in: heap into which to build */ -{ - dtuple_t* tuple; - dfield_t* field; - byte* buf; - - tuple = dtuple_create(heap, IBUF_REC_FIELD_METADATA); - - /* Store the space id in tuple */ - - field = dtuple_get_nth_field(tuple, IBUF_REC_FIELD_SPACE); - - buf = static_cast(mem_heap_alloc(heap, 4)); - - mach_write_to_4(buf, space); - - dfield_set_data(field, buf, 4); - - /* Store the new format record marker byte */ - - field = dtuple_get_nth_field(tuple, IBUF_REC_FIELD_MARKER); - - buf = static_cast(mem_heap_alloc(heap, 1)); - - mach_write_to_1(buf, 0); - - dfield_set_data(field, buf, 1); - - /* Store the page number in tuple */ - - field = dtuple_get_nth_field(tuple, IBUF_REC_FIELD_PAGE); - - buf = static_cast(mem_heap_alloc(heap, 4)); - - mach_write_to_4(buf, page_no); - - dfield_set_data(field, buf, 4); - - dtuple_set_types_binary(tuple, IBUF_REC_FIELD_METADATA); - - return(tuple); -} - -/*********************************************************************//** -Checks if there are enough pages in the free list of the ibuf tree that we -dare to start a pessimistic insert to the insert buffer. -@return whether enough free pages in list */ -static inline bool ibuf_data_enough_free_for_insert() -{ - mysql_mutex_assert_owner(&ibuf_mutex); - - /* We want a big margin of free pages, because a B-tree can sometimes - grow in size also if records are deleted from it, as the node pointers - can change, and we must make sure that we are able to delete the - inserts buffered for pages that we read to the buffer pool, without - any risk of running out of free space in the insert buffer. */ - - return(ibuf.free_list_len >= (ibuf.size / 2) + 3 * ibuf.height); -} - -/*********************************************************************//** -Checks if there are enough pages in the free list of the ibuf tree that we -should remove them and free to the file space management. -@return TRUE if enough free pages in list */ -UNIV_INLINE -ibool -ibuf_data_too_much_free(void) -/*=========================*/ -{ - mysql_mutex_assert_owner(&ibuf_mutex); - - return(ibuf.free_list_len >= 3 + (ibuf.size / 2) + 3 * ibuf.height); -} - -/** Allocate a change buffer page. -@retval true on success -@retval false if no space left */ -static bool ibuf_add_free_page() -{ - mtr_t mtr; - page_t* header_page; - buf_block_t* block; - - mtr.start(); - /* Acquire the fsp latch before the ibuf header, obeying the latching - order */ - mtr.x_lock_space(fil_system.sys_space); - header_page = ibuf_header_page_get(&mtr); - if (!header_page) { - mtr.commit(); - return false; - } - - /* Allocate a new page: NOTE that if the page has been a part of a - non-clustered index which has subsequently been dropped, then the - page may have buffered inserts in the insert buffer, and these - should be deleted from there. These get deleted when the page - allocation creates the page in buffer. Thus the call below may end - up calling the insert buffer routines and, as we yet have no latches - to insert buffer tree pages, these routines can run without a risk - of a deadlock. This is the reason why we created a special ibuf - header page apart from the ibuf tree. */ - - dberr_t err; - block = fseg_alloc_free_page_general( - header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER, 0, FSP_UP, - false, &mtr, &mtr, &err); - - if (!block) { - mtr.commit(); - return false; - } - - ut_ad(block->page.lock.not_recursive()); - ibuf_enter(&mtr); - mysql_mutex_lock(&ibuf_mutex); - - mtr.write<2>(*block, block->page.frame + FIL_PAGE_TYPE, - FIL_PAGE_IBUF_FREE_LIST); - buf_block_t* ibuf_root = ibuf_tree_root_get(&mtr); - if (UNIV_UNLIKELY(!ibuf_root)) { -corrupted: - /* Do not bother to try to free the allocated block, because - the change buffer is seriously corrupted already. */ - mysql_mutex_unlock(&ibuf_mutex); - ibuf_mtr_commit(&mtr); - return false; - } - - /* Add the page to the free list and update the ibuf size data */ - - err = flst_add_last(ibuf_root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - block, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, - &mtr); - if (UNIV_UNLIKELY(err != DB_SUCCESS)) { - goto corrupted; - } - - /* Set the bit indicating that this page is now an ibuf tree page - (level 2 page) */ - - const page_id_t page_id(block->page.id()); - buf_block_t* bitmap_page = ibuf_bitmap_get_map_page(page_id, 0, &mtr); - - if (UNIV_UNLIKELY(!bitmap_page)) { - goto corrupted; - } - - ibuf.seg_size++; - ibuf.free_list_len++; - - mysql_mutex_unlock(&ibuf_mutex); - - ibuf_bitmap_page_set_bits(bitmap_page, page_id, - srv_page_size, true, &mtr); - ibuf_mtr_commit(&mtr); - return true; -} - -/*********************************************************************//** -Removes a page from the free list and frees it to the fsp system. */ -static void ibuf_remove_free_page() -{ - mtr_t mtr; - mtr_t mtr2; - page_t* header_page; - - log_free_check(); - - mtr_start(&mtr); - /* Acquire the fsp latch before the ibuf header, obeying the latching - order */ - - mtr.x_lock_space(fil_system.sys_space); - header_page = ibuf_header_page_get(&mtr); - - /* Prevent pessimistic inserts to insert buffer trees for a while */ - ibuf_enter(&mtr); - mysql_mutex_lock(&ibuf_pessimistic_insert_mutex); - mysql_mutex_lock(&ibuf_mutex); - - if (!header_page || !ibuf_data_too_much_free()) { -early_exit: - mysql_mutex_unlock(&ibuf_mutex); - mysql_mutex_unlock(&ibuf_pessimistic_insert_mutex); - - ibuf_mtr_commit(&mtr); - - return; - } - - ibuf_mtr_start(&mtr2); - - buf_block_t* root = ibuf_tree_root_get(&mtr2); - - if (UNIV_UNLIKELY(!root)) { - ibuf_mtr_commit(&mtr2); - goto early_exit; - } - - mysql_mutex_unlock(&ibuf_mutex); - - const uint32_t page_no = flst_get_last(PAGE_HEADER - + PAGE_BTR_IBUF_FREE_LIST - + root->page.frame).page; - - /* NOTE that we must release the latch on the ibuf tree root - because in fseg_free_page we access level 1 pages, and the root - is a level 2 page. */ - - ibuf_mtr_commit(&mtr2); - ibuf_exit(&mtr); - - /* Since pessimistic inserts were prevented, we know that the - page is still in the free list. NOTE that also deletes may take - pages from the free list, but they take them from the start, and - the free list was so long that they cannot have taken the last - page from it. */ - - compile_time_assert(IBUF_SPACE_ID == 0); - const page_id_t page_id{IBUF_SPACE_ID, page_no}; - buf_block_t* bitmap_page = nullptr; - dberr_t err = fseg_free_page( - header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER, - fil_system.sys_space, page_no, &mtr); - - if (err != DB_SUCCESS) { - goto func_exit; - } - - ibuf_enter(&mtr); - - mysql_mutex_lock(&ibuf_mutex); - - root = ibuf_tree_root_get(&mtr, &err); - if (UNIV_UNLIKELY(!root)) { - mysql_mutex_unlock(&ibuf_pessimistic_insert_mutex); - goto func_exit; - } - - ut_ad(page_no == flst_get_last(PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST - + root->page.frame).page); - - /* Remove the page from the free list and update the ibuf size data */ - if (buf_block_t* block = - buf_page_get_gen(page_id, 0, RW_X_LATCH, nullptr, BUF_GET, - &mtr, &err)) { - err = flst_remove(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - block, - PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, - &mtr); - } - - mysql_mutex_unlock(&ibuf_pessimistic_insert_mutex); - - if (err == DB_SUCCESS) { - ibuf.seg_size--; - ibuf.free_list_len--; - bitmap_page = ibuf_bitmap_get_map_page(page_id, 0, &mtr); - } - -func_exit: - mysql_mutex_unlock(&ibuf_mutex); - - if (bitmap_page) { - /* Set the bit indicating that this page is no more an - ibuf tree page (level 2 page) */ - ibuf_bitmap_page_set_bits( - bitmap_page, page_id, srv_page_size, false, &mtr); - } - - if (err == DB_SUCCESS) { - buf_page_free(fil_system.sys_space, page_no, &mtr); - } - - ibuf_mtr_commit(&mtr); -} - -/***********************************************************************//** -Frees excess pages from the ibuf free list. This function is called when an OS -thread calls fsp services to allocate a new file segment, or a new page to a -file segment, and the thread did not own the fsp latch before this call. */ -void -ibuf_free_excess_pages(void) -/*========================*/ -{ - /* Free at most a few pages at a time, so that we do not delay the - requested service too much */ - - for (ulint i = 0; i < 4; i++) { - - ibool too_much_free; - - mysql_mutex_lock(&ibuf_mutex); - too_much_free = ibuf_data_too_much_free(); - mysql_mutex_unlock(&ibuf_mutex); - - if (!too_much_free) { - return; - } - - ibuf_remove_free_page(); - } -} - -#ifdef UNIV_DEBUG -# define ibuf_get_merge_page_nos(contract,rec,mtr,ids,pages,n_stored) \ - ibuf_get_merge_page_nos_func(contract,rec,mtr,ids,pages,n_stored) -#else /* UNIV_DEBUG */ -# define ibuf_get_merge_page_nos(contract,rec,mtr,ids,pages,n_stored) \ - ibuf_get_merge_page_nos_func(contract,rec,ids,pages,n_stored) -#endif /* UNIV_DEBUG */ - -/*********************************************************************//** -Reads page numbers from a leaf in an ibuf tree. -@return a lower limit for the combined volume of records which will be -merged */ -static -ulint -ibuf_get_merge_page_nos_func( -/*=========================*/ - ibool contract,/*!< in: TRUE if this function is called to - contract the tree, FALSE if this is called - when a single page becomes full and we look - if it pays to read also nearby pages */ - const rec_t* rec, /*!< in: insert buffer record */ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction holding rec */ -#endif /* UNIV_DEBUG */ - uint32_t* space_ids,/*!< in/out: space id's of the pages */ - uint32_t* page_nos,/*!< in/out: buffer for at least - IBUF_MAX_N_PAGES_MERGED many page numbers; - the page numbers are in an ascending order */ - ulint* n_stored)/*!< out: number of page numbers stored to - page_nos in this function */ -{ - uint32_t prev_page_no; - uint32_t prev_space_id; - uint32_t first_page_no; - uint32_t first_space_id; - uint32_t rec_page_no; - uint32_t rec_space_id; - ulint sum_volumes; - ulint volume_for_page; - ulint rec_volume; - ulint limit; - ulint n_pages; - - ut_ad(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX - | MTR_MEMO_PAGE_S_FIX)); - ut_ad(ibuf_inside(mtr)); - - *n_stored = 0; - - if (page_rec_is_supremum(rec)) { - - rec = page_rec_get_prev_const(rec); - if (UNIV_UNLIKELY(!rec)) { -corruption: - ut_ad("corrupted page" == 0); - return 0; - } - } - - if (page_rec_is_infimum(rec)) { - rec = page_rec_get_next_const(rec); - if (!rec || page_rec_is_supremum(rec)) { - return 0; - } - } - - limit = ut_min(IBUF_MAX_N_PAGES_MERGED, - buf_pool_get_curr_size() / 4); - - first_page_no = ibuf_rec_get_page_no(mtr, rec); - first_space_id = ibuf_rec_get_space(mtr, rec); - n_pages = 0; - prev_page_no = 0; - prev_space_id = 0; - - /* Go backwards from the first rec until we reach the border of the - 'merge area', or the page start or the limit of storeable pages is - reached */ - - while (!page_rec_is_infimum(rec) && UNIV_LIKELY(n_pages < limit)) { - - rec_page_no = ibuf_rec_get_page_no(mtr, rec); - rec_space_id = ibuf_rec_get_space(mtr, rec); - - if (rec_space_id != first_space_id - || (rec_page_no / IBUF_MERGE_AREA) - != (first_page_no / IBUF_MERGE_AREA)) { - - break; - } - - if (rec_page_no != prev_page_no - || rec_space_id != prev_space_id) { - n_pages++; - } - - prev_page_no = rec_page_no; - prev_space_id = rec_space_id; - - if (UNIV_UNLIKELY(!(rec = page_rec_get_prev_const(rec)))) { - goto corruption; - } - } - - rec = page_rec_get_next_const(rec); - - /* At the loop start there is no prev page; we mark this with a pair - of space id, page no (0, 0) for which there can never be entries in - the insert buffer */ - - prev_page_no = 0; - prev_space_id = 0; - sum_volumes = 0; - volume_for_page = 0; - - while (*n_stored < limit && rec) { - if (page_rec_is_supremum(rec)) { - /* When no more records available, mark this with - another 'impossible' pair of space id, page no */ - rec_page_no = 1; - rec_space_id = 0; - } else { - rec_page_no = ibuf_rec_get_page_no(mtr, rec); - rec_space_id = ibuf_rec_get_space(mtr, rec); - /* In the system tablespace the smallest - possible secondary index leaf page number is - bigger than FSP_DICT_HDR_PAGE_NO (7). - In all tablespaces, pages 0 and 1 are reserved - for the allocation bitmap and the change - buffer bitmap. In file-per-table tablespaces, - a file segment inode page will be created at - page 2 and the clustered index tree is created - at page 3. So for file-per-table tablespaces, - page 4 is the smallest possible secondary - index leaf page. CREATE TABLESPACE also initially - uses pages 2 and 3 for the first created table, - but that table may be dropped, allowing page 2 - to be reused for a secondary index leaf page. - To keep this assertion simple, just - make sure the page is >= 2. */ - ut_ad(rec_page_no >= FSP_FIRST_INODE_PAGE_NO); - } - -#ifdef UNIV_IBUF_DEBUG - ut_a(*n_stored < IBUF_MAX_N_PAGES_MERGED); -#endif - if ((rec_space_id != prev_space_id - || rec_page_no != prev_page_no) - && (prev_space_id != 0 || prev_page_no != 0)) { - - if (contract - || (prev_page_no == first_page_no - && prev_space_id == first_space_id) - || (volume_for_page - > ((IBUF_MERGE_THRESHOLD - 1) - * 4U << srv_page_size_shift - / IBUF_PAGE_SIZE_PER_FREE_SPACE) - / IBUF_MERGE_THRESHOLD)) { - - space_ids[*n_stored] = prev_space_id; - page_nos[*n_stored] = prev_page_no; - - (*n_stored)++; - - sum_volumes += volume_for_page; - } - - if (rec_space_id != first_space_id - || rec_page_no / IBUF_MERGE_AREA - != first_page_no / IBUF_MERGE_AREA) { - - break; - } - - volume_for_page = 0; - } - - if (rec_page_no == 1 && rec_space_id == 0) { - /* Supremum record */ - - break; - } - - rec_volume = ibuf_rec_get_volume(mtr, rec); - - volume_for_page += rec_volume; - - prev_page_no = rec_page_no; - prev_space_id = rec_space_id; - - rec = page_rec_get_next_const(rec); - } - -#ifdef UNIV_IBUF_DEBUG - ut_a(*n_stored <= IBUF_MAX_N_PAGES_MERGED); -#endif -#if 0 - fprintf(stderr, "Ibuf merge batch %lu pages %lu volume\n", - *n_stored, sum_volumes); -#endif - return(sum_volumes); -} - -/*******************************************************************//** -Get the matching records for space id. -@return current rec or NULL */ -static MY_ATTRIBUTE((nonnull, warn_unused_result)) -const rec_t* -ibuf_get_user_rec( -/*===============*/ - btr_pcur_t* pcur, /*!< in: the current cursor */ - mtr_t* mtr) /*!< in: mini transaction */ -{ - do { - const rec_t* rec = btr_pcur_get_rec(pcur); - - if (page_rec_is_user_rec(rec)) { - return(rec); - } - } while (btr_pcur_move_to_next(pcur, mtr)); - - return(NULL); -} - -/*********************************************************************//** -Reads page numbers for a space id from an ibuf tree. -@return a lower limit for the combined volume of records which will be -merged */ -static MY_ATTRIBUTE((nonnull, warn_unused_result)) -ulint -ibuf_get_merge_pages( -/*=================*/ - btr_pcur_t* pcur, /*!< in/out: cursor */ - uint32_t space, /*!< in: space for which to merge */ - ulint limit, /*!< in: max page numbers to read */ - uint32_t* pages, /*!< out: pages read */ - uint32_t* spaces, /*!< out: spaces read */ - ulint* n_pages,/*!< out: number of pages read */ - mtr_t* mtr) /*!< in: mini transaction */ -{ - const rec_t* rec; - ulint volume = 0; - - *n_pages = 0; - - while ((rec = ibuf_get_user_rec(pcur, mtr)) != 0 - && ibuf_rec_get_space(mtr, rec) == space - && *n_pages < limit) { - - uint32_t page_no = ibuf_rec_get_page_no(mtr, rec); - - if (*n_pages == 0 || pages[*n_pages - 1] != page_no) { - spaces[*n_pages] = space; - pages[*n_pages] = page_no; - ++*n_pages; - } - - volume += ibuf_rec_get_volume(mtr, rec); - - btr_pcur_move_to_next(pcur, mtr); - } - - return(volume); -} - -/** -Delete a change buffer record. -@param[in] page_id page identifier -@param[in,out] pcur persistent cursor positioned on the record -@param[in] search_tuple search key for (space,page_no) -@param[in,out] mtr mini-transaction -@return whether mtr was committed (due to pessimistic operation) */ -static MY_ATTRIBUTE((warn_unused_result, nonnull)) -bool ibuf_delete_rec(const page_id_t page_id, btr_pcur_t* pcur, - const dtuple_t* search_tuple, mtr_t* mtr); - -/** Delete the change buffer records for the given page id -@param page_id page identifier */ -static void ibuf_delete_recs(const page_id_t page_id) -{ - if (!ibuf.index || srv_read_only_mode) - return; - dfield_t dfield[IBUF_REC_FIELD_METADATA]; - dtuple_t tuple {0,IBUF_REC_FIELD_METADATA,IBUF_REC_FIELD_METADATA, - dfield,0,nullptr -#ifdef UNIV_DEBUG - ,DATA_TUPLE_MAGIC_N -#endif - }; - byte space_id[4], page_no[4]; - - mach_write_to_4(space_id, page_id.space()); - mach_write_to_4(page_no, page_id.page_no()); - - dfield_set_data(&dfield[0], space_id, 4); - dfield_set_data(&dfield[1], field_ref_zero, 1); - dfield_set_data(&dfield[2], page_no, 4); - dtuple_set_types_binary(&tuple, IBUF_REC_FIELD_METADATA); - - mtr_t mtr; -loop: - btr_pcur_t pcur; - pcur.btr_cur.page_cur.index= ibuf.index; - ibuf_mtr_start(&mtr); - if (btr_pcur_open(&tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF, &pcur, 0, &mtr)) - goto func_exit; - if (!btr_pcur_is_on_user_rec(&pcur)) - { - ut_ad(btr_pcur_is_after_last_on_page(&pcur)); - goto func_exit; - } - - for (;;) - { - ut_ad(btr_pcur_is_on_user_rec(&pcur)); - const rec_t* ibuf_rec = btr_pcur_get_rec(&pcur); - if (ibuf_rec_get_space(&mtr, ibuf_rec) != page_id.space() - || ibuf_rec_get_page_no(&mtr, ibuf_rec) != page_id.page_no()) - break; - /* Delete the record from ibuf */ - if (ibuf_delete_rec(page_id, &pcur, &tuple, &mtr)) - { - /* Deletion was pessimistic and mtr was committed: - we start from the beginning again */ - ut_ad(mtr.has_committed()); - goto loop; - } - - if (btr_pcur_is_after_last_on_page(&pcur)) - { - ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); - goto loop; - } - } -func_exit: - ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); -} - -/** Merge the change buffer to some pages. */ -static void ibuf_read_merge_pages(const uint32_t* space_ids, - const uint32_t* page_nos, ulint n_stored) -{ - for (ulint i = 0; i < n_stored; i++) { - const uint32_t space_id = space_ids[i]; - fil_space_t* s = fil_space_t::get(space_id); - if (!s) { -tablespace_deleted: - /* The tablespace was not found: remove all - entries for it */ - ibuf_delete_for_discarded_space(space_id); - while (i + 1 < n_stored - && space_ids[i + 1] == space_id) { - i++; - } - continue; - } - - const ulint zip_size = s->zip_size(), size = s->size; - s->release(); - mtr_t mtr; - - if (UNIV_LIKELY(page_nos[i] < size)) { - mtr.start(); - dberr_t err; - buf_block_t *block = - buf_page_get_gen(page_id_t(space_id, page_nos[i]), - zip_size, RW_X_LATCH, nullptr, - BUF_GET_POSSIBLY_FREED, - &mtr, &err, true); - bool remove = !block - || fil_page_get_type(block->page.frame) - != FIL_PAGE_INDEX - || !page_is_leaf(block->page.frame); - mtr.commit(); - if (err == DB_TABLESPACE_DELETED) { - goto tablespace_deleted; - } - if (!remove) { - continue; - } - } - - if (srv_shutdown_state == SRV_SHUTDOWN_NONE - || srv_fast_shutdown) { - continue; - } - - /* The following code works around a hang when the - change buffer is corrupted, likely due to the - failure of ibuf_merge_or_delete_for_page() to - invoke ibuf_delete_recs() if (!bitmap_bits). - - It also introduced corruption by itself in the - following scenario: - - (1) We merged buffered changes in buf_page_get_gen() - (2) We committed the mini-transaction - (3) Redo log and the page with the merged changes is written - (4) A write completion callback thread evicts the page. - (5) Other threads buffer changes for that page. - (6) We will wrongly discard those newly buffered changes below. - - To prevent this scenario, we will only invoke this code - on shutdown. A call to ibuf_max_size_update(0) will cause - ibuf_insert_low() to refuse to insert anything into the - change buffer. */ - - /* Prevent an infinite loop, by removing entries from - the change buffer in the case the bitmap bits were - wrongly clear even though buffered changes exist. */ - ibuf_delete_recs(page_id_t(space_ids[i], page_nos[i])); - } -} - -/** Contract the change buffer by reading pages to the buffer pool. -@return a lower limit for the combined size in bytes of entries which -will be merged from ibuf trees to the pages read -@retval 0 if ibuf.empty */ -ulint ibuf_contract() -{ - mtr_t mtr; - btr_cur_t cur; - ulint sum_sizes; - uint32_t page_nos[IBUF_MAX_N_PAGES_MERGED]; - uint32_t space_ids[IBUF_MAX_N_PAGES_MERGED]; - - ibuf_mtr_start(&mtr); - - if (cur.open_leaf(true, ibuf.index, BTR_SEARCH_LEAF, &mtr) != - DB_SUCCESS) { - return 0; - } - - ut_ad(page_validate(btr_cur_get_page(&cur), ibuf.index)); - - if (page_is_empty(btr_cur_get_page(&cur))) { - /* If a B-tree page is empty, it must be the root page - and the whole B-tree must be empty. InnoDB does not - allow empty B-tree pages other than the root. */ - ut_ad(ibuf.empty); - ut_ad(btr_cur_get_block(&cur)->page.id() - == page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO)); - - ibuf_mtr_commit(&mtr); - - return(0); - } - - ulint n_pages = 0; - sum_sizes = ibuf_get_merge_page_nos(TRUE, - btr_cur_get_rec(&cur), &mtr, - space_ids, - page_nos, &n_pages); - ibuf_mtr_commit(&mtr); - - ibuf_read_merge_pages(space_ids, page_nos, n_pages); - - return(sum_sizes + 1); -} - -/*********************************************************************//** -Contracts insert buffer trees by reading pages referring to space_id -to the buffer pool. -@returns number of pages merged.*/ -ulint -ibuf_merge_space( -/*=============*/ - ulint space) /*!< in: tablespace id to merge */ -{ - mtr_t mtr; - btr_pcur_t pcur; - - dfield_t dfield[IBUF_REC_FIELD_METADATA]; - dtuple_t tuple {0, IBUF_REC_FIELD_METADATA, - IBUF_REC_FIELD_METADATA,dfield,0,nullptr -#ifdef UNIV_DEBUG - , DATA_TUPLE_MAGIC_N -#endif - }; - byte space_id[4]; - - mach_write_to_4(space_id, space); - - dfield_set_data(&dfield[0], space_id, 4); - dfield_set_data(&dfield[1], field_ref_zero, 1); - dfield_set_data(&dfield[2], field_ref_zero, 4); - - dtuple_set_types_binary(&tuple, IBUF_REC_FIELD_METADATA); - ulint n_pages = 0; - - ut_ad(space < SRV_SPACE_ID_UPPER_BOUND); - - log_free_check(); - ibuf_mtr_start(&mtr); - - /* Position the cursor on the first matching record. */ - - pcur.btr_cur.page_cur.index = ibuf.index; - dberr_t err = btr_pcur_open(&tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, 0, &mtr); - ut_ad(err != DB_SUCCESS || page_validate(btr_pcur_get_page(&pcur), - ibuf.index)); - - ulint sum_sizes = 0; - uint32_t pages[IBUF_MAX_N_PAGES_MERGED]; - uint32_t spaces[IBUF_MAX_N_PAGES_MERGED]; - - if (err != DB_SUCCESS) { - } else if (page_is_empty(btr_pcur_get_page(&pcur))) { - /* If a B-tree page is empty, it must be the root page - and the whole B-tree must be empty. InnoDB does not - allow empty B-tree pages other than the root. */ - ut_ad(ibuf.empty); - ut_ad(btr_pcur_get_block(&pcur)->page.id() - == page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO)); - } else { - - sum_sizes = ibuf_get_merge_pages( - &pcur, uint32_t(space), IBUF_MAX_N_PAGES_MERGED, - &pages[0], &spaces[0], &n_pages, - &mtr); - ib::info() << "Size of pages merged " << sum_sizes; - } - - ibuf_mtr_commit(&mtr); - - if (n_pages > 0) { - ut_ad(n_pages <= UT_ARR_SIZE(pages)); - -#ifdef UNIV_DEBUG - for (ulint i = 0; i < n_pages; ++i) { - ut_ad(spaces[i] == space); - } -#endif /* UNIV_DEBUG */ - - ibuf_read_merge_pages(spaces, pages, n_pages); - } - - return(n_pages); -} - -/*********************************************************************//** -Contract insert buffer trees after insert if they are too big. */ -UNIV_INLINE -void -ibuf_contract_after_insert( -/*=======================*/ - ulint entry_size) /*!< in: size of a record which was inserted - into an ibuf tree */ -{ - /* dirty comparison, to avoid contention on ibuf_mutex */ - if (ibuf.size < ibuf.max_size) { - return; - } - - /* Contract at least entry_size many bytes */ - ulint sum_sizes = 0; - ulint size; - - do { - size = ibuf_contract(); - sum_sizes += size; - } while (size > 0 && sum_sizes < entry_size); -} - -/** Determine if a change buffer record has been encountered already. -@param rec change buffer record in the MySQL 5.5 format -@param hash hash table of encountered records -@param size number of elements in hash -@retval true if a distinct record -@retval false if this may be duplicating an earlier record */ -static bool ibuf_get_volume_buffered_hash(const rec_t *rec, ulint *hash, - ulint size) -{ - ut_ad(rec_get_n_fields_old(rec) > IBUF_REC_FIELD_USER); - const ulint start= rec_get_field_start_offs(rec, IBUF_REC_FIELD_USER); - const ulint len= rec_get_data_size_old(rec) - start; - const uint32_t fold= my_crc32c(0, rec + start, len); - hash+= (fold / (CHAR_BIT * sizeof *hash)) % size; - ulint bitmask= static_cast(1) << (fold % (CHAR_BIT * sizeof(*hash))); - - if (*hash & bitmask) - return false; - - /* We have not seen this record yet. Remember it. */ - *hash|= bitmask; - return true; -} - -#ifdef UNIV_DEBUG -# define ibuf_get_volume_buffered_count(mtr,rec,hash,size,n_recs) \ - ibuf_get_volume_buffered_count_func(mtr,rec,hash,size,n_recs) -#else /* UNIV_DEBUG */ -# define ibuf_get_volume_buffered_count(mtr,rec,hash,size,n_recs) \ - ibuf_get_volume_buffered_count_func(rec,hash,size,n_recs) -#endif /* UNIV_DEBUG */ - -/*********************************************************************//** -Update the estimate of the number of records on a page, and -get the space taken by merging the buffered record to the index page. -@return size of index record in bytes + an upper limit of the space -taken in the page directory */ -static -ulint -ibuf_get_volume_buffered_count_func( -/*================================*/ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction owning rec */ -#endif /* UNIV_DEBUG */ - const rec_t* rec, /*!< in: insert buffer record */ - ulint* hash, /*!< in/out: hash array */ - ulint size, /*!< in: number of elements in hash array */ - lint* n_recs) /*!< in/out: estimated number of records - on the page that rec points to */ -{ - ulint len; - ibuf_op_t ibuf_op; - const byte* types; - ulint n_fields; - - ut_ad(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX - | MTR_MEMO_PAGE_S_FIX)); - ut_ad(ibuf_inside(mtr)); - - n_fields = rec_get_n_fields_old(rec); - ut_ad(n_fields > IBUF_REC_FIELD_USER); - n_fields -= IBUF_REC_FIELD_USER; - - rec_get_nth_field_offs_old(rec, 1, &len); - /* This function is only invoked when buffering new - operations. All pre-4.1 records should have been merged - when the database was started up. */ - ut_a(len == 1); - - if (rec_get_deleted_flag(rec, 0)) { - /* This record has been merged already, - but apparently the system crashed before - the change was discarded from the buffer. - Pretend that the record does not exist. */ - return(0); - } - - types = rec_get_nth_field_old(rec, IBUF_REC_FIELD_METADATA, &len); - - switch (UNIV_EXPECT(int(len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE), - IBUF_REC_INFO_SIZE)) { - default: - ut_error; - case 0: - /* This ROW_TYPE=REDUNDANT record does not include an - operation counter. Exclude it from the *n_recs, - because deletes cannot be buffered if there are - old-style inserts buffered for the page. */ - - len = ibuf_rec_get_size(rec, types, n_fields, 0); - - return(len - + rec_get_converted_extra_size(len, n_fields, 0) - + page_dir_calc_reserved_space(1)); - case 1: - /* This ROW_TYPE=COMPACT record does not include an - operation counter. Exclude it from the *n_recs, - because deletes cannot be buffered if there are - old-style inserts buffered for the page. */ - goto get_volume_comp; - - case IBUF_REC_INFO_SIZE: - ibuf_op = (ibuf_op_t) types[IBUF_REC_OFFSET_TYPE]; - break; - } - - switch (ibuf_op) { - case IBUF_OP_INSERT: - /* Inserts can be done by updating a delete-marked record. - Because delete-mark and insert operations can be pointing to - the same records, we must not count duplicates. */ - case IBUF_OP_DELETE_MARK: - /* There must be a record to delete-mark. - See if this record has been already buffered. */ - if (n_recs && ibuf_get_volume_buffered_hash(rec, hash, size)) { - (*n_recs)++; - } - - if (ibuf_op == IBUF_OP_DELETE_MARK) { - /* Setting the delete-mark flag does not - affect the available space on the page. */ - return(0); - } - break; - case IBUF_OP_DELETE: - /* A record will be removed from the page. */ - if (n_recs) { - (*n_recs)--; - } - /* While deleting a record actually frees up space, - we have to play it safe and pretend that it takes no - additional space (the record might not exist, etc.). */ - return(0); - default: - ut_error; - } - - ut_ad(ibuf_op == IBUF_OP_INSERT); - -get_volume_comp: - { - dtuple_t* entry; - ulint volume; - dict_index_t* dummy_index; - mem_heap_t* heap = mem_heap_create(500); - - entry = ibuf_build_entry_from_ibuf_rec( - mtr, rec, heap, &dummy_index); - - volume = rec_get_converted_size(dummy_index, entry, 0); - - ibuf_dummy_index_free(dummy_index); - mem_heap_free(heap); - - return(volume + page_dir_calc_reserved_space(1)); - } -} - -/*********************************************************************//** -Gets an upper limit for the combined size of entries buffered in the insert -buffer for a given page. -@return upper limit for the volume of buffered inserts for the index -page, in bytes; srv_page_size, if the entries for the index page span -several pages in the insert buffer */ -static -ulint -ibuf_get_volume_buffered( -/*=====================*/ - const btr_pcur_t*pcur, /*!< in: pcur positioned at a place in an - insert buffer tree where we would insert an - entry for the index page whose number is - page_no, latch mode has to be BTR_MODIFY_PREV - or BTR_MODIFY_TREE */ - ulint space, /*!< in: space id */ - ulint page_no,/*!< in: page number of an index page */ - lint* n_recs, /*!< in/out: minimum number of records on the - page after the buffered changes have been - applied, or NULL to disable the counting */ - mtr_t* mtr) /*!< in: mini-transaction of pcur */ -{ - ulint volume; - const rec_t* rec; - const page_t* page; - const page_t* prev_page; - const page_t* next_page; - /* bitmap of buffered recs */ - ulint hash_bitmap[128 / sizeof(ulint)]; - - ut_ad((pcur->latch_mode == BTR_MODIFY_PREV) - || (pcur->latch_mode == BTR_MODIFY_TREE)); - - /* Count the volume of inserts earlier in the alphabetical order than - pcur */ - - volume = 0; - - if (n_recs) { - memset(hash_bitmap, 0, sizeof hash_bitmap); - } - - rec = btr_pcur_get_rec(pcur); - page = page_align(rec); - ut_ad(page_validate(page, ibuf.index)); - - if (page_rec_is_supremum(rec) - && UNIV_UNLIKELY(!(rec = page_rec_get_prev_const(rec)))) { -corruption: - ut_ad("corrupted page" == 0); - return srv_page_size; - } - - uint32_t prev_page_no; - - for (; !page_rec_is_infimum(rec); ) { - ut_ad(page_align(rec) == page); - - if (page_no != ibuf_rec_get_page_no(mtr, rec) - || space != ibuf_rec_get_space(mtr, rec)) { - - goto count_later; - } - - volume += ibuf_get_volume_buffered_count( - mtr, rec, - hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs); - - if (UNIV_UNLIKELY(!(rec = page_rec_get_prev_const(rec)))) { - goto corruption; - } - } - - /* Look at the previous page */ - - prev_page_no = btr_page_get_prev(page); - - if (prev_page_no == FIL_NULL) { - - goto count_later; - } - - if (buf_block_t* block = - buf_page_get(page_id_t(IBUF_SPACE_ID, prev_page_no), - 0, RW_X_LATCH, mtr)) { - prev_page = buf_block_get_frame(block); - ut_ad(page_validate(prev_page, ibuf.index)); - } else { - return srv_page_size; - } - - static_assert(FIL_PAGE_NEXT % 4 == 0, "alignment"); - static_assert(FIL_PAGE_OFFSET % 4 == 0, "alignment"); - - if (UNIV_UNLIKELY(memcmp_aligned<4>(prev_page + FIL_PAGE_NEXT, - page + FIL_PAGE_OFFSET, 4))) { - return srv_page_size; - } - - rec = page_rec_get_prev_const(page_get_supremum_rec(prev_page)); - - if (UNIV_UNLIKELY(!rec)) { - goto corruption; - } - - for (;;) { - ut_ad(page_align(rec) == prev_page); - - if (page_rec_is_infimum(rec)) { - - /* We cannot go to yet a previous page, because we - do not have the x-latch on it, and cannot acquire one - because of the latching order: we have to give up */ - - return(srv_page_size); - } - - if (page_no != ibuf_rec_get_page_no(mtr, rec) - || space != ibuf_rec_get_space(mtr, rec)) { - - goto count_later; - } - - volume += ibuf_get_volume_buffered_count( - mtr, rec, - hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs); - - if (UNIV_UNLIKELY(!(rec = page_rec_get_prev_const(rec)))) { - goto corruption; - } - } - -count_later: - rec = btr_pcur_get_rec(pcur); - - if (!page_rec_is_supremum(rec)) { - rec = page_rec_get_next_const(rec); - } - - for (; !page_rec_is_supremum(rec); - rec = page_rec_get_next_const(rec)) { - if (UNIV_UNLIKELY(!rec)) { - return srv_page_size; - } - if (page_no != ibuf_rec_get_page_no(mtr, rec) - || space != ibuf_rec_get_space(mtr, rec)) { - - return(volume); - } - - volume += ibuf_get_volume_buffered_count( - mtr, rec, - hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs); - } - - /* Look at the next page */ - - uint32_t next_page_no = btr_page_get_next(page); - - if (next_page_no == FIL_NULL) { - - return(volume); - } - - if (buf_block_t* block = - buf_page_get(page_id_t(IBUF_SPACE_ID, next_page_no), - 0, RW_X_LATCH, mtr)) { - next_page = buf_block_get_frame(block); - ut_ad(page_validate(next_page, ibuf.index)); - } else { - return srv_page_size; - } - - static_assert(FIL_PAGE_PREV % 4 == 0, "alignment"); - static_assert(FIL_PAGE_OFFSET % 4 == 0, "alignment"); - - if (UNIV_UNLIKELY(memcmp_aligned<4>(next_page + FIL_PAGE_PREV, - page + FIL_PAGE_OFFSET, 4))) { - return 0; - } - - rec = page_get_infimum_rec(next_page); - rec = page_rec_get_next_const(rec); - - for (; ; rec = page_rec_get_next_const(rec)) { - if (!rec || page_rec_is_supremum(rec)) { - /* We give up */ - return(srv_page_size); - } - - ut_ad(page_align(rec) == next_page); - - if (page_no != ibuf_rec_get_page_no(mtr, rec) - || space != ibuf_rec_get_space(mtr, rec)) { - - return(volume); - } - - volume += ibuf_get_volume_buffered_count( - mtr, rec, - hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs); - } -} - -/*********************************************************************//** -Reads the biggest tablespace id from the high end of the insert buffer -tree and updates the counter in fil_system. */ -void -ibuf_update_max_tablespace_id(void) -/*===============================*/ -{ - const rec_t* rec; - const byte* field; - ulint len; - btr_pcur_t pcur; - mtr_t mtr; - - ut_a(!dict_table_is_comp(ibuf.index->table)); - - ibuf_mtr_start(&mtr); - - if (pcur.open_leaf(false, ibuf.index, BTR_SEARCH_LEAF, &mtr) - != DB_SUCCESS) { -func_exit: - ibuf_mtr_commit(&mtr); - return; - } - - ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf.index)); - - if (!btr_pcur_move_to_prev(&pcur, &mtr) - || btr_pcur_is_before_first_on_page(&pcur)) { - goto func_exit; - } - - rec = btr_pcur_get_rec(&pcur); - - field = rec_get_nth_field_old(rec, IBUF_REC_FIELD_SPACE, &len); - - ut_a(len == 4); - - const uint32_t max_space_id = mach_read_from_4(field); - - ibuf_mtr_commit(&mtr); - - /* printf("Maximum space id in insert buffer %lu\n", max_space_id); */ - - fil_set_max_space_id_if_bigger(max_space_id); -} - -#ifdef UNIV_DEBUG -# define ibuf_get_entry_counter_low(mtr,rec,space,page_no) \ - ibuf_get_entry_counter_low_func(mtr,rec,space,page_no) -#else /* UNIV_DEBUG */ -# define ibuf_get_entry_counter_low(mtr,rec,space,page_no) \ - ibuf_get_entry_counter_low_func(rec,space,page_no) -#endif -/****************************************************************//** -Helper function for ibuf_get_entry_counter_func. Checks if rec is for -(space, page_no), and if so, reads counter value from it and returns -that + 1. -@retval ULINT_UNDEFINED if the record does not contain any counter -@retval 0 if the record is not for (space, page_no) -@retval 1 + previous counter value, otherwise */ -static -ulint -ibuf_get_entry_counter_low_func( -/*============================*/ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction of rec */ -#endif /* UNIV_DEBUG */ - const rec_t* rec, /*!< in: insert buffer record */ - ulint space, /*!< in: space id */ - ulint page_no) /*!< in: page number */ -{ - ulint counter; - const byte* field; - ulint len; - - ut_ad(ibuf_inside(mtr)); - ut_ad(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX - | MTR_MEMO_PAGE_S_FIX)); - ut_ad(rec_get_n_fields_old(rec) > 2); - - field = rec_get_nth_field_old(rec, IBUF_REC_FIELD_MARKER, &len); - - ut_a(len == 1); - - /* Check the tablespace identifier. */ - field = rec_get_nth_field_old(rec, IBUF_REC_FIELD_SPACE, &len); - - ut_a(len == 4); - - if (mach_read_from_4(field) != space) { - - return(0); - } - - /* Check the page offset. */ - field = rec_get_nth_field_old(rec, IBUF_REC_FIELD_PAGE, &len); - ut_a(len == 4); - - if (mach_read_from_4(field) != page_no) { - - return(0); - } - - /* Check if the record contains a counter field. */ - field = rec_get_nth_field_old(rec, IBUF_REC_FIELD_METADATA, &len); - - switch (len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE) { - default: - ut_error; - case 0: /* ROW_FORMAT=REDUNDANT */ - case 1: /* ROW_FORMAT=COMPACT */ - return(ULINT_UNDEFINED); - - case IBUF_REC_INFO_SIZE: - counter = mach_read_from_2(field + IBUF_REC_OFFSET_COUNTER); - ut_a(counter < 0xFFFF); - return(counter + 1); - } -} - -#ifdef UNIV_DEBUG -# define ibuf_get_entry_counter(space,page_no,rec,mtr,exact_leaf) \ - ibuf_get_entry_counter_func(space,page_no,rec,mtr,exact_leaf) -#else /* UNIV_DEBUG */ -# define ibuf_get_entry_counter(space,page_no,rec,mtr,exact_leaf) \ - ibuf_get_entry_counter_func(space,page_no,rec,exact_leaf) -#endif /* UNIV_DEBUG */ - -/****************************************************************//** -Calculate the counter field for an entry based on the current -last record in ibuf for (space, page_no). -@return the counter field, or ULINT_UNDEFINED -if we should abort this insertion to ibuf */ -static -ulint -ibuf_get_entry_counter_func( -/*========================*/ - ulint space, /*!< in: space id of entry */ - ulint page_no, /*!< in: page number of entry */ - const rec_t* rec, /*!< in: the record preceding the - insertion point */ -#ifdef UNIV_DEBUG - mtr_t* mtr, /*!< in: mini-transaction */ -#endif /* UNIV_DEBUG */ - ibool only_leaf) /*!< in: TRUE if this is the only - leaf page that can contain entries - for (space,page_no), that is, there - was no exact match for (space,page_no) - in the node pointer */ -{ - ut_ad(ibuf_inside(mtr)); - ut_ad(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX)); - ut_ad(page_validate(page_align(rec), ibuf.index)); - - if (page_rec_is_supremum(rec)) { - /* This is just for safety. The record should be a - page infimum or a user record. */ - ut_ad(0); - return(ULINT_UNDEFINED); - } else if (!page_rec_is_infimum(rec)) { - return(ibuf_get_entry_counter_low(mtr, rec, space, page_no)); - } else if (only_leaf || !page_has_prev(page_align(rec))) { - /* The parent node pointer did not contain the - searched for (space, page_no), which means that the - search ended on the correct page regardless of the - counter value, and since we're at the infimum record, - there are no existing records. */ - return(0); - } else { - /* We used to read the previous page here. It would - break the latching order, because the caller has - buffer-fixed an insert buffer bitmap page. */ - return(ULINT_UNDEFINED); - } -} - - -/** Translates the ibuf free bits to the free space on a page in bytes. -@param[in] physical_size page_size -@param[in] bits value for ibuf bitmap bits -@return maximum insert size after reorganize for the page */ -inline ulint -ibuf_index_page_calc_free_from_bits(ulint physical_size, ulint bits) -{ - ut_ad(bits < 4); - ut_ad(physical_size > IBUF_PAGE_SIZE_PER_FREE_SPACE); - - if (bits == 3) { - bits = 4; - } - - return bits * physical_size / IBUF_PAGE_SIZE_PER_FREE_SPACE; + dtype_get_len(type)); + dict_index_add_col(index, index->table, + dict_table_get_nth_col(index->table, i), len); } -/** Buffer an operation in the insert/delete buffer, instead of doing it -directly to the disk page, if this is possible. -@param[in] mode BTR_MODIFY_PREV or BTR_INSERT_TREE -@param[in] op operation type -@param[in] no_counter TRUE=use 5.0.3 format; FALSE=allow delete -buffering -@param[in] entry index entry to insert -@param[in] entry_size rec_get_converted_size(index, entry) -@param[in,out] index index where to insert; must not be unique -or clustered -@param[in] page_id page id where to insert -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in,out] thr query thread -@return DB_SUCCESS, DB_STRONG_FAIL or other error */ -static TRANSACTIONAL_TARGET MY_ATTRIBUTE((warn_unused_result)) -dberr_t -ibuf_insert_low( - btr_latch_mode mode, - ibuf_op_t op, - ibool no_counter, - const dtuple_t* entry, - ulint entry_size, - dict_index_t* index, - const page_id_t page_id, - ulint zip_size, - que_thr_t* thr) +/**********************************************************************//** +Reads to a type the stored information which determines its alphabetical +ordering and the storage size of an SQL NULL value. This is the >= 4.1.x +storage format. */ +static +void +dtype_new_read_for_order_and_null_size( +/*===================================*/ + dtype_t* type, /*!< in: type struct */ + const byte* buf) /*!< in: buffer for stored type order info */ { - big_rec_t* dummy_big_rec; - btr_pcur_t pcur; - btr_cur_t* cursor; - dtuple_t* ibuf_entry; - mem_heap_t* offsets_heap = NULL; - mem_heap_t* heap; - rec_offs* offsets = NULL; - ulint buffered; - lint min_n_recs; - rec_t* ins_rec; - buf_block_t* bitmap_page; - buf_block_t* block = NULL; - page_t* root; - dberr_t err; - ibool do_merge; - uint32_t space_ids[IBUF_MAX_N_PAGES_MERGED]; - uint32_t page_nos[IBUF_MAX_N_PAGES_MERGED]; - ulint n_stored; - mtr_t mtr; - mtr_t bitmap_mtr; - - ut_a(!dict_index_is_clust(index)); - ut_ad(!dict_index_is_spatial(index)); - ut_ad(dtuple_check_typed(entry)); - ut_ad(!no_counter || op == IBUF_OP_INSERT); - ut_ad(page_id.space() == index->table->space_id); - ut_a(op < IBUF_OP_COUNT); - - do_merge = FALSE; - - /* Perform dirty comparison of ibuf.max_size and ibuf.size to - reduce ibuf_mutex contention. This should be OK; at worst we - are doing some excessive ibuf_contract() or occasionally - skipping an ibuf_contract(). */ - const ulint max_size = ibuf.max_size; - - if (max_size == 0) { - return(DB_STRONG_FAIL); - } - - if (ibuf.size >= max_size + IBUF_CONTRACT_DO_NOT_INSERT) { - /* Insert buffer is now too big, contract it but do not try - to insert */ - - -#ifdef UNIV_IBUF_DEBUG - fputs("Ibuf too big\n", stderr); -#endif - ibuf_contract(); + type->mtype = buf[0] & 63; + type->prtype = buf[1]; - return(DB_STRONG_FAIL); + if (buf[0] & 128) { + type->prtype |= DATA_BINARY_TYPE; } - heap = mem_heap_create(1024); - - /* Build the entry which contains the space id and the page number - as the first fields and the type information for other fields, and - which will be inserted to the insert buffer. Using a counter value - of 0xFFFF we find the last record for (space, page_no), from which - we can then read the counter value N and use N + 1 in the record we - insert. (We patch the ibuf_entry's counter field to the correct - value just before actually inserting the entry.) */ - - ibuf_entry = ibuf_entry_build( - op, index, entry, page_id.space(), page_id.page_no(), - no_counter ? ULINT_UNDEFINED : 0xFFFF, heap); - - /* Open a cursor to the insert buffer tree to calculate if we can add - the new entry to it without exceeding the free space limit for the - page. */ - - if (mode == BTR_INSERT_TREE) { - for (;;) { - mysql_mutex_lock(&ibuf_pessimistic_insert_mutex); - mysql_mutex_lock(&ibuf_mutex); - - if (UNIV_LIKELY(ibuf_data_enough_free_for_insert())) { - - break; - } - - mysql_mutex_unlock(&ibuf_mutex); - mysql_mutex_unlock(&ibuf_pessimistic_insert_mutex); - - if (!ibuf_add_free_page()) { - - mem_heap_free(heap); - return(DB_STRONG_FAIL); - } - } + if (buf[4] & 128) { + type->prtype |= DATA_NOT_NULL; } - ibuf_mtr_start(&mtr); - pcur.btr_cur.page_cur.index = ibuf.index; - - err = btr_pcur_open(ibuf_entry, PAGE_CUR_LE, mode, &pcur, 0, &mtr); - if (err != DB_SUCCESS) { -func_exit: - ibuf_mtr_commit(&mtr); - ut_free(pcur.old_rec_buf); - mem_heap_free(heap); + type->len = mach_read_from_2(buf + 2); - if (err == DB_SUCCESS && mode == BTR_INSERT_TREE) { - ibuf_contract_after_insert(entry_size); - } + uint32_t charset_coll = (mach_read_from_2(buf + 4) & CHAR_COLL_MASK) + << 16; - if (do_merge) { -#ifdef UNIV_IBUF_DEBUG - ut_a(n_stored <= IBUF_MAX_N_PAGES_MERGED); -#endif - ibuf_read_merge_pages(space_ids, page_nos, n_stored); - } - return err; - } + if (dtype_is_string_type(type->mtype)) { + type->prtype |= charset_coll << 16; - ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf.index)); - - /* Find out the volume of already buffered inserts for the same index - page */ - min_n_recs = 0; - buffered = ibuf_get_volume_buffered(&pcur, - page_id.space(), - page_id.page_no(), - op == IBUF_OP_DELETE - ? &min_n_recs - : NULL, &mtr); - - const ulint physical_size = zip_size ? zip_size : srv_page_size; - - if (op == IBUF_OP_DELETE - && (min_n_recs < 2 || buf_pool.watch_occurred(page_id))) { - /* The page could become empty after the record is - deleted, or the page has been read in to the buffer - pool. Refuse to buffer the operation. */ - - /* The buffer pool watch is needed for IBUF_OP_DELETE - because of latching order considerations. We can - check buf_pool_watch_occurred() only after latching - the insert buffer B-tree pages that contain buffered - changes for the page. We never buffer IBUF_OP_DELETE, - unless some IBUF_OP_INSERT or IBUF_OP_DELETE_MARK have - been previously buffered for the page. Because there - are buffered operations for the page, the insert - buffer B-tree page latches held by mtr will guarantee - that no changes for the user page will be merged - before mtr_commit(&mtr). We must not mtr_commit(&mtr) - until after the IBUF_OP_DELETE has been buffered. */ - -fail_exit: - if (mode == BTR_INSERT_TREE) { - mysql_mutex_unlock(&ibuf_mutex); - mysql_mutex_unlock(&ibuf_pessimistic_insert_mutex); + if (charset_coll == 0) { + /* This insert buffer record was inserted before + MySQL 4.1.2, and the charset-collation code was not + explicitly stored to dtype->prtype at that time. It + must be the default charset-collation of this MySQL + installation. */ + type->prtype |= default_charset_info->number << 16; } - - err = DB_STRONG_FAIL; - goto func_exit; } - /* After this point, the page could still be loaded to the - buffer pool, but we do not have to care about it, since we are - holding a latch on the insert buffer leaf page that contains - buffered changes for (space, page_no). If the page enters the - buffer pool, buf_page_t::read_complete() for (space, page_no) will - have to acquire a latch on the same insert buffer leaf page, - which it cannot do until we have buffered the IBUF_OP_DELETE - and done mtr_commit(&mtr) to release the latch. */ - - ibuf_mtr_start(&bitmap_mtr); - - bitmap_page = ibuf_bitmap_get_map_page(page_id, zip_size, &bitmap_mtr); - - /* We check if the index page is suitable for buffered entries */ + dtype_set_mblen(type); +} - if (!bitmap_page || buf_pool.page_hash_contains( - page_id, buf_pool.page_hash.cell_get(page_id.fold()))) { -commit_exit: - ibuf_mtr_commit(&bitmap_mtr); - goto fail_exit; - } else if (!lock_sys.rd_lock_try()) { - goto commit_exit; - } else { - hash_cell_t* cell = lock_sys.rec_hash.cell_get(page_id.fold()); - lock_sys.rec_hash.latch(cell)->acquire(); - const lock_t* lock = lock_sys_t::get_first(*cell, page_id); - lock_sys.rec_hash.latch(cell)->release(); - lock_sys.rd_unlock(); - if (lock) { - goto commit_exit; - } - } +/** Construct an index entry and an index for applying an operation. +@param ibuf_rec change buffer record in an X-latched page +@param not_redundant whether another format than ROW_FORMAT=REDUNDANT is used +@param n_fields number of index record fields +@param types type information +@param heap memory heap +@param index dummy index metadata +@return the index entry for applying the operation */ +static dtuple_t *ibuf_entry_build(const rec_t *ibuf_rec, ulint not_redundant, + ulint n_fields, const byte *types, + mem_heap_t *heap, dict_index_t *&index) +{ + dtuple_t* tuple; + dfield_t* field; + const byte* data; + ulint len; - if (op == IBUF_OP_INSERT) { - ulint bits = ibuf_bitmap_page_get_bits( - bitmap_page->page.frame, page_id, physical_size, - IBUF_BITMAP_FREE, &bitmap_mtr); + tuple = dtuple_create(heap, n_fields); - if (buffered + entry_size + page_dir_calc_reserved_space(1) - > ibuf_index_page_calc_free_from_bits(physical_size, - bits)) { - /* Release the bitmap page latch early. */ - ibuf_mtr_commit(&bitmap_mtr); + index = dict_mem_index_create( + dict_table_t::create({C_STRING_WITH_LEN("")}, nullptr, + n_fields, 0, + not_redundant ? DICT_TF_COMPACT : 0, 0), + "IBUF_DUMMY", 0, n_fields); + /* avoid ut_ad(index->cached) in dict_index_get_n_unique_in_tree */ + ut_d(index->cached = true); + ut_d(index->is_dummy = true); - /* It may not fit */ - do_merge = TRUE; + for (ulint i = 0; i < n_fields; i++) { + field = dtuple_get_nth_field(tuple, i); - ibuf_get_merge_page_nos(FALSE, - btr_pcur_get_rec(&pcur), &mtr, - space_ids, - page_nos, &n_stored); + data = rec_get_nth_field_old( + ibuf_rec, i + IBUF_REC_FIELD_USER, &len); - goto fail_exit; - } - } + dfield_set_data(field, data, len); - if (!no_counter) { - /* Patch correct counter value to the entry to - insert. This can change the insert position, which can - result in the need to abort in some cases. */ - ulint counter = ibuf_get_entry_counter( - page_id.space(), page_id.page_no(), - btr_pcur_get_rec(&pcur), &mtr, - btr_pcur_get_btr_cur(&pcur)->low_match - < IBUF_REC_FIELD_METADATA); - dfield_t* field; - - if (counter == ULINT_UNDEFINED) { - goto commit_exit; - } + dtype_new_read_for_order_and_null_size( + dfield_get_type(field), types + i * 6); - field = dtuple_get_nth_field( - ibuf_entry, IBUF_REC_FIELD_METADATA); - mach_write_to_2( - (byte*) dfield_get_data(field) - + IBUF_REC_OFFSET_COUNTER, counter); + ibuf_dummy_index_add_col(index, dfield_get_type(field), len); } - /* Set the bitmap bit denoting that the insert buffer contains - buffered entries for this index page, if the bit is not set yet */ - index->set_modified(bitmap_mtr); - ibuf_bitmap_page_set_bits( - bitmap_page, page_id, physical_size, true, &bitmap_mtr); - ibuf_mtr_commit(&bitmap_mtr); - - cursor = btr_pcur_get_btr_cur(&pcur); - - if (mode == BTR_MODIFY_PREV) { - err = btr_cur_optimistic_insert( - BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG, - cursor, &offsets, &offsets_heap, - ibuf_entry, &ins_rec, - &dummy_big_rec, 0, thr, &mtr); - block = btr_cur_get_block(cursor); - ut_ad(block->page.id().space() == IBUF_SPACE_ID); - - /* If this is the root page, update ibuf.empty. */ - if (block->page.id().page_no() == FSP_IBUF_TREE_ROOT_PAGE_NO) { - const page_t* root = buf_block_get_frame(block); - - ut_ad(page_get_space_id(root) == IBUF_SPACE_ID); - ut_ad(page_get_page_no(root) - == FSP_IBUF_TREE_ROOT_PAGE_NO); - - ibuf.empty = page_is_empty(root); - } - } else { - ut_ad(mode == BTR_INSERT_TREE); - - /* We acquire an sx-latch to the root page before the insert, - because a pessimistic insert releases the tree x-latch, - which would cause the sx-latching of the root after that to - break the latching order. */ - if (buf_block_t* ibuf_root = ibuf_tree_root_get(&mtr)) { - root = ibuf_root->page.frame; - } else { - err = DB_CORRUPTION; - mysql_mutex_unlock(&ibuf_pessimistic_insert_mutex); - mysql_mutex_unlock(&ibuf_mutex); - goto ibuf_insert_done; - } - - err = btr_cur_optimistic_insert( - BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG, - cursor, &offsets, &offsets_heap, - ibuf_entry, &ins_rec, - &dummy_big_rec, 0, thr, &mtr); - - if (err == DB_FAIL) { - err = btr_cur_pessimistic_insert( - BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG, - cursor, &offsets, &offsets_heap, - ibuf_entry, &ins_rec, - &dummy_big_rec, 0, thr, &mtr); - } + index->n_core_null_bytes = static_cast( + UT_BITS_IN_BYTES(unsigned(index->n_nullable))); - mysql_mutex_unlock(&ibuf_pessimistic_insert_mutex); - ibuf_size_update(root); - mysql_mutex_unlock(&ibuf_mutex); - ibuf.empty = page_is_empty(root); + /* Prevent an ut_ad() failure in page_zip_write_rec() by + adding system columns to the dummy table pointed to by the + dummy secondary index. The change buffer was only used for + secondary indexes, whose records never contain any system + columns, such as DB_TRX_ID. */ + ut_d(dict_table_add_system_columns(index->table, index->table->heap)); + return(tuple); +} - block = btr_cur_get_block(cursor); - ut_ad(block->page.id().space() == IBUF_SPACE_ID); - } +/** Removes a page from the free list and frees it to the fsp system. +@param mtr mini-transaction +@return error code +@retval DB_SUCCESS if more work may remain to be done +@retval DB_SUCCESS_LOCKED_REC if everything was freed */ +ATTRIBUTE_COLD static dberr_t ibuf_remove_free_page(mtr_t &mtr) +{ + log_free_check(); -ibuf_insert_done: - if (offsets_heap) { - mem_heap_free(offsets_heap); - } + mtr.start(); - if (err == DB_SUCCESS && op != IBUF_OP_DELETE) { - /* Update the page max trx id field */ - page_update_max_trx_id(block, NULL, - thr_get_trx(thr)->id, &mtr); - } + mtr.x_lock_space(fil_system.sys_space); + dberr_t err; + buf_block_t* header= buf_page_get_gen(ibuf_header, 0, RW_X_LATCH, nullptr, + BUF_GET, &mtr, &err); - goto func_exit; -} + if (!header) + { +func_exit: + mtr.commit(); + return err; + } -/** Buffer an operation in the change buffer, instead of applying it -directly to the file page, if this is possible. Does not do it if the index -is clustered or unique. -@param[in] op operation type -@param[in] entry index entry to insert -@param[in,out] index index where to insert -@param[in] page_id page id where to insert -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in,out] thr query thread -@return true if success */ -TRANSACTIONAL_TARGET -bool -ibuf_insert( - ibuf_op_t op, - const dtuple_t* entry, - dict_index_t* index, - const page_id_t page_id, - ulint zip_size, - que_thr_t* thr) -{ - dberr_t err; - ulint entry_size; - ibool no_counter; - /* Read the settable global variable only once in - this function, so that we will have a consistent view of it. */ - ibuf_use_t use = ibuf_use_t(innodb_change_buffering); - DBUG_ENTER("ibuf_insert"); + buf_block_t *root= buf_page_get_gen(ibuf_root, 0, RW_X_LATCH, + nullptr, BUF_GET, &mtr, &err); - DBUG_PRINT("ibuf", ("op: %d, space: " UINT32PF ", page_no: " UINT32PF, - op, page_id.space(), page_id.page_no())); + if (UNIV_UNLIKELY(!root)) + goto func_exit; - ut_ad(dtuple_check_typed(entry)); - ut_ad(page_id.space() != SRV_TMP_SPACE_ID); - ut_ad(index->is_btree()); - ut_a(!dict_index_is_clust(index)); - ut_ad(!index->table->is_temporary()); - - no_counter = use <= IBUF_USE_INSERT; - - switch (op) { - case IBUF_OP_INSERT: - switch (use) { - case IBUF_USE_NONE: - case IBUF_USE_DELETE: - case IBUF_USE_DELETE_MARK: - DBUG_RETURN(false); - case IBUF_USE_INSERT: - case IBUF_USE_INSERT_DELETE_MARK: - case IBUF_USE_ALL: - goto check_watch; - } - break; - case IBUF_OP_DELETE_MARK: - switch (use) { - case IBUF_USE_NONE: - case IBUF_USE_INSERT: - DBUG_RETURN(false); - case IBUF_USE_DELETE_MARK: - case IBUF_USE_DELETE: - case IBUF_USE_INSERT_DELETE_MARK: - case IBUF_USE_ALL: - ut_ad(!no_counter); - goto check_watch; - } - break; - case IBUF_OP_DELETE: - switch (use) { - case IBUF_USE_NONE: - case IBUF_USE_INSERT: - case IBUF_USE_INSERT_DELETE_MARK: - DBUG_RETURN(false); - case IBUF_USE_DELETE_MARK: - case IBUF_USE_DELETE: - case IBUF_USE_ALL: - ut_ad(!no_counter); - goto skip_watch; - } - break; - case IBUF_OP_COUNT: - break; - } + const uint32_t page_no= flst_get_last(PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST + + root->page.frame).page; + if (page_no == FIL_NULL) + { + mtr.set_modified(*root); + fsp_init_file_page(fil_system.sys_space, root, &mtr); + err= DB_SUCCESS_LOCKED_REC; + goto func_exit; + } - /* unknown op or use */ - ut_error; - -check_watch: - /* If a thread attempts to buffer an insert on a page while a - purge is in progress on the same page, the purge must not be - buffered, because it could remove a record that was - re-inserted later. For simplicity, we block the buffering of - all operations on a page that has a purge pending. - - We do not check this in the IBUF_OP_DELETE case, because that - would always trigger the buffer pool watch during purge and - thus prevent the buffering of delete operations. We assume - that the issuer of IBUF_OP_DELETE has called - buf_pool_t::watch_set(). */ - - if (buf_pool.page_hash_contains( - page_id, buf_pool.page_hash.cell_get(page_id.fold()))) { - /* A buffer pool watch has been set or the - page has been read into the buffer pool. - Do not buffer the request. If a purge operation - is being buffered, have this request executed - directly on the page in the buffer pool after the - buffered entries for this page have been merged. */ - DBUG_RETURN(false); - } + /* Since pessimistic inserts were prevented, we know that the + page is still in the free list. NOTE that also deletes may take + pages from the free list, but they take them from the start, and + the free list was so long that they cannot have taken the last + page from it. */ -skip_watch: - entry_size = rec_get_converted_size(index, entry, 0); + err= fseg_free_page(header->page.frame + PAGE_DATA, fil_system.sys_space, + page_no, &mtr); - if (entry_size - >= page_get_free_space_of_empty(dict_table_is_comp(index->table)) - / 2) { + if (err != DB_SUCCESS) + goto func_exit; - DBUG_RETURN(false); - } + if (page_no != flst_get_last(PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST + + root->page.frame).page) + { + err= DB_CORRUPTION; + goto func_exit; + } - err = ibuf_insert_low(BTR_MODIFY_PREV, op, no_counter, - entry, entry_size, - index, page_id, zip_size, thr); - if (err == DB_FAIL) { - err = ibuf_insert_low(BTR_INSERT_TREE, - op, no_counter, entry, entry_size, - index, page_id, zip_size, thr); - } + /* Remove the page from the free list and update the ibuf size data */ + if (buf_block_t *block= + buf_page_get_gen(page_id_t{0, page_no}, 0, RW_X_LATCH, nullptr, BUF_GET, + &mtr, &err)) + err= flst_remove(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, + block, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr); - ut_a(err == DB_SUCCESS || err == DB_STRONG_FAIL - || err == DB_TOO_BIG_RECORD); + if (err == DB_SUCCESS) + buf_page_free(fil_system.sys_space, page_no, &mtr); - DBUG_RETURN(err == DB_SUCCESS); + goto func_exit; } MY_ATTRIBUTE((nonnull, warn_unused_result)) @@ -3616,9 +316,7 @@ ibuf_insert_to_index_page_low( return DB_SUCCESS; /* Page reorganization or recompression should already have been - attempted by page_cur_tuple_insert(). Besides, per - ibuf_index_page_calc_free_zip() the page should not have been - recompressed or reorganized. */ + attempted by page_cur_tuple_insert(). */ ut_ad(!is_buf_block_get_page_zip(page_cur->block)); /* If the record did not fit, reorganize */ @@ -3656,19 +354,16 @@ ibuf_insert_to_index_page( block->page.id().page_no())); ut_ad(!dict_index_is_online_ddl(index));// this is an ibuf_dummy index - ut_ad(ibuf_inside(mtr)); ut_ad(dtuple_check_typed(entry)); #ifdef BTR_CUR_HASH_ADAPT - /* A change buffer merge must occur before users are granted - any access to the page. No adaptive hash index entries may - point to a freshly read page. */ + /* ibuf_cleanup() must finish before the adaptive hash index + can be inserted into. */ ut_ad(!block->index); - assert_block_ahi_empty(block); #endif /* BTR_CUR_HASH_ADAPT */ ut_ad(mtr->is_named_space(block->page.id().space())); - if (UNIV_UNLIKELY(dict_table_is_comp(index->table) - != (ibool)!!page_is_comp(page))) { + if (UNIV_UNLIKELY(index->table->not_redundant() + != !!page_is_comp(page))) { return DB_CORRUPTION; } @@ -3808,7 +503,6 @@ ibuf_set_del_mark( page_cur.index = index; ulint up_match = 0, low_match = 0; - ut_ad(ibuf_inside(mtr)); ut_ad(dtuple_check_typed(entry)); if (!page_cur_search_with_match(entry, PAGE_CUR_LE, @@ -3867,7 +561,6 @@ ibuf_delete( page_cur.index = index; ulint up_match = 0, low_match = 0; - ut_ad(ibuf_inside(mtr)); ut_ad(dtuple_check_typed(entry)); ut_ad(!index->is_spatial()); ut_ad(!index->is_clust()); @@ -3876,7 +569,6 @@ ibuf_delete( &up_match, &low_match, &page_cur, nullptr) && low_match == dtuple_get_n_fields(entry)) { - page_zip_des_t* page_zip= buf_block_get_page_zip(block); page_t* page = buf_block_get_frame(block); rec_t* rec = page_cur_get_rec(&page_cur); @@ -3886,7 +578,6 @@ ibuf_delete( rec_offs offsets_[REC_OFFS_NORMAL_SIZE]; rec_offs* offsets = offsets_; mem_heap_t* heap = NULL; - ulint max_ins_size = 0; rec_offs_init(offsets_); @@ -3917,12 +608,8 @@ ibuf_delete( return; } - if (!page_zip) { - max_ins_size - = page_get_max_insert_size_after_reorganize( - page, 1); - } #ifdef UNIV_ZIP_DEBUG + page_zip_des_t* page_zip= buf_block_get_page_zip(block); ut_a(!page_zip || page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ page_cur_delete_rec(&page_cur, offsets, mtr); @@ -3930,774 +617,370 @@ ibuf_delete( ut_a(!page_zip || page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ - if (page_zip) { - ibuf_update_free_bits_zip(block, mtr); - } else { - ibuf_update_free_bits_low(block, max_ins_size, mtr); - } - if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } } } -/*********************************************************************//** -Restores insert buffer tree cursor position -@return whether the position was restored */ -static MY_ATTRIBUTE((nonnull)) -bool -ibuf_restore_pos( -/*=============*/ - const page_id_t page_id,/*!< in: page identifier */ - const dtuple_t* search_tuple, - /*!< in: search tuple for entries of page_no */ - btr_latch_mode mode, /*!< in: BTR_MODIFY_LEAF or BTR_PURGE_TREE */ - btr_pcur_t* pcur, /*!< in/out: persistent cursor whose - position is to be restored */ - mtr_t* mtr) /*!< in/out: mini-transaction */ +/** Reset the bits in the bitmap page for the given page number. +@param bitmap change buffer bitmap page +@param offset page number +@param mtr mini-transaction */ +static void ibuf_reset(buf_block_t &bitmap, uint32_t offset, mtr_t *mtr) { - ut_ad(mode == BTR_MODIFY_LEAF || mode == BTR_PURGE_TREE); - - if (UNIV_LIKELY(pcur->restore_position(mode, mtr) == - btr_pcur_t::SAME_ALL)) { - return true; - } - - if (fil_space_t* s = fil_space_t::get(page_id.space())) { - ib::error() << "ibuf cursor restoration fails!" - " ibuf record inserted to page " - << page_id - << " in file " << s->chain.start->name; - s->release(); - - ib::error() << BUG_REPORT_MSG; - - rec_print_old(stderr, btr_pcur_get_rec(pcur)); - rec_print_old(stderr, pcur->old_rec); - dtuple_print(stderr, search_tuple); - } - - ibuf_btr_pcur_commit_specify_mtr(pcur, mtr); - return false; + offset&= uint32_t(bitmap.physical_size() - 1); + byte *map_byte= &bitmap.page.frame[PAGE_DATA + offset / 2]; + /* We must reset IBUF_BITMAP_BUFFERED, but at the same time we will also + reset IBUF_BITMAP_FREE (and IBUF_BITMAP_IBUF, which should be clear). */ + byte b= byte(*map_byte & ((offset & 1) ? byte{0xf} : byte{0xf0})); + mtr->write<1,mtr_t::MAYBE_NOP>(bitmap, map_byte, b); } -/** -Delete a change buffer record. -@param[in] page_id page identifier -@param[in,out] pcur persistent cursor positioned on the record -@param[in] search_tuple search key for (space,page_no) -@param[in,out] mtr mini-transaction -@return whether mtr was committed (due to pessimistic operation) */ -static MY_ATTRIBUTE((warn_unused_result, nonnull)) -bool ibuf_delete_rec(const page_id_t page_id, btr_pcur_t* pcur, - const dtuple_t* search_tuple, mtr_t* mtr) +/** Move to the next change buffer record. */ +ATTRIBUTE_COLD static dberr_t ibuf_move_to_next(btr_cur_t *cur, mtr_t *mtr) { - dberr_t err; - - ut_ad(ibuf_inside(mtr)); - ut_ad(page_rec_is_user_rec(btr_pcur_get_rec(pcur))); - ut_ad(ibuf_rec_get_page_no(mtr, btr_pcur_get_rec(pcur)) - == page_id.page_no()); - ut_ad(ibuf_rec_get_space(mtr, btr_pcur_get_rec(pcur)) - == page_id.space()); - - switch (btr_cur_optimistic_delete(btr_pcur_get_btr_cur(pcur), - BTR_CREATE_FLAG, mtr)) { - case DB_FAIL: - break; - case DB_SUCCESS: - if (page_is_empty(btr_pcur_get_page(pcur))) { - /* If a B-tree page is empty, it must be the root page - and the whole B-tree must be empty. InnoDB does not - allow empty B-tree pages other than the root. */ - ut_d(const page_t* root = btr_pcur_get_page(pcur)); - - ut_ad(page_get_space_id(root) == IBUF_SPACE_ID); - ut_ad(page_get_page_no(root) - == FSP_IBUF_TREE_ROOT_PAGE_NO); - - /* ibuf.empty is protected by the root page latch. - Before the deletion, it had to be FALSE. */ - ut_ad(!ibuf.empty); - ibuf.empty = true; - } - /* fall through */ - default: - return(FALSE); - } - - /* We have to resort to a pessimistic delete from ibuf. - Delete-mark the record so that it will not be applied again, - in case the server crashes before the pessimistic delete is - made persistent. */ - btr_rec_set_deleted(btr_pcur_get_block(pcur), - btr_pcur_get_rec(pcur), mtr); - - btr_pcur_store_position(pcur, mtr); - ibuf_btr_pcur_commit_specify_mtr(pcur, mtr); - - ibuf_mtr_start(mtr); - mysql_mutex_lock(&ibuf_mutex); - - if (!ibuf_restore_pos(page_id, search_tuple, BTR_PURGE_TREE, - pcur, mtr)) { - - mysql_mutex_unlock(&ibuf_mutex); - ut_ad(mtr->has_committed()); - goto func_exit; - } - - if (buf_block_t* ibuf_root = ibuf_tree_root_get(mtr)) { - btr_cur_pessimistic_delete(&err, TRUE, - btr_pcur_get_btr_cur(pcur), - BTR_CREATE_FLAG, false, mtr); - ut_a(err == DB_SUCCESS); - - ibuf_size_update(ibuf_root->page.frame); - mysql_mutex_unlock(&ibuf_mutex); - - ibuf.empty = page_is_empty(ibuf_root->page.frame); - } else { - mysql_mutex_unlock(&ibuf_mutex); - } - - ibuf_btr_pcur_commit_specify_mtr(pcur, mtr); - -func_exit: - ut_ad(mtr->has_committed()); - btr_pcur_close(pcur); - - return(TRUE); -} + if (!page_cur_move_to_next(&cur->page_cur)) + return DB_CORRUPTION; + if (!page_cur_is_after_last(&cur->page_cur)) + return DB_SUCCESS; -/** Check whether buffered changes exist for a page. -@param[in] id page identifier -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@return whether buffered changes exist */ -bool ibuf_page_exists(const page_id_t id, ulint zip_size) -{ - ut_ad(!fsp_is_system_temporary(id.space())); + /* The following is adapted from btr_pcur_move_to_next_page(), + but we will not release any latches. */ - const ulint physical_size = zip_size ? zip_size : srv_page_size; + const buf_block_t &block= *cur->page_cur.block; + const uint32_t next_page_no= btr_page_get_next(block.page.frame); + switch (next_page_no) { + case 0: + case 1: + return DB_CORRUPTION; + case FIL_NULL: + return DB_SUCCESS; + } - if (ibuf_fixed_addr_page(id, physical_size) - || fsp_descr_page(id, physical_size)) { - return false; - } + if (UNIV_UNLIKELY(next_page_no == block.page.id().page_no())) + return DB_CORRUPTION; - mtr_t mtr; - bool bitmap_bits = false; + dberr_t err; + buf_block_t *next= + btr_block_get(*cur->index(), next_page_no, BTR_MODIFY_LEAF, mtr, &err); + if (!next) + return err; - ibuf_mtr_start(&mtr); - if (const buf_block_t* bitmap_page = ibuf_bitmap_get_map_page( - id, zip_size, &mtr)) { - bitmap_bits = ibuf_bitmap_page_get_bits( - bitmap_page->page.frame, id, zip_size, - IBUF_BITMAP_BUFFERED, &mtr) != 0; - } - ibuf_mtr_commit(&mtr); - return bitmap_bits; -} + if (UNIV_UNLIKELY(memcmp_aligned<4>(next->page.frame + FIL_PAGE_PREV, + block.page.frame + FIL_PAGE_OFFSET, 4))) + return DB_CORRUPTION; -/** Reset the bits in the bitmap page for the given block and page id. -@param b X-latched secondary index page (nullptr to discard changes) -@param page_id page identifier -@param zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param mtr mini-transaction */ -static void ibuf_reset_bitmap(buf_block_t *b, page_id_t page_id, - ulint zip_size, mtr_t *mtr) -{ - buf_block_t *bitmap= ibuf_bitmap_get_map_page(page_id, zip_size, mtr); - if (!bitmap) - return; - - const ulint physical_size = zip_size ? zip_size : srv_page_size; - /* FIXME: update the bitmap byte only once! */ - ibuf_bitmap_page_set_bits(bitmap, page_id, - physical_size, false, mtr); - - if (b) - ibuf_bitmap_page_set_bits(bitmap, page_id, physical_size, - ibuf_index_page_calc_free(b), - mtr); + page_cur_set_before_first(next, &cur->page_cur); + return page_cur_move_to_next(&cur->page_cur) ? DB_SUCCESS : DB_CORRUPTION; } -/** When an index page is read from a disk to the buffer pool, this function -applies any buffered operations to the page and deletes the entries from the -insert buffer. If the page is not read, but created in the buffer pool, this -function deletes its buffered entries from the insert buffer; there can -exist entries for such a page if the page belonged to an index which -subsequently was dropped. -@param block X-latched page to try to apply changes to, or NULL to discard -@param page_id page identifier -@param zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@return error code */ -dberr_t ibuf_merge_or_delete_for_page(buf_block_t *block, - const page_id_t page_id, - ulint zip_size) +/** Apply changes to a block. */ +ATTRIBUTE_COLD +static dberr_t ibuf_merge(fil_space_t *space, btr_cur_t *cur, mtr_t *mtr) { - if (trx_sys_hdr_page(page_id)) { - return DB_SUCCESS; - } - - ut_ad(!block || page_id == block->page.id()); - ut_ad(!block || block->page.frame); - ut_ad(!block || !block->page.is_ibuf_exist()); - ut_ad(!block || !block->page.is_reinit()); - ut_ad(!trx_sys_hdr_page(page_id)); - ut_ad(page_id < page_id_t(SRV_SPACE_ID_UPPER_BOUND, 0)); - - const ulint physical_size = zip_size ? zip_size : srv_page_size; - - if (ibuf_fixed_addr_page(page_id, physical_size) - || fsp_descr_page(page_id, physical_size)) { - return DB_SUCCESS; - } - - btr_pcur_t pcur; -#ifdef UNIV_IBUF_DEBUG - ulint volume = 0; -#endif /* UNIV_IBUF_DEBUG */ - dberr_t err = DB_SUCCESS; - mtr_t mtr; - - fil_space_t* space = fil_space_t::get(page_id.space()); - - if (UNIV_UNLIKELY(!space)) { - block = nullptr; - } else { - ulint bitmap_bits = 0; - - ibuf_mtr_start(&mtr); - - buf_block_t* bitmap_page = ibuf_bitmap_get_map_page( - page_id, zip_size, &mtr); - - if (bitmap_page - && fil_page_get_type(bitmap_page->page.frame) - != FIL_PAGE_TYPE_ALLOCATED) { - bitmap_bits = ibuf_bitmap_page_get_bits( - bitmap_page->page.frame, page_id, zip_size, - IBUF_BITMAP_BUFFERED, &mtr); - } - - ibuf_mtr_commit(&mtr); - - if (bitmap_bits - && DB_SUCCESS - == fseg_page_is_allocated(space, page_id.page_no())) { - ibuf_mtr_start(&mtr); - mtr.set_named_space(space); - ibuf_reset_bitmap(block, page_id, zip_size, &mtr); - ibuf_mtr_commit(&mtr); - bitmap_bits = 0; - if (!block - || btr_page_get_index_id(block->page.frame) - != DICT_IBUF_ID_MIN + IBUF_SPACE_ID) { - ibuf_delete_recs(page_id); - } - } - - if (!bitmap_bits) { - /* No changes are buffered for this page. */ - space->release(); - return DB_SUCCESS; - } - } - - if (!block) { - } else if (!fil_page_index_page_check(block->page.frame) - || !page_is_leaf(block->page.frame)) { - space->set_corrupted(); - err = DB_CORRUPTION; - block = nullptr; - } else { - /* Move the ownership of the x-latch on the page to this OS - thread, so that we can acquire a second x-latch on it. This - is needed for the insert operations to the index page to pass - the debug checks. */ - - block->page.lock.claim_ownership(); - } - - mem_heap_t* heap = mem_heap_create(512); - - const dtuple_t* search_tuple = ibuf_search_tuple_build( - page_id.space(), page_id.page_no(), heap); - - /* Counts for merged & discarded operations. */ - ulint mops[IBUF_OP_COUNT]; - ulint dops[IBUF_OP_COUNT]; + if (btr_cur_get_rec(cur)[4]) + return DB_CORRUPTION; - memset(mops, 0, sizeof(mops)); - memset(dops, 0, sizeof(dops)); - pcur.btr_cur.page_cur.index = ibuf.index; + const uint32_t space_id= mach_read_from_4(btr_cur_get_rec(cur)); + const uint32_t page_no= mach_read_from_4(btr_cur_get_rec(cur) + 5); -loop: - ibuf_mtr_start(&mtr); + buf_block_t *block= space && page_no < space->size + ? buf_page_get_gen(page_id_t{space_id, page_no}, space->zip_size(), + RW_X_LATCH, nullptr, BUF_GET_POSSIBLY_FREED, mtr) + : nullptr; - /* Position pcur in the insert buffer at the first entry for this - index page */ - if (btr_pcur_open_on_user_rec(search_tuple, PAGE_CUR_GE, - BTR_MODIFY_LEAF, &pcur, &mtr) - != DB_SUCCESS) { - err = DB_CORRUPTION; - goto reset_bit; - } - - if (block) { - block->page.fix(); - block->page.lock.x_lock_recursive(); - mtr.memo_push(block, MTR_MEMO_PAGE_X_FIX); - } - - if (space) { - mtr.set_named_space(space); - } - - if (!btr_pcur_is_on_user_rec(&pcur)) { - ut_ad(btr_pcur_is_after_last_on_page(&pcur)); - goto reset_bit; - } + buf_block_t *bitmap= block + ? buf_page_get_gen(page_id_t(space_id, + uint32_t(page_no & + ~(block->physical_size() - 1)) + 1), + block->zip_size(), RW_X_LATCH, nullptr, + BUF_GET_POSSIBLY_FREED, mtr) + : nullptr; - for (;;) { - rec_t* rec; + if (!block); + else if (fil_page_get_type(block->page.frame) != FIL_PAGE_INDEX || + !page_is_leaf(block->page.frame) || + DB_SUCCESS == fseg_page_is_allocated(space, page_no)) + block= nullptr; - ut_ad(btr_pcur_is_on_user_rec(&pcur)); + do + { + rec_t *rec= cur->page_cur.rec; + ulint n_fields= rec_get_n_fields_old(rec); - rec = btr_pcur_get_rec(&pcur); + if (n_fields <= IBUF_REC_FIELD_USER + 1 || rec[4]) + return DB_CORRUPTION; - /* Check if the entry is for this index page */ - if (ibuf_rec_get_page_no(&mtr, rec) != page_id.page_no() - || ibuf_rec_get_space(&mtr, rec) != page_id.space()) { + n_fields-= IBUF_REC_FIELD_USER; - if (block != NULL) { - page_header_reset_last_insert(block, &mtr); - } + ulint types_len, not_redundant; - goto reset_bit; - } + if (rec_get_1byte_offs_flag(rec)) + { + if (rec_1_get_field_end_info(rec, 0) != 4 || + rec_1_get_field_end_info(rec, 1) != 5 || + rec_1_get_field_end_info(rec, 2) != 9) + return DB_CORRUPTION; + types_len= rec_1_get_field_end_info(rec, 3); + } + else + { + if (rec_2_get_field_end_info(rec, 0) != 4 || + rec_2_get_field_end_info(rec, 1) != 5 || + rec_2_get_field_end_info(rec, 2) != 9) + return DB_CORRUPTION; + types_len= rec_2_get_field_end_info(rec, 3); + } - if (err) { - fputs("InnoDB: Discarding record\n ", stderr); - rec_print_old(stderr, rec); - fputs("\nInnoDB: from the insert buffer!\n\n", stderr); - } else if (block != NULL && !rec_get_deleted_flag(rec, 0)) { - /* Now we have at pcur a record which should be - applied on the index page; NOTE that the call below - copies pointers to fields in rec, and we must - keep the latch to the rec page until the - insertion is finished! */ - dtuple_t* entry; - trx_id_t max_trx_id; - dict_index_t* dummy_index; - ibuf_op_t op = ibuf_rec_get_op_type(&mtr, rec); - - max_trx_id = page_get_max_trx_id(page_align(rec)); - page_update_max_trx_id(block, - buf_block_get_page_zip(block), - max_trx_id, &mtr); - - ut_ad(page_validate(page_align(rec), ibuf.index)); - - entry = ibuf_build_entry_from_ibuf_rec( - &mtr, rec, heap, &dummy_index); - ut_ad(!dummy_index->table->space); - dummy_index->table->space = space; - dummy_index->table->space_id = space->id; - - ut_ad(page_validate(block->page.frame, dummy_index)); - - switch (op) { - case IBUF_OP_INSERT: -#ifdef UNIV_IBUF_DEBUG - volume += rec_get_converted_size( - dummy_index, entry, 0); - - volume += page_dir_calc_reserved_space(1); - - ut_a(volume <= (4U << srv_page_size_shift) - / IBUF_PAGE_SIZE_PER_FREE_SPACE); -#endif - ibuf_insert_to_index_page( - entry, block, dummy_index, &mtr); - break; - - case IBUF_OP_DELETE_MARK: - ibuf_set_del_mark( - entry, block, dummy_index, &mtr); - break; - - case IBUF_OP_DELETE: - ibuf_delete(entry, block, dummy_index, &mtr); - /* Because ibuf_delete() will latch an - insert buffer bitmap page, commit mtr - before latching any further pages. - Store and restore the cursor position. */ - ut_ad(rec == btr_pcur_get_rec(&pcur)); - ut_ad(page_rec_is_user_rec(rec)); - ut_ad(ibuf_rec_get_page_no(&mtr, rec) - == page_id.page_no()); - ut_ad(ibuf_rec_get_space(&mtr, rec) - == page_id.space()); - - /* Mark the change buffer record processed, - so that it will not be merged again in case - the server crashes between the following - mtr_commit() and the subsequent mtr_commit() - of deleting the change buffer record. */ - btr_rec_set_deleted( - btr_pcur_get_block(&pcur), - btr_pcur_get_rec(&pcur), &mtr); - - btr_pcur_store_position(&pcur, &mtr); - ibuf_btr_pcur_commit_specify_mtr(&pcur, &mtr); - - ibuf_mtr_start(&mtr); - mtr.set_named_space(space); - - block->page.lock.x_lock_recursive(); - block->fix(); - mtr.memo_push(block, MTR_MEMO_PAGE_X_FIX); - - if (!ibuf_restore_pos(page_id, search_tuple, - BTR_MODIFY_LEAF, - &pcur, &mtr)) { - - ut_ad(mtr.has_committed()); - mops[op]++; - ibuf_dummy_index_free(dummy_index); - goto loop; - } - - break; - default: - ut_error; - } - - mops[op]++; - - ibuf_dummy_index_free(dummy_index); - } else { - dops[ibuf_rec_get_op_type(&mtr, rec)]++; - } + if (types_len < 9 || (types_len - 9) / 6 != n_fields) + return DB_CORRUPTION; - /* Delete the record from ibuf */ - if (ibuf_delete_rec(page_id, &pcur, search_tuple, &mtr)) { - /* Deletion was pessimistic and mtr was committed: - we start from the beginning again */ + ibuf_op op= IBUF_OP_INSERT; + const ulint info_len= (types_len - 9) % 6; - ut_ad(mtr.has_committed()); - goto loop; - } else if (btr_pcur_is_after_last_on_page(&pcur)) { - ibuf_mtr_commit(&mtr); - goto loop; - } - } + switch (info_len) { + default: + return DB_CORRUPTION; + case 0: case 1: + not_redundant= info_len; + break; + case 4: + not_redundant= rec[9 + 3]; + if (rec[9 + 2] > IBUF_OP_DELETE || not_redundant > 1) + return DB_CORRUPTION; + op= static_cast(rec[9 + 2]); + } -reset_bit: - if (space) { - ibuf_reset_bitmap(block, page_id, zip_size, &mtr); - } + const byte *const types= rec + 9 + info_len; - ibuf_mtr_commit(&mtr); - ut_free(pcur.old_rec_buf); + if (ibuf_rec_get_space(rec) != space_id || + ibuf_rec_get_page_no(rec) != page_no) + break; - if (space) { - space->release(); - } + if (!rec_get_deleted_flag(rec, 0)) + { + /* Delete-mark the record so that it will not be applied again if + the server is killed before the completion of ibuf_upgrade(). */ + btr_rec_set_deleted(cur->page_cur.block, rec, mtr); + + if (block) + { + page_header_reset_last_insert(block, mtr); + page_update_max_trx_id(block, buf_block_get_page_zip(block), + page_get_max_trx_id(page_align(rec)), mtr); + dict_index_t *index; + mem_heap_t *heap = mem_heap_create(512); + dtuple_t *entry= ibuf_entry_build(rec, not_redundant, n_fields, + types, heap, index); + dict_table_t *table= index->table; + ut_ad(!table->space); + table->space= space; + table->space_id= space_id; + + switch (op) { + case IBUF_OP_INSERT: + ibuf_insert_to_index_page(entry, block, index, mtr); + break; + case IBUF_OP_DELETE_MARK: + ibuf_set_del_mark(entry, block, index, mtr); + break; + case IBUF_OP_DELETE: + ibuf_delete(entry, block, index, mtr); + break; + } + + mem_heap_free(heap); + dict_mem_index_free(index); + dict_mem_table_free(table); + } + } - mem_heap_free(heap); + if (dberr_t err= ibuf_move_to_next(cur, mtr)) + return err; + } + while (!page_cur_is_after_last(&cur->page_cur)); - ibuf.n_merges++; - ibuf_add_ops(ibuf.n_merged_ops, mops); - ibuf_add_ops(ibuf.n_discarded_ops, dops); + if (bitmap) + ibuf_reset(*bitmap, page_no, mtr); - return err; + return DB_SUCCESS; } -/** Delete all change buffer entries for a tablespace, -in DISCARD TABLESPACE, IMPORT TABLESPACE, or read-ahead. -@param[in] space missing or to-be-discarded tablespace */ -void ibuf_delete_for_discarded_space(uint32_t space) +ATTRIBUTE_COLD dberr_t ibuf_upgrade() { - btr_pcur_t pcur; - const rec_t* ibuf_rec; - mtr_t mtr; - - /* Counts for discarded operations. */ - ulint dops[IBUF_OP_COUNT]; - - dfield_t dfield[IBUF_REC_FIELD_METADATA]; - dtuple_t search_tuple {0,IBUF_REC_FIELD_METADATA, - IBUF_REC_FIELD_METADATA,dfield,0 - ,nullptr -#ifdef UNIV_DEBUG - ,DATA_TUPLE_MAGIC_N -#endif /* UNIV_DEBUG */ - }; - byte space_id[4]; - mach_write_to_4(space_id, space); - - dfield_set_data(&dfield[0], space_id, 4); - dfield_set_data(&dfield[1], field_ref_zero, 1); - dfield_set_data(&dfield[2], field_ref_zero, 4); - dtuple_set_types_binary(&search_tuple, IBUF_REC_FIELD_METADATA); - /* Use page number 0 to build the search tuple so that we get the - cursor positioned at the first entry for this space id */ - - memset(dops, 0, sizeof(dops)); - pcur.btr_cur.page_cur.index = ibuf.index; - -loop: - log_free_check(); - ibuf_mtr_start(&mtr); - - /* Position pcur in the insert buffer at the first entry for the - space */ - if (btr_pcur_open_on_user_rec(&search_tuple, PAGE_CUR_GE, - BTR_MODIFY_LEAF, &pcur, &mtr) - != DB_SUCCESS) { - goto leave_loop; - } - - if (!btr_pcur_is_on_user_rec(&pcur)) { - ut_ad(btr_pcur_is_after_last_on_page(&pcur)); - goto leave_loop; - } - - for (;;) { - ut_ad(btr_pcur_is_on_user_rec(&pcur)); - - ibuf_rec = btr_pcur_get_rec(&pcur); + if (srv_read_only_mode) + { + sql_print_error("InnoDB: innodb_read_only_mode prevents an upgrade"); + return DB_READ_ONLY; + } - /* Check if the entry is for this space */ - if (ibuf_rec_get_space(&mtr, ibuf_rec) != space) { + sql_print_information("InnoDB: Upgrading the change buffer"); - goto leave_loop; - } +#ifdef BTR_CUR_HASH_ADAPT + const bool ahi= btr_search_enabled; + if (ahi) + btr_search_disable(); +#endif - uint32_t page_no = ibuf_rec_get_page_no(&mtr, ibuf_rec); + dict_table_t *ibuf_table= dict_table_t::create({C_STRING_WITH_LEN("ibuf")}, + fil_system.sys_space, + 1, 0, 0, 0); + dict_index_t *ibuf_index= + dict_mem_index_create(ibuf_table, "CLUST_IND", DICT_CLUSTERED, 1); + ibuf_index->id= ibuf_index_id; + ibuf_index->n_uniq= REC_MAX_N_FIELDS; + ibuf_index->lock.SRW_LOCK_INIT(index_tree_rw_lock_key); + ibuf_index->page= FSP_IBUF_TREE_ROOT_PAGE_NO; + ut_d(ibuf_index->is_dummy= true); + ut_d(ibuf_index->cached= true); + + size_t spaces=0, pages= 0; + dberr_t err; + mtr_t mtr; + { + btr_cur_t cur; + uint32_t prev_space_id= ~0U; + fil_space_t *space= nullptr; - dops[ibuf_rec_get_op_type(&mtr, ibuf_rec)]++; + log_free_check(); + mtr.start(); + err= cur.open_leaf(true, ibuf_index, BTR_CONT_MODIFY_TREE, &mtr); - /* Delete the record from ibuf */ - if (ibuf_delete_rec(page_id_t(space, page_no), - &pcur, &search_tuple, &mtr)) { - /* Deletion was pessimistic and mtr was committed: - we start from the beginning again */ + if (err == DB_SUCCESS) + { + cur.page_cur.block->fix(); + mtr.page_lock(cur.page_cur.block, RW_X_LATCH); + err= ibuf_move_to_next(&cur, &mtr); + } - ut_ad(mtr.has_committed()); -clear: - ut_free(pcur.old_rec_buf); - goto loop; - } + while (err == DB_SUCCESS && !page_cur_is_after_last(&cur.page_cur)) + { + const uint32_t space_id= ibuf_rec_get_space(cur.page_cur.rec); + if (space_id != prev_space_id) + { + if (space) + space->release(); + prev_space_id= space_id; + space= fil_space_t::get(space_id); + if (space) + mtr.set_named_space(space); + spaces++; + } + pages++; + err= ibuf_merge(space, &cur, &mtr); + if (err == DB_SUCCESS) + { + /* Move to the next user index page. We buffer-fix the current + change buffer leaf page to prevent it from being evicted + before we have started a new mini-transaction. */ + cur.page_cur.block->fix(); + mtr.commit(); + + if (recv_sys.report(time(nullptr))) + { + sql_print_information("InnoDB: merged changes to" + " %zu tablespaces, %zu pages", spaces, pages); + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "merged changes to" + " %zu tablespaces, %zu pages", + spaces, pages); + } + + log_free_check(); + mtr.start(); + mtr.page_lock(cur.page_cur.block, RW_X_LATCH); + if (space) + mtr.set_named_space(space); + } + } + mtr.commit(); + if (space) + space->release(); + } - if (btr_pcur_is_after_last_on_page(&pcur)) { - ibuf_mtr_commit(&mtr); - goto clear; - } - } + if (err == DB_SUCCESS) + { + mtr.start(); + if (buf_block_t *root= buf_page_get_gen(ibuf_root, 0, RW_X_LATCH, + nullptr, BUF_GET, &mtr, &err)) + { + page_create(root, &mtr, false); + mtr.write<2,mtr_t::MAYBE_NOP>(*root, PAGE_HEADER + PAGE_LEVEL + + root->page.frame, 0U); + } + mtr.commit(); -leave_loop: - ibuf_mtr_commit(&mtr); - ut_free(pcur.old_rec_buf); + while (err == DB_SUCCESS) + err= ibuf_remove_free_page(mtr); - ibuf_add_ops(ibuf.n_discarded_ops, dops); -} + if (err == DB_SUCCESS_LOCKED_REC) + err= DB_SUCCESS; + } -/******************************************************************//** -Looks if the insert buffer is empty. -@return true if empty */ -bool -ibuf_is_empty(void) -/*===============*/ -{ - mtr_t mtr; +#ifdef BTR_CUR_HASH_ADAPT + if (ahi) + btr_search_enable(); +#endif - ibuf_mtr_start(&mtr); + ibuf_index->lock.free(); + dict_mem_index_free(ibuf_index); + dict_mem_table_free(ibuf_table); - ut_d(mysql_mutex_lock(&ibuf_mutex)); - const buf_block_t* root = ibuf_tree_root_get(&mtr); - bool is_empty = root && page_is_empty(root->page.frame); - ut_ad(!root || is_empty == ibuf.empty); - ut_d(mysql_mutex_unlock(&ibuf_mutex)); - ibuf_mtr_commit(&mtr); + if (err) + sql_print_error("InnoDB: Unable to upgrade the change buffer"); + else + sql_print_information("InnoDB: Upgraded the change buffer: " + "%zu tablespaces, %zu pages", spaces, pages); - return(is_empty); + return err; } -/******************************************************************//** -Prints info of ibuf. */ -void -ibuf_print( -/*=======*/ - FILE* file) /*!< in: file where to print */ +dberr_t ibuf_upgrade_needed() { + mtr_t mtr; + mtr.start(); + mtr.x_lock_space(fil_system.sys_space); + dberr_t err; + const buf_block_t *header_page= + buf_page_get_gen(ibuf_header, 0, RW_S_LATCH, nullptr, BUF_GET, &mtr, &err); - mysql_mutex_lock(&ibuf_mutex); - if (ibuf.empty) + if (!header_page) { - mysql_mutex_unlock(&ibuf_mutex); - return; + err_exit: + sql_print_error("InnoDB: The change buffer is corrupted"); + if (srv_force_recovery == SRV_FORCE_NO_LOG_REDO) + err= DB_SUCCESS; + func_exit: + mtr.commit(); + return err; } - const ulint size= ibuf.size; - const ulint free_list_len= ibuf.free_list_len; - const ulint seg_size= ibuf.seg_size; - mysql_mutex_unlock(&ibuf_mutex); - - fprintf(file, - "-------------\n" - "INSERT BUFFER\n" - "-------------\n" - "size " ULINTPF ", free list len " ULINTPF "," - " seg size " ULINTPF ", " ULINTPF " merges\n", - size, free_list_len, seg_size, ulint{ibuf.n_merges}); - ibuf_print_ops("merged operations:\n", ibuf.n_merged_ops, file); - ibuf_print_ops("discarded operations:\n", ibuf.n_discarded_ops, file); -} - -/** Check the insert buffer bitmaps on IMPORT TABLESPACE. -@param[in] trx transaction -@param[in,out] space tablespace being imported -@return DB_SUCCESS or error code */ -dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) -{ - ut_ad(trx->mysql_thd); - ut_ad(space->purpose == FIL_TYPE_IMPORT); - - const unsigned zip_size = space->zip_size(); - const unsigned physical_size = space->physical_size(); - - uint32_t size= std::min(space->free_limit, space->size); - - if (size == 0) { - return(DB_TABLE_NOT_FOUND); - } - - mtr_t mtr; - - mysql_mutex_lock(&ibuf_mutex); - - /* The two bitmap pages (allocation bitmap and ibuf bitmap) repeat - every page_size pages. For example if page_size is 16 KiB, then the - two bitmap pages repeat every 16 KiB * 16384 = 256 MiB. In the loop - below page_no is measured in number of pages since the beginning of - the space, as usual. */ - - for (uint32_t page_no = 0; page_no < size; page_no += physical_size) { - if (trx_is_interrupted(trx)) { - mysql_mutex_unlock(&ibuf_mutex); - return(DB_INTERRUPTED); - } - - mtr_start(&mtr); - ibuf_enter(&mtr); - - buf_block_t* bitmap_page = ibuf_bitmap_get_map_page( - page_id_t(space->id, page_no), zip_size, &mtr); - if (!bitmap_page) { - mysql_mutex_unlock(&ibuf_mutex); - ibuf_exit(&mtr); - mtr.commit(); - return DB_CORRUPTION; - } - - if (buf_is_zeroes(span(bitmap_page->page.frame, - physical_size))) { - /* This means we got all-zero page instead of - ibuf bitmap page. The subsequent page should be - all-zero pages. */ -#ifdef UNIV_DEBUG - for (uint32_t curr_page = page_no + 1; - curr_page < physical_size; curr_page++) { - - buf_block_t* block = buf_page_get( - page_id_t(space->id, curr_page), - zip_size, RW_S_LATCH, &mtr); - page_t* page = buf_block_get_frame(block); - ut_ad(buf_is_zeroes(span( - page, - physical_size))); - } -#endif /* UNIV_DEBUG */ - ibuf_exit(&mtr); - mtr_commit(&mtr); - continue; - } - - for (uint32_t i = FSP_IBUF_BITMAP_OFFSET + 1; i < physical_size; - i++) { - const uint32_t offset = page_no + i; - const page_id_t cur_page_id(space->id, offset); - - if (ibuf_bitmap_page_get_bits( - bitmap_page->page.frame, - cur_page_id, zip_size, - IBUF_BITMAP_IBUF, &mtr)) { - - mysql_mutex_unlock(&ibuf_mutex); - ibuf_exit(&mtr); - mtr_commit(&mtr); - - ib_errf(trx->mysql_thd, - IB_LOG_LEVEL_ERROR, - ER_INNODB_INDEX_CORRUPT, - "File %s page %u" - " is wrongly flagged to belong to the" - " insert buffer", - space->chain.start->name, offset); - return(DB_CORRUPTION); - } - - if (ibuf_bitmap_page_get_bits( - bitmap_page->page.frame, - cur_page_id, zip_size, - IBUF_BITMAP_BUFFERED, &mtr)) { - - ib_errf(trx->mysql_thd, - IB_LOG_LEVEL_WARN, - ER_INNODB_INDEX_CORRUPT, - "Buffered changes" - " for file %s page %u are lost", - space->chain.start->name, offset); - - /* Tolerate this error, so that - slightly corrupted tables can be - imported and dumped. Clear the bit. */ - ibuf_bitmap_page_set_bits( - bitmap_page, cur_page_id, - physical_size, false, &mtr); - } - } - - ibuf_exit(&mtr); - mtr_commit(&mtr); - } - - mysql_mutex_unlock(&ibuf_mutex); - return(DB_SUCCESS); -} - -void ibuf_set_bitmap_for_bulk_load(buf_block_t *block, mtr_t *mtr, bool reset) -{ - ut_a(page_is_leaf(block->page.frame)); - const page_id_t id{block->page.id()}; - const auto zip_size= block->zip_size(); - - if (buf_block_t *bitmap_page= ibuf_bitmap_get_map_page(id, zip_size, mtr)) + const buf_block_t *root= buf_page_get_gen(ibuf_root, 0, RW_S_LATCH, nullptr, + BUF_GET, &mtr, &err); + if (!root) + goto err_exit; + + if (UNIV_LIKELY(!page_has_siblings(root->page.frame)) && + UNIV_LIKELY(!memcmp(root->page.frame + FIL_PAGE_TYPE, field_ref_zero, + srv_page_size - + (FIL_PAGE_DATA_END + FIL_PAGE_TYPE)))) + /* the change buffer was removed; no need to upgrade */; + else if (page_is_comp(root->page.frame) || + btr_page_get_index_id(root->page.frame) != ibuf_index_id || + fil_page_get_type(root->page.frame) != FIL_PAGE_INDEX) + { + err= DB_CORRUPTION; + goto err_exit; + } + else if (srv_read_only_mode) { - if (ibuf_bitmap_page_get_bits(bitmap_page->page.frame, id, zip_size, - IBUF_BITMAP_BUFFERED, mtr)) - ibuf_delete_recs(id); - - ulint free_val= reset ? 0 : ibuf_index_page_calc_free(block); - /* FIXME: update the bitmap byte only once! */ - ibuf_bitmap_page_set_bits - (bitmap_page, id, block->physical_size(), free_val, mtr); - ibuf_bitmap_page_set_bits - (bitmap_page, id, block->physical_size(), false, mtr); + sql_print_error("InnoDB: innodb_read_only=ON prevents an upgrade" + " of the change buffer"); + err= DB_READ_ONLY; } + else if (srv_force_recovery != SRV_FORCE_NO_LOG_REDO) + err= DB_FAIL; + + goto func_exit; } diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index a2aa46b62da5c..a397aa6b7f109 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -2,7 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2014, 2022, MariaDB Corporation. +Copyright (c) 2014, 2023, 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 @@ -56,12 +56,8 @@ is acceptable for the program to die with a clear assert failure. */ #define BTR_MAX_LEVELS 100 #define BTR_LATCH_MODE_WITHOUT_FLAGS(latch_mode) \ - btr_latch_mode((latch_mode) & ~(BTR_INSERT \ - | BTR_DELETE_MARK \ - | BTR_RTREE_UNDO_INS \ + btr_latch_mode((latch_mode) & ~(BTR_RTREE_UNDO_INS \ | BTR_RTREE_DELETE_MARK \ - | BTR_DELETE \ - | BTR_IGNORE_SEC_UNIQUE \ | BTR_ALREADY_S_LATCHED \ | BTR_LATCH_FOR_INSERT \ | BTR_LATCH_FOR_DELETE)) @@ -79,6 +75,14 @@ btr_root_adjust_on_import( const dict_index_t* index) /*!< in: index tree */ MY_ATTRIBUTE((warn_unused_result)); +/** Check a file segment header within a B-tree root page. +@param offset file segment header offset +@param block B-tree root page +@param space tablespace +@return whether the segment header is valid */ +bool btr_root_fseg_validate(ulint offset, const buf_block_t &block, + const fil_space_t &space); + /** Report a decryption failure. */ ATTRIBUTE_COLD void btr_decryption_failed(const dict_index_t &index); @@ -86,12 +90,11 @@ ATTRIBUTE_COLD void btr_decryption_failed(const dict_index_t &index); @param[in] index index tree @param[in] page page number @param[in] mode latch mode -@param[in] merge whether change buffer merge should be attempted @param[in,out] mtr mini-transaction @param[out] err error code @return block */ buf_block_t *btr_block_get(const dict_index_t &index, - uint32_t page, ulint mode, bool merge, + uint32_t page, ulint mode, mtr_t *mtr, dberr_t *err= nullptr); /**************************************************************//** @@ -242,15 +245,7 @@ btr_root_raise_and_insert( mtr_t* mtr, /*!< in: mtr */ dberr_t* err) /*!< out: error code */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************//** -Reorganizes an index page. - -IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE -if this is a compressed leaf page in a secondary index. This has to -be done either within the same mini-transaction, or by invoking -ibuf_reset_free_bits() before mtr_commit(). On uncompressed pages, -IBUF_BITMAP_FREE is unaffected by reorganization. - +/** Reorganize an index page. @param cursor page cursor @param mtr mini-transaction @return error code @@ -348,6 +343,7 @@ btr_check_node_ptr( /*===============*/ dict_index_t* index, /*!< in: index tree */ buf_block_t* block, /*!< in: index page */ + que_thr_t* thr, /*!< in/out: query thread */ mtr_t* mtr) /*!< in: mtr */ MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_DEBUG */ @@ -451,15 +447,8 @@ btr_root_block_get( or RW_X_LATCH */ mtr_t* mtr, /*!< in: mtr */ dberr_t* err); /*!< out: error code */ -/*************************************************************//** -Reorganizes an index page. - -IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE -if this is a compressed leaf page in a secondary index. This has to -be done either within the same mini-transaction, or by invoking -ibuf_reset_free_bits() before mtr_commit(). On uncompressed pages, -IBUF_BITMAP_FREE is unaffected by reorganization. +/** Reorganize an index page. @return error code @retval DB_FAIL if reorganizing a ROW_FORMAT=COMPRESSED page failed */ dberr_t btr_page_reorganize_block( @@ -530,9 +519,10 @@ btr_lift_page_up( must not be empty: use btr_discard_only_page_on_level if the last record from the page should be removed */ + que_thr_t* thr, /*!< in/out: query thread for SPATIAL INDEX */ mtr_t* mtr, /*!< in/out: mini-transaction */ dberr_t* err) /*!< out: error code */ - __attribute__((nonnull)); + __attribute__((nonnull(1,2,4,5))); #define BTR_N_LEAF_PAGES 1 #define BTR_TOTAL_SIZE 2 diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index 49bc8a4ff1bb7..b317b3abbc3e0 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -56,11 +56,7 @@ enum { BTR_KEEP_POS_FLAG = 8, /** the caller is creating the index or wants to bypass the index->info.online creation log */ - BTR_CREATE_FLAG = 16, - /** the caller of btr_cur_optimistic_update() or - btr_cur_update_in_place() will take care of - updating IBUF_BITMAP_FREE */ - BTR_KEEP_IBUF_BITMAP = 32 + BTR_CREATE_FLAG = 16 }; /* btr_cur_latch_leaves() returns latched blocks and savepoints. */ @@ -156,8 +152,7 @@ If mode is PAGE_CUR_GE, then up_match will a have a sensible value. PAGE_CUR_GE, as the latter may end up on the previous page of the record! Inserts should always be made using PAGE_CUR_LE to search the position! -@param latch_mode BTR_SEARCH_LEAF, ..., ORed with at most one of BTR_INSERT, - BTR_DELETE_MARK, or BTR_DELETE; +@param latch_mode BTR_SEARCH_LEAF, ... cursor->left_block is used to store a pointer to the left neighbor page @param cursor tree cursor; the cursor page is s- or x-latched, but see also @@ -242,14 +237,8 @@ btr_cur_pessimistic_insert( See if there is enough place in the page modification log to log an update-in-place. -@retval false if out of space; IBUF_BITMAP_FREE will be reset -outside mtr if the page was recompressed -@retval true if enough place; - -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if this is -a secondary index leaf page. This has to be done either within the -same mini-transaction, or by invoking ibuf_reset_free_bits() before -mtr_commit(mtr). */ +@retval false if out of space +@retval true if enough place */ bool btr_cur_update_alloc_zip_func( /*==========================*/ @@ -291,7 +280,7 @@ Updates a record when the update causes no size changes in its fields. @return locking or undo log related error code, or @retval DB_SUCCESS on success @retval DB_ZIP_OVERFLOW if there is not enough space left -on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) */ +on a ROW_FORMAT=COMPRESSED page */ dberr_t btr_cur_update_in_place( /*====================*/ @@ -712,34 +701,19 @@ enum btr_cur_method { reference is stored in the field hash_node, and might be necessary to update */ - BTR_CUR_BINARY, /*!< success using the binary search */ - BTR_CUR_INSERT_TO_IBUF, /*!< performed the intended insert to - the insert buffer */ - BTR_CUR_DEL_MARK_IBUF, /*!< performed the intended delete - mark in the insert/delete buffer */ - BTR_CUR_DELETE_IBUF, /*!< performed the intended delete in - the insert/delete buffer */ - BTR_CUR_DELETE_REF /*!< row_purge_poss_sec() failed */ + BTR_CUR_BINARY /*!< success using the binary search */ }; /** The tree cursor: the definition appears here only for the compiler to know struct size! */ struct btr_cur_t { page_cur_t page_cur; /*!< page cursor */ - purge_node_t* purge_node; /*!< purge node, for BTR_DELETE */ buf_block_t* left_block; /*!< this field is used to store a pointer to the left neighbor page, in the cases BTR_SEARCH_PREV and BTR_MODIFY_PREV */ /*------------------------------*/ - que_thr_t* thr; /*!< this field is only used - when btr_cur_search_to_nth_level - is called for an index entry - insertion: the calling query - thread is passed here to be - used in the insert buffer */ - /*------------------------------*/ /** The following fields are used in btr_cur_search_to_nth_level to pass information: */ /* @{ */ diff --git a/storage/innobase/include/btr0types.h b/storage/innobase/include/btr0types.h index 6118bfbc1289d..0c0f4a9cc7965 100644 --- a/storage/innobase/include/btr0types.h +++ b/storage/innobase/include/btr0types.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, 2022, MariaDB Corporation. +Copyright (c) 2018, 2023, 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 @@ -76,24 +76,8 @@ enum btr_latch_mode { /** Continue modifying the entire B-tree. */ BTR_CONT_MODIFY_TREE = 4 | BTR_MODIFY_TREE, - /* BTR_INSERT, BTR_DELETE and BTR_DELETE_MARK are mutually - exclusive. */ - /** The search tuple will be inserted to the secondary index - at the searched position. When the leaf page is not in the - buffer pool, try to use the change buffer. */ - BTR_INSERT = 64, - - /** Try to delete mark a secondary index leaf page record at - the searched position using the change buffer when the page is - not in the buffer pool. */ - BTR_DELETE_MARK = 128, - - /** Try to purge the record using the change buffer when the - secondary index leaf page is not in the buffer pool. */ - BTR_DELETE = BTR_INSERT | BTR_DELETE_MARK, - /** The caller is already holding dict_index_t::lock S-latch. */ - BTR_ALREADY_S_LATCHED = 256, + BTR_ALREADY_S_LATCHED = 16, /** Search and S-latch a leaf page, assuming that the dict_index_t::lock S-latch is being held. */ BTR_SEARCH_LEAF_ALREADY_S_LATCHED = BTR_SEARCH_LEAF @@ -107,28 +91,15 @@ enum btr_latch_mode { BTR_MODIFY_LEAF_ALREADY_LATCHED = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED, - /** Attempt to delete-mark a secondary index record. */ - BTR_DELETE_MARK_LEAF = BTR_MODIFY_LEAF | BTR_DELETE_MARK, - /** Attempt to delete-mark a secondary index record - while holding the dict_index_t::lock S-latch. */ - BTR_DELETE_MARK_LEAF_ALREADY_S_LATCHED = BTR_DELETE_MARK_LEAF - | BTR_ALREADY_S_LATCHED, - /** Attempt to purge a secondary index record. */ - BTR_PURGE_LEAF = BTR_MODIFY_LEAF | BTR_DELETE, - /** Attempt to purge a secondary index record - while holding the dict_index_t::lock S-latch. */ - BTR_PURGE_LEAF_ALREADY_S_LATCHED = BTR_PURGE_LEAF - | BTR_ALREADY_S_LATCHED, - /** In the case of BTR_MODIFY_TREE, the caller specifies the intention to delete record only. It is used to optimize block->lock range.*/ - BTR_LATCH_FOR_DELETE = 512, + BTR_LATCH_FOR_DELETE = 32, /** In the case of BTR_MODIFY_TREE, the caller specifies the intention to delete record only. It is used to optimize block->lock range.*/ - BTR_LATCH_FOR_INSERT = 1024, + BTR_LATCH_FOR_INSERT = 64, /** Attempt to delete a record in the tree. */ BTR_PURGE_TREE = BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE, @@ -136,12 +107,8 @@ enum btr_latch_mode { /** Attempt to insert a record into the tree. */ BTR_INSERT_TREE = BTR_MODIFY_TREE | BTR_LATCH_FOR_INSERT, - /** This flag ORed to BTR_INSERT says that we can ignore possible - UNIQUE definition on secondary indexes when we decide if we can use - the insert buffer to speed up inserts */ - BTR_IGNORE_SEC_UNIQUE = 2048, /** Rollback in spatial index */ - BTR_RTREE_UNDO_INS = 4096, + BTR_RTREE_UNDO_INS = 128, /** Try to delete mark a spatial index record */ - BTR_RTREE_DELETE_MARK = 8192 + BTR_RTREE_DELETE_MARK = 256 }; diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index eb84aff8354e9..5fc8789f3653b 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, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -48,10 +48,6 @@ Created 11/5/1995 Heikki Tuuri #define BUF_GET_IF_IN_POOL 11 /*!< get if in pool */ #define BUF_PEEK_IF_IN_POOL 12 /*!< get if in pool, do not make the block young in the LRU list */ -#define BUF_GET_IF_IN_POOL_OR_WATCH 15 - /*!< Get the page only if it's in the - buffer pool, if not then set a watch - on the page. */ #define BUF_GET_POSSIBLY_FREED 16 /*!< Like BUF_GET, but do not mind if the file page has been freed. */ @@ -194,11 +190,9 @@ buf_page_t *buf_page_get_zip(const page_id_t page_id, ulint zip_size); @param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH @param[in] guess guessed block or NULL @param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, -BUF_PEEK_IF_IN_POOL, or BUF_GET_IF_IN_POOL_OR_WATCH +or BUF_PEEK_IF_IN_POOL @param[in,out] mtr mini-transaction @param[out] err DB_SUCCESS or error code -@param[in] allow_ibuf_merge Allow change buffer merge while -reading the pages from file. @return pointer to the block or NULL */ buf_block_t* buf_page_get_gen( @@ -208,9 +202,8 @@ buf_page_get_gen( buf_block_t* guess, ulint mode, mtr_t* mtr, - dberr_t* err = NULL, - bool allow_ibuf_merge = false) - MY_ATTRIBUTE((nonnull(6), warn_unused_result)); + dberr_t* err = NULL) + MY_ATTRIBUTE((nonnull(6))); /** This is the low level function used to get access to a database page. @param[in] page_id page id @@ -218,14 +211,10 @@ buf_page_get_gen( @param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH @param[in] guess guessed block or NULL @param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, -BUF_PEEK_IF_IN_POOL, or BUF_GET_IF_IN_POOL_OR_WATCH +or BUF_PEEK_IF_IN_POOL @param[in,out] mtr mini-transaction, or NULL if a block with page_id is to be evicted @param[out] err DB_SUCCESS or error code -@param[in] allow_ibuf_merge Allow change buffer merge to happen -while reading the page from file -then it makes sure that it does merging of change buffer changes while -reading the page from file. @return pointer to the block or NULL */ buf_block_t* buf_page_get_low( @@ -235,8 +224,7 @@ buf_page_get_low( buf_block_t* guess, ulint mode, mtr_t* mtr, - dberr_t* err, - bool allow_ibuf_merge); + dberr_t* err); /** Initialize a page in the buffer pool. The page is usually not read from a file even if it cannot be found in the buffer buf_pool. This is one @@ -539,18 +527,16 @@ class buf_page_t static constexpr uint32_t REMOVE_HASH= 2; /** smallest state() of a buffer page that is freed in the tablespace */ static constexpr uint32_t FREED= 3; + /* unused state: 1U<<29 */ /** smallest state() for a block that belongs to buf_pool.LRU */ - static constexpr uint32_t UNFIXED= 1U << 29; - /** smallest state() of a block for which buffered changes may exist */ - static constexpr uint32_t IBUF_EXIST= 2U << 29; + static constexpr uint32_t UNFIXED= 2U << 29; /** smallest state() of a (re)initialized page (no doublewrite needed) */ static constexpr uint32_t REINIT= 3U << 29; /** smallest state() for an io-fixed block */ static constexpr uint32_t READ_FIX= 4U << 29; + /* unused state: 5U<<29 */ /** smallest state() for a write-fixed block */ - static constexpr uint32_t WRITE_FIX= 5U << 29; - /** smallest state() for a write-fixed block with buffered changes */ - static constexpr uint32_t WRITE_FIX_IBUF= 6U << 29; + static constexpr uint32_t WRITE_FIX= 6U << 29; /** smallest state() for a write-fixed block (no doublewrite was used) */ static constexpr uint32_t WRITE_FIX_REINIT= 7U << 29; /** buf_pool.LRU status mask in state() */ @@ -562,8 +548,7 @@ class buf_page_t byte *frame; /* @} */ /** ROW_FORMAT=COMPRESSED page; zip.data (but not the data it points to) - is also protected by buf_pool.mutex; - !frame && !zip.data means an active buf_pool.watch */ + is also protected by buf_pool.mutex */ page_zip_des_t zip; #ifdef UNIV_DEBUG /** whether this->list is in buf_pool.zip_hash; protected by buf_pool.mutex */ @@ -696,13 +681,6 @@ class buf_page_t bool is_freed() const { const auto s= state(); ut_ad(s >= FREED); return s < UNFIXED; } - bool is_ibuf_exist() const - { - const auto s= state(); - ut_ad(s >= UNFIXED); - ut_ad(s < READ_FIX); - return (s & LRU_MASK) == IBUF_EXIST; - } bool is_reinit() const { return !(~state() & REINIT); } void set_reinit(uint32_t prev_state) @@ -713,29 +691,10 @@ class buf_page_t ut_ad(s < prev_state + UNFIXED); } - void set_ibuf_exist() - { - ut_ad(lock.is_write_locked()); - ut_ad(id() < page_id_t(SRV_SPACE_ID_UPPER_BOUND, 0)); - const auto s= state(); - ut_ad(s >= UNFIXED); - ut_ad(s < READ_FIX); - ut_ad(s < IBUF_EXIST || s >= REINIT); - zip.fix.fetch_add(IBUF_EXIST - (LRU_MASK & s)); - } - void clear_ibuf_exist() - { - ut_ad(lock.is_write_locked()); - ut_ad(id() < page_id_t(SRV_SPACE_ID_UPPER_BOUND, 0)); - ut_d(const auto s=) zip.fix.fetch_sub(IBUF_EXIST - UNFIXED); - ut_ad(s >= IBUF_EXIST); - ut_ad(s < REINIT); - } - void read_unfix(uint32_t s) { ut_ad(lock.is_write_locked()); - ut_ad(s == UNFIXED + 1 || s == IBUF_EXIST + 1 || s == REINIT + 1); + ut_ad(s == UNFIXED + 1 || s == REINIT + 1); ut_d(auto old_state=) zip.fix.fetch_add(s - READ_FIX); ut_ad(old_state >= READ_FIX); ut_ad(old_state < WRITE_FIX); @@ -822,7 +781,7 @@ class buf_page_t uint32_t fix(uint32_t count= 1) { ut_ad(count); - ut_ad(count < IBUF_EXIST); + ut_ad(count < REINIT); uint32_t f= zip.fix.fetch_add(count); ut_ad(f >= FREED); ut_ad(!((f ^ (f + 1)) & LRU_MASK)); @@ -1426,82 +1385,6 @@ class buf_pool_t } public: - /** @return whether the buffer pool contains a page - @tparam allow_watch whether to allow watch_is_sentinel() - @param page_id page identifier - @param chain hash table chain for page_id.fold() */ - template - TRANSACTIONAL_INLINE - bool page_hash_contains(const page_id_t page_id, hash_chain &chain) - { - transactional_shared_lock_guard g - {page_hash.lock_get(chain)}; - buf_page_t *bpage= page_hash.get(page_id, chain); - if (bpage >= &watch[0] && bpage < &watch[UT_ARR_SIZE(watch)]) - { - ut_ad(!bpage->in_zip_hash); - ut_ad(!bpage->zip.data); - if (!allow_watch) - bpage= nullptr; - } - return bpage; - } - - /** Determine if a block is a sentinel for a buffer pool watch. - @param bpage page descriptor - @return whether bpage a sentinel for a buffer pool watch */ - bool watch_is_sentinel(const buf_page_t &bpage) - { -#ifdef SAFE_MUTEX - DBUG_ASSERT(mysql_mutex_is_owner(&mutex) || - page_hash.lock_get(page_hash.cell_get(bpage.id().fold())). - is_locked()); -#endif /* SAFE_MUTEX */ - ut_ad(bpage.in_file()); - if (&bpage < &watch[0] || &bpage >= &watch[array_elements(watch)]) - return false; - ut_ad(!bpage.in_zip_hash); - ut_ad(!bpage.zip.data); - return true; - } - - /** Check if a watched page has been read. - This may only be called after !watch_set() and before invoking watch_unset(). - @param id page identifier - @return whether the page was read to the buffer pool */ - TRANSACTIONAL_INLINE - bool watch_occurred(const page_id_t id) - { - hash_chain &chain= page_hash.cell_get(id.fold()); - transactional_shared_lock_guard g - {page_hash.lock_get(chain)}; - /* The page must exist because watch_set() increments buf_fix_count. */ - return !watch_is_sentinel(*page_hash.get(id, chain)); - } - - /** Register a watch for a page identifier. The caller must hold an - exclusive page hash latch. The *hash_lock may be released, - relocated, and reacquired. - @param id page identifier - @param chain hash table chain with exclusively held page_hash - @return a buffer pool block corresponding to id - @retval nullptr if the block was not present, and a watch was installed */ - inline buf_page_t *watch_set(const page_id_t id, hash_chain &chain); - - /** Stop watching whether a page has been read in. - watch_set(id) must have returned nullptr before. - @param id page identifier - @param chain unlocked hash table chain */ - void watch_unset(const page_id_t id, hash_chain &chain); - - /** Remove the sentinel block for the watch before replacing it with a - real block. watch_unset() or watch_occurred() will notice - that the block has been replaced with the real block. - @param w sentinel - @param chain locked hash table chain - @return w->state() */ - inline uint32_t watch_remove(buf_page_t *w, hash_chain &chain); - /** @return whether less than 1/4 of the buffer pool is available */ TPOOL_SUPPRESS_TSAN bool running_out() const @@ -1851,9 +1734,6 @@ class buf_pool_t # error "BUF_BUDDY_LOW > UNIV_ZIP_SIZE_MIN" #endif - /** Sentinels to detect if pages are read into the buffer pool while - a delete-buffering operation is pending. Protected by mutex. */ - buf_page_t watch[innodb_purge_threads_MAX + 1]; /** Reserve a buffer. */ buf_tmp_buffer_t *io_buf_reserve() { return io_buf.reserve(); } diff --git a/storage/innobase/include/buf0rea.h b/storage/innobase/include/buf0rea.h index 986a792b97e2a..af72c544ebf9d 100644 --- a/storage/innobase/include/buf0rea.h +++ b/storage/innobase/include/buf0rea.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2021, MariaDB Corporation. +Copyright (c) 2015, 2023, 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 @@ -24,8 +24,7 @@ The database buffer read Created 11/5/1995 Heikki Tuuri *******************************************************/ -#ifndef buf0rea_h -#define buf0rea_h +#pragma once #include "buf0buf.h" @@ -56,21 +55,14 @@ void buf_read_page_background(fil_space_t *space, const page_id_t page_id, /** Applies a random read-ahead in buf_pool if there are at least a threshold value of accessed pages from the random read-ahead area. Does not read any page, not even the one at the position (space, offset), if the read-ahead -mechanism is not activated. NOTE 1: the calling thread may own latches on +mechanism is not activated. NOTE: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot -end up waiting for these latches! NOTE 2: the calling thread must want -access to the page given: this rule is set to prevent unintended read-aheads -performed by ibuf routines, a situation which could result in a deadlock if -the OS does not support asynchronous i/o. +end up waiting for these latches! @param[in] page_id page id of a page which the current thread wants to access @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] ibuf whether we are inside ibuf routine -@return number of page read requests issued; NOTE that if we read ibuf -pages, it may happen that the page at the given page number does not -get read even if we return a positive value! */ -ulint -buf_read_ahead_random(const page_id_t page_id, ulint zip_size, bool ibuf); +@return number of page read requests issued */ +ulint buf_read_ahead_random(const page_id_t page_id, ulint zip_size); /** Applies linear read-ahead if in the buf_pool the page is a border page of a linear read-ahead area and all the pages in the area have been accessed. @@ -91,26 +83,12 @@ only very improbably. NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! -NOTE 3: the calling thread must want access to the page given: this rule is -set to prevent unintended read-aheads performed by ibuf routines, a situation -which could result in a deadlock if the OS does not support asynchronous io. @param[in] page_id page id; see NOTE 3 above @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] ibuf whether if we are inside ibuf routine @return number of page read requests issued */ -ulint -buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf); +ulint buf_read_ahead_linear(const page_id_t page_id, ulint zip_size); /** Issue read requests for pages that need to be recovered. @param space_id tablespace identifier @param page_nos page numbers to read, in ascending order */ void buf_read_recv_pages(uint32_t space_id, st_::span page_nos); - -/** @name Modes used in read-ahead @{ */ -/** read only pages belonging to the insert buffer tree */ -#define BUF_READ_IBUF_PAGES_ONLY 131 -/** read any page */ -#define BUF_READ_ANY_PAGE 132 -/* @} */ - -#endif diff --git a/storage/innobase/include/data0type.h b/storage/innobase/include/data0type.h index 3d63ddb767c74..d48851860879e 100644 --- a/storage/innobase/include/data0type.h +++ b/storage/innobase/include/data0type.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -33,7 +33,6 @@ Created 1/16/1996 Heikki Tuuri /** @return whether a length is actually stored in a field */ #define len_is_stored(len) (len != UNIV_SQL_NULL && len != UNIV_SQL_DEFAULT) -extern ulint data_mysql_default_charset_coll; #define DATA_MYSQL_BINARY_CHARSET_COLL 63 /* SQL data type struct */ @@ -196,14 +195,6 @@ constexpr uint8_t DATA_MBR_LEN= uint8_t(SPDIMS * 2 * sizeof(double)); /*-------------------------------------------*/ -/* This many bytes we need to store the type information affecting the -alphabetical order for a single field and decide the storage size of an -SQL null*/ -#define DATA_ORDER_NULL_TYPE_BUF_SIZE 4 -/* In the >= 4.1.x storage format we add 2 bytes more so that we can also -store the charset-collation number; one byte is left unused, though */ -#define DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE 6 - /* Maximum multi-byte character length in bytes, plus 1 */ #define DATA_MBMAX 8 @@ -344,13 +335,11 @@ charset-collation code. DATA_BINARY_TYPE etc. @param[in] charset_coll character-set collation code @return precise type, including the charset-collation code */ -UNIV_INLINE -uint32_t -dtype_form_prtype(ulint old_prtype, ulint charset_coll) +inline uint32_t dtype_form_prtype(ulint old_prtype, ulint charset_coll) { - ut_ad(old_prtype < 256 * 256); - ut_ad(charset_coll <= MAX_CHAR_COLL_NUM); - return(uint32_t(old_prtype + (charset_coll << 16))); + ut_ad(old_prtype <= 0xffff); + ut_ad(charset_coll <= MAX_CHAR_COLL_NUM); + return uint32_t(old_prtype | (charset_coll << 16)); } /*********************************************************************//** @@ -439,40 +428,6 @@ dtype_get_sql_null_size( const dtype_t* type, /*!< in: type */ ulint comp); /*!< in: nonzero=ROW_FORMAT=COMPACT */ -/**********************************************************************//** -Reads to a type the stored information which determines its alphabetical -ordering and the storage size of an SQL NULL value. */ -UNIV_INLINE -void -dtype_read_for_order_and_null_size( -/*===============================*/ - dtype_t* type, /*!< in: type struct */ - const byte* buf); /*!< in: buffer for the stored order info */ -/**********************************************************************//** -Stores for a type the information which determines its alphabetical ordering -and the storage size of an SQL NULL value. This is the >= 4.1.x storage -format. */ -UNIV_INLINE -void -dtype_new_store_for_order_and_null_size( -/*====================================*/ - byte* buf, /*!< in: buffer for - DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE - bytes where we store the info */ - const dtype_t* type, /*!< in: type struct */ - ulint prefix_len);/*!< in: prefix length to - replace type->len, or 0 */ -/**********************************************************************//** -Reads to a type the stored information which determines its alphabetical -ordering and the storage size of an SQL NULL value. This is the 4.1.x storage -format. */ -UNIV_INLINE -void -dtype_new_read_for_order_and_null_size( -/*===================================*/ - dtype_t* type, /*!< in: type struct */ - const byte* buf); /*!< in: buffer for stored type order info */ - /*********************************************************************//** Validates a data type structure. @return TRUE if ok */ @@ -494,8 +449,6 @@ struct dict_col_t; If you add fields to this structure, be sure to initialize them everywhere. This structure is initialized in the following functions: dtype_set() -dtype_read_for_order_and_null_size() -dtype_new_read_for_order_and_null_size() sym_tab_add_null_lit() */ struct dtype_t{ diff --git a/storage/innobase/include/data0type.inl b/storage/innobase/include/data0type.inl index 329cee5d190a0..add6c211bb942 100644 --- a/storage/innobase/include/data0type.inl +++ b/storage/innobase/include/data0type.inl @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -183,126 +183,6 @@ dtype_get_mbmaxlen( return type->mbmaxlen; } -/**********************************************************************//** -Stores for a type the information which determines its alphabetical ordering -and the storage size of an SQL NULL value. This is the >= 4.1.x storage -format. */ -UNIV_INLINE -void -dtype_new_store_for_order_and_null_size( -/*====================================*/ - byte* buf, /*!< in: buffer for - DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE - bytes where we store the info */ - const dtype_t* type, /*!< in: type struct */ - ulint prefix_len)/*!< in: prefix length to - replace type->len, or 0 */ -{ - compile_time_assert(6 == DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); - - ulint len; - - ut_ad(type); - ut_ad(type->mtype >= DATA_VARCHAR); - ut_ad(type->mtype <= DATA_MTYPE_MAX); - - buf[0] = (byte)(type->mtype & 0xFFUL); - - if (type->prtype & DATA_BINARY_TYPE) { - buf[0] |= 128; - } - - /* In versions < 4.1.2 we had: if (type->prtype & DATA_NONLATIN1) { - buf[0] |= 64; - } - */ - - buf[1] = (byte)(type->prtype & 0xFFUL); - - len = prefix_len ? prefix_len : type->len; - - mach_write_to_2(buf + 2, len & 0xFFFFUL); - - ut_ad(dtype_get_charset_coll(type->prtype) <= MAX_CHAR_COLL_NUM); - mach_write_to_2(buf + 4, dtype_get_charset_coll(type->prtype)); - - if (type->prtype & DATA_NOT_NULL) { - buf[4] |= 128; - } -} - -/**********************************************************************//** -Reads to a type the stored information which determines its alphabetical -ordering and the storage size of an SQL NULL value. This is the < 4.1.x -storage format. */ -UNIV_INLINE -void -dtype_read_for_order_and_null_size( -/*===============================*/ - dtype_t* type, /*!< in: type struct */ - const byte* buf) /*!< in: buffer for stored type order info */ -{ - compile_time_assert(4 == DATA_ORDER_NULL_TYPE_BUF_SIZE); - type->mtype = buf[0] & 63; - type->prtype = buf[1]; - - if (buf[0] & 128) { - type->prtype |= DATA_BINARY_TYPE; - } - - type->len = mach_read_from_2(buf + 2); - - type->prtype = dtype_form_prtype(type->prtype, - data_mysql_default_charset_coll); - dtype_set_mblen(type); -} - -/**********************************************************************//** -Reads to a type the stored information which determines its alphabetical -ordering and the storage size of an SQL NULL value. This is the >= 4.1.x -storage format. */ -UNIV_INLINE -void -dtype_new_read_for_order_and_null_size( -/*===================================*/ - dtype_t* type, /*!< in: type struct */ - const byte* buf) /*!< in: buffer for stored type order info */ -{ - compile_time_assert(6 == DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); - - type->mtype = buf[0] & 63; - type->prtype = buf[1]; - - if (buf[0] & 128) { - type->prtype |= DATA_BINARY_TYPE; - } - - if (buf[4] & 128) { - type->prtype |= DATA_NOT_NULL; - } - - type->len = mach_read_from_2(buf + 2); - - ulint charset_coll = mach_read_from_2(buf + 4) & CHAR_COLL_MASK; - - if (dtype_is_string_type(type->mtype)) { - ut_a(charset_coll <= MAX_CHAR_COLL_NUM); - - if (charset_coll == 0) { - /* This insert buffer record was inserted with MySQL - version < 4.1.2, and the charset-collation code was not - explicitly stored to dtype->prtype at that time. It - must be the default charset-collation of this MySQL - installation. */ - - charset_coll = data_mysql_default_charset_coll; - } - - type->prtype = dtype_form_prtype(type->prtype, charset_coll); - } - dtype_set_mblen(type); -} - /***********************************************************************//** Returns the size of a fixed size data type, 0 if not a fixed size type. @return fixed size, or 0 */ diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 8daa07160a3e8..1002213e61c3f 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -2,7 +2,7 @@ Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -634,8 +634,6 @@ dict_table_get_next_index( #define dict_index_is_auto_gen_clust(index) (index)->is_gen_clust() #define dict_index_is_unique(index) (index)->is_unique() #define dict_index_is_spatial(index) (index)->is_spatial() -#define dict_index_is_ibuf(index) (index)->is_ibuf() -#define dict_index_is_sec_or_ibuf(index) !(index)->is_primary() #define dict_index_has_virtual(index) (index)->has_virtual() /** Get all the FTS indexes on a table. diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index f7d33d5b43bae..bd55848a776b6 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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,9 +39,7 @@ Created 4/24/1996 Heikki Tuuri /** A stack of table names related through foreign key constraints */ typedef std::deque > dict_names_t; -/** Check each tablespace found in the data dictionary. -Then look at each table defined in SYS_TABLES that has a space_id > 0 -to find all the file-per-table tablespaces. +/** Open each tablespace found in the data dictionary. In a crash recovery we already have some tablespace objects created from processing the REDO log. We will compare the @@ -50,7 +48,7 @@ tablespace file. In addition, more validation will be done if recovery was needed and force_recovery is not set. We also scan the biggest space id, and store it to fil_system. */ -void dict_check_tablespaces_and_store_max_id(); +void dict_load_tablespaces(); /** Make sure the data_file_name is saved in dict_table_t if needed. @param[in,out] table Table object */ diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index c76262ff5bebd..d9ef949ac1311 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -64,7 +64,6 @@ combination of types */ auto-generated clustered indexes, also DICT_UNIQUE will be set */ #define DICT_UNIQUE 2 /*!< unique index */ -#define DICT_IBUF 8 /*!< insert buffer tree */ #define DICT_CORRUPT 16 /*!< bit to store the corrupted flag in SYS_INDEXES.TYPE */ #define DICT_FTS 32 /* FTS index; can't be combined with the @@ -995,7 +994,7 @@ struct dict_index_t { # define DICT_INDEX_MERGE_THRESHOLD_DEFAULT 50 unsigned type:DICT_IT_BITS; /*!< index type (DICT_CLUSTERED, DICT_UNIQUE, - DICT_IBUF, DICT_CORRUPT) */ + DICT_CORRUPT) */ #define MAX_KEY_LENGTH_BITS 12 unsigned trx_id_offset:MAX_KEY_LENGTH_BITS; /*!< position of the trx id column @@ -1184,12 +1183,8 @@ struct dict_index_t { /** @return whether instant ALTER TABLE is in effect */ inline bool is_instant() const; - /** @return whether the index is the primary key index - (not the clustered index of the change buffer) */ - bool is_primary() const - { - return DICT_CLUSTERED == (type & (DICT_CLUSTERED | DICT_IBUF)); - } + /** @return whether the index is the primary key index */ + bool is_primary() const { return is_clust(); } /** @return whether this is a generated clustered index */ bool is_gen_clust() const { return type == DICT_CLUSTERED; } @@ -1203,16 +1198,13 @@ struct dict_index_t { /** @return whether this is a spatial index */ bool is_spatial() const { return UNIV_UNLIKELY(type & DICT_SPATIAL); } - /** @return whether this is the change buffer */ - bool is_ibuf() const { return UNIV_UNLIKELY(type & DICT_IBUF); } - /** @return whether this index requires locking */ - bool has_locking() const { return !is_ibuf(); } + static constexpr bool has_locking() { return true; } /** @return whether this is a normal B-tree index (not the change buffer, not SPATIAL or FULLTEXT) */ bool is_btree() const { - return UNIV_LIKELY(!(type & (DICT_IBUF | DICT_SPATIAL + return UNIV_LIKELY(!(type & (DICT_SPATIAL | DICT_FTS | DICT_CORRUPT))); } diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h index 271e4e1fb7642..82a0f78072323 100644 --- a/storage/innobase/include/dict0types.h +++ b/storage/innobase/include/dict0types.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -48,10 +48,6 @@ struct dict_add_v_col_t; #define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */ #define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO -/* The ibuf table and indexes's ID are assigned as the number -DICT_IBUF_ID_MIN plus the space id */ -#define DICT_IBUF_ID_MIN 0xFFFFFFFF00000000ULL - typedef ib_id_t table_id_t; typedef ib_id_t index_id_t; @@ -136,13 +132,6 @@ struct table_name_t inline bool is_temporary() const; }; -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG -/** Dump the change buffer at startup */ -extern my_bool ibuf_dump; -/** Flag to control insert buffer debugging. */ -extern uint ibuf_debug; -#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ - /** Shift for spatial status */ #define SPATIAL_STATUS_SHIFT 12 diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 210f365ddd826..65ca704b6d895 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -1247,11 +1247,11 @@ constexpr uint16_t FIL_PAGE_RTREE= 17854; constexpr uint16_t FIL_PAGE_UNDO_LOG= 2; /** Index node (of file-in-file metadata) */ constexpr uint16_t FIL_PAGE_INODE= 3; -/** Insert buffer free list */ +/** Former change buffer free list */ constexpr uint16_t FIL_PAGE_IBUF_FREE_LIST= 4; /** Freshly allocated page */ constexpr uint16_t FIL_PAGE_TYPE_ALLOCATED= 0; -/** Change buffer bitmap (pages n*innodb_page_size+1) */ +/** Former change buffer bitmap pages (pages n*innodb_page_size+1) */ constexpr uint16_t FIL_PAGE_IBUF_BITMAP= 5; /** System page */ constexpr uint16_t FIL_PAGE_TYPE_SYS= 6; diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h index 9a23e84038051..757ead55d0358 100644 --- a/storage/innobase/include/fsp0types.h +++ b/storage/innobase/include/fsp0types.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2022, MariaDB Corporation. +Copyright (c) 2014, 2023, 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 @@ -157,28 +157,20 @@ this many file pages */ /* This has been replaced with either srv_page_size or page_zip->size. */ /** @name The space low address page map -The pages at FSP_XDES_OFFSET and FSP_IBUF_BITMAP_OFFSET are repeated +The 2 pages at FSP_XDES_OFFSET are repeated every XDES_DESCRIBED_PER_PAGE pages in every tablespace. */ /* @{ */ /*--------------------------------------*/ #define FSP_XDES_OFFSET 0U /* !< extent descriptor */ -#define FSP_IBUF_BITMAP_OFFSET 1U /* !< insert buffer bitmap */ - /* The ibuf bitmap pages are the ones whose - page number is the number above plus a - multiple of XDES_DESCRIBED_PER_PAGE */ - #define FSP_FIRST_INODE_PAGE_NO 2U /*!< in every tablespace */ /* The following pages exist in the system tablespace (space 0). */ -#define FSP_IBUF_HEADER_PAGE_NO 3U /*!< insert buffer +#define FSP_IBUF_HEADER_PAGE_NO 3U /*!< former change buffer header page, in tablespace 0 */ -#define FSP_IBUF_TREE_ROOT_PAGE_NO 4U /*!< insert buffer +#define FSP_IBUF_TREE_ROOT_PAGE_NO 4U /*!< former change buffer B-tree root page in tablespace 0 */ - /* The ibuf tree root page number in - tablespace 0; its fseg inode is on the page - number FSP_FIRST_INODE_PAGE_NO */ #define FSP_TRX_SYS_PAGE_NO 5U /*!< transaction system header, in tablespace 0 */ diff --git a/storage/innobase/include/gis0rtree.h b/storage/innobase/include/gis0rtree.h index 777f2432c93a7..12b7eb785be8b 100644 --- a/storage/innobase/include/gis0rtree.h +++ b/storage/innobase/include/gis0rtree.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -94,7 +94,29 @@ rtr_page_split_and_insert( const dtuple_t* tuple, /*!< in: tuple to insert */ ulint n_ext, /*!< in: number of externally stored columns */ mtr_t* mtr, /*!< in: mtr */ - dberr_t* err); /*!< out: error code */ + dberr_t* err, /*!< out: error code */ + que_thr_t* thr); /*!< in: query thread */ + +/*************************************************************//** +Makes tree one level higher by splitting the root, and inserts the tuple. +NOTE that the operation of this function must always succeed, +we cannot reverse it: therefore enough free disk space must be +guaranteed to be available before this function is called. +@return inserted record */ +rec_t* +rtr_root_raise_and_insert( + ulint flags, /*!< in: undo logging and locking flags */ + btr_cur_t* cursor, /*!< in: cursor at which to insert: must be + on the root page; when the function returns, + the cursor is positioned on the predecessor + of the inserted record */ + rec_offs** offsets,/*!< out: offsets on inserted record */ + mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */ + const dtuple_t* tuple, /*!< in: tuple to insert */ + ulint n_ext, /*!< in: number of externally stored columns */ + mtr_t* mtr, /*!< in: mtr */ + dberr_t* err, /*!< out: error code */ + que_thr_t* thr); /*!< in: query thread */ /**************************************************************//** Sets the child node mbr in a node pointer. */ @@ -205,8 +227,8 @@ rtr_create_rtr_info( bool init_matches, /*!< in: Whether to initiate the "matches" structure for collecting matched leaf records */ - btr_cur_t* cursor, /*!< in: tree search cursor */ - dict_index_t* index); /*!< in: index struct */ + que_thr_t* thr, /*!< in/out: query thread */ + btr_cur_t* cursor); /*!< in: tree search cursor */ /********************************************************************//** Update a btr_cur_t with rtr_info */ @@ -261,8 +283,10 @@ rtr_get_mbr_from_tuple( about parent nodes in search @param[in,out] cursor cursor on node pointer record, its page x-latched +@param[in,out] thr query thread @return whether the cursor was successfully positioned */ -bool rtr_page_get_father(mtr_t *mtr, btr_cur_t *sea_cur, btr_cur_t *cursor) +bool rtr_page_get_father(mtr_t *mtr, btr_cur_t *sea_cur, btr_cur_t *cursor, + que_thr_t *thr) MY_ATTRIBUTE((nonnull(1,3), warn_unused_result)); /************************************************************//** @@ -274,11 +298,12 @@ rtr_page_get_father_block( /*======================*/ rec_offs* offsets,/*!< in: work area for the return value */ mem_heap_t* heap, /*!< in: memory heap to use */ - mtr_t* mtr, /*!< in: mtr */ btr_cur_t* sea_cur,/*!< in: search cursor, contains information about parent nodes in search */ - btr_cur_t* cursor);/*!< out: cursor on node pointer record, + btr_cur_t* cursor, /*!< out: cursor on node pointer record, its page x-latched */ + que_thr_t* thr, /*!< in/out: query thread */ + mtr_t* mtr); /*!< in/out: mtr */ /**************************************************************//** Store the parent path cursor @return number of cursor stored */ @@ -297,10 +322,10 @@ Initializes and opens a persistent cursor to an index tree. It should be closed with btr_pcur_close. */ bool rtr_pcur_open( - dict_index_t* index, /*!< in: index */ const dtuple_t* tuple, /*!< in: tuple on which search done */ btr_latch_mode latch_mode,/*!< in: BTR_SEARCH_LEAF, ... */ btr_pcur_t* cursor, /*!< in: memory buffer for persistent cursor */ + que_thr_t* thr, /*!< in/out; query thread */ mtr_t* mtr) /*!< in: mtr */ MY_ATTRIBUTE((warn_unused_result)); diff --git a/storage/innobase/include/gis0rtree.inl b/storage/innobase/include/gis0rtree.inl index 5101eeb6f7ace..460496d1978f3 100644 --- a/storage/innobase/include/gis0rtree.inl +++ b/storage/innobase/include/gis0rtree.inl @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2021, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -240,6 +240,9 @@ rtr_info_reinit_in_cursor( bool need_prdt) /*!< in: Whether predicate lock is needed */ { + que_thr_t* thr = cursor->rtr_info->thr; + ut_ad(thr); rtr_clean_rtr_info(cursor->rtr_info, false); rtr_init_rtr_info(cursor->rtr_info, need_prdt, cursor, index, true); + cursor->rtr_info->thr = thr; } diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h index c246b2ef513ec..d1ff331fe2161 100644 --- a/storage/innobase/include/ibuf0ibuf.h +++ b/storage/innobase/include/ibuf0ibuf.h @@ -1,7 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2022, MariaDB Corporation. +Copyright (c) 2023, 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 @@ -17,420 +16,40 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************//** -@file include/ibuf0ibuf.h -Insert buffer - -Created 7/19/1997 Heikki Tuuri -*******************************************************/ - -#ifndef ibuf0ibuf_h -#define ibuf0ibuf_h - -#include "mtr0mtr.h" -#include "dict0mem.h" -#include "fsp0fsp.h" - -/** Default value for maximum on-disk size of change buffer in terms -of percentage of the buffer pool. */ -#define CHANGE_BUFFER_DEFAULT_SIZE (25) - -/* Possible operations buffered in the insert/whatever buffer. See -ibuf_insert(). DO NOT CHANGE THE VALUES OF THESE, THEY ARE STORED ON DISK. */ -typedef enum { - IBUF_OP_INSERT = 0, - IBUF_OP_DELETE_MARK = 1, - IBUF_OP_DELETE = 2, - - /* Number of different operation types. */ - IBUF_OP_COUNT = 3 -} ibuf_op_t; - -/** Combinations of operations that can be buffered. -@see innodb_change_buffering_names */ -enum ibuf_use_t { - IBUF_USE_NONE = 0, - IBUF_USE_INSERT, /* insert */ - IBUF_USE_DELETE_MARK, /* delete */ - IBUF_USE_INSERT_DELETE_MARK, /* insert+delete */ - IBUF_USE_DELETE, /* delete+purge */ - IBUF_USE_ALL /* insert+delete+purge */ -}; - -/** Operations that can currently be buffered. */ -extern ulong innodb_change_buffering; - -/** Insert buffer struct */ -struct ibuf_t{ - Atomic_relaxed size; /*!< current size of the ibuf index - tree, in pages */ - Atomic_relaxed max_size; /*!< recommended maximum size of the - ibuf index tree, in pages */ - ulint seg_size; /*!< allocated pages of the file - segment containing ibuf header and - tree */ - bool empty; /*!< Protected by the page - latch of the root page of the - insert buffer tree - (FSP_IBUF_TREE_ROOT_PAGE_NO). true - if and only if the insert - buffer tree is empty. */ - ulint free_list_len; /*!< length of the free list */ - ulint height; /*!< tree height */ - dict_index_t* index; /*!< insert buffer index */ - - /** number of pages merged */ - Atomic_counter n_merges; - Atomic_counter n_merged_ops[IBUF_OP_COUNT]; - /*!< number of operations of each type - merged to index pages */ - Atomic_counter n_discarded_ops[IBUF_OP_COUNT]; - /*!< number of operations of each type - discarded without merging due to the - tablespace being deleted or the - index being dropped */ -}; - -/** The insert buffer control structure */ -extern ibuf_t ibuf; - -/* The purpose of the insert buffer is to reduce random disk access. -When we wish to insert a record into a non-unique secondary index and -the B-tree leaf page where the record belongs to is not in the buffer -pool, we insert the record into the insert buffer B-tree, indexed by -(space_id, page_no). When the page is eventually read into the buffer -pool, we look up the insert buffer B-tree for any modifications to the -page, and apply these upon the completion of the read operation. This -is called the insert buffer merge. */ - -/* The insert buffer merge must always succeed. To guarantee this, -the insert buffer subsystem keeps track of the free space in pages for -which it can buffer operations. Two bits per page in the insert -buffer bitmap indicate the available space in coarse increments. The -free bits in the insert buffer bitmap must never exceed the free space -on a page. It is safe to decrement or reset the bits in the bitmap in -a mini-transaction that is committed before the mini-transaction that -affects the free space. It is unsafe to increment the bits in a -separately committed mini-transaction, because in crash recovery, the -free bits could momentarily be set too high. */ - -/******************************************************************//** -Creates the insert buffer data structure at a database startup. -@return DB_SUCCESS or failure */ -dberr_t -ibuf_init_at_db_start(void); -/*=======================*/ -/*********************************************************************//** -Updates the max_size value for ibuf. */ -void -ibuf_max_size_update( -/*=================*/ - ulint new_val); /*!< in: new value in terms of - percentage of the buffer pool size */ -/*********************************************************************//** -Reads the biggest tablespace id from the high end of the insert buffer -tree and updates the counter in fil_system. */ -void -ibuf_update_max_tablespace_id(void); -/*===============================*/ -/***************************************************************//** -Starts an insert buffer mini-transaction. */ -UNIV_INLINE -void -ibuf_mtr_start( -/*===========*/ - mtr_t* mtr) /*!< out: mini-transaction */ - MY_ATTRIBUTE((nonnull)); -/***************************************************************//** -Commits an insert buffer mini-transaction. */ -UNIV_INLINE -void -ibuf_mtr_commit( -/*============*/ - mtr_t* mtr) /*!< in/out: mini-transaction */ - MY_ATTRIBUTE((nonnull)); -/************************************************************************//** -Resets the free bits of the page in the ibuf bitmap. This is done in a -separate mini-transaction, hence this operation does not restrict -further work to only ibuf bitmap operations, which would result if the -latch to the bitmap page were kept. NOTE: The free bits in the insert -buffer bitmap must never exceed the free space on a page. It is safe -to decrement or reset the bits in the bitmap in a mini-transaction -that is committed before the mini-transaction that affects the free -space. */ -void -ibuf_reset_free_bits( -/*=================*/ - buf_block_t* block); /*!< in: index page; free bits are set to 0 - if the index is a non-clustered - non-unique, and page level is 0 */ -/************************************************************************//** -Updates the free bits of an uncompressed page in the ibuf bitmap if -there is not enough free on the page any more. This is done in a -separate mini-transaction, hence this operation does not restrict -further work to only ibuf bitmap operations, which would result if the -latch to the bitmap page were kept. NOTE: The free bits in the insert -buffer bitmap must never exceed the free space on a page. It is -unsafe to increment the bits in a separately committed -mini-transaction, because in crash recovery, the free bits could -momentarily be set too high. It is only safe to use this function for -decrementing the free bits. Should more free space become available, -we must not update the free bits here, because that would break crash -recovery. */ -UNIV_INLINE -void -ibuf_update_free_bits_if_full( -/*==========================*/ - buf_block_t* block, /*!< in: index page to which we have added new - records; the free bits are updated if the - index is non-clustered and non-unique and - the page level is 0, and the page becomes - fuller */ - ulint max_ins_size,/*!< in: value of maximum insert size with - reorganize before the latest operation - performed to the page */ - ulint increase);/*!< in: upper limit for the additional space - used in the latest operation, if known, or - ULINT_UNDEFINED */ -/**********************************************************************//** -Updates the free bits for an uncompressed page to reflect the present -state. Does this in the mtr given, which means that the latching -order rules virtually prevent any further operations for this OS -thread until mtr is committed. NOTE: The free bits in the insert -buffer bitmap must never exceed the free space on a page. It is safe -to set the free bits in the same mini-transaction that updated the -page. */ -void -ibuf_update_free_bits_low( -/*======================*/ - const buf_block_t* block, /*!< in: index page */ - ulint max_ins_size, /*!< in: value of - maximum insert size - with reorganize before - the latest operation - performed to the page */ - mtr_t* mtr); /*!< in/out: mtr */ -/**********************************************************************//** -Updates the free bits for a compressed page to reflect the present -state. Does this in the mtr given, which means that the latching -order rules virtually prevent any further operations for this OS -thread until mtr is committed. NOTE: The free bits in the insert -buffer bitmap must never exceed the free space on a page. It is safe -to set the free bits in the same mini-transaction that updated the -page. */ -void -ibuf_update_free_bits_zip( -/*======================*/ - buf_block_t* block, /*!< in/out: index page */ - mtr_t* mtr); /*!< in/out: mtr */ -/**********************************************************************//** -Updates the free bits for the two pages to reflect the present state. -Does this in the mtr given, which means that the latching order rules -virtually prevent any further operations until mtr is committed. -NOTE: The free bits in the insert buffer bitmap must never exceed the -free space on a page. It is safe to set the free bits in the same -mini-transaction that updated the pages. */ -void -ibuf_update_free_bits_for_two_pages_low( -/*====================================*/ - buf_block_t* block1, /*!< in: index page */ - buf_block_t* block2, /*!< in: index page */ - mtr_t* mtr); /*!< in: mtr */ -/**********************************************************************//** -A basic partial test if an insert to the insert buffer could be possible and -recommended. */ -UNIV_INLINE -ibool -ibuf_should_try( -/*============*/ - dict_index_t* index, /*!< in: index where to insert */ - ulint ignore_sec_unique); /*!< in: if != 0, we should - ignore UNIQUE constraint on - a secondary index when we - decide */ -/******************************************************************//** -Returns TRUE if the current OS thread is performing an insert buffer -routine. - -For instance, a read-ahead of non-ibuf pages is forbidden by threads -that are executing an insert buffer routine. -@return TRUE if inside an insert buffer routine */ -UNIV_INLINE -ibool -ibuf_inside( -/*========*/ - const mtr_t* mtr) /*!< in: mini-transaction */ - MY_ATTRIBUTE((warn_unused_result)); - -/** Checks if a page address is an ibuf bitmap page (level 3 page) address. -@param[in] page_id page id -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@return TRUE if a bitmap page */ -inline bool ibuf_bitmap_page(const page_id_t page_id, ulint zip_size) -{ - ut_ad(ut_is_2pow(zip_size)); - ulint size = zip_size ? zip_size : srv_page_size; - return (page_id.page_no() & (size - 1)) == FSP_IBUF_BITMAP_OFFSET; -} - -/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. -Must not be called when recv_no_ibuf_operations==true. -@param[in] page_id page id -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] x_latch FALSE if relaxed check (avoid latching the -bitmap page) -@param[in,out] mtr mtr which will contain an x-latch to the -bitmap page if the page is not one of the fixed address ibuf pages, or NULL, -in which case a new transaction is created. -@return true if level 2 or level 3 page */ -bool -ibuf_page_low( - const page_id_t page_id, - ulint zip_size, -#ifdef UNIV_DEBUG - bool x_latch, -#endif /* UNIV_DEBUG */ - mtr_t* mtr) - MY_ATTRIBUTE((warn_unused_result)); - -#ifdef UNIV_DEBUG -/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. -Must not be called when recv_no_ibuf_operations==true. -@param[in] page_id tablespace/page identifier -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in,out] mtr mini-transaction or NULL -@return TRUE if level 2 or level 3 page */ -# define ibuf_page(page_id, zip_size, mtr) \ - ibuf_page_low(page_id, zip_size, true, mtr) - -#else /* UNIV_DEBUG */ - -/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. -Must not be called when recv_no_ibuf_operations==true. -@param[in] page_id tablespace/page identifier -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in,out] mtr mini-transaction or NULL -@return TRUE if level 2 or level 3 page */ -# define ibuf_page(page_id, zip_size, mtr) \ - ibuf_page_low(page_id, zip_size, mtr) - -#endif /* UNIV_DEBUG */ -/***********************************************************************//** -Frees excess pages from the ibuf free list. This function is called when an OS -thread calls fsp services to allocate a new file segment, or a new page to a -file segment, and the thread did not own the fsp latch before this call. */ -void -ibuf_free_excess_pages(void); -/*========================*/ - -/** Buffer an operation in the change buffer, instead of applying it -directly to the file page, if this is possible. Does not do it if the index -is clustered or unique. -@param[in] op operation type -@param[in] entry index entry to insert -@param[in,out] index index where to insert -@param[in] page_id page id where to insert -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in,out] thr query thread -@return true if success */ -bool -ibuf_insert( - ibuf_op_t op, - const dtuple_t* entry, - dict_index_t* index, - const page_id_t page_id, - ulint zip_size, - que_thr_t* thr); - -/** Check whether buffered changes exist for a page. -@param[in] id page identifier -@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@return whether buffered changes exist */ -bool ibuf_page_exists(const page_id_t id, ulint zip_size); - -/** When an index page is read from a disk to the buffer pool, this function -applies any buffered operations to the page and deletes the entries from the -insert buffer. If the page is not read, but created in the buffer pool, this -function deletes its buffered entries from the insert buffer; there can -exist entries for such a page if the page belonged to an index which -subsequently was dropped. -@param block X-latched page to try to apply changes to, or NULL to discard -@param page_id page identifier -@param zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@return error code */ -dberr_t ibuf_merge_or_delete_for_page(buf_block_t *block, - const page_id_t page_id, - ulint zip_size); - -/** Delete all change buffer entries for a tablespace, -in DISCARD TABLESPACE, IMPORT TABLESPACE, or read-ahead. -@param[in] space missing or to-be-discarded tablespace */ -void ibuf_delete_for_discarded_space(uint32_t space); - -/** Contract the change buffer by reading pages to the buffer pool. -@return a lower limit for the combined size in bytes of entries which -will be merged from ibuf trees to the pages read -@retval 0 if ibuf.empty */ -ulint ibuf_contract(); - -/** Contracts insert buffer trees by reading pages referring to space_id -to the buffer pool. -@returns number of pages merged.*/ -ulint -ibuf_merge_space( -/*=============*/ - ulint space); /*!< in: space id */ - -/******************************************************************//** -Looks if the insert buffer is empty. -@return true if empty */ -bool -ibuf_is_empty(void); -/*===============*/ -/******************************************************************//** -Prints info of ibuf. */ -void -ibuf_print( -/*=======*/ - FILE* file); /*!< in: file where to print */ -/******************************************************************** -Read the first two bytes from a record's fourth field (counter field in new -records; something else in older records). -@return "counter" field, or ULINT_UNDEFINED if for some reason it can't be read */ -ulint -ibuf_rec_get_counter( -/*=================*/ - const rec_t* rec); /*!< in: ibuf record */ -/******************************************************************//** -Closes insert buffer and frees the data structures. */ -void -ibuf_close(void); -/*============*/ - -/** Check the insert buffer bitmaps on IMPORT TABLESPACE. -@param[in] trx transaction -@param[in,out] space tablespace being imported -@return DB_SUCCESS or error code */ -dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) - MY_ATTRIBUTE((nonnull, warn_unused_result)); - -/** Update free bits and buffered bits for bulk loaded page. -@param block secondary index leaf page -@param mtr mini-transaction -@param reset whether the page is full */ -void ibuf_set_bitmap_for_bulk_load(buf_block_t *block, mtr_t *mtr, bool reset); - -#define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO -#define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO - -/* The ibuf header page currently contains only the file segment header -for the file segment from which the pages for the ibuf tree are allocated */ -#define IBUF_HEADER PAGE_DATA -#define IBUF_TREE_SEG_HEADER 0 /* fseg header for ibuf tree */ - -/* The insert buffer tree itself is always located in space 0. */ -#define IBUF_SPACE_ID static_cast(0) - -#include "ibuf0ibuf.inl" - -#endif +#include "db0err.h" + +/* The purpose of the change buffer was to reduce random disk access. +When we wished to +(1) insert a record into a non-unique secondary index, +(2) delete-mark a secondary index record, +(3) delete a secondary index record as part of purge (but not ROLLBACK), +and the B-tree leaf page where the record belongs to is not in the buffer +pool, we inserted a record into the change buffer B-tree, indexed by +the page identifier. When the page was eventually read into the buffer +pool, we looked up the change buffer B-tree for any modifications to the +page, applied these upon the completion of the read operation. This +was called the insert buffer merge. + +There was a hash index of the change buffer B-tree, implemented as the +"change buffer bitmap". Bits in these bitmap pages indicated how full +the page roughly was, and whether any records for the page identifier +exist in the change buffer. The "free" bits had to be updated as part of +operations that modified secondary index leaf pages. + +Because the change buffer has been removed, we will no longer update +any change buffer bitmap pages. Instead, on database startup, we will +check if an upgrade needs to be performed, and apply any buffered +changes if that is the case. Finally, the change buffer will be +transformed to a format that will not be recognized by earlier +versions of MariaDB Server, to prevent downgrades from causing +corruption (due to the removed updates of the bitmap pages) when the +change buffer might be enabled. */ + +/** Check if ibuf_upgrade() is needed as part of server startup. +@return error code +@retval DB_SUCCESS if no upgrade is needed +@retval DB_FAIL if the change buffer is not empty (need ibuf_upgrade()) */ +dberr_t ibuf_upgrade_needed(); + +/** Upgrade the change buffer after all redo log has been applied. */ +dberr_t ibuf_upgrade(); diff --git a/storage/innobase/include/ibuf0ibuf.inl b/storage/innobase/include/ibuf0ibuf.inl deleted file mode 100644 index 12aa1ca68371b..0000000000000 --- a/storage/innobase/include/ibuf0ibuf.inl +++ /dev/null @@ -1,282 +0,0 @@ -/***************************************************************************** - -Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2021, 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 -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-1335 USA - -*****************************************************************************/ - -/**************************************************//** -@file include/ibuf0ibuf.ic -Insert buffer - -Created 7/19/1997 Heikki Tuuri -*******************************************************/ - -#include "page0page.h" -#include "page0zip.h" -#include "fsp0types.h" -#include "buf0lru.h" - -/** An index page must contain at least srv_page_size / -IBUF_PAGE_SIZE_PER_FREE_SPACE bytes of free space for ibuf to try to -buffer inserts to this page. If there is this much of free space, the -corresponding bits are set in the ibuf bitmap. */ -#define IBUF_PAGE_SIZE_PER_FREE_SPACE 32 - -/***************************************************************//** -Starts an insert buffer mini-transaction. */ -UNIV_INLINE -void -ibuf_mtr_start( -/*===========*/ - mtr_t* mtr) /*!< out: mini-transaction */ -{ - mtr_start(mtr); - mtr->enter_ibuf(); - - if (high_level_read_only || srv_read_only_mode) { - mtr_set_log_mode(mtr, MTR_LOG_NO_REDO); - } - -} -/***************************************************************//** -Commits an insert buffer mini-transaction. */ -UNIV_INLINE -void -ibuf_mtr_commit( -/*============*/ - mtr_t* mtr) /*!< in/out: mini-transaction */ -{ - ut_ad(mtr->is_inside_ibuf()); - ut_d(mtr->exit_ibuf()); - - mtr_commit(mtr); -} - -/************************************************************************//** -Sets the free bit of the page in the ibuf bitmap. This is done in a separate -mini-transaction, hence this operation does not restrict further work to only -ibuf bitmap operations, which would result if the latch to the bitmap page -were kept. */ -void -ibuf_set_free_bits_func( -/*====================*/ - buf_block_t* block, /*!< in: index page of a non-clustered index; - free bit is reset if page level is 0 */ -#ifdef UNIV_IBUF_DEBUG - ulint max_val,/*!< in: ULINT_UNDEFINED or a maximum - value which the bits must have before - setting; this is for debugging */ -#endif /* UNIV_IBUF_DEBUG */ - ulint val); /*!< in: value to set: < 4 */ -#ifdef UNIV_IBUF_DEBUG -# define ibuf_set_free_bits(b,v,max) ibuf_set_free_bits_func(b,max,v) -#else /* UNIV_IBUF_DEBUG */ -# define ibuf_set_free_bits(b,v,max) ibuf_set_free_bits_func(b,v) -#endif /* UNIV_IBUF_DEBUG */ - -/**********************************************************************//** -A basic partial test if an insert to the insert buffer could be possible and -recommended. */ -UNIV_INLINE -ibool -ibuf_should_try( -/*============*/ - dict_index_t* index, /*!< in: index where to insert */ - ulint ignore_sec_unique) /*!< in: if != 0, we should - ignore UNIQUE constraint on - a secondary index when we - decide */ -{ - if (!innodb_change_buffering || !ibuf.max_size || index->is_clust() || - index->is_spatial()) - return false; - if (!ignore_sec_unique && index->is_unique()) - return false; - if (index->table->quiesce != QUIESCE_NONE) - return false; - for (unsigned i= 0; i < index->n_fields; i++) - if (index->fields[i].descending) - return false; - return true; -} - -/******************************************************************//** -Returns TRUE if the current OS thread is performing an insert buffer -routine. - -For instance, a read-ahead of non-ibuf pages is forbidden by threads -that are executing an insert buffer routine. -@return TRUE if inside an insert buffer routine */ -UNIV_INLINE -ibool -ibuf_inside( -/*========*/ - const mtr_t* mtr) /*!< in: mini-transaction */ -{ - return(mtr->is_inside_ibuf()); -} - -/** Translates the free space on a page to a value in the ibuf bitmap. -@param[in] page_size page size in bytes -@param[in] max_ins_size maximum insert size after reorganize for -the page -@return value for ibuf bitmap bits */ -UNIV_INLINE -ulint -ibuf_index_page_calc_free_bits( - ulint page_size, - ulint max_ins_size) -{ - ulint n; - ut_ad(ut_is_2pow(page_size)); - ut_ad(page_size > IBUF_PAGE_SIZE_PER_FREE_SPACE); - - n = max_ins_size / (page_size / IBUF_PAGE_SIZE_PER_FREE_SPACE); - - if (n == 3) { - n = 2; - } - - if (n > 3) { - n = 3; - } - - return(n); -} - -/*********************************************************************//** -Translates the free space on a compressed page to a value in the ibuf bitmap. -@return value for ibuf bitmap bits */ -UNIV_INLINE -ulint -ibuf_index_page_calc_free_zip( -/*==========================*/ - const buf_block_t* block) /*!< in: buffer block */ -{ - ulint max_ins_size; - const page_zip_des_t* page_zip; - lint zip_max_ins; - - ut_ad(block->page.zip.data); - - /* Consider the maximum insert size on the uncompressed page - without reorganizing the page. We must not assume anything - about the compression ratio. If zip_max_ins > max_ins_size and - there is 1/4 garbage on the page, recompression after the - reorganize could fail, in theory. So, let us guarantee that - merging a buffered insert to a compressed page will always - succeed without reorganizing or recompressing the page, just - by using the page modification log. */ - max_ins_size = page_get_max_insert_size( - buf_block_get_frame(block), 1); - - page_zip = buf_block_get_page_zip(block); - zip_max_ins = page_zip_max_ins_size(page_zip, - FALSE/* not clustered */); - - if (zip_max_ins < 0) { - return(0); - } else if (max_ins_size > (ulint) zip_max_ins) { - max_ins_size = (ulint) zip_max_ins; - } - - return(ibuf_index_page_calc_free_bits(block->physical_size(), - max_ins_size)); -} - -/*********************************************************************//** -Translates the free space on a page to a value in the ibuf bitmap. -@return value for ibuf bitmap bits */ -UNIV_INLINE -ulint -ibuf_index_page_calc_free( -/*======================*/ - const buf_block_t* block) /*!< in: buffer block */ -{ - if (!block->page.zip.data) { - ulint max_ins_size; - - max_ins_size = page_get_max_insert_size_after_reorganize( - buf_block_get_frame(block), 1); - - return(ibuf_index_page_calc_free_bits( - block->physical_size(), max_ins_size)); - } else { - return(ibuf_index_page_calc_free_zip(block)); - } -} - -/************************************************************************//** -Updates the free bits of an uncompressed page in the ibuf bitmap if -there is not enough free on the page any more. This is done in a -separate mini-transaction, hence this operation does not restrict -further work to only ibuf bitmap operations, which would result if the -latch to the bitmap page were kept. NOTE: The free bits in the insert -buffer bitmap must never exceed the free space on a page. It is -unsafe to increment the bits in a separately committed -mini-transaction, because in crash recovery, the free bits could -momentarily be set too high. It is only safe to use this function for -decrementing the free bits. Should more free space become available, -we must not update the free bits here, because that would break crash -recovery. */ -UNIV_INLINE -void -ibuf_update_free_bits_if_full( -/*==========================*/ - buf_block_t* block, /*!< in: index page to which we have added new - records; the free bits are updated if the - index is non-clustered and non-unique and - the page level is 0, and the page becomes - fuller */ - ulint max_ins_size,/*!< in: value of maximum insert size with - reorganize before the latest operation - performed to the page */ - ulint increase)/*!< in: upper limit for the additional space - used in the latest operation, if known, or - ULINT_UNDEFINED */ -{ - ulint before; - ulint after; - - ut_ad(buf_block_get_page_zip(block) == NULL); - - before = ibuf_index_page_calc_free_bits( - srv_page_size, max_ins_size); - - if (max_ins_size >= increase) { - compile_time_assert(ULINT32_UNDEFINED > UNIV_PAGE_SIZE_MAX); - after = ibuf_index_page_calc_free_bits( - srv_page_size, max_ins_size - increase); -#ifdef UNIV_IBUF_DEBUG - ut_a(after <= ibuf_index_page_calc_free(block)); -#endif - } else { - after = ibuf_index_page_calc_free(block); - } - - if (after == 0) { - /* We move the page to the front of the buffer pool LRU list: - the purpose of this is to prevent those pages to which we - cannot make inserts using the insert buffer from slipping - out of the buffer pool */ - - buf_page_make_young(&block->page); - } - - if (before > after) { - ibuf_set_free_bits(block, after, before); - } -} diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index e787d81e8c290..c0b79f1a76de3 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -417,16 +417,6 @@ struct recv_sys_t /** The recovery system */ extern recv_sys_t recv_sys; -/** If the following is TRUE, the buffer pool file pages must be invalidated -after recovery and no ibuf operations are allowed; this will be set if -recv_sys.pages becomes too full, and log records must be merged -to file pages already before the recovery is finished: in this case no -ibuf operations are allowed, as they could modify the pages read in the -buffer pool before the pages have been recovered to the up-to-date state. - -TRUE means that recovery is running and no operations on the log files -are allowed yet: the variable name is misleading. */ -extern bool recv_no_ibuf_operations; /** TRUE when recv_init_crash_recovery() has been called. */ extern bool recv_needed_recovery; #ifdef UNIV_DEBUG diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index abc1f65e6920a..debc3a3fc9c63 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -381,15 +381,6 @@ struct mtr_t { @retval 0 if the transaction only modified temporary tablespaces */ lsn_t commit_lsn() const { ut_ad(has_committed()); return m_commit_lsn; } - /** Note that we are inside the change buffer code. */ - void enter_ibuf() { m_inside_ibuf= true; } - - /** Note that we have exited from the change buffer code. */ - void exit_ibuf() { m_inside_ibuf= false; } - - /** @return true if we are inside the change buffer code */ - bool is_inside_ibuf() const { return m_inside_ibuf; } - /** Note that some pages have been freed */ void set_trim_pages() { m_trim_pages= true; } @@ -792,10 +783,6 @@ struct mtr_t { /** whether log_sys.latch is locked exclusively */ uint16_t m_latch_ex:1; - /** whether change buffer is latched; only needed in non-debug builds - to suppress some read-ahead operations, @see ibuf_inside() */ - uint16_t m_inside_ibuf:1; - /** whether the pages has been trimmed */ uint16_t m_trim_pages:1; diff --git a/storage/innobase/include/page0cur.h b/storage/innobase/include/page0cur.h index 28aa30565e46a..279138acd791d 100644 --- a/storage/innobase/include/page0cur.h +++ b/storage/innobase/include/page0cur.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, 2022, MariaDB Corporation. +Copyright (c) 2018, 2023, 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 @@ -117,11 +117,6 @@ succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same logical position, but the physical position may change if it is pointing to a compressed page that was reorganized. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if this is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return pointer to record if succeed, NULL otherwise */ UNIV_INLINE rec_t* @@ -151,11 +146,6 @@ page_cur_insert_rec_low( Inserts a record next to page cursor on a compressed and uncompressed page. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if this is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return pointer to inserted record @return nullptr on failure */ rec_t* diff --git a/storage/innobase/include/page0cur.inl b/storage/innobase/include/page0cur.inl index 7c4eafa266a88..a73c31a7bffad 100644 --- a/storage/innobase/include/page0cur.inl +++ b/storage/innobase/include/page0cur.inl @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, 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 @@ -155,11 +155,6 @@ succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same logical position, but the physical position may change if it is pointing to a compressed page that was reorganized. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if this is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return pointer to record if succeed, NULL otherwise */ UNIV_INLINE rec_t* diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index 2978656b508f4..38373f6bb19de 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -1,6 +1,6 @@ /***************************************************************************** Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -95,7 +95,7 @@ this byte can be garbage. */ direction */ #define PAGE_N_RECS 16 /* number of user records on the page */ /** The largest DB_TRX_ID that may have modified a record on the page; -Defined only in secondary index leaf pages and in change buffer leaf pages. +Defined only in secondary index leaf pages. Otherwise written as 0. @see PAGE_ROOT_AUTO_INC */ #define PAGE_MAX_TRX_ID 18 /** The AUTO_INCREMENT value (on persistent clustered index root pages). */ @@ -901,11 +901,6 @@ MY_ATTRIBUTE((nonnull, warn_unused_result)) Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if new_block is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_t::commit(). - @return error code */ dberr_t page_copy_rec_list_end_no_locks( @@ -920,11 +915,6 @@ Copies records from page to new_page, from the given record onward, including that record. Infimum and supremum records are not copied. The records are copied to the start of the record list on new_page. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if new_block is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_t::commit(). - @return pointer to the original successor of the infimum record on new_block @retval nullptr on ROW_FORMAT=COMPRESSED page overflow */ rec_t* @@ -942,11 +932,6 @@ Copies records from page to new_page, up to the given record, NOT including that record. Infimum and supremum records are not copied. The records are copied to the end of the record list on new_page. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if new_block is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return pointer to the original predecessor of the supremum record on new_block @retval nullptr on ROW_FORMAT=COMPRESSED page overflow */ rec_t* diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index 4332990619e75..501ef31a8f913 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -2,7 +2,7 @@ Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -213,9 +213,9 @@ page_zip_max_ins_size( /**********************************************************************//** Determine if enough space is available in the modification log. -@return TRUE if page_zip_write_rec() will succeed */ +@return true if page_zip_write_rec() will succeed */ UNIV_INLINE -ibool +bool page_zip_available( /*===============*/ const page_zip_des_t* page_zip,/*!< in: compressed page */ @@ -323,10 +323,6 @@ Reorganize and compress a page. This is a low-level operation for compressed pages, to be used when page_zip_compress() fails. On success, redo log will be written. The function btr_page_reorganize() should be preferred whenever possible. -IMPORTANT: if page_zip_reorganize() is invoked on a leaf page of a -non-clustered index, the caller must update the insert buffer free -bits in the same mini-transaction in such a way that the modification -will be redo-logged. @return error code @retval DB_FAIL on overflow; the block_zip will be left intact */ dberr_t diff --git a/storage/innobase/include/page0zip.inl b/storage/innobase/include/page0zip.inl index afc877c37209c..edcd4ab48fae9 100644 --- a/storage/innobase/include/page0zip.inl +++ b/storage/innobase/include/page0zip.inl @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -269,7 +269,7 @@ page_zip_max_ins_size( Determine if enough space is available in the modification log. @return TRUE if enough space is available */ UNIV_INLINE -ibool +bool page_zip_available( /*===============*/ const page_zip_des_t* page_zip,/*!< in: compressed page */ diff --git a/storage/innobase/include/rem0rec.inl b/storage/innobase/include/rem0rec.inl index 46c209cbdec43..da7337a3b82b9 100644 --- a/storage/innobase/include/rem0rec.inl +++ b/storage/innobase/include/rem0rec.inl @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -1095,9 +1095,7 @@ rec_get_converted_size( ut_ad(dtuple_check_typed(dtuple)); #ifdef UNIV_DEBUG - if (dict_index_is_ibuf(index)) { - ut_ad(dtuple->n_fields > 1); - } else if ((dtuple_get_info_bits(dtuple) & REC_NEW_STATUS_MASK) + if ((dtuple_get_info_bits(dtuple) & REC_NEW_STATUS_MASK) == REC_STATUS_NODE_PTR) { ut_ad(dtuple->n_fields - 1 == dict_index_get_n_unique_in_tree_nonleaf(index)); diff --git a/storage/innobase/include/row0purge.h b/storage/innobase/include/row0purge.h index b1390fd1ef10f..686bbaa73841f 100644 --- a/storage/innobase/include/row0purge.h +++ b/storage/innobase/include/row0purge.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -37,39 +37,6 @@ Created 3/14/1997 Heikki Tuuri #include class MDL_ticket; -/** Determines if it is possible to remove a secondary index entry. -Removal is possible if the secondary index entry does not refer to any -not delete marked version of a clustered index record where DB_TRX_ID -is newer than the purge view. - -NOTE: This function should only be called by the purge thread, only -while holding a latch on the leaf page of the secondary index entry -(or keeping the buffer pool watch on the page). It is possible that -this function first returns true and then false, if a user transaction -inserts a record that the secondary index entry would refer to. -However, in that case, the user transaction would also re-insert the -secondary index entry after purge has removed it and released the leaf -page latch. -@param[in,out] node row purge node -@param[in] index secondary index -@param[in] entry secondary index entry -@param[in,out] sec_pcur secondary index cursor or NULL - if it is called for purge buffering - operation. -@param[in,out] sec_mtr mini-transaction which holds - secondary index entry or NULL if it is - called for purge buffering operation. -@param[in] is_tree true=pessimistic purge, - false=optimistic (leaf-page only) -@return true if the secondary index record can be purged */ -bool -row_purge_poss_sec( - purge_node_t* node, - dict_index_t* index, - const dtuple_t* entry, - btr_pcur_t* sec_pcur=NULL, - mtr_t* sec_mtr=NULL, - bool is_tree=false); /*************************************************************** Does the purge operation. diff --git a/storage/innobase/include/row0row.h b/storage/innobase/include/row0row.h index a1350740e2a47..25cadf272dd90 100644 --- a/storage/innobase/include/row0row.h +++ b/storage/innobase/include/row0row.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2022, MariaDB Corporation. +Copyright (c) 2016, 2023, 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 @@ -28,7 +28,6 @@ Created 4/20/1996 Heikki Tuuri #define row0row_h #include "que0types.h" -#include "ibuf0ibuf.h" #include "trx0types.h" #include "mtr0mtr.h" #include "rem0types.h" @@ -344,31 +343,19 @@ row_parse_int( ulint mtype, bool unsigned_type); -/** Result of row_search_index_entry */ -enum row_search_result { - ROW_FOUND = 0, /*!< the record was found */ - ROW_NOT_FOUND, /*!< record not found */ - ROW_BUFFERED, /*!< one of BTR_INSERT, BTR_DELETE, or - BTR_DELETE_MARK was specified, the - secondary index leaf page was not in - the buffer pool, and the operation was - enqueued in the insert/delete buffer */ - ROW_NOT_DELETED_REF /*!< BTR_DELETE was specified, and - row_purge_poss_sec() failed */ -}; - /***************************************************************//** Searches an index record. -@return whether the record was found or buffered */ -enum row_search_result +@return whether the record was found */ +bool row_search_index_entry( /*===================*/ const dtuple_t* entry, /*!< in: index entry */ btr_latch_mode mode, /*!< in: BTR_MODIFY_LEAF, ... */ btr_pcur_t* pcur, /*!< in/out: persistent cursor, which must be closed by the caller */ + que_thr_t* thr, /*!< in/out: query thread */ mtr_t* mtr) /*!< in: mtr */ - MY_ATTRIBUTE((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,3,5), warn_unused_result)); #define ROW_COPY_DATA 1 #define ROW_COPY_POINTERS 2 @@ -398,22 +385,17 @@ row_raw_format( in bytes */ MY_ATTRIBUTE((nonnull, warn_unused_result)); +#include "dict0mem.h" + /** Prepare to start a mini-transaction to modify an index. @param[in,out] mtr mini-transaction -@param[in,out] index possibly secondary index -@param[in] pessimistic whether this is a pessimistic operation */ -inline -void -row_mtr_start(mtr_t* mtr, dict_index_t* index, bool pessimistic) +@param[in,out] index possibly secondary index */ +inline void row_mtr_start(mtr_t* mtr, dict_index_t* index) { mtr->start(); switch (index->table->space_id) { - case IBUF_SPACE_ID: - if (pessimistic - && !(index->type & (DICT_UNIQUE | DICT_SPATIAL))) { - ibuf_free_excess_pages(); - } + case 0: break; case SRV_TMP_SPACE_ID: mtr->set_log_mode(MTR_LOG_NO_REDO); diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index 51f3049b81ac3..4672ce00a3675 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -2,7 +2,7 @@ Copyright (c) 2010, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -228,12 +228,8 @@ enum monitor_id_t { MONITOR_MODULE_BUF_PAGE, MONITOR_INDEX_LEAF_PAGE_READ, MONITOR_INDEX_NON_LEAF_PAGE_READ, - MONITOR_INDEX_IBUF_LEAF_PAGE_READ, - MONITOR_INDEX_IBUF_NON_LEAF_PAGE_READ, MONITOR_UNDO_LOG_PAGE_READ, MONITOR_INODE_PAGE_READ, - MONITOR_IBUF_FREELIST_PAGE_READ, - MONITOR_IBUF_BITMAP_PAGE_READ, MONITOR_SYSTEM_PAGE_READ, MONITOR_TRX_SYSTEM_PAGE_READ, MONITOR_FSP_HDR_PAGE_READ, @@ -244,12 +240,8 @@ enum monitor_id_t { MONITOR_OTHER_PAGE_READ, MONITOR_INDEX_LEAF_PAGE_WRITTEN, MONITOR_INDEX_NON_LEAF_PAGE_WRITTEN, - MONITOR_INDEX_IBUF_LEAF_PAGE_WRITTEN, - MONITOR_INDEX_IBUF_NON_LEAF_PAGE_WRITTEN, MONITOR_UNDO_LOG_PAGE_WRITTEN, MONITOR_INODE_PAGE_WRITTEN, - MONITOR_IBUF_FREELIST_PAGE_WRITTEN, - MONITOR_IBUF_BITMAP_PAGE_WRITTEN, MONITOR_SYSTEM_PAGE_WRITTEN, MONITOR_TRX_SYSTEM_PAGE_WRITTEN, MONITOR_FSP_HDR_PAGE_WRITTEN, @@ -347,17 +339,6 @@ enum monitor_id_t { MONITOR_MODULE_FIL_SYSTEM, MONITOR_OVLD_N_FILE_OPENED, - /* InnoDB Change Buffer related counters */ - MONITOR_MODULE_IBUF_SYSTEM, - MONITOR_OVLD_IBUF_MERGE_INSERT, - MONITOR_OVLD_IBUF_MERGE_DELETE, - MONITOR_OVLD_IBUF_MERGE_PURGE, - MONITOR_OVLD_IBUF_MERGE_DISCARD_INSERT, - MONITOR_OVLD_IBUF_MERGE_DISCARD_DELETE, - MONITOR_OVLD_IBUF_MERGE_DISCARD_PURGE, - MONITOR_OVLD_IBUF_MERGES, - MONITOR_OVLD_IBUF_SIZE, - /* Counters for server operations */ MONITOR_MODULE_SERVER, MONITOR_MASTER_THREAD_SLEEP, diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 606d94818cfb8..f94c52c2d97a4 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -170,9 +170,9 @@ extern char* srv_data_home; recovery and open all tables in RO mode instead of RW mode. We don't sync the max trx id to disk either. */ extern my_bool srv_read_only_mode; -/** Set if InnoDB operates in read-only mode or innodb-force-recovery -is greater than SRV_FORCE_NO_IBUF_MERGE. */ -extern my_bool high_level_read_only; +/** Set if innodb_read_only is set or innodb_force_recovery +is SRV_FORCE_NO_UNDO_LOG_SCAN or greater. */ +extern bool high_level_read_only; /** store to its own file each table created by an user; data dictionary tables are in the system tablespace 0 */ extern my_bool srv_file_per_table; @@ -585,11 +585,6 @@ void srv_monitor_task(void*); void srv_master_callback(void*); -/** -Complete the shutdown tasks such as background DROP TABLE, -and optionally change buffer merge (on innodb_fast_shutdown=0). */ -void srv_shutdown(bool ibuf_merge); - } /* extern "C" */ #ifdef UNIV_DEBUG diff --git a/storage/innobase/include/sux_lock.h b/storage/innobase/include/sux_lock.h index 2c0167ac651e0..7a7f93b6787e6 100644 --- a/storage/innobase/include/sux_lock.h +++ b/storage/innobase/include/sux_lock.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2020, 2022, MariaDB Corporation. +Copyright (c) 2020, 2023, 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 @@ -149,7 +149,7 @@ class sux_lock final #endif public: - /** In crash recovery or the change buffer, claim the ownership + /** In crash recovery, claim the ownership of the exclusive block lock to the current thread */ void claim_ownership() { set_new_owner(pthread_self()); } diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 0450be89cfb76..a571de04f2f57 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, 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 @@ -774,13 +774,17 @@ struct trx_t : ilist_node<> const char* op_info; /*!< English text describing the current operation, or an empty string */ - uint isolation_level;/*!< TRX_ISO_REPEATABLE_READ, ... */ - bool check_foreigns; /*!< normally TRUE, but if the user - wants to suppress foreign key checks, - (in table imports, for example) we - set this FALSE */ + /** TRX_ISO_REPEATABLE_READ, ... */ + unsigned isolation_level:2; + /** normally set; "SET foreign_key_checks=0" can be issued to suppress + foreign key checks, in table imports, for example */ + unsigned check_foreigns:1; + /** normally set; "SET unique_checks=0, foreign_key_checks=0" + enables bulk insert into an empty table */ + unsigned check_unique_secondary:1; + /** whether an insert into an empty table is active */ - bool bulk_insert; + unsigned bulk_insert:1; /*------------------------------*/ /* MySQL has a transaction coordinator to coordinate two phase commit between multiple storage engines and the binary log. When @@ -794,13 +798,6 @@ struct trx_t : ilist_node<> /** whether this is holding the prepare mutex */ bool active_commit_ordered; /*------------------------------*/ - bool check_unique_secondary; - /*!< normally TRUE, but if the user - wants to speed up inserts by - suppressing unique key checks - for secondary indexes when we decide - if we can use the insert buffer for - them, we set this FALSE */ bool flush_log_later;/* In 2PC, we hold the prepare_commit mutex across both phases. In that case, we diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index d06343fcabe68..93352b279b114 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, MariaDB Corporation. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -142,7 +142,6 @@ using the call command. */ assertions. */ #define UNIV_LRU_DEBUG /* debug the buffer pool LRU */ #define UNIV_HASH_DEBUG /* debug HASH_ macros */ -#define UNIV_IBUF_DEBUG /* debug the insert buffer */ #define UNIV_PERF_DEBUG /* debug flag that enables light weight performance related stuff. */ @@ -475,9 +474,6 @@ extern mysql_pfs_key_t fts_cache_mutex_key; extern mysql_pfs_key_t fts_cache_init_mutex_key; extern mysql_pfs_key_t fts_delete_mutex_key; extern mysql_pfs_key_t fts_doc_id_mutex_key; -extern mysql_pfs_key_t ibuf_bitmap_mutex_key; -extern mysql_pfs_key_t ibuf_mutex_key; -extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key; extern mysql_pfs_key_t recalc_pool_mutex_key; extern mysql_pfs_key_t purge_sys_pq_mutex_key; extern mysql_pfs_key_t recv_sys_mutex_key; diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 4e9ed1263f6a7..e144b9fea38ad 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/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, 2022, MariaDB Corporation. +Copyright (c) 2014, 2023, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -913,15 +913,6 @@ void log_write_up_to(lsn_t lsn, bool durable, { ut_ad(!srv_read_only_mode); ut_ad(lsn != LSN_MAX); - - if (UNIV_UNLIKELY(recv_no_ibuf_operations)) - { - /* A non-final batch of recovery is active no writes to the log - are allowed yet. */ - ut_a(!callback); - return; - } - ut_ad(lsn <= log_sys.get_lsn()); #ifdef HAVE_PMEM @@ -947,6 +938,7 @@ void log_write_up_to(lsn_t lsn, bool durable, if (write_lock.acquire(lsn, durable ? nullptr : callback) == group_commit_lock::ACQUIRED) { + ut_ad(!recv_no_log_write || srv_operation != SRV_OPERATION_NORMAL); log_sys.latch.wr_lock(SRW_LOCK_CALL); pending_write_lsn= write_lock.release(log_sys.write_buf()); } @@ -1079,11 +1071,9 @@ ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown() ib::info() << "Starting shutdown..."; - /* Wait until the master thread and all other operations are idle: our + /* Wait until the master task and all other operations are idle: our algorithm only works if the server is idle at shutdown */ - bool do_srv_shutdown = false; if (srv_master_timer) { - do_srv_shutdown = srv_fast_shutdown < 2; srv_master_timer.reset(); } @@ -1100,11 +1090,6 @@ ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown() } srv_monitor_timer.reset(); - if (do_srv_shutdown) { - srv_shutdown(srv_fast_shutdown == 0); - } - - loop: ut_ad(lock_sys.is_initialised() || !srv_was_started); ut_ad(log_sys.is_initialised() || !srv_was_started); diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 7d23001962b6a..1f96fbcc9d63d 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -46,7 +46,6 @@ Created 9/20/1997 Heikki Tuuri #include "page0page.h" #include "page0cur.h" #include "trx0undo.h" -#include "ibuf0ibuf.h" #include "trx0undo.h" #include "trx0rec.h" #include "fil0fil.h" @@ -71,17 +70,6 @@ number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by recv_recovery_from_checkpoint_start(). */ bool recv_lsn_checks_on; -/** If the following is TRUE, the buffer pool file pages must be invalidated -after recovery and no ibuf operations are allowed; this becomes TRUE if -the log record hash table becomes too full, and log records must be merged -to file pages already before the recovery is finished: in this case no -ibuf operations are allowed, as they could modify the pages read in the -buffer pool before the pages have been recovered to the up-to-date state. - -true means that recovery is running and no operations on the log file -are allowed yet: the variable name is misleading. */ -bool recv_no_ibuf_operations; - /** The maximum lsn we see for a page during the recovery process. If this is bigger than the lsn we are able to scan up to, that is an indication that the recovery failed and the database may be corrupt. */ @@ -1089,64 +1077,11 @@ class mlog_init_t void reset() { mysql_mutex_assert_owner(&recv_sys.mutex); - ut_ad(recv_no_ibuf_operations); for (map::value_type& i : inits) { i.second.created = false; } } - /** On the last recovery batch, mark whether there exist - buffered changes for the pages that were initialized - by buf_page_create() and still reside in the buffer pool. - @param[in,out] mtr dummy mini-transaction */ - void mark_ibuf_exist(mtr_t& mtr) - { - mysql_mutex_assert_owner(&recv_sys.mutex); - mtr.start(); - - for (const map::value_type& i : inits) { - if (!i.second.created) { - continue; - } - if (buf_block_t* block = buf_page_get_low( - i.first, 0, RW_X_LATCH, nullptr, - BUF_GET_IF_IN_POOL, - &mtr, nullptr, false)) { - if (UNIV_LIKELY_NULL(block->page.zip.data)) { - switch (fil_page_get_type( - block->page.zip.data)) { - case FIL_PAGE_INDEX: - case FIL_PAGE_RTREE: - if (page_zip_decompress( - &block->page.zip, - block->page.frame, - true)) { - break; - } - ib::error() << "corrupted " - << block->page.id(); - } - } - if (recv_no_ibuf_operations) { - mtr.commit(); - mtr.start(); - continue; - } - mysql_mutex_unlock(&recv_sys.mutex); - if (ibuf_page_exists(block->page.id(), - block->zip_size())) { - block->page.set_ibuf_exist(); - } - mtr.commit(); - mtr.start(); - mysql_mutex_lock(&recv_sys.mutex); - } - } - - mtr.commit(); - clear(); - } - /** Clear the data structure */ void clear() { inits.clear(); } }; @@ -3436,10 +3371,6 @@ void recv_sys_t::apply(bool last_batch) } } - recv_no_ibuf_operations = !last_batch || - srv_operation == SRV_OPERATION_RESTORE || - srv_operation == SRV_OPERATION_RESTORE_EXPORT; - mtr_t mtr; if (!pages.empty()) @@ -3580,10 +3511,7 @@ void recv_sys_t::apply(bool last_batch) } } - if (last_batch) - /* We skipped this in buf_page_create(). */ - mlog_init.mark_ibuf_exist(mtr); - else + if (!last_batch) { mlog_init.reset(); log_sys.latch.wr_unlock(); @@ -4298,7 +4226,6 @@ dberr_t recv_recovery_from_checkpoint_start() mysql_mutex_lock(&recv_sys.mutex); recv_sys.apply_log_recs = true; - recv_no_ibuf_operations = false; ut_d(recv_no_log_write = srv_operation == SRV_OPERATION_RESTORE || srv_operation == SRV_OPERATION_RESTORE_EXPORT); if (srv_operation == SRV_OPERATION_NORMAL) { diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 3eacd3ab7e17a..04b20de8e96dc 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -175,7 +175,6 @@ void mtr_t::start() m_made_dirty= false; m_latch_ex= false; - m_inside_ibuf= false; m_modifications= false; m_log_mode= MTR_LOG_ALL; ut_d(m_user_space_id= TRX_SYS_SPACE); @@ -323,7 +322,6 @@ void mtr_t::release() void mtr_t::commit() { ut_ad(is_active()); - ut_ad(!is_inside_ibuf()); /* This is a dirty read, for debugging. */ ut_ad(!m_modifications || !recv_no_log_write); @@ -506,7 +504,6 @@ void mtr_t::rollback_to_savepoint(ulint begin, ulint end) void mtr_t::commit_shrink(fil_space_t &space) { ut_ad(is_active()); - ut_ad(!is_inside_ibuf()); ut_ad(!high_level_read_only); ut_ad(m_modifications); ut_ad(m_made_dirty); @@ -613,7 +610,6 @@ void mtr_t::commit_shrink(fil_space_t &space) bool mtr_t::commit_file(fil_space_t &space, const char *name) { ut_ad(is_active()); - ut_ad(!is_inside_ibuf()); ut_ad(!high_level_read_only); ut_ad(m_modifications); ut_ad(!m_made_dirty); @@ -724,7 +720,6 @@ lsn_t mtr_t::commit_files(lsn_t checkpoint_lsn) ut_ad(log_sys.latch.is_write_locked()); #endif ut_ad(is_active()); - ut_ad(!is_inside_ibuf()); ut_ad(m_log_mode == MTR_LOG_ALL); ut_ad(!m_made_dirty); ut_ad(!m_memo); diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index b019694b9f616..8d3a44d630d86 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -2,7 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2018, 2022, MariaDB Corporation. +Copyright (c) 2018, 2023, 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 @@ -1369,8 +1369,7 @@ page_cur_insert_rec_low( ut_ad(!!page_is_comp(block->page.frame) == !!rec_offs_comp(offsets)); ut_ad(fil_page_index_page_check(block->page.frame)); ut_ad(mach_read_from_8(PAGE_HEADER + PAGE_INDEX_ID + block->page.frame) == - index->id || - mtr->is_inside_ibuf()); + index->id || index->is_dummy); ut_ad(page_dir_get_n_slots(block->page.frame) >= 2); ut_ad(!page_rec_is_supremum(cur->rec)); @@ -1769,11 +1768,6 @@ static inline void page_zip_dir_add_slot(buf_block_t *block, Inserts a record next to page cursor on a compressed and uncompressed page. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if this is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return pointer to inserted record @return nullptr on failure */ rec_t* @@ -1797,8 +1791,7 @@ page_cur_insert_rec_zip( ut_ad(rec_offs_comp(offsets)); ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX || fil_page_get_type(page) == FIL_PAGE_RTREE); - ut_ad(mach_read_from_8(PAGE_HEADER + PAGE_INDEX_ID + page) == - index->id || mtr->is_inside_ibuf()); + ut_ad(mach_read_from_8(PAGE_HEADER + PAGE_INDEX_ID + page) == index->id); ut_ad(!page_get_instant(page)); ut_ad(!page_cur_is_after_last(cursor)); #ifdef UNIV_ZIP_DEBUG @@ -2265,8 +2258,7 @@ page_cur_delete_rec( == index->table->not_redundant()); ut_ad(fil_page_index_page_check(block->page.frame)); ut_ad(mach_read_from_8(PAGE_HEADER + PAGE_INDEX_ID + block->page.frame) - == index->id - || mtr->is_inside_ibuf()); + == index->id); ut_ad(mtr->is_named_space(index->table->space)); /* The record must not be the supremum or infimum record. */ diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index 127eb11f939ce..63bd39feb4db5 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -2,7 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -336,17 +336,13 @@ page_create_zip( /* PAGE_MAX_TRX_ID or PAGE_ROOT_AUTO_INC are always 0 for temporary tables. */ ut_ad(max_trx_id == 0 || !index->table->is_temporary()); - /* In secondary indexes and the change buffer, PAGE_MAX_TRX_ID + /* In secondary indexes, PAGE_MAX_TRX_ID must be zero on non-leaf pages. max_trx_id can be 0 when the - index consists of an empty root (leaf) page. */ - ut_ad(max_trx_id == 0 - || level == 0 - || !dict_index_is_sec_or_ibuf(index) - || index->table->is_temporary()); - /* In the clustered index, PAGE_ROOT_AUTOINC or + index consists of an empty root (leaf) page. + + the clustered index, PAGE_ROOT_AUTOINC or PAGE_MAX_TRX_ID must be 0 on other pages than the root. */ - ut_ad(level == 0 || max_trx_id == 0 - || !dict_index_is_sec_or_ibuf(index) + ut_ad(max_trx_id == 0 || level == 0 || index->is_primary() || index->table->is_temporary()); buf_block_modify_clock_inc(block); @@ -390,8 +386,7 @@ page_create_empty( same temp-table in parallel. max_trx_id is ignored for temp tables because it not required for MVCC. */ - if (dict_index_is_sec_or_ibuf(index) - && !index->table->is_temporary() + if (!index->is_primary() && !index->table->is_temporary() && page_is_leaf(block->page.frame)) { max_trx_id = page_get_max_trx_id(block->page.frame); ut_ad(max_trx_id); @@ -435,11 +430,6 @@ page_create_empty( Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if new_block is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return error code */ dberr_t page_copy_rec_list_end_no_locks( @@ -507,11 +497,6 @@ Copies records from page to new_page, from a given record onward, including that record. Infimum and supremum records are not copied. The records are copied to the start of the record list on new_page. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if new_block is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_t::commit(). - @return pointer to the original successor of the infimum record on new_block @retval nullptr on ROW_FORMAT=COMPRESSED page overflow */ rec_t* @@ -603,8 +588,7 @@ page_copy_rec_list_end( same temp-table in parallel. max_trx_id is ignored for temp tables because it not required for MVCC. */ - if (dict_index_is_sec_or_ibuf(index) - && page_is_leaf(page) + if (!index->is_primary() && page_is_leaf(page) && !index->table->is_temporary()) { ut_ad(!was_empty || page_dir_get_n_heap(new_page) == PAGE_HEAP_NO_USER_LOW @@ -677,11 +661,6 @@ Copies records from page to new_page, up to the given record, NOT including that record. Infimum and supremum records are not copied. The records are copied to the end of the record list on new_page. -IMPORTANT: The caller will have to update IBUF_BITMAP_FREE -if new_block is a compressed leaf page in a secondary index. -This has to be done either within the same mini-transaction, -or by invoking ibuf_reset_free_bits() before mtr_commit(). - @return pointer to the original predecessor of the supremum record on new_block @retval nullptr on ROW_FORMAT=COMPRESSED page overflow */ rec_t* @@ -786,8 +765,7 @@ page_copy_rec_list_start( same temp-table in parallel. max_trx_id is ignored for temp tables because it not required for MVCC. */ - if (n_core && dict_index_is_sec_or_ibuf(index) - && !index->table->is_temporary()) { + if (n_core && !index->is_primary() && !index->table->is_temporary()) { page_update_max_trx_id(new_block, new_page_zip, page_get_max_trx_id(block->page.frame), @@ -2059,7 +2037,7 @@ bool page_validate(const page_t* page, const dict_index_t* index) max_trx_id is ignored for temp tables because it not required for MVCC. */ if (!page_is_leaf(page) || page_is_empty(page) - || !dict_index_is_sec_or_ibuf(index) + || index->is_primary() || index->table->is_temporary()) { } else if (trx_id_t sys_max_trx_id = trx_sys.get_max_trx_id()) { trx_id_t max_trx_id = page_get_max_trx_id(page); diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 56b58dd87d087..aff01764be6fc 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -2,7 +2,7 @@ Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2014, 2022, MariaDB Corporation. +Copyright (c) 2014, 2023, 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 @@ -408,8 +408,6 @@ inline void mtr_t::zmemcpy(const buf_block_t &b, void *dest, const void *str, static void page_zip_compress_write_log(buf_block_t *block, dict_index_t *index, mtr_t *mtr) { - ut_ad(!index->is_ibuf()); - if (!mtr->is_logged()) return; @@ -463,8 +461,7 @@ page_zip_get_n_prev_extern( ut_ad(page_is_leaf(page)); ut_ad(page_is_comp(page)); ut_ad(dict_table_is_comp(index->table)); - ut_ad(dict_index_is_clust(index)); - ut_ad(!dict_index_is_ibuf(index)); + ut_ad(index->is_primary()); heap_no = rec_get_heap_no_new(rec); ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW); @@ -1282,7 +1279,6 @@ page_zip_compress( ut_ad(page_simple_validate_new((page_t*) page)); ut_ad(page_zip_simple_validate(page_zip)); ut_ad(dict_table_is_comp(index->table)); - ut_ad(!dict_index_is_ibuf(index)); MEM_CHECK_DEFINED(page, srv_page_size); @@ -4374,10 +4370,6 @@ Reorganize and compress a page. This is a low-level operation for compressed pages, to be used when page_zip_compress() fails. On success, redo log will be written. The function btr_page_reorganize() should be preferred whenever possible. -IMPORTANT: if page_zip_reorganize() is invoked on a leaf page of a -non-clustered index, the caller must update the insert buffer free -bits in the same mini-transaction in such a way that the modification -will be redo-logged. @return error code @retval DB_FAIL on overflow; the block_zip will be left intact */ dberr_t @@ -4398,7 +4390,6 @@ page_zip_reorganize( ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); ut_ad(block->page.zip.data); ut_ad(page_is_comp(page)); - ut_ad(!dict_index_is_ibuf(index)); ut_ad(!index->table->is_temporary()); /* Note that page_zip_validate(page_zip, page, index) may fail here. */ MEM_CHECK_DEFINED(page, srv_page_size); @@ -4505,7 +4496,6 @@ page_zip_copy_recs( ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr->memo_contains_page_flagged(src, MTR_MEMO_PAGE_X_FIX)); - ut_ad(!dict_index_is_ibuf(index)); ut_ad(!index->table->is_temporary()); #ifdef UNIV_ZIP_DEBUG /* The B-tree operations that call this function may set diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc index a77ddafd56837..92ec8ba0869bc 100644 --- a/storage/innobase/rem/rem0cmp.cc +++ b/storage/innobase/rem/rem0cmp.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2020, 2022, MariaDB Corporation. +Copyright (c) 2020, 2023, 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 @@ -401,8 +401,8 @@ int cmp_dtuple_rec_with_match_low(const dtuple_t *dtuple, const rec_t *rec, ut_ad(!dfield_is_ext(dtuple_field)); - ret = cmp_data(type->mtype, type->prtype, !index->is_ibuf() - && index->fields[cur_field].descending, + ret = cmp_data(type->mtype, type->prtype, + index->fields[cur_field].descending, dtuple_b_ptr, dtuple_f_len, rec_b_ptr, rec_f_len); if (ret) { @@ -480,7 +480,6 @@ cmp_dtuple_rec_with_match_bytes( ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(!(REC_INFO_MIN_REC_FLAG & dtuple_get_info_bits(dtuple))); - ut_ad(!index->is_ibuf()); if (UNIV_UNLIKELY(REC_INFO_MIN_REC_FLAG & rec_get_info_bits(rec, rec_offs_comp(offsets)))) { @@ -829,32 +828,21 @@ cmp_rec_rec( dict_index_get_n_unique_in_tree(index)); for (; cur_field < n_fields; cur_field++) { - ulint mtype; - ulint prtype; - bool descending; - - if (UNIV_UNLIKELY(dict_index_is_ibuf(index))) { - /* This is for the insert buffer B-tree. */ - mtype = DATA_BINARY; + const dict_field_t* field = dict_index_get_nth_field( + index, cur_field); + bool descending = field->descending; + ulint mtype = field->col->mtype; + ulint prtype = field->col->prtype; + + if (UNIV_LIKELY(!index->is_spatial())) { + } else if (cur_field == 0) { + ut_ad(DATA_GEOMETRY_MTYPE(mtype)); + prtype |= DATA_GIS_MBR; + } else if (!page_rec_is_leaf(rec2)) { + /* Compare the child page number. */ + ut_ad(cur_field == 1); + mtype = DATA_SYS_CHILD; prtype = 0; - descending = false; - } else { - const dict_field_t* field = dict_index_get_nth_field( - index, cur_field); - descending = field->descending; - mtype = field->col->mtype; - prtype = field->col->prtype; - - if (UNIV_LIKELY(!dict_index_is_spatial(index))) { - } else if (cur_field == 0) { - ut_ad(DATA_GEOMETRY_MTYPE(mtype)); - prtype |= DATA_GIS_MBR; - } else if (!page_rec_is_leaf(rec2)) { - /* Compare the child page number. */ - ut_ad(cur_field == 1); - mtype = DATA_SYS_CHILD; - prtype = 0; - } } /* We should never encounter an externally stored field. diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc index da6447c390eff..a84cba01ef0dd 100644 --- a/storage/innobase/rem/rem0rec.cc +++ b/storage/innobase/rem/rem0rec.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -479,7 +479,7 @@ rec_offs_make_valid( const bool is_alter_metadata = leaf && rec_is_alter_metadata(rec, *index); ut_ad((leaf && rec_is_metadata(rec, *index)) - || index->is_dummy || index->is_ibuf() + || index->is_dummy || (leaf ? rec_offs_n_fields(offsets) <= dict_index_get_n_fields(index) @@ -891,18 +891,15 @@ rec_get_offsets_func( /* The infimum and supremum records carry 1 field. */ ut_ad(is_user_rec || n == 1); ut_ad(!is_user_rec || n_core || index->is_dummy - || dict_index_is_ibuf(index) || n == n_fields /* dict_stats_analyze_index_level() */ || n - 1 == dict_index_get_n_unique_in_tree_nonleaf(index)); ut_ad(!is_user_rec || !n_core || index->is_dummy - || dict_index_is_ibuf(index) || n == n_fields /* btr_pcur_restore_position() */ || (n + (index->id == DICT_INDEXES_ID) >= n_core)); if (is_user_rec && n_core && n < index->n_fields) { ut_ad(!index->is_dummy); - ut_ad(!dict_index_is_ibuf(index)); n = index->n_fields; } } @@ -1993,7 +1990,7 @@ rec_copy_prefix_to_buf( or NULL */ ulint* buf_size) /*!< in/out: buffer size */ { - ut_ad(n_fields <= index->n_fields || dict_index_is_ibuf(index)); + ut_ad(n_fields <= index->n_fields); ut_ad(index->n_core_null_bytes <= UT_BITS_IN_BYTES(index->n_nullable)); UNIV_PREFETCH_RW(*buf); diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index c4ee55e79b3cf..f86b3c8674aa4 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, 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 @@ -2071,7 +2071,7 @@ dberr_t PageConverter::operator()(buf_block_t* block) UNIV_NOTHROW we no longer evict the pages on DISCARD TABLESPACE. */ buf_page_get_low(block->page.id(), get_zip_size(), RW_NO_LATCH, nullptr, BUF_PEEK_IF_IN_POOL, - nullptr, nullptr, false); + nullptr, nullptr); uint16_t page_type; @@ -4256,8 +4256,6 @@ row_import_for_mysql( ut_ad(trx->state == TRX_STATE_ACTIVE); ut_ad(!table->is_readable()); - ibuf_delete_for_discarded_space(table->space_id); - /* Assign an undo segment for the transaction, so that the transaction will be recovered after a crash. */ @@ -4456,12 +4454,6 @@ row_import_for_mysql( ut_free(filepath); - if (err == DB_SUCCESS) { - err = ibuf_check_bitmap_on_import(trx, table->space); - } - - DBUG_EXECUTE_IF("ib_import_check_bitmap_failure", err = DB_CORRUPTION;); - if (err != DB_SUCCESS) { return row_import_cleanup(prebuilt, err); } diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 590aded1441ab..52ccce4d0af77 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2022, MariaDB Corporation. +Copyright (c) 2016, 2023, 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 @@ -31,7 +31,6 @@ Created 4/20/1996 Heikki Tuuri #include "btr0btr.h" #include "btr0cur.h" #include "mach0data.h" -#include "ibuf0ibuf.h" #include "que0que.h" #include "row0upd.h" #include "row0sel.h" @@ -2683,7 +2682,6 @@ row_ins_clust_index_entry_low( } cursor = btr_pcur_get_btr_cur(&pcur); - cursor->thr = thr; #ifdef UNIV_DEBUG { @@ -2949,7 +2947,6 @@ row_ins_sec_index_entry_low( ut_ad(!dict_index_is_clust(index)); ut_ad(mode == BTR_MODIFY_LEAF || mode == BTR_INSERT_TREE); - cursor.thr = thr; cursor.rtr_info = NULL; cursor.page_cur.index = index; ut_ad(thr_get_trx(thr)->id != 0); @@ -2971,6 +2968,7 @@ row_ins_sec_index_entry_low( if (index->is_spatial()) { rtr_init_rtr_info(&rtr_info, false, &cursor, index, false); + rtr_info.thr = thr; rtr_info_update_btr(&cursor, &rtr_info); err = btr_cur_search_to_nth_level(0, entry, @@ -2984,6 +2982,7 @@ row_ins_sec_index_entry_low( rtr_clean_rtr_info(&rtr_info, true); rtr_init_rtr_info(&rtr_info, false, &cursor, index, false); + rtr_info.thr = thr; rtr_info_update_btr(&cursor, &rtr_info); mtr.start(); if (index->table->is_temporary()) { @@ -3001,14 +3000,6 @@ row_ins_sec_index_entry_low( goto func_exit;}); } else { - if (!index->table->is_temporary()) { - search_mode = btr_latch_mode( - search_mode - | (thr_get_trx(thr)->check_unique_secondary - ? BTR_INSERT | BTR_IGNORE_SEC_UNIQUE - : BTR_INSERT)); - } - err = btr_cur_search_to_nth_level(0, entry, PAGE_CUR_LE, search_mode, &cursor, &mtr); } @@ -3020,12 +3011,6 @@ row_ins_sec_index_entry_low( goto func_exit; } - if (cursor.flag == BTR_CUR_INSERT_TO_IBUF) { - ut_ad(!dict_index_is_spatial(index)); - /* The insert was buffered during the search: we are done */ - goto func_exit; - } - #ifdef UNIV_DEBUG { page_t* page = btr_cur_get_page(&cursor); @@ -3085,13 +3070,9 @@ row_ins_sec_index_entry_low( locked with s-locks the necessary records to prevent any insertion of a duplicate by another transaction. Let us now reposition the cursor and - continue the insertion (bypassing the change buffer). */ + continue the insertion. */ err = btr_cur_search_to_nth_level( - 0, entry, PAGE_CUR_LE, - btr_latch_mode(search_mode - & ~(BTR_INSERT - | BTR_IGNORE_SEC_UNIQUE)), - &cursor, &mtr); + 0, entry, PAGE_CUR_LE, search_mode, &cursor, &mtr); if (err != DB_SUCCESS) { goto func_exit; } @@ -3322,11 +3303,6 @@ row_ins_sec_index_entry( if (err == DB_FAIL) { mem_heap_empty(heap); - if (index->table->space == fil_system.sys_space - && !(index->type & (DICT_UNIQUE | DICT_SPATIAL))) { - ibuf_free_excess_pages(); - } - /* Try then pessimistic descent to the B-tree */ log_free_check(); diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index 64b4d02fa181c..958975804b23d 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -1701,22 +1701,6 @@ row_log_table_apply_delete_low( if (error) { goto err_exit; } -#ifdef UNIV_DEBUG - switch (btr_pcur_get_btr_cur(pcur)->flag) { - case BTR_CUR_DELETE_REF: - case BTR_CUR_DEL_MARK_IBUF: - case BTR_CUR_DELETE_IBUF: - case BTR_CUR_INSERT_TO_IBUF: - /* We did not request buffering. */ - break; - case BTR_CUR_HASH: - case BTR_CUR_HASH_FAIL: - case BTR_CUR_BINARY: - goto flag_ok; - } - ut_ad(0); -flag_ok: -#endif /* UNIV_DEBUG */ if (page_rec_is_infimum(btr_pcur_get_rec(pcur)) || btr_pcur_get_low_match(pcur) < index->n_uniq) { @@ -1724,8 +1708,8 @@ row_log_table_apply_delete_low( found, because new_table is being modified by this thread only, and all indexes should be updated in sync. */ - mtr->commit(); - return(DB_INDEX_CORRUPT); + error = DB_INDEX_CORRUPT; + goto err_exit; } btr_cur_pessimistic_delete(&error, FALSE, @@ -1785,22 +1769,6 @@ row_log_table_apply_delete( if (err != DB_SUCCESS) { goto all_done; } -#ifdef UNIV_DEBUG - switch (btr_pcur_get_btr_cur(&pcur)->flag) { - case BTR_CUR_DELETE_REF: - case BTR_CUR_DEL_MARK_IBUF: - case BTR_CUR_DELETE_IBUF: - case BTR_CUR_INSERT_TO_IBUF: - /* We did not request buffering. */ - break; - case BTR_CUR_HASH: - case BTR_CUR_HASH_FAIL: - case BTR_CUR_BINARY: - goto flag_ok; - } - ut_ad(0); -flag_ok: -#endif /* UNIV_DEBUG */ if (page_rec_is_infimum(btr_pcur_get_rec(&pcur)) || btr_pcur_get_low_match(&pcur) < index->n_uniq) { @@ -1934,19 +1902,6 @@ row_log_table_apply_update( return error; } -#ifdef UNIV_DEBUG - switch (btr_pcur_get_btr_cur(&pcur)->flag) { - case BTR_CUR_DELETE_REF: - case BTR_CUR_DEL_MARK_IBUF: - case BTR_CUR_DELETE_IBUF: - case BTR_CUR_INSERT_TO_IBUF: - ut_ad(0);/* We did not request buffering. */ - case BTR_CUR_HASH: - case BTR_CUR_HASH_FAIL: - case BTR_CUR_BINARY: - break; - } -#endif /* UNIV_DEBUG */ ut_ad(!page_rec_is_infimum(btr_pcur_get_rec(&pcur)) && btr_pcur_get_low_match(&pcur) >= index->n_uniq); @@ -2096,8 +2051,17 @@ row_log_table_apply_update( ut_free(pcur.old_rec_buf); pcur.old_rec_buf = nullptr; - if (ROW_FOUND != row_search_index_entry( - entry, BTR_MODIFY_TREE, &pcur, &mtr)) { + error = btr_pcur_open(entry, PAGE_CUR_LE, BTR_MODIFY_TREE, + &pcur, 0, &mtr); + + if (error != DB_SUCCESS) { + ut_ad(0); + break; + } + + if (btr_pcur_is_before_first_on_page(&pcur) + || btr_pcur_get_low_match(&pcur) + != dtuple_get_n_fields(entry)) { ut_ad(0); error = DB_CORRUPTION; break; diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 723b4b1d38766..d321546430690 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2227,7 +2227,7 @@ row_merge_read_clustered_index( next_page_no), old_table->space->zip_size(), RW_S_LATCH, nullptr, BUF_GET, &mtr, - &err, false); + &err); if (!block) { goto err_exit; } @@ -3715,8 +3715,6 @@ row_merge_mtuple_to_dtuple( dtuple_t* dtuple, const mtuple_t* mtuple) { - ut_ad(!dict_index_is_ibuf(index)); - memcpy(dtuple->fields, mtuple->fields, dtuple->n_fields * sizeof *mtuple->fields); } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 549d274522364..81879431096b9 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, 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 @@ -43,7 +43,6 @@ Created 9/17/2000 Heikki Tuuri #include "fsp0file.h" #include "fts0fts.h" #include "fts0types.h" -#include "ibuf0ibuf.h" #include "lock0lock.h" #include "log0log.h" #include "pars0pars.h" @@ -2334,12 +2333,7 @@ row_discard_tablespace( 2) Purge and rollback: we assign a new table id for the table. Since purge and rollback look for the table based on the table id, they see the table as 'dropped' and discard - their operations. - - 3) Insert buffer: we remove all entries for the tablespace in - the insert buffer tree. */ - - ibuf_delete_for_discarded_space(table->space_id); + their operations. */ table_id_t new_id; @@ -2442,9 +2436,8 @@ dberr_t row_discard_tablespace_for_mysql(dict_table_t *table, trx_t *trx) /* Note: The following cannot be rolled back. Rollback would see the UPDATE of SYS_INDEXES.TABLE_ID as two operations: DELETE and INSERT. It would invoke btr_free_if_exists() when rolling back the INSERT, - effectively dropping all indexes of the table. Furthermore, calls like - ibuf_delete_for_discarded_space() are already discarding data - before the transaction is committed. + effectively dropping all indexes of the table. Furthermore, we are + already discarding data before the transaction is committed. It would be better to remove the integrity-breaking ALTER TABLE...DISCARD TABLESPACE operation altogether. */ diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index df042f6652151..81b02fea8a3cc 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -273,10 +273,10 @@ not delete marked version of a clustered index record where DB_TRX_ID is newer than the purge view. NOTE: This function should only be called by the purge thread, only -while holding a latch on the leaf page of the secondary index entry -(or keeping the buffer pool watch on the page). It is possible that -this function first returns true and then false, if a user transaction -inserts a record that the secondary index entry would refer to. +while holding a latch on the leaf page of the secondary index entry. +It is possible that this function first returns true and then false, +if a user transaction inserts a record that the secondary index entry +would refer to. However, in that case, the user transaction would also re-insert the secondary index entry after purge has removed it and released the leaf page latch. @@ -292,6 +292,7 @@ page latch. @param[in] is_tree true=pessimistic purge, false=optimistic (leaf-page only) @return true if the secondary index record can be purged */ +static bool row_purge_poss_sec( purge_node_t* node, @@ -342,18 +343,14 @@ row_purge_remove_sec_if_poss_tree( ibool success = TRUE; dberr_t err; mtr_t mtr; - enum row_search_result search_result; log_free_check(); mtr.start(); index->set_modified(mtr); pcur.btr_cur.page_cur.index = index; - search_result = row_search_index_entry(entry, BTR_PURGE_TREE, - &pcur, &mtr); - - switch (search_result) { - case ROW_NOT_FOUND: + if (!row_search_index_entry(entry, BTR_PURGE_TREE, &pcur, + nullptr, &mtr)) { /* Not found. This is a legitimate condition. In a rollback, InnoDB will remove secondary recs that would be purged anyway. Then the actual purge will not find @@ -363,18 +360,7 @@ row_purge_remove_sec_if_poss_tree( index, it will remove it. Then if/when the purge comes to consider the secondary index record a second time, it will not exist any more in the index. */ - - /* fputs("PURGE:........sec entry not found\n", stderr); */ - /* dtuple_print(stderr, entry); */ goto func_exit; - case ROW_FOUND: - break; - case ROW_BUFFERED: - case ROW_NOT_DELETED_REF: - /* These are invalid outcomes, because the mode passed - to row_search_index_entry() did not include any of the - flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */ - ut_error; } /* We should remove the index record if no later version of the row, @@ -439,8 +425,6 @@ row_purge_remove_sec_if_poss_leaf( { mtr_t mtr; btr_pcur_t pcur; - enum btr_latch_mode mode; - enum row_search_result search_result; bool success = true; log_free_check(); @@ -449,31 +433,21 @@ row_purge_remove_sec_if_poss_leaf( mtr.start(); index->set_modified(mtr); - /* Change buffering is disabled for spatial index and - virtual index. */ - mode = (index->type & (DICT_SPATIAL | DICT_VIRTUAL)) - ? BTR_MODIFY_LEAF : BTR_PURGE_LEAF; + const auto mode = BTR_MODIFY_LEAF; pcur.btr_cur.page_cur.index = index; - /* Set the purge node for the call to row_purge_poss_sec(). */ - pcur.btr_cur.purge_node = node; + bool found; if (index->is_spatial()) { - pcur.btr_cur.thr = NULL; index->lock.u_lock(SRW_LOCK_CALL); - search_result = row_search_index_entry( - entry, mode, &pcur, &mtr); + found = !rtr_pcur_open(entry, mode, &pcur, nullptr, &mtr); index->lock.u_unlock(); } else { - /* Set the query thread, so that ibuf_insert_low() will be - able to invoke thd_get_trx(). */ - pcur.btr_cur.thr = static_cast( - que_node_get_parent(node)); - search_result = row_search_index_entry( - entry, mode, &pcur, &mtr); + found = btr_pcur_open(entry, PAGE_CUR_LE, mode, &pcur, 0, &mtr) + == DB_SUCCESS; } - switch (search_result) { - case ROW_FOUND: + if (found && !btr_pcur_is_before_first_on_page(&pcur) + && btr_pcur_get_low_match(&pcur) == dtuple_get_n_fields(entry)) { /* Before attempting to purge a record, check if it is safe to do so. */ if (row_purge_poss_sec(node, index, entry, &pcur, &mtr, false)) { @@ -501,25 +475,18 @@ row_purge_remove_sec_if_poss_leaf( if (index->is_spatial()) { const buf_block_t* block = btr_cur_get_block( btr_cur); + const page_id_t id{block->page.id()}; - if (block->page.id().page_no() - != index->page + if (id.page_no() != index->page && page_get_n_recs(block->page.frame) < 2 - && !lock_test_prdt_page_lock( - btr_cur->rtr_info - && btr_cur->rtr_info->thr - ? thr_get_trx( - btr_cur->rtr_info->thr) - : nullptr, - block->page.id())) { + && !lock_test_prdt_page_lock(nullptr, id)){ /* this is the last record on page, and it has a "page" lock on it, which mean search is still depending on it, so do not delete */ DBUG_LOG("purge", "skip purging last" - " record on page " - << block->page.id()); + " record on page " << id); goto func_exit; } } @@ -527,25 +494,13 @@ row_purge_remove_sec_if_poss_leaf( success = btr_cur_optimistic_delete(btr_cur, 0, &mtr) != DB_FAIL; } + } - /* (The index entry is still needed, - or the deletion succeeded) */ - /* fall through */ - case ROW_NOT_DELETED_REF: - /* The index entry is still needed. */ - case ROW_BUFFERED: - /* The deletion was buffered. */ - case ROW_NOT_FOUND: - /* The index entry does not exist, nothing to do. */ func_exit: - mtr.commit(); + mtr.commit(); cleanup: - btr_pcur_close(&pcur); // FIXME: do we need these? when is btr_cur->rtr_info set? - return(success); - } - - ut_error; - return(false); + btr_pcur_close(&pcur); + return success; } /***********************************************************//** @@ -598,10 +553,7 @@ Purges a delete marking of a record. @retval false the purge needs to be suspended because of running out of file space */ static MY_ATTRIBUTE((nonnull, warn_unused_result)) -bool -row_purge_del_mark( -/*===============*/ - purge_node_t* node) /*!< in/out: row purge node */ +bool row_purge_del_mark(purge_node_t *node) { if (node->index) { diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc index a4d634f2d140c..059aee6f14029 100644 --- a/storage/innobase/row/row0quiesce.cc +++ b/storage/innobase/row/row0quiesce.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2021, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -26,7 +26,6 @@ Created 2012-02-08 by Sunny Bains. #include "row0quiesce.h" #include "row0mysql.h" -#include "ibuf0ibuf.h" #include "srv0start.h" #include "trx0purge.h" @@ -533,18 +532,6 @@ row_quiesce_table_start( purge_sys.stop(); } - for (ulint count = 0; - ibuf_merge_space(table->space_id); - ++count) { - if (trx_is_interrupted(trx)) { - goto aborted; - } - if (!(count % 20)) { - ib::info() << "Merging change buffer entries for " - << table->name; - } - } - while (buf_flush_list_space(table->space)) { if (trx_is_interrupted(trx)) { goto aborted; diff --git a/storage/innobase/row/row0row.cc b/storage/innobase/row/row0row.cc index b998d27d83646..616423e8a2147 100644 --- a/storage/innobase/row/row0row.cc +++ b/storage/innobase/row/row0row.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, 2022, MariaDB Corporation. +Copyright (c) 2018, 2023, 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 @@ -215,28 +215,20 @@ row_build_index_entry_low( entry = dtuple_create(heap, entry_len); } - if (dict_index_is_ibuf(index)) { - dtuple_set_n_fields_cmp(entry, entry_len); - /* There may only be externally stored columns - in a clustered index B-tree of a user table. */ - ut_a(!ext); - } else { - dtuple_set_n_fields_cmp( - entry, dict_index_get_n_unique_in_tree(index)); - if (dict_index_is_spatial(index)) { - /* Set the MBR field */ - if (!row_build_spatial_index_key( - index, ext, - dtuple_get_nth_field(entry, 0), - dtuple_get_nth_field( - row, - dict_index_get_nth_field(index, i) - ->col->ind), flag, heap)) { - return NULL; - } - - i = 1; + dtuple_set_n_fields_cmp(entry, dict_index_get_n_unique_in_tree(index)); + if (index->is_spatial()) { + /* Set the MBR field */ + if (!row_build_spatial_index_key( + index, ext, + dtuple_get_nth_field(entry, 0), + dtuple_get_nth_field( + row, + dict_index_get_nth_field(index, i) + ->col->ind), flag, heap)) { + return NULL; } + + i = 1; } for (; i < entry_len; i++) { @@ -1262,65 +1254,32 @@ row_get_clust_rec( /***************************************************************//** Searches an index record. -@return whether the record was found or buffered */ -enum row_search_result +@return whether the record was found */ +bool row_search_index_entry( /*===================*/ const dtuple_t* entry, /*!< in: index entry */ btr_latch_mode mode, /*!< in: BTR_MODIFY_LEAF, ... */ btr_pcur_t* pcur, /*!< in/out: persistent cursor, which must be closed by the caller */ + que_thr_t* thr, /*!< in/out: query thread */ mtr_t* mtr) /*!< in: mtr */ { - ulint n_fields; - ulint low_match; - rec_t* rec; - ut_ad(dtuple_check_typed(entry)); if (pcur->index()->is_spatial()) { - if (rtr_pcur_open(pcur->index(), entry, mode, pcur, mtr)) { - return ROW_NOT_FOUND; + if (rtr_pcur_open(entry, mode, pcur, thr, mtr)) { + return false; } } else { if (btr_pcur_open(entry, PAGE_CUR_LE, mode, pcur, 0, mtr) != DB_SUCCESS) { - return ROW_NOT_FOUND; + return false; } } - switch (btr_pcur_get_btr_cur(pcur)->flag) { - case BTR_CUR_DELETE_REF: - ut_ad(!(~mode & BTR_DELETE)); - ut_ad(!pcur->index()->is_spatial()); - return(ROW_NOT_DELETED_REF); - - case BTR_CUR_DEL_MARK_IBUF: - case BTR_CUR_DELETE_IBUF: - case BTR_CUR_INSERT_TO_IBUF: - return(ROW_BUFFERED); - - case BTR_CUR_HASH: - case BTR_CUR_HASH_FAIL: - case BTR_CUR_BINARY: - break; - } - - low_match = btr_pcur_get_low_match(pcur); - - rec = btr_pcur_get_rec(pcur); - - n_fields = dtuple_get_n_fields(entry); - - if (page_rec_is_infimum(rec)) { - - return(ROW_NOT_FOUND); - } else if (low_match != n_fields) { - - return(ROW_NOT_FOUND); - } - - return(ROW_FOUND); + return !btr_pcur_is_before_first_on_page(pcur) + && btr_pcur_get_low_match(pcur) == dtuple_get_n_fields(entry); } /*******************************************************************//** diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 9d7259ba20c95..5f5c6fe6c44dd 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -2,7 +2,7 @@ Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2015, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -4768,14 +4768,13 @@ row_search_mvcc( } } else if (dtuple_get_n_fields(search_tuple) > 0) { - pcur->btr_cur.thr = thr; pcur->old_rec = nullptr; if (dict_index_is_spatial(index)) { if (!prebuilt->rtr_info) { prebuilt->rtr_info = rtr_create_rtr_info( - set_also_gap_locks, true, - btr_pcur_get_btr_cur(pcur), index); + set_also_gap_locks, true, thr, + btr_pcur_get_btr_cur(pcur)); prebuilt->rtr_info->search_tuple = search_tuple; prebuilt->rtr_info->search_mode = mode; rtr_info_update_btr(btr_pcur_get_btr_cur(pcur), diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index 6567019a33d12..3e20503d39c37 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -40,7 +40,6 @@ Created 2/25/1997 Heikki Tuuri #include "row0row.h" #include "row0upd.h" #include "que0que.h" -#include "ibuf0ibuf.h" #include "log0log.h" #include "fil0fil.h" #include @@ -266,7 +265,7 @@ row_undo_ins_remove_sec_low( const bool modify_leaf = mode == BTR_MODIFY_LEAF; pcur.btr_cur.page_cur.index = index; - row_mtr_start(&mtr, index, !modify_leaf); + row_mtr_start(&mtr, index); if (modify_leaf) { mode = BTR_MODIFY_LEAF_ALREADY_LATCHED; @@ -282,19 +281,9 @@ row_undo_ins_remove_sec_low( | BTR_RTREE_DELETE_MARK | BTR_RTREE_UNDO_INS) : btr_latch_mode(BTR_PURGE_TREE | BTR_RTREE_UNDO_INS); - btr_pcur_get_btr_cur(&pcur)->thr = thr; } - switch (row_search_index_entry(entry, mode, &pcur, &mtr)) { - case ROW_BUFFERED: - case ROW_NOT_DELETED_REF: - /* These are invalid outcomes, because the mode passed - to row_search_index_entry() did not include any of the - flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */ - ut_error; - case ROW_NOT_FOUND: - break; - case ROW_FOUND: + if (row_search_index_entry(entry, mode, &pcur, thr, &mtr)) { if (dict_index_is_spatial(index) && rec_get_deleted_flag( btr_pcur_get_rec(&pcur), diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index 2d04dca400352..2eadb05eccc62 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -33,7 +33,6 @@ Created 2/27/1997 Heikki Tuuri #include "trx0purge.h" #include "btr0btr.h" #include "mach0data.h" -#include "ibuf0ibuf.h" #include "row0undo.h" #include "row0vers.h" #include "trx0trx.h" @@ -490,10 +489,9 @@ row_undo_mod_del_mark_or_remove_sec_low( dberr_t err = DB_SUCCESS; mtr_t mtr; mtr_t mtr_vers; - row_search_result search_result; const bool modify_leaf = mode == BTR_MODIFY_LEAF; - row_mtr_start(&mtr, index, !modify_leaf); + row_mtr_start(&mtr, index); pcur.btr_cur.page_cur.index = index; btr_cur = btr_pcur_get_btr_cur(&pcur); @@ -504,7 +502,6 @@ row_undo_mod_del_mark_or_remove_sec_low( | BTR_RTREE_DELETE_MARK | BTR_RTREE_UNDO_INS) : btr_latch_mode(BTR_PURGE_TREE | BTR_RTREE_UNDO_INS); - btr_cur->thr = thr; } else if (!index->is_committed()) { /* The index->online_status may change if the index is or was being created online, but not committed yet. It @@ -523,10 +520,7 @@ row_undo_mod_del_mark_or_remove_sec_low( ut_ad(!dict_index_is_online_ddl(index)); } - search_result = row_search_index_entry(entry, mode, &pcur, &mtr); - - switch (UNIV_EXPECT(search_result, ROW_FOUND)) { - case ROW_NOT_FOUND: + if (!row_search_index_entry(entry, mode, &pcur, thr, &mtr)) { /* In crash recovery, the secondary index record may be missing if the UPDATE did not have time to insert the secondary index records before the crash. When we @@ -537,14 +531,6 @@ row_undo_mod_del_mark_or_remove_sec_low( before it has inserted all updated secondary index records, then the undo will not find those records. */ goto func_exit; - case ROW_FOUND: - break; - case ROW_BUFFERED: - case ROW_NOT_DELETED_REF: - /* These are invalid outcomes, because the mode passed - to row_search_index_entry() did not include any of the - flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */ - ut_error; } /* We should remove the index record if no prior version of the row, @@ -665,7 +651,6 @@ row_undo_mod_del_unmark_sec_and_undo_update( trx_t* trx = thr_get_trx(thr); const ulint flags = BTR_KEEP_SYS_FLAG | BTR_NO_LOCKING_FLAG; - row_search_result search_result; const auto orig_mode = mode; pcur.btr_cur.page_cur.index = index; @@ -682,23 +667,12 @@ row_undo_mod_del_unmark_sec_and_undo_update( } try_again: - row_mtr_start(&mtr, index, mode & 8); - - btr_cur->thr = thr; + row_mtr_start(&mtr, index); - search_result = row_search_index_entry(entry, mode, &pcur, &mtr); + mem_heap_t* offsets_heap = nullptr; + rec_offs* offsets = nullptr; - switch (search_result) { - mem_heap_t* heap; - mem_heap_t* offsets_heap; - rec_offs* offsets; - case ROW_BUFFERED: - case ROW_NOT_DELETED_REF: - /* These are invalid outcomes, because the mode passed - to row_search_index_entry() did not include any of the - flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */ - ut_error; - case ROW_NOT_FOUND: + if (!row_search_index_entry(entry, mode, &pcur, thr, &mtr)) { /* For spatial index, if first search didn't find an undel-marked rec, try to find a del-marked rec. */ if (dict_index_is_spatial(index) && btr_cur->rtr_info->fd_del) { @@ -720,7 +694,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( << " at: " << rec_index_print( btr_cur_get_rec(btr_cur), index); err = DB_DUPLICATE_KEY; - break; + goto func_exit; } ib::warn() << "Record in index " << index->name @@ -734,8 +708,6 @@ row_undo_mod_del_unmark_sec_and_undo_update( delete-unmark. */ big_rec_t* big_rec; rec_t* insert_rec; - offsets = NULL; - offsets_heap = NULL; err = btr_cur_optimistic_insert( flags, btr_cur, &offsets, &offsets_heap, @@ -764,15 +736,13 @@ row_undo_mod_del_unmark_sec_and_undo_update( if (offsets_heap) { mem_heap_free(offsets_heap); } - - break; - case ROW_FOUND: + } else { + mem_heap_t* heap; btr_rec_set_deleted(btr_cur_get_block(btr_cur), btr_cur_get_rec(btr_cur), &mtr); heap = mem_heap_create( sizeof(upd_t) + dtuple_get_n_fields(entry) * sizeof(upd_field_t)); - offsets_heap = NULL; offsets = rec_get_offsets( btr_cur_get_rec(btr_cur), index, nullptr, index->n_core_fields, ULINT_UNDEFINED, @@ -811,6 +781,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( mem_heap_free(offsets_heap); } +func_exit: btr_pcur_close(&pcur); mtr_commit(&mtr); diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index a3f940adff5ef..3cdc8d1cfb9cc 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, 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 @@ -1842,7 +1842,6 @@ row_upd_sec_index_entry( trx_t* trx = thr_get_trx(thr); btr_latch_mode mode; ulint flags; - enum row_search_result search_result; ut_ad(trx->id != 0); @@ -1884,41 +1883,29 @@ row_upd_sec_index_entry( default: index->set_modified(mtr); /* fall through */ - case IBUF_SPACE_ID: + case 0: flags = index->table->no_rollback() ? BTR_NO_ROLLBACK : 0; /* We can only buffer delete-mark operations if there are no foreign key constraints referring to the index. */ mode = index->is_spatial() ? btr_latch_mode(BTR_MODIFY_LEAF | BTR_RTREE_DELETE_MARK) - : referenced - ? BTR_MODIFY_LEAF : BTR_DELETE_MARK_LEAF; + : BTR_MODIFY_LEAF; break; } - /* Set the query thread, so that ibuf_insert_low() will be - able to invoke thd_get_trx(). */ - btr_pcur_get_btr_cur(&pcur)->thr = thr; pcur.btr_cur.page_cur.index = index; - search_result = row_search_index_entry(entry, mode, &pcur, &mtr); + bool found = row_search_index_entry(entry, mode, &pcur, thr, &mtr); btr_cur = btr_pcur_get_btr_cur(&pcur); rec = btr_cur_get_rec(btr_cur); - switch (search_result) { - case ROW_NOT_DELETED_REF: /* should only occur for BTR_DELETE */ - ut_error; - break; - case ROW_BUFFERED: - /* Entry was delete marked already. */ - break; - - case ROW_NOT_FOUND: + if (!found) { if (dict_index_is_spatial(index) && btr_cur->rtr_info->fd_del) { /* We found the record, but a delete marked */ - break; + goto done; } ib::error() @@ -1932,8 +1919,7 @@ row_upd_sec_index_entry( ut_ad(btr_validate_index(index, 0) == DB_SUCCESS); ut_ad(0); #endif /* UNIV_DEBUG */ - break; - case ROW_FOUND: + } else { ut_ad(err == DB_SUCCESS); /* Delete mark the old index record; it can already be @@ -1946,7 +1932,7 @@ row_upd_sec_index_entry( btr_cur_get_block(btr_cur), btr_cur_get_rec(btr_cur), index, thr, &mtr); if (err != DB_SUCCESS) { - break; + goto done; } btr_rec_set_deleted(btr_cur_get_block(btr_cur), @@ -2009,6 +1995,7 @@ row_upd_sec_index_entry( } } +done: btr_pcur_close(&pcur); mtr_commit(&mtr); diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index f362708093a85..f277ec4ec95b2 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -2,7 +2,7 @@ Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, 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 @@ -27,7 +27,6 @@ Created 12/9/2009 Jimmy Yang #include "buf0buf.h" #include "dict0mem.h" -#include "ibuf0ibuf.h" #include "lock0lock.h" #include "mach0data.h" #include "os0file.h" @@ -527,23 +526,10 @@ static monitor_info_t innodb_counter_info[] = MONITOR_BUF_PAGE_READ("index_non_leaf","Index Non-leaf", INDEX_NON_LEAF), - MONITOR_BUF_PAGE_READ("index_ibuf_leaf", "Insert Buffer Index Leaf", - INDEX_IBUF_LEAF), - - MONITOR_BUF_PAGE_READ("index_ibuf_non_leaf", - "Insert Buffer Index Non-Leaf", - INDEX_IBUF_NON_LEAF), - MONITOR_BUF_PAGE_READ("undo_log", "Undo Log", UNDO_LOG), MONITOR_BUF_PAGE_READ("index_inode", "Index Inode", INODE), - MONITOR_BUF_PAGE_READ("ibuf_free_list", "Insert Buffer Free List", - IBUF_FREELIST), - - MONITOR_BUF_PAGE_READ("ibuf_bitmap", "Insert Buffer Bitmap", - IBUF_BITMAP), - MONITOR_BUF_PAGE_READ("system_page", "System", SYSTEM), MONITOR_BUF_PAGE_READ("trx_system", "Transaction System", TRX_SYSTEM), @@ -566,23 +552,10 @@ static monitor_info_t innodb_counter_info[] = MONITOR_BUF_PAGE_WRITTEN("index_non_leaf","Index Non-leaf", INDEX_NON_LEAF), - MONITOR_BUF_PAGE_WRITTEN("index_ibuf_leaf", "Insert Buffer Index Leaf", - INDEX_IBUF_LEAF), - - MONITOR_BUF_PAGE_WRITTEN("index_ibuf_non_leaf", - "Insert Buffer Index Non-Leaf", - INDEX_IBUF_NON_LEAF), - MONITOR_BUF_PAGE_WRITTEN("undo_log", "Undo Log", UNDO_LOG), MONITOR_BUF_PAGE_WRITTEN("index_inode", "Index Inode", INODE), - MONITOR_BUF_PAGE_WRITTEN("ibuf_free_list", "Insert Buffer Free List", - IBUF_FREELIST), - - MONITOR_BUF_PAGE_WRITTEN("ibuf_bitmap", "Insert Buffer Bitmap", - IBUF_BITMAP), - MONITOR_BUF_PAGE_WRITTEN("system_page", "System", SYSTEM), MONITOR_BUF_PAGE_WRITTEN("trx_system", "Transaction System", @@ -948,57 +921,6 @@ static monitor_info_t innodb_counter_info[] = MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT | MONITOR_DEFAULT_ON), MONITOR_DEFAULT_START, MONITOR_OVLD_N_FILE_OPENED}, - /* ========== Counters for Change Buffer ========== */ - {"module_ibuf_system", "change_buffer", "InnoDB Change Buffer", - MONITOR_MODULE, - MONITOR_DEFAULT_START, MONITOR_MODULE_IBUF_SYSTEM}, - - {"ibuf_merges_insert", "change_buffer", - "Number of inserted records merged by change buffering", - static_cast( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_INSERT}, - - {"ibuf_merges_delete_mark", "change_buffer", - "Number of deleted records merged by change buffering", - static_cast( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_DELETE}, - - {"ibuf_merges_delete", "change_buffer", - "Number of purge records merged by change buffering", - static_cast( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_PURGE}, - - {"ibuf_merges_discard_insert", "change_buffer", - "Number of insert merged operations discarded", - static_cast( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_DISCARD_INSERT}, - - {"ibuf_merges_discard_delete_mark", "change_buffer", - "Number of deleted merged operations discarded", - static_cast( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_DISCARD_DELETE}, - - {"ibuf_merges_discard_delete", "change_buffer", - "Number of purge merged operations discarded", - static_cast( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_DISCARD_PURGE}, - - {"ibuf_merges", "change_buffer", "Number of change buffer merges", - static_cast( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGES}, - - {"ibuf_size", "change_buffer", "Change buffer size in pages", - static_cast( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_SIZE}, - /* ========== Counters for server operations ========== */ {"module_innodb", "innodb", "Counter for general InnoDB server wide operations and properties", @@ -1529,38 +1451,6 @@ srv_mon_process_existing_counter( value = fil_system.n_open; break; - case MONITOR_OVLD_IBUF_MERGE_INSERT: - value = ibuf.n_merged_ops[IBUF_OP_INSERT]; - break; - - case MONITOR_OVLD_IBUF_MERGE_DELETE: - value = ibuf.n_merged_ops[IBUF_OP_DELETE_MARK]; - break; - - case MONITOR_OVLD_IBUF_MERGE_PURGE: - value = ibuf.n_merged_ops[IBUF_OP_DELETE]; - break; - - case MONITOR_OVLD_IBUF_MERGE_DISCARD_INSERT: - value = ibuf.n_discarded_ops[IBUF_OP_INSERT]; - break; - - case MONITOR_OVLD_IBUF_MERGE_DISCARD_DELETE: - value = ibuf.n_discarded_ops[IBUF_OP_DELETE_MARK]; - break; - - case MONITOR_OVLD_IBUF_MERGE_DISCARD_PURGE: - value = ibuf.n_discarded_ops[IBUF_OP_DELETE]; - break; - - case MONITOR_OVLD_IBUF_MERGES: - value = ibuf.n_merges; - break; - - case MONITOR_OVLD_IBUF_SIZE: - value = ibuf.size; - break; - case MONITOR_OVLD_SERVER_ACTIVITY: value = srv_get_activity_count(); break; diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 02c7367cc937f..7c4e5a0d8906c 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -3,7 +3,7 @@ Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -48,7 +48,6 @@ Created 10/8/1995 Heikki Tuuri #include "buf0lru.h" #include "dict0boot.h" #include "dict0load.h" -#include "ibuf0ibuf.h" #include "lock0lock.h" #include "log0recv.h" #include "mem0mem.h" @@ -126,9 +125,9 @@ my_bool srv_read_only_mode; /** store to its own file each table created by an user; data dictionary tables are in the system tablespace 0 */ my_bool srv_file_per_table; -/** Set if InnoDB operates in read-only mode or innodb-force-recovery -is greater than SRV_FORCE_NO_TRX_UNDO. */ -my_bool high_level_read_only; +/** Set if innodb_read_only is set or innodb_force_recovery +is SRV_FORCE_NO_UNDO_LOG_SCAN or greater. */ +bool high_level_read_only; /** Sort buffer size in index creation */ ulong srv_sort_buf_size; @@ -279,7 +278,7 @@ my_bool srv_print_all_deadlocks; INFORMATION_SCHEMA.innodb_cmp_per_index */ my_bool srv_cmp_per_index_enabled; -/** innodb_fast_shutdown=1 skips purge and change buffer merge. +/** innodb_fast_shutdown=1 skips the purge of transaction history. innodb_fast_shutdown=2 effectively crashes the server (no log checkpoint). innodb_fast_shutdown=3 is a clean shutdown that skips the rollback of active transaction (to be done on restart). */ @@ -381,8 +380,6 @@ FILE* srv_misc_tmpfile; ulint srv_main_active_loops; /** Iterations of the loop bounded by the 'srv_idle' label. */ ulint srv_main_idle_loops; -/** Iterations of the loop bounded by the 'srv_shutdown' label. */ -static ulint srv_main_shutdown_loops; /** Log writes involving flush. */ ulint srv_log_writes_and_flush; @@ -577,10 +574,9 @@ srv_print_master_thread_info( FILE *file) /* in: output stream */ { fprintf(file, "srv_master_thread loops: " ULINTPF " srv_active, " - ULINTPF " srv_shutdown, " ULINTPF " srv_idle\n" + ULINTPF " srv_idle\n" "srv_master_thread log flush and writes: " ULINTPF "\n", srv_main_active_loops, - srv_main_shutdown_loops, srv_main_idle_loops, srv_log_writes_and_flush); } @@ -798,8 +794,6 @@ srv_printf_innodb_monitor( "--------\n", file); os_aio_print(file); - ibuf_print(file); - #ifdef BTR_CUR_HASH_ADAPT if (btr_search_enabled) { fputs("-------------------\n" @@ -1340,31 +1334,6 @@ static void srv_sync_log_buffer_in_background() } } -/** Report progress during shutdown. -@param last time of last output -@param n_read number of page reads initiated for change buffer merge */ -static void srv_shutdown_print(time_t &last, ulint n_read) -{ - time_t now= time(nullptr); - if (now - last >= 15) - { - last= now; - - const ulint ibuf_size= ibuf.size; - sql_print_information("Completing change buffer merge;" - " %zu page reads initiated;" - " %zu change buffer pages remain", - n_read, ibuf_size); -#if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY - service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, - "Completing change buffer merge;" - " %zu page reads initiated;" - " %zu change buffer pages remain", - n_read, ibuf_size); -#endif - } -} - /** Perform periodic tasks whenever the server is active. @param counter_time microsecond_interval_timer() */ static void srv_master_do_active_tasks(ulonglong counter_time) @@ -1402,32 +1371,6 @@ static void srv_master_do_idle_tasks(ulonglong counter_time) MONITOR_SRV_DICT_LRU_MICROSECOND, counter_time); } -/** -Complete the shutdown tasks such as background DROP TABLE, -and optionally change buffer merge (on innodb_fast_shutdown=0). */ -void srv_shutdown(bool ibuf_merge) -{ - ulint n_read = 0; - time_t now = time(NULL); - - do { - ut_ad(!srv_read_only_mode); - ut_ad(srv_shutdown_state == SRV_SHUTDOWN_CLEANUP); - ++srv_main_shutdown_loops; - - if (ibuf_merge) { - srv_main_thread_op_info = "doing insert buffer merge"; - /* Disallow the use of change buffer to - avoid a race condition with - ibuf_read_merge_pages() */ - ibuf_max_size_update(0); - log_free_check(); - n_read = ibuf_contract(); - srv_shutdown_print(now, n_read); - } - } while (n_read); -} - /** The periodic master task controlling the server. */ void srv_master_callback(void*) { diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 83571939d1be3..75116a0201a72 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -3,7 +3,7 @@ Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2009, Percona Inc. -Copyright (c) 2013, 2022, MariaDB Corporation. +Copyright (c) 2013, 2023, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -69,7 +69,6 @@ Created 2/16/1996 Heikki Tuuri #include "btr0btr.h" #include "btr0cur.h" #include "rem0rec.h" -#include "ibuf0ibuf.h" #include "srv0start.h" #include "srv0srv.h" #include "btr0defragment.h" @@ -95,6 +94,7 @@ Created 2/16/1996 Heikki Tuuri #include "row0row.h" #include "row0mysql.h" #include "btr0pcur.h" +#include "ibuf0ibuf.h" #include "zlib.h" #include "log.h" @@ -1021,7 +1021,7 @@ srv_init_abort_low( /** Prepare to delete the redo log file. Flush the dirty pages from all the buffer pools. Flush the redo log buffer to the redo log file. @return lsn upto which data pages have been flushed. */ -static lsn_t srv_prepare_to_delete_redo_log_file() +ATTRIBUTE_COLD static lsn_t srv_prepare_to_delete_redo_log_file() { DBUG_ENTER("srv_prepare_to_delete_redo_log_file"); @@ -1090,6 +1090,67 @@ static lsn_t srv_prepare_to_delete_redo_log_file() DBUG_RETURN(flushed_lsn); } +/** Upgrade the redo log to the latest format, or change its size +or encryption, before starting to write any log records. */ +ATTRIBUTE_COLD static dberr_t srv_log_rebuild() +{ + /* Prepare to delete the old redo log file */ + const lsn_t lsn{srv_prepare_to_delete_redo_log_file()}; + + DBUG_EXECUTE_IF("innodb_log_abort_1", return DB_ERROR;); + /* Prohibit redo log writes from any other threads until creating a + log checkpoint at the end of create_log_file(). */ + ut_d(recv_no_log_write= true); + DBUG_ASSERT(!buf_pool.any_io_pending()); + + /* Close the redo log file, so that we can replace it */ + log_sys.close_file(); + + DBUG_EXECUTE_IF("innodb_log_abort_5", return DB_ERROR;); + + dberr_t err= create_log_file(false, lsn); + + if (err == DB_SUCCESS && log_sys.resize_rename()) + err = DB_ERROR; + + return err; +} + +/** Rebuild the redo log if needed. */ +static dberr_t srv_log_rebuild_if_needed() +{ + if (srv_force_recovery == SRV_FORCE_NO_LOG_REDO) + /* Completely ignore the redo log. */ + return DB_SUCCESS; + if (srv_read_only_mode) + /* Leave the redo log alone. */ + return DB_SUCCESS; + + if (log_sys.file_size == srv_log_file_size && + log_sys.format == + (srv_encrypt_log ? log_t::FORMAT_ENC_10_8 : log_t::FORMAT_10_8)) + { + /* No need to add or remove encryption, upgrade, or resize. */ + delete_log_files(); + return DB_SUCCESS; + } + + return srv_log_rebuild(); +} + +ATTRIBUTE_COLD static dberr_t ibuf_log_rebuild_if_needed() +{ + mysql_mutex_lock(&recv_sys.mutex); + recv_sys.apply(true); + mysql_mutex_unlock(&recv_sys.mutex); + + if (recv_sys.is_corrupt_log() || recv_sys.is_corrupt_fs()) + return DB_CORRUPTION; + + recv_sys.debug_free(); + return srv_log_rebuild_if_needed(); +} + static tpool::task_group rollback_all_recovered_group(1); static tpool::task rollback_all_recovered_task(trx_rollback_all_recovered, nullptr, @@ -1128,10 +1189,6 @@ dberr_t srv_start(bool create_new_db) ib::info() << "!!!!!!!! UNIV_DEBUG switched on !!!!!!!!!"; #endif -#ifdef UNIV_IBUF_DEBUG - ib::info() << "!!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!"; -#endif - ib::info() << "Compressed tables use zlib " ZLIB_VERSION #ifdef UNIV_ZIP_DEBUG " with validation" @@ -1227,11 +1284,6 @@ dberr_t srv_start(bool create_new_db) return(srv_init_abort(err)); } - if (srv_read_only_mode) { - ib::info() << "Disabling background log and ibuf IO write" - << " threads."; - } - if (os_aio_init()) { ib::error() << "Cannot initialize AIO sub-system"; @@ -1377,31 +1429,41 @@ dberr_t srv_start(bool create_new_db) if (create_new_db) { ut_ad(!srv_read_only_mode); - mtr_start(&mtr); + mtr.start(); ut_ad(fil_system.sys_space->id == 0); compile_time_assert(TRX_SYS_SPACE == 0); - compile_time_assert(IBUF_SPACE_ID == 0); - ut_a(fsp_header_init(fil_system.sys_space, - uint32_t(sum_of_new_sizes), &mtr) - == DB_SUCCESS); - - ulint ibuf_root = btr_create( - DICT_CLUSTERED | DICT_IBUF, fil_system.sys_space, - DICT_IBUF_ID_MIN, nullptr, &mtr, &err); - - mtr_commit(&mtr); - - if (ibuf_root == FIL_NULL) { - return srv_init_abort(err); + err = fsp_header_init(fil_system.sys_space, + uint32_t(sum_of_new_sizes), &mtr); + /* Allocate dummy change buffer pages for backward + compatibility and to prevent a downgrade. */ + if (err != DB_SUCCESS) { + } else if (buf_block_t *b = + fseg_create(fil_system.sys_space, PAGE_DATA, &mtr, + &err)) { + ut_ad(b->page.id() + == page_id_t(0, FSP_IBUF_HEADER_PAGE_NO)); + b = fseg_alloc_free_page_general( + b->page.frame + PAGE_DATA, + FSP_IBUF_TREE_ROOT_PAGE_NO, FSP_UP, false, + &mtr, &mtr, &err); + if (b) { + ut_ad(b->page.id() == page_id_t + (0, FSP_IBUF_TREE_ROOT_PAGE_NO)); + mtr.set_modified(*b); + fsp_init_file_page(fil_system.sys_space, b, + &mtr); + } else { + ut_ad(err != DB_SUCCESS); + } } - - ut_ad(ibuf_root == IBUF_TREE_ROOT_PAGE_NO); - /* To maintain backward compatibility we create only the first rollback segment before the double write buffer. All the remaining rollback segments will be created later, after the double write buffer has been created. */ - err = trx_sys_create_sys_pages(&mtr); + if (err == DB_SUCCESS) { + err = trx_sys_create_sys_pages(&mtr); + } + mtr.commit(); if (err != DB_SUCCESS) { return(srv_init_abort(err)); @@ -1435,38 +1497,58 @@ dberr_t srv_start(bool create_new_db) recv_sys.dblwr.pages.clear(); - if (err != DB_SUCCESS) { - return(srv_init_abort(err)); - } + bool must_upgrade_ibuf = false; switch (srv_operation) { case SRV_OPERATION_NORMAL: case SRV_OPERATION_RESTORE_EXPORT: - /* Initialize the change buffer. */ - err = dict_boot(); if (err != DB_SUCCESS) { - return(srv_init_abort(err)); + break; + } + + err = ibuf_upgrade_needed(); + + if (UNIV_UNLIKELY(err == DB_FAIL)) { + must_upgrade_ibuf = true; + err = ibuf_log_rebuild_if_needed(); } + + if (err != DB_SUCCESS) { + break; + } + + err = dict_boot(); /* fall through */ case SRV_OPERATION_RESTORE: - /* This must precede recv_sys.apply(true). */ + if (err != DB_SUCCESS) { + break; + } + srv_undo_tablespaces_active = trx_rseg_get_n_undo_tablespaces(); if (srv_operation != SRV_OPERATION_RESTORE) { dict_sys.load_sys_tables(); } - err = trx_lists_init_at_db_start(); - if (err != DB_SUCCESS) { - return srv_init_abort(err); + + if (UNIV_UNLIKELY(must_upgrade_ibuf)) { + dict_load_tablespaces(); + err = ibuf_upgrade(); + if (err != DB_SUCCESS) { + break; + } } + + err = trx_lists_init_at_db_start(); break; - case SRV_OPERATION_RESTORE_DELTA: - case SRV_OPERATION_BACKUP: - case SRV_OPERATION_BACKUP_NO_DEFER: + default: ut_ad("wrong mariabackup mode" == 0); } + if (err != DB_SUCCESS) { + return srv_init_abort(err); + } + if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) { /* Apply the hashed log records to the respective file pages, for the last batch of @@ -1586,47 +1668,10 @@ dberr_t srv_start(bool create_new_db) /* Upgrade or resize or rebuild the redo logs before generating any dirty pages, so that the old redo log file will not be written to. */ + err = srv_log_rebuild_if_needed(); - if (srv_force_recovery == SRV_FORCE_NO_LOG_REDO) { - /* Completely ignore the redo log. */ - } else if (srv_read_only_mode) { - /* Leave the redo log alone. */ - } else if (log_sys.file_size == srv_log_file_size - && log_sys.format - == (srv_encrypt_log - ? log_t::FORMAT_ENC_10_8 - : log_t::FORMAT_10_8)) { - /* No need to add or remove encryption, - upgrade, or resize. */ - delete_log_files(); - } else { - /* Prepare to delete the old redo log file */ - const lsn_t lsn{srv_prepare_to_delete_redo_log_file()}; - - DBUG_EXECUTE_IF("innodb_log_abort_1", - return(srv_init_abort(DB_ERROR));); - /* Prohibit redo log writes from any other - threads until creating a log checkpoint at the - end of create_log_file(). */ - ut_d(recv_no_log_write = true); - DBUG_ASSERT(!buf_pool.any_io_pending()); - - /* Close the redo log file, so that we can replace it */ - log_sys.close_file(); - - DBUG_EXECUTE_IF("innodb_log_abort_5", - return(srv_init_abort(DB_ERROR));); - DBUG_PRINT("ib_log", ("After innodb_log_abort_5")); - - err = create_log_file(false, lsn); - - if (err == DB_SUCCESS && log_sys.resize_rename()) { - err = DB_ERROR; - } - - if (err != DB_SUCCESS) { - return(srv_init_abort(err)); - } + if (err != DB_SUCCESS) { + return(srv_init_abort(err)); } } @@ -1678,8 +1723,7 @@ dberr_t srv_start(bool create_new_db) /* Bitmap page types will be reset in buf_dblwr_check_block() without redo logging. */ block = buf_page_get( - page_id_t(IBUF_SPACE_ID, - FSP_IBUF_HEADER_PAGE_NO), + page_id_t(0, FSP_IBUF_HEADER_PAGE_NO), 0, RW_X_LATCH, &mtr); if (UNIV_UNLIKELY(!block)) { corrupted_old_page: @@ -1737,21 +1781,7 @@ dberr_t srv_start(bool create_new_db) } if (srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN) { - /* The following call is necessary for the insert - buffer to work with multiple tablespaces. We must - know the mapping between space id's and .ibd file - names. - - In a crash recovery, we check that the info in data - dictionary is consistent with what we already know - about space id's from the calls to fil_ibd_load(). - - In a normal startup, we create the space objects for - every table in the InnoDB data dictionary that has - an .ibd file. - - We also determine the maximum tablespace id used. */ - dict_check_tablespaces_and_store_max_id(); + dict_load_tablespaces(); } if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO @@ -1833,13 +1863,6 @@ dberr_t srv_start(bool create_new_db) trx_sys.get_max_trx_id()); } - if (srv_force_recovery == 0) { - /* In the change buffer we may have even bigger tablespace - id's, because we may have dropped those tablespaces, but - the buffered records have not been cleaned yet. */ - ibuf_update_max_tablespace_id(); - } - if (!srv_read_only_mode) { if (create_new_db) { srv_buffer_pool_load_at_startup = FALSE; @@ -1894,10 +1917,6 @@ void innodb_preshutdown() return; if (!srv_fast_shutdown && srv_operation == SRV_OPERATION_NORMAL) { - /* Because a slow shutdown must empty the change buffer, we had - better prevent any further changes from being buffered. */ - innodb_change_buffering= 0; - if (trx_sys.is_initialised()) while (trx_sys.any_active_transactions()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); @@ -1963,8 +1982,6 @@ void innodb_shutdown() || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO); ut_ad(lock_sys.is_initialised() || !srv_was_started); ut_ad(log_sys.is_initialised() || !srv_was_started); - ut_ad(ibuf.index || !srv_was_started - || srv_force_recovery >= SRV_FORCE_NO_DDL_UNDO); dict_stats_deinit(); @@ -1985,7 +2002,6 @@ void innodb_shutdown() btr_search_disable(); } #endif /* BTR_CUR_HASH_ADAPT */ - ibuf_close(); log_sys.close(); purge_sys.close(); trx_sys.close(); diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index 0dc82fd21bc47..3885544331544 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -449,7 +449,7 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, trx_id_t &max_trx_id, return DB_TABLESPACE_NOT_FOUND; dberr_t err; const buf_block_t *rseg_hdr= - buf_page_get_gen(rseg->page_id(), 0, RW_S_LATCH, nullptr, BUF_GET, mtr, + buf_page_get_gen(rseg->page_id(), 0, RW_X_LATCH, nullptr, BUF_GET, mtr, &err); if (!rseg_hdr) return err; @@ -580,7 +580,7 @@ dberr_t trx_rseg_array_init() for (ulint rseg_id = 0; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) { mtr.start(); - if (const buf_block_t* sys = trx_sysf_get(&mtr, false)) { + if (const buf_block_t* sys = trx_sysf_get(&mtr, true)) { if (rseg_id == 0) { /* In case this is an upgrade from before MariaDB 10.3.5, fetch the base diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 374a9d724bc6c..ab8c0b34e7d3c 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2022, MariaDB Corporation. +Copyright (c) 2017, 2023, 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 @@ -105,7 +105,6 @@ trx_sysf_get_n_rseg_slots() /** Initialize the transaction system when creating the database. */ dberr_t trx_sys_create_sys_pages(mtr_t *mtr) { - mtr->start(); mtr->x_lock_space(fil_system.sys_space); static_assert(TRX_SYS_SPACE == 0, "compatibility"); @@ -114,11 +113,7 @@ dberr_t trx_sys_create_sys_pages(mtr_t *mtr) buf_block_t *block= fseg_create(fil_system.sys_space, TRX_SYS + TRX_SYS_FSEG_HEADER, mtr, &err); if (UNIV_UNLIKELY(!block)) - { - error: - mtr->commit(); return err; - } ut_a(block->page.id() == page_id_t(0, TRX_SYS_PAGE_NO)); mtr->write<2>(*block, FIL_PAGE_TYPE + block->page.frame, @@ -138,9 +133,8 @@ dberr_t trx_sys_create_sys_pages(mtr_t *mtr) buf_block_t *r= trx_rseg_header_create(fil_system.sys_space, 0, 0, mtr, &err); if (UNIV_UNLIKELY(!r)) - goto error; + return err; ut_a(r->page.id() == page_id_t(0, FSP_FIRST_RSEG_PAGE_NO)); - mtr->commit(); return trx_lists_init_at_db_start(); } diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 0ff20b31771b5..e5e6de97987bd 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, 2022, MariaDB Corporation. +Copyright (c) 2015, 2023, 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 @@ -410,12 +410,12 @@ void trx_t::free() #endif read_view.mem_noaccess(); MEM_NOACCESS(&lock, sizeof lock); - MEM_NOACCESS(&op_info, sizeof op_info); - MEM_NOACCESS(&isolation_level, sizeof isolation_level); - MEM_NOACCESS(&check_foreigns, sizeof check_foreigns); + MEM_NOACCESS(&op_info, sizeof op_info + + sizeof(unsigned) /* isolation_level, + check_foreigns, check_unique_secondary, + bulk_insert */); MEM_NOACCESS(&is_registered, sizeof is_registered); MEM_NOACCESS(&active_commit_ordered, sizeof active_commit_ordered); - MEM_NOACCESS(&check_unique_secondary, sizeof check_unique_secondary); MEM_NOACCESS(&flush_log_later, sizeof flush_log_later); MEM_NOACCESS(&must_flush_log_later, sizeof must_flush_log_later); MEM_NOACCESS(&duplicates, sizeof duplicates); diff --git a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result index de5ed76ad2785..9d67a60cee9d3 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result @@ -98,12 +98,8 @@ buffer_LRU_unzip_search_num_scan buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL N buffer_LRU_unzip_search_scanned_per_call buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Page scanned per single LRU unzip search buffer_page_read_index_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Leaf Pages read buffer_page_read_index_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Non-leaf Pages read -buffer_page_read_index_ibuf_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Leaf Pages read -buffer_page_read_index_ibuf_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Non-Leaf Pages read buffer_page_read_undo_log buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Undo Log Pages read buffer_page_read_index_inode buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Inode Pages read -buffer_page_read_ibuf_free_list buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Free List Pages read -buffer_page_read_ibuf_bitmap buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Bitmap Pages read buffer_page_read_system_page buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of System Pages read buffer_page_read_trx_system buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Transaction System Pages read buffer_page_read_fsp_hdr buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of File Space Header Pages read @@ -114,12 +110,8 @@ buffer_page_read_zblob2 buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NU buffer_page_read_other buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of other/unknown (old version of InnoDB) Pages read buffer_page_written_index_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Leaf Pages written buffer_page_written_index_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Non-leaf Pages written -buffer_page_written_index_ibuf_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Leaf Pages written -buffer_page_written_index_ibuf_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Non-Leaf Pages written buffer_page_written_undo_log buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Undo Log Pages written buffer_page_written_index_inode buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Inode Pages written -buffer_page_written_ibuf_free_list buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Free List Pages written -buffer_page_written_ibuf_bitmap buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Bitmap Pages written buffer_page_written_system_page buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of System Pages written buffer_page_written_trx_system buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Transaction System Pages written buffer_page_written_fsp_hdr buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of File Space Header Pages written @@ -187,14 +179,6 @@ adaptive_hash_rows_removed adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL adaptive_hash_rows_deleted_no_hash_entry adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of rows deleted that did not have corresponding Adaptive Hash Index entries adaptive_hash_rows_updated adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Adaptive Hash Index rows updated file_num_open_files file_system 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of files currently open (innodb_num_open_files) -ibuf_merges_insert change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of inserted records merged by change buffering -ibuf_merges_delete_mark change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of deleted records merged by change buffering -ibuf_merges_delete change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of purge records merged by change buffering -ibuf_merges_discard_insert change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of insert merged operations discarded -ibuf_merges_discard_delete_mark change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of deleted merged operations discarded -ibuf_merges_discard_delete change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of purge merged operations discarded -ibuf_merges change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of change buffer merges -ibuf_size change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Change buffer size in pages innodb_master_thread_sleeps server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times (seconds) master thread sleeps innodb_activity_count server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Current server activity count innodb_master_active_loops server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times master thread performs its tasks when server is active From 944beb9e7acd53488dbfc7edc09bf29e10ce68ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 14 Dec 2022 14:44:28 +0200 Subject: [PATCH 110/113] MDEV-19506 Remove the global sequence DICT_HDR_ROW_ID for DB_ROW_ID InnoDB tables that lack a primary key (and any UNIQUE INDEX whose all columns are NOT NULL) will use an internally generated index, called GEN_CLUST_INDEX(DB_ROW_ID) in the InnoDB data dictionary, and hidden from the SQL layer. The 48-bit (6-byte) DB_ROW_ID is being assigned from a global sequence that is persisted in the DICT_HDR page. There is absolutely no reason for the DB_ROW_ID to be globally unique across all InnoDB tables. A downgrade to earlier versions will be prevented by the file format change related to removing the InnoDB change buffer (MDEV-29694). DICT_HDR_ROW_ID, dict_sys_t::row_id: Remove. dict_table_t::row_id: The per-table sequence of DB_ROW_ID. commit_try_rebuild(): Copy dict_table_t::row_id from the old table. btr_cur_instant_init(), row_import_cleanup(): If needed, perform the equivalent of SELECT MAX(DB_ROW_ID) to initialize dict_table_t::row_id. row_ins(): If needed, obtain DB_ROW_ID from dict_table_t::row_id. Should it exceed the maximum 48-bit value, return DB_OUT_OF_FILE_SPACE to prevent further inserts into the table. dict_load_table_one(): Move a condition to btr_cur_instant_init_low() so that dict_table_t::row_id will be restored also for ROW_FORMAT=COMPRESSED tables. Tested by: Matthias Leich --- storage/innobase/btr/btr0cur.cc | 36 +++++++---- storage/innobase/dict/dict0boot.cc | 27 +------- storage/innobase/dict/dict0dict.cc | 1 + storage/innobase/dict/dict0load.cc | 4 +- storage/innobase/handler/handler0alter.cc | 1 + storage/innobase/include/dict0boot.h | 35 +--------- storage/innobase/include/dict0dict.h | 19 +----- storage/innobase/include/dict0dict.inl | 2 +- storage/innobase/include/dict0mem.h | 2 + storage/innobase/row/row0import.cc | 79 ++++++----------------- storage/innobase/row/row0ins.cc | 24 +++---- 11 files changed, 62 insertions(+), 168 deletions(-) diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index a4260c7f11120..9a25892ab529a 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -348,10 +348,14 @@ when loading a table definition. static dberr_t btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr) { ut_ad(index->is_primary()); - ut_ad(index->n_core_null_bytes == dict_index_t::NO_CORE_NULL_BYTES); - ut_ad(index->table->supports_instant()); ut_ad(index->table->is_readable()); + if (!index->table->supports_instant()) { + return DB_SUCCESS; + } + + ut_ad(index->n_core_null_bytes == dict_index_t::NO_CORE_NULL_BYTES); + dberr_t err; const fil_space_t* space = index->table->space; if (!space) { @@ -618,17 +622,25 @@ when loading a table definition. @param[in,out] table table definition from the data dictionary @return error code @retval DB_SUCCESS if no error occurred */ -dberr_t -btr_cur_instant_init(dict_table_t* table) +dberr_t btr_cur_instant_init(dict_table_t *table) { - mtr_t mtr; - dict_index_t* index = dict_table_get_first_index(table); - mtr.start(); - dberr_t err = index - ? btr_cur_instant_init_low(index, &mtr) - : DB_CORRUPTION; - mtr.commit(); - return(err); + mtr_t mtr; + dict_index_t *index= dict_table_get_first_index(table); + mtr.start(); + dberr_t err = index ? btr_cur_instant_init_low(index, &mtr) : DB_CORRUPTION; + mtr.commit(); + if (err == DB_SUCCESS && index->is_gen_clust()) + { + btr_cur_t cur; + mtr.start(); + err= cur.open_leaf(false, index, BTR_SEARCH_LEAF, &mtr); + if (err != DB_SUCCESS); + else if (const rec_t *rec= page_rec_get_prev(btr_cur_get_rec(&cur))) + if (page_rec_is_user_rec(rec)) + table->row_id= mach_read_from_6(rec); + mtr.commit(); + } + return(err); } /** Initialize the n_core_null_bytes on first access to a clustered diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc index 8d18b37f132d2..316d0f0132255 100644 --- a/storage/innobase/dict/dict0boot.cc +++ b/storage/innobase/dict/dict0boot.cc @@ -93,18 +93,6 @@ dict_hdr_get_new_id( mtr.commit(); } -/** Update dict_sys.row_id in the dictionary header file page. */ -void dict_hdr_flush_row_id(row_id_t id) -{ - mtr_t mtr; - mtr.start(); - buf_block_t* d= dict_hdr_get(&mtr); - byte *row_id= DICT_HDR + DICT_HDR_ROW_ID + d->page.frame; - if (mach_read_from_8(row_id) < id) - mtr.write<8>(*d, row_id, id); - mtr.commit(); -} - /** Create the DICT_HDR page on database initialization. @return error code */ dberr_t dict_create() @@ -126,10 +114,8 @@ dberr_t dict_create() } ut_a(d->page.id() == hdr_page_id); - /* Start counting row, table, index, and tree ids from + /* Start counting table, index, and tree ids from DICT_HDR_FIRST_ID */ - mtr.write<8>(*d, DICT_HDR + DICT_HDR_ROW_ID + d->page.frame, - DICT_HDR_FIRST_ID); mtr.write<8>(*d, DICT_HDR + DICT_HDR_TABLE_ID + d->page.frame, DICT_HDR_FIRST_ID); mtr.write<8>(*d, DICT_HDR + DICT_HDR_INDEX_ID + d->page.frame, @@ -245,17 +231,6 @@ dberr_t dict_boot() const byte* dict_hdr = &d->page.frame[DICT_HDR]; - /* Because we only write new row ids to disk-based data structure - (dictionary header) when it is divisible by - DICT_HDR_ROW_ID_WRITE_MARGIN, in recovery we will not recover - the latest value of the row id counter. Therefore we advance - the counter at the database startup to avoid overlapping values. - Note that when a user after database startup first time asks for - a new row id, then because the counter is now divisible by - ..._MARGIN, it will immediately be updated to the disk-based - header. */ - - dict_sys.recover_row_id(mach_read_from_8(dict_hdr + DICT_HDR_ROW_ID)); if (uint32_t max_space_id = mach_read_from_4(dict_hdr + DICT_HDR_MAX_SPACE_ID)) { max_space_id--; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index c1c911480dd5a..6c003c43b4f1e 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1180,6 +1180,7 @@ inline void dict_sys_t::add(dict_table_t* table) ulint fold = my_crc32c(0, table->name.m_name, strlen(table->name.m_name)); + table->row_id = 0; table->autoinc_mutex.init(); table->lock_mutex_init(); diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index b442e92664822..cb81e4008df0d 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -2471,9 +2471,7 @@ static dict_table_t *dict_load_table_one(const span &name, goto corrupted; } - if (table->supports_instant()) { - err = btr_cur_instant_init(table); - } + err = btr_cur_instant_init(table); } } else { ut_ad(ignore_err & DICT_ERR_IGNORE_INDEX); diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index abca00323e012..d0f1aa9c34252 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -10219,6 +10219,7 @@ commit_try_rebuild( /* We must be still holding a table handle. */ DBUG_ASSERT(user_table->get_ref_count() == 1); + rebuilt_table->row_id = uint64_t{user_table->row_id}; DBUG_EXECUTE_IF("ib_rebuild_cannot_rename", error = DB_ERROR;); switch (error) { diff --git a/storage/innobase/include/dict0boot.h b/storage/innobase/include/dict0boot.h index a65287476ef8e..68400d2095d87 100644 --- a/storage/innobase/include/dict0boot.h +++ b/storage/innobase/include/dict0boot.h @@ -44,39 +44,6 @@ dict_hdr_get_new_id( (not assigned if NULL) */ uint32_t* space_id); /*!< out: space id (not assigned if NULL) */ -/** Update dict_sys.row_id in the dictionary header file page. */ -void dict_hdr_flush_row_id(row_id_t id); -/** @return A new value for GEN_CLUST_INDEX(DB_ROW_ID) */ -inline row_id_t dict_sys_t::get_new_row_id() -{ - row_id_t id= row_id.fetch_add(1); - if (!(id % ROW_ID_WRITE_MARGIN)) - dict_hdr_flush_row_id(id); - return id; -} - -/** Ensure that row_id is not smaller than id, on IMPORT TABLESPACE */ -inline void dict_sys_t::update_row_id(row_id_t id) -{ - row_id_t sys_id= row_id; - while (id >= sys_id) - { - if (!row_id.compare_exchange_strong(sys_id, id)) - continue; - if (!(id % ROW_ID_WRITE_MARGIN)) - dict_hdr_flush_row_id(id); - break; - } -} - -/**********************************************************************//** -Writes a row id to a record or other 6-byte stored form. */ -inline void dict_sys_write_row_id(byte *field, row_id_t row_id) -{ - static_assert(DATA_ROW_ID_LEN == 6, "compatibility"); - mach_write_to_6(field, row_id); -} - /*****************************************************************//** Initializes the data dictionary memory structures when the database is started. This function is also called when the data dictionary is created. @@ -116,7 +83,7 @@ inline bool dict_is_sys_table(table_id_t id) { return id < DICT_HDR_FIRST_ID; } /*-------------------------------------------------------------*/ /* Dictionary header offsets */ -#define DICT_HDR_ROW_ID 0 /* The latest assigned row id */ +//#define DICT_HDR_ROW_ID 0 /* Was: latest assigned DB_ROW_ID */ #define DICT_HDR_TABLE_ID 8 /* The latest assigned table id */ #define DICT_HDR_INDEX_ID 16 /* The latest assigned index id */ #define DICT_HDR_MAX_SPACE_ID 24 /* The latest assigned space id,or 0*/ diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 1002213e61c3f..628ad8366af87 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -648,7 +648,7 @@ dict_table_get_all_fts_indexes( /********************************************************************//** Gets the number of user-defined non-virtual columns in a table in the dictionary cache. -@return number of user-defined (e.g., not ROW_ID) non-virtual +@return number of user-defined (e.g., not DB_ROW_ID) non-virtual columns of a table */ UNIV_INLINE unsigned @@ -1370,27 +1370,10 @@ class dict_sys_t std::atomic temp_table_id{DICT_HDR_FIRST_ID}; /** hash table of temporary table IDs */ hash_table_t temp_id_hash; - /** the next value of DB_ROW_ID, backed by DICT_HDR_ROW_ID - (FIXME: remove this, and move to dict_table_t) */ - Atomic_relaxed row_id; - /** The synchronization interval of row_id */ - static constexpr size_t ROW_ID_WRITE_MARGIN= 256; public: /** Diagnostic message for exceeding the lock_wait() timeout */ static const char fatal_msg[]; - /** @return A new value for GEN_CLUST_INDEX(DB_ROW_ID) */ - inline row_id_t get_new_row_id(); - - /** Ensure that row_id is not smaller than id, on IMPORT TABLESPACE */ - inline void update_row_id(row_id_t id); - - /** Recover the global DB_ROW_ID sequence on database startup */ - void recover_row_id(row_id_t id) - { - row_id= ut_uint64_align_up(id, ROW_ID_WRITE_MARGIN) + ROW_ID_WRITE_MARGIN; - } - /** @return a new temporary table ID */ table_id_t acquire_temporary_table_id() { diff --git a/storage/innobase/include/dict0dict.inl b/storage/innobase/include/dict0dict.inl index 4cc3eae96ab03..ead22a21757f2 100644 --- a/storage/innobase/include/dict0dict.inl +++ b/storage/innobase/include/dict0dict.inl @@ -244,7 +244,7 @@ dict_table_get_next_index( /********************************************************************//** Gets the number of user-defined non-virtual columns in a table in the dictionary cache. -@return number of user-defined (e.g., not ROW_ID) non-virtual +@return number of user-defined (e.g., not DB_ROW_ID) non-virtual columns of a table */ UNIV_INLINE unsigned diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index d9ef949ac1311..bbbda57b05d5d 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -2347,6 +2347,8 @@ struct dict_table_t { Atomic_relaxed lock_mutex_owner{0}; #endif public: + /** The next DB_ROW_ID value */ + Atomic_counter row_id{0}; /** Autoinc counter value to give to the next inserted row. */ uint64_t autoinc; diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index f86b3c8674aa4..c2c17f718ec95 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -2109,8 +2109,9 @@ row_import_cleanup( row_prebuilt_t* prebuilt, /*!< in/out: prebuilt from handler */ dberr_t err) /*!< in: error code */ { + dict_table_t* table = prebuilt->table; + if (err != DB_SUCCESS) { - dict_table_t* table = prebuilt->table; table->file_unreadable = true; if (table->space) { fil_close_tablespace(table->space_id); @@ -2141,7 +2142,25 @@ row_import_cleanup( DBUG_EXECUTE_IF("ib_import_before_checkpoint_crash", DBUG_SUICIDE();); - return(err); + if (err != DB_SUCCESS + || !dict_table_get_first_index(table)->is_gen_clust()) { + return err; + } + + btr_cur_t cur; + mtr_t mtr; + mtr.start(); + err = cur.open_leaf(false, dict_table_get_first_index(table), + BTR_SEARCH_LEAF, &mtr); + if (err != DB_SUCCESS) { + } else if (const rec_t *rec = + page_rec_get_prev(btr_cur_get_rec(&cur))) { + if (page_rec_is_user_rec(rec)) + table->row_id= mach_read_from_6(rec); + } + mtr.commit(); + + return err; } /*****************************************************************//** @@ -2276,55 +2295,6 @@ row_import_adjust_root_pages_of_secondary_indexes( return(err); } -/*****************************************************************//** -Ensure that dict_sys.row_id exceeds SELECT MAX(DB_ROW_ID). */ -MY_ATTRIBUTE((nonnull)) static -void -row_import_set_sys_max_row_id( -/*==========================*/ - row_prebuilt_t* prebuilt, /*!< in/out: prebuilt from - handler */ - const dict_table_t* table) /*!< in: table to import */ -{ - const rec_t* rec; - mtr_t mtr; - btr_pcur_t pcur; - row_id_t row_id = 0; - dict_index_t* index; - - index = dict_table_get_first_index(table); - ut_ad(index->is_primary()); - ut_ad(dict_index_is_auto_gen_clust(index)); - - mtr_start(&mtr); - - mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO); - - if (pcur.open_leaf(false, index, BTR_SEARCH_LEAF, &mtr) - == DB_SUCCESS) { - rec = btr_pcur_move_to_prev_on_page(&pcur); - - if (!rec) { - /* The table is corrupted. */ - } else if (page_rec_is_infimum(rec)) { - /* The table is empty. */ - } else if (rec_is_metadata(rec, *index)) { - /* The clustered index contains the metadata - record only, that is, the table is empty. */ - } else { - row_id = mach_read_from_6(rec); - } - } - - mtr_commit(&mtr); - - if (row_id) { - /* Update the system row id if the imported index row id is - greater than the max system row id. */ - dict_sys.update_row_id(row_id); - } -} - /*****************************************************************//** Read the a string from the meta data file. @return DB_SUCCESS or error code. */ @@ -4510,13 +4480,6 @@ row_import_for_mysql( return row_import_error(prebuilt, err); } - /* Ensure that the next available DB_ROW_ID is not smaller than - any DB_ROW_ID stored in the table. */ - - if (prebuilt->clust_index_was_generated) { - row_import_set_sys_max_row_id(prebuilt, table); - } - ib::info() << "Phase III - Flush changes to disk"; /* Ensure that all pages dirtied during the IMPORT make it to disk. diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 52ccce4d0af77..9cd83e98528b3 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -3525,19 +3525,6 @@ row_ins_index_entry_step( DBUG_RETURN(err); } -/***********************************************************//** -Allocates a row id for row and inits the node->index field. */ -UNIV_INLINE -void -row_ins_alloc_row_id_step( -/*======================*/ - ins_node_t* node) /*!< in: row insert node */ -{ - ut_ad(node->state == INS_NODE_ALLOC_ROW_ID); - if (dict_table_get_first_index(node->table)->is_gen_clust()) - dict_sys_write_row_id(node->sys_buf, dict_sys.get_new_row_id()); -} - /***********************************************************//** Gets a row to insert from the values list. */ UNIV_INLINE @@ -3618,13 +3605,18 @@ row_ins( DBUG_PRINT("row_ins", ("table: %s", node->table->name.m_name)); if (node->state == INS_NODE_ALLOC_ROW_ID) { - - row_ins_alloc_row_id_step(node); - node->index = dict_table_get_first_index(node->table); ut_ad(node->entry_list.empty() == false); node->entry = node->entry_list.begin(); + if (node->index->is_gen_clust()) { + const uint64_t db_row_id{++node->table->row_id}; + if (db_row_id >> 48) { + DBUG_RETURN(DB_OUT_OF_FILE_SPACE); + } + mach_write_to_6(node->sys_buf, db_row_id); + } + if (node->ins_type == INS_SEARCHED) { row_ins_get_row_from_select(node); From f879ee9ca0d87d3574cb80f2259168cb7d01cbaa Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 11 Jan 2023 00:25:01 +1100 Subject: [PATCH 111/113] deb: add lunar --- debian/autobake-deb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index d9b2b007066df..f82cc7eb375eb 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -144,7 +144,7 @@ in replace_uring_with_aio disable_libfmt ;& - impish|jammy|kinetic) + impish|jammy|kinetic|lunar) # mariadb-plugin-rocksdb s390x not supported by us (yet) # ubuntu doesn't support mips64el yet, so keep this just # in case something changes. From 44dce3b2077e64a1efc607668d0d7b42a7c4ee78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Jan 2023 12:46:30 +0200 Subject: [PATCH 112/113] MDEV-29986 Set innodb_undo_tablespaces=3 by default Starting with commit baf276e6d4a44fe7cdf3b435c0153da0a42af2b6 (MDEV-19229) the parameter innodb_undo_tablespaces can be increased from its previous default value 0 while allowing an upgrade from old databases. We will change the default setting to innodb_undo_tablespaces=3 so that the space occupied by possible bursts of undo log records can be reclaimed after SET GLOBAL innodb_undo_log_truncate=ON. We will not enable innodb_undo_log_truncate by default, because it causes some observable performance degradation. Special thanks to Thirunarayanan Balathandayuthapani for diagnosing and fixing a number of bugs related to this new default setting. Tested by: Matthias Leich, Axel Schwenke, Vladislav Vaintroub (with both values of innodb_undo_log_truncate) --- extra/mariabackup/xtrabackup.cc | 2 +- .../suite/encryption/r/innodb-spatial-index.result | 3 +++ .../suite/innodb/r/innodb-system-table-view.result | 2 +- .../suite/innodb/t/encryption_threads_shutdown.test | 13 +++++++++++++ mysql-test/suite/innodb/t/log_data_file_size.opt | 1 + mysql-test/suite/innodb/t/row_format_redundant.opt | 1 + mysql-test/suite/innodb/t/table_flags.opt | 2 +- mysql-test/suite/sys_vars/r/sysvars_innodb.result | 2 +- .../vault/t/hashicorp_key_rotation_age.test | 8 ++++---- storage/innobase/buf/buf0buf.cc | 5 +++-- storage/innobase/handler/ha_innodb.cc | 2 +- 11 files changed, 30 insertions(+), 11 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 9d86ae100afbb..e0ea4a17ab87c 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1667,7 +1667,7 @@ struct my_option xb_server_options[] = {"innodb_undo_tablespaces", OPT_INNODB_UNDO_TABLESPACES, "Number of undo tablespaces to use.", (G_PTR*)&srv_undo_tablespaces, (G_PTR*)&srv_undo_tablespaces, - 0, GET_UINT, REQUIRED_ARG, 0, 0, 126, 0, 1, 0}, + 0, GET_UINT, REQUIRED_ARG, 3, 0, 126, 0, 1, 0}, {"innodb_compression_level", OPT_INNODB_COMPRESSION_LEVEL, "Compression level used for zlib compression.", diff --git a/mysql-test/suite/encryption/r/innodb-spatial-index.result b/mysql-test/suite/encryption/r/innodb-spatial-index.result index 66c3edcd109be..6bd22d6c25f0a 100644 --- a/mysql-test/suite/encryption/r/innodb-spatial-index.result +++ b/mysql-test/suite/encryption/r/innodb-spatial-index.result @@ -38,6 +38,9 @@ INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)') SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0; NAME innodb_system +innodb_undo001 +innodb_undo002 +innodb_undo003 mysql/innodb_index_stats mysql/innodb_table_stats mysql/transaction_registry diff --git a/mysql-test/suite/innodb/r/innodb-system-table-view.result b/mysql-test/suite/innodb/r/innodb-system-table-view.result index 580ed08e42460..5be25e62ae2e2 100644 --- a/mysql-test/suite/innodb/r/innodb-system-table-view.result +++ b/mysql-test/suite/innodb/r/innodb-system-table-view.result @@ -10,7 +10,7 @@ TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE 11 SYS_FOREIGN 0 7 0 Redundant 0 System 12 SYS_FOREIGN_COLS 0 7 0 Redundant 0 System 13 SYS_VIRTUAL 0 6 0 Redundant 0 System -16 mysql/transaction_registry 33 8 3 Dynamic 0 Single +16 mysql/transaction_registry 33 8 6 Dynamic 0 Single SELECT table_id,pos,mtype,prtype,len,name FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE table_id NOT IN (@table_stats_id, @index_stats_id) diff --git a/mysql-test/suite/innodb/t/encryption_threads_shutdown.test b/mysql-test/suite/innodb/t/encryption_threads_shutdown.test index 5a63df5db8696..d6e58a19ad9c5 100644 --- a/mysql-test/suite/innodb/t/encryption_threads_shutdown.test +++ b/mysql-test/suite/innodb/t/encryption_threads_shutdown.test @@ -10,10 +10,20 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile --let $MYSQLD_DATADIR=`SELECT @@datadir` --let $DATA= $MYSQLD_DATADIR/ibdata1 --let $DATACOPY=$MYSQLTEST_VARDIR/tmp/ibdata1 +--let $UNDO_1= $MYSQLD_DATADIR/undo001 +--let $UNDO_2= $MYSQLD_DATADIR/undo002 +--let $UNDO_3= $MYSQLD_DATADIR/undo003 +--let $UNDO_1_COPY=$MYSQLTEST_VARDIR/tmp/undo001 +--let $UNDO_2_COPY=$MYSQLTEST_VARDIR/tmp/undo002 +--let $UNDO_3_COPY=$MYSQLTEST_VARDIR/tmp/undo003 + CREATE TABLE t(a INT) ENGINE=InnoDB; --source include/kill_mysqld.inc # Move the file to cause srv_init_abort_low() call from srv_start() --move_file $DATA $DATACOPY +--move_file $UNDO_1 $UNDO_1_COPY +--move_file $UNDO_2 $UNDO_2_COPY +--move_file $UNDO_3 $UNDO_3_COPY # If the bug is not fixed, the server will hang here. Note that the test is # unstable because the condition @@ -28,5 +38,8 @@ CREATE TABLE t(a INT) ENGINE=InnoDB; SELECT * FROM t; --source include/kill_mysqld.inc --move_file $DATACOPY $DATA +--move_file $UNDO_1_COPY $UNDO_1 +--move_file $UNDO_2_COPY $UNDO_2 +--move_file $UNDO_3_COPY $UNDO_3 --source include/start_mysqld.inc DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/log_data_file_size.opt b/mysql-test/suite/innodb/t/log_data_file_size.opt index d9a364a32872d..20e2cf0dc4086 100644 --- a/mysql-test/suite/innodb/t/log_data_file_size.opt +++ b/mysql-test/suite/innodb/t/log_data_file_size.opt @@ -1,2 +1,3 @@ --loose-innodb-sys-indexes --innodb-data-file-path=ibdata1:1M:autoextend +--innodb-undo-tablespaces=0 diff --git a/mysql-test/suite/innodb/t/row_format_redundant.opt b/mysql-test/suite/innodb/t/row_format_redundant.opt index c44c611ed60c7..3147bad47130a 100644 --- a/mysql-test/suite/innodb/t/row_format_redundant.opt +++ b/mysql-test/suite/innodb/t/row_format_redundant.opt @@ -1 +1,2 @@ --innodb-checksum-algorithm=crc32 +--innodb-undo-tablespaces=0 diff --git a/mysql-test/suite/innodb/t/table_flags.opt b/mysql-test/suite/innodb/t/table_flags.opt index bca674950d203..3147bad47130a 100644 --- a/mysql-test/suite/innodb/t/table_flags.opt +++ b/mysql-test/suite/innodb/t/table_flags.opt @@ -1,2 +1,2 @@ --innodb-checksum-algorithm=crc32 ---skip-innodb-read-only-compressed +--innodb-undo-tablespaces=0 diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 53c02d962067d..79341b8582259 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -1653,7 +1653,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_UNDO_TABLESPACES SESSION_VALUE NULL -DEFAULT_VALUE 0 +DEFAULT_VALUE 3 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE INT UNSIGNED VARIABLE_COMMENT Number of undo tablespaces to use. diff --git a/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_key_rotation_age.test b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_key_rotation_age.test index ce99406ab0678..c446036aaaee8 100644 --- a/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_key_rotation_age.test +++ b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_key_rotation_age.test @@ -33,7 +33,7 @@ let $restart_parameters=$default_parameters --innodb_encryption_threads=5 --inno --echo # Wait until encryption threads have encrypted all tablespaces ---let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'` +--let $tables_count= `select count(*) + 1 + @@global.innodb_undo_tablespaces 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; --source include/wait_condition.inc @@ -63,7 +63,7 @@ alter table t33 encryption_key_id=222; --echo # Wait until encryption threads have encrypted all tablespaces ---let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` +--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces 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; --source include/wait_condition.inc @@ -77,7 +77,7 @@ set global innodb_encrypt_tables = OFF; --echo # Wait until encryption threads to decrypt all encrypted tablespaces ---let $tables_count= `select count(*) - 1 from information_schema.tables where engine = 'InnoDB'` +--let $tables_count= `select count(*) - 1 + @@global.innodb_undo_tablespaces 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 @@ -105,7 +105,7 @@ set global innodb_encrypt_tables = ON; --echo # Wait until encryption threads to encrypt all unencrypted tablespaces ---let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` +--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces 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; --source include/wait_condition.inc diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index e48538545f00c..c22a4cb1b5f2e 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -588,7 +588,7 @@ bool buf_page_is_corrupted(bool check_lsn, const byte *read_buf, DBUG_EXECUTE_IF( "page_intermittent_checksum_mismatch", { static int page_counter; - if (page_counter++ == 3) { + if (page_counter++ == 6) { crc32++; } }); @@ -723,7 +723,8 @@ bool buf_page_is_corrupted(bool check_lsn, const byte *read_buf, DBUG_EXECUTE_IF( "page_intermittent_checksum_mismatch", { static int page_counter; - if (page_counter++ == 3) return true; + if (page_counter++ == 6) + return true; }); if ((checksum_field1 != crc32 diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index b85c46276e664..ea71fb1202677 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -19345,7 +19345,7 @@ static MYSQL_SYSVAR_UINT(undo_tablespaces, srv_undo_tablespaces, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "Number of undo tablespaces to use.", NULL, NULL, - 0L, /* Default seting */ + 3L, /* Default seting */ 0L, /* Minimum value */ TRX_SYS_MAX_UNDO_SPACES, 0); /* Maximum value */ From 314e50b464e31a45c791ea47661efdadf924cfc5 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 12 Jan 2023 10:34:14 +1100 Subject: [PATCH 113/113] Use MariaDB as the project name in CMakeLists.txt (fix) Partial revert of d29d915790f7da41cd89c469f0a4c6c9b8f8a5c3. It seems from CI that lower case RPM names are generated without explictly setting the package name to mixed case. --- CMakeLists.txt | 2 ++ cmake/cpack_rpm.cmake | 1 + 2 files changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fcd4d9347f05..3ac59eeefa625 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,8 @@ ELSE() SET(CMAKE_CXX_STANDARD 11) ENDIF() +# Lower case package names from PROJECT are used if not explictly upper case. +SET(CPACK_PACKAGE_NAME "MariaDB") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MariaDB: a very fast and robust SQL database server") SET(CPACK_PACKAGE_URL "http://mariadb.org") diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index f14bc9e93b8e9..339363b216943 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -34,6 +34,7 @@ SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts backup ) +SET(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) SET(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) IF(CMAKE_VERSION VERSION_LESS "3.6.0") SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${SERVER_VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}")