summaryrefslogtreecommitdiff
path: root/sql/handler.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge from mysql-next-mr.Alexander Nozdrin2009-10-281-0/+11
|\
| * manual merge: mysql-5.1-rep+2-delivery1 --> mysql-5.1-rpl-mergeLuis Soares2009-10-221-0/+11
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts ========= Text conflict in .bzr-mysql/default.conf Text conflict in libmysqld/CMakeLists.txt Text conflict in libmysqld/Makefile.am Text conflict in mysql-test/collections/default.experimental Text conflict in mysql-test/extra/rpl_tests/rpl_row_sp006.test Text conflict in mysql-test/suite/binlog/r/binlog_tmp_table.result Text conflict in mysql-test/suite/rpl/r/rpl_loaddata.result Text conflict in mysql-test/suite/rpl/r/rpl_loaddata_fatal.result Text conflict in mysql-test/suite/rpl/r/rpl_row_create_table.result Text conflict in mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result Text conflict in mysql-test/suite/rpl/r/rpl_stm_log.result Text conflict in mysql-test/suite/rpl_ndb/r/rpl_ndb_circular_simplex.result Text conflict in mysql-test/suite/rpl_ndb/r/rpl_ndb_sp006.result Text conflict in mysql-test/t/mysqlbinlog.test Text conflict in sql/CMakeLists.txt Text conflict in sql/Makefile.am Text conflict in sql/log_event_old.cc Text conflict in sql/rpl_rli.cc Text conflict in sql/slave.cc Text conflict in sql/sql_binlog.cc Text conflict in sql/sql_lex.h 21 conflicts encountered. NOTE ==== mysql-5.1-rpl-merge has been made a mirror of mysql-next-mr: - "mysql-5.1-rpl-merge$ bzr pull ../mysql-next-mr" This is the first cset (merge/...) committed after pulling from mysql-next-mr.
| | * Backport BUG#41013 main.bootstrap coredumps in 6.0-rplHe Zhenxing2009-10-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | When a storage engine failed to initialize before allocated slot number, the slot number would be 0, and when later finalizing this plugin, it would accidentally unplug the storage engine currently uses slot 0. This patch fixed this problem by add a new macro value HA_SLOT_UNDEF to distinguish undefined slot number from slot 0.
| | * WL#5016: Fix header file include guardsMats Kindahl2009-09-231-0/+4
| | | | | | | | | | | | Adding header include file guards to files that are missing such.
* | | Merge from mysql-next-mr.Alexander Nozdrin2009-10-231-0/+9
|\ \ \ | |/ /
| * | Bug#46760: Fast ALTER TABLE no longer works for InnoDBGeorgi Kodinov2009-09-181-0/+9
| |/ | | | | | | | | | | | | | | | | Despite copying the value of the old table's row type we don't always have to mark row type as being specified. Innodb uses this to check if it can do fast ALTER TABLE or not. Fixed by correctly flagging the presence of row_type only when it's actually changed. Added a test case for 39200.
* | Backport of:Konstantin Osipov2009-10-161-0/+1
| | | | | | | | | | | | | | | | | | ---------------------------------------------------------- revno: 2630.22.11 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-records timestamp: Mon 2008-08-11 16:40:09 +0400 message: Move read_record related functions to a new header - records.h
* | Backport of:Konstantin Osipov2009-10-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | ---------------------------------------------------------- revno: 2630.13.6 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-3288 timestamp: Fri 2008-07-11 20:22:44 +0400 message: WL#3288, step 1: ensure that the SQL layer always closes an open cursor (rnd or index read) before closing a handler.
* | Backport of:Konstantin Osipov2009-10-141-5/+4
|/ | | | | | | | | | | | ---------------------------------------------------------- revno: 2630.22.8 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-runtime timestamp: Sun 2008-08-10 18:49:52 +0400 message: Get rid of typedef struct for the most commonly used types: TABLE, TABLE_SHARE, LEX. This simplifies use of tags and forward declarations.
* automergeGeorgi Kodinov2009-08-171-2/+2
|\
| * Merge mysql-5.1-innodb_plugin to mysql-5.1.Sergey Vojtovich2009-08-111-2/+2
| |\
| | * Backport WL#3653 to 5.1 to enable bundled innodb plugin.Vladislav Vaintroub2009-06-101-2/+2
| | | | | | | | | | | | | | | Remove custom DLL loader code from innodb plugin code, use symbols exported from mysqld.
* | | A follow up patch for the follow up patch for Bug#45829 Konstantin Osipov2009-08-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | "CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing". Put back stubs for members of structures that are shared between sql/ and pluggable storage engines. to not break ABI unnecessarily. To be NULL-merged into 5.4, where we do break the ABI already.
* | | A follow up patch for Bug#45829 "CREATE TABLE TRANSACTIONAL Konstantin Osipov2009-08-121-6/+0
|/ / | | | | | | | | | | PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing" Remove unused code that would lead to warnings when compiling sql_yacc.yy.
* | Bug#45829 "CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE ↵Guilhem Bichot2009-07-291-3/+8
|/ | | | | | | | accepted, does nothing": those keywords do nothing in 5.1 (they are meant for future versions, for example featuring the Maria engine) so they are here removed from the syntax. Adding those keywords to future versions when needed is: - WL#5034 "Add TRANSACTIONA=0|1 and PAGE_CHECKSUM=0|1 clauses to CREATE TABLE" - WL#5037 "New ROW_FORMAT value for CREATE TABLE: PAGE"
* BUG#39802 On Windows, 32-bit time_t should be enforcedNarayanan V2009-05-041-6/+6
| | | | | | | | | | | | | A backport of fix for "BUG40092 - Storage engine API uses time_t datatype". Starting from MSVC C++ 2005 (v8), the default size of time_t is changed from 32-bit to 64-bit. As the result, the binaries built with pre-v8 MSVC C++ do not work with the binaries (storage engine plugins) built with v8 or after (server crashes). Fixed storage engine API to use datatype with known size (ulong) instead of time_t.
* Merge from mysql-5.1.30-releasetimothy.smith@sun.com2008-11-271-1/+1
|\
| * Added "Sun Microsystems, Inc." to copyright headers on files modifiedBuild Team2008-11-101-1/+1
| | | | | | | | since Oct 1st
* | mergeMattias Jonsson2008-11-051-0/+3
|\ \
| * | Bug#39084: Getting intermittent errors with statement-based binary loggingMattias Jonsson2008-10-291-0/+3
| |/ | | | | | | | | | | Problem was that partitioning cached the table flags. These flags could change due to TRANSACTION LEVEL changes. Solution was to remove the cache and always return the table flags from the first partition (if the handler was initialized).
* | mergeMattias Jonsson2008-10-291-1/+1
|\ \ | |/ |/|
| * Bug#37453: Dropping/creating index on partitioned table withMattias Jonsson2008-10-051-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | InnoDB Plugin locks table The fast/on-line add/drop index handler calls was not implemented whithin the partitioning. This implements it in the partitioning handler. Since this is only used by the not included InnoDB plugin, there is no test case. (Have tested it manually with the plugin, and it does not allow unique indexes not including partitioning function, or removal of pk, which in innodb generates a new pk, which is not in the partitioning function.) NOTE: This introduces a new handler method, and because of that changes the storage engine api. (One cannot use a handlerton to see the capabilities of a table's handler if it is partitioned. So I added a wrapper function in the handler that defaults to the handlerton function, which the partitioning handler overrides.
* | Fix for bug#39585: innodb and myisam corruption after binary Ramil Kalimullin2008-10-081-0/+1
| | | | | | | | | | | | | | | | | | upgrade from <=5.0.46 to >=5.0.48 Problem: 'check table .. for upgrade' doesn't detect incompatible collation changes made in 5.0.48. Fix: check for incompatible collation changes.
* | Bug#37453: Dropping/creating index on partitioned table withMattias Jonsson2008-10-081-0/+6
| | | | | | | | | | | | | | | | InnoDB Plugin locks table This is a pre fix update that does the change to the handler api. This is done since there are already changes in this version, so the real fix does not need to change the api.
* | Fix for BUG#31612Guilhem Bichot2008-10-061-1/+9
| | | | | | | | | | | | | | | | | | | | "Trigger fired multiple times leads to gaps in auto_increment sequence". The bug was that if a trigger fired multiple times inside a top statement (for example top-statement is a multi-row INSERT, and trigger is ON INSERT), and that trigger inserted into an auto_increment column, then gaps could be observed in the auto_increment sequence, even if there were no other users of the database (no concurrency). It was wrong usage of THD::auto_inc_intervals_in_cur_stmt_for_binlog. Note that the fix changes "class handler", I'll tell the Storage Engine API team.
* | Bug#38804: Query deadlock causes all tables to be inaccessible.Mattias Jonsson2008-09-081-5/+6
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem was a mutex added in bug n 27405 for solving a problem with auto_increment in partitioned innodb tables. (in ha_partition::write_row over partitions file->ha_write_row) Solution is to use the patch for bug#33479, which refines the usage of mutexes for auto_increment. Backport of bug-33479 from 6.0: Bug-33479: auto_increment failures in partitioning Several problems with auto_increment in partitioning (with MyISAM, InnoDB. Locking issues, not handling multi-row INSERTs properly etc.) Changed the auto_increment handling for partitioning: Added a ha_data variable in table_share for storage engine specific data such as auto_increment value handling in partitioning, also see WL 4305 and using the ha_data->mutex to lock around read + update. The idea is this: Store the table's reserved auto_increment value in the TABLE_SHARE and use a mutex to, lock it for reading and updating it and unlocking it, in one block. Only accessing all partitions when it is not initialized. Also allow reservations of ranges, and if no one has done a reservation afterwards, lower the reservation to what was actually used after the statement is done (via release_auto_increment from WL 3146). The lock is kept from the first reservation if it is statement based replication and a multi-row INSERT statement where the number of candidate rows to insert is not known in advance (like INSERT SELECT, LOAD DATA, unlike INSERT VALUES (row1), (row2),,(rowN)). This should also lead to better concurrancy (no need to have a mutex protection around write_row in all cases) and work with any local storage engine.
* Bug#20129: ALTER TABLE ... REPAIR PARTITION ... complains thatMattias Jonsson2008-08-111-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | partition is corrupt The main problem was that ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION took another code path (over mysql_alter_table instead of mysql_admin_table) which differs in two ways: 1) alter table opens the tables in a different way than admin tables do resulting in returning with error before it tried the command 2) alter table does not start to send any diagnostic rows to the client which the lower admin functions continue to use -> resulting in assertion crash The fix: Remapped ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION to use the same code path as ANALYZE/CHECK/OPTIMIZE/REPAIR TABLE t. Adding check in mysql_admin_table to setup the partition list for which partitions that should be used. Partitioned tables will still not work with REPAIR TABLE/PARTITION USE_FRM, since that requires moving partitions to tables, REPAIR TABLE t USE_FRM, and check that the data still fulfills the partitioning function and then move the table back to being a partition. NOTE: I have removed the following functions from the handler interface: analyze_partitions, check_partitions, optimize_partitions, repair_partitions Since they are not longer needed. THIS ALTERS THE STORAGE ENGINE API
* Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-mainjani@a88-113-38-195.elisa-laajakaista.fi2008-03-281-0/+5
|\ | | | | | | into a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel
| * Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-mainjani@a88-113-38-195.elisa-laajakaista.fi2008-03-071-0/+5
| |\ | | | | | | | | | into a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel
| | * Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-mainjani@a88-113-38-195.elisa-laajakaista.fi2008-02-081-0/+5
| | |\ | | | | | | | | | | | | into a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel
| | | * Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1monty@mysql.com/narttu.mysql.fi2007-10-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Reserver namespace and place in frm for TABLE_CHECKSUM and PAGE_CHECKSUM create options - Added syncing of directory when creating .frm files - Portability fixes - Added missing cast that could cause bugs - Code cleanups - Made some bit functions inline - Moved things out of myisam.h to my_handler.h to make them more accessable - Renamed some myisam variables and defines to make them more globaly usable (as they are used outside of MyISAM) - Fixed bugs in error conditions - Use compiler time asserts instead of run time - Fixed indentation HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP as the old name was wrong (Added a define for old value to ensure we don't break any old code) Added HA_EXTRA_PREPARE_FOR_RENAME as a signal for rename (before we used a DROP signal which is wrong) - Initialize error messages early to get better errors when mysqld or an engine fails to start - Fix windows bug that query_performance_frequency was not initialized if registry code failed - thread_stack -> my_thread_stack_size
* | | | merge bug 26461 to 5.1-optgkodinov/kgeorge@macbook.gmz2008-03-231-1/+1
|/ / /
* | | A fix and a test case for Bug#12713 "Error in a stored function called from kostja@dipika.(none)2008-02-191-9/+113
|/ / | | | | | | | | | | | | | | | | | | a SELECT doesn't cause ROLLBACK of statem". The idea of the fix is to ensure that we always commit the current statement at the end of dispatch_command(). In order to not issue redundant disc syncs, an optimization of the two-phase commit protocol is implemented to bypass the two phase commit if the transaction is read-only.
* | A pre-requisite for the fix for Bug#12713 "Error in a stored function kostja@bodhi.(none)2007-12-201-89/+123
| | | | | | | | | | | | | | | | | | | | called from a SELECT doesn't cause ROLLBACK of state" Make private all class handler methods (PSEA API) that may modify data. Introduce and deploy public ha_* wrappers for these methods in all sql/. This necessary to keep track of all data modifications in sql/, which is in turn necessary to be able to optimize two-phase commit of those transactions that do not modify data.
* | Make handler::{write,delete,update}_row private. It's criticalkostja@bodhi.(none)2007-12-191-16/+15
| | | | | | | | | | | | | | | | that the entire server uses their public ha_* counterparts instead, since only then we can ensure proper tracing of these calls that is necessary for Bug#12713. A pre-requisite for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem"
* | Sort class handler public declarations. kostja@bodhi.(none)2007-12-191-126/+115
| |
* | Consistently use doxygen comments in class handler.kostja@vajra.(none)2007-12-181-114/+92
| |
* | Bug#30273 - merge tables: Can't lock file (errno: 155)istruewing@stella.local2007-12-111-1/+10
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch for Bug 26379 (Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table) fixed this bug too. However it revealed a new bug that crashed the server. Flushing a merge table at the moment when it is between open and attach of children crashed the server. The flushing thread wants to abort locks on the flushed table. It calls ha_myisammrg::lock_count() and ha_myisammrg::store_lock() on the TABLE object of the other thread. Changed ha_myisammrg::lock_count() and ha_myisammrg::store_lock() to accept non-attached children. ha_myisammrg::lock_count() returns the number of MyISAM tables in the MERGE table so that the memory allocation done by get_lock_data() is done correctly, even if the children become attached before ha_myisammrg::store_lock() is called. ha_myisammrg::store_lock() will not return any lock if the children are not attached. This is however a change in the handler interface. lock_count() can now return a higher number than store_lock() stores locks. This is more safe than the reverse implementation would be. get_lock_data() in the SQL layer is adjusted accordingly. It sets MYSQL_LOCK::lock_count based on the number of locks returned by the handler::store_lock() calls, not based on the numbers returned by the handler::lock_count() calls. The latter are only used for allocation of memory now. No test case. The test suite cannot reliably run FLUSH between lock_count() and store_lock() of another thread. The bug report contains a program that can repeat the problem with some probability.
* Bug #28430 Failure in replication of innodb partitioned tables on row/mixed ↵holyfoot/hf@mysql.com/hfmain.(none)2007-09-071-0/+11
| | | | | | | | | | | | | | format. In the ha_partition::position() we don't calculate the number of the partition of the record, but use m_last_part value instead, relying on that it's previously set by some other call like ::write_row(). Delete_rows_log_event::do_exec_row() calls find_and_fetch_row(), where we used position() + rnd_pos() call for the InnoDB-based PARTITION-ed table as there HA_PRIMARY_KEY_REQUIRED_FOR_POSITION enabled. fixed by introducing new handler::rnd_pos_by_record() method to be used for random record-based positioning
* Merge bk-internal.mysql.com:/home/bk/mysql-5.1monty@narttu.mysql.fi2007-08-141-33/+38
|\ | | | | | | into mysql.com:/home/my/mysql-5.1
| * Fixed a lot of compiler warnings and errors detected by Forte C++ on Solarismonty@mysql.com/nosik.monty.fi2007-08-131-33/+38
| | | | | | | | | | | | | | | | | | | | | | | | Faster thr_alarm() Added 'Opened_files' status variable to track calls to my_open() Don't give warnings when running mysql_install_db Added option --source-install to mysql_install_db I had to do the following renames() as used polymorphism didn't work with Forte compiler on 64 bit systems index_read() -> index_read_map() index_read_idx() -> index_read_idx_map() index_read_last() -> index_read_last_map()
* | WL#3732 Information schema optimizationgluh@mysql.com/eagle.(none)2007-08-031-2/+2
| |
* | Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.1-opttsmith@ramayana.hindu.god2007-08-011-0/+29
|\ \ | |/ |/| | | into ramayana.hindu.god:/home/tsmith/m/bk/maint/51
| * (Pushing for Andrei)gkodinov/kgeorge@magare.gmz2007-07-301-0/+29
| |\ | | | | | | | | | | | | Merge magare.gmz:/home/kgeorge/mysql/work/B27417-5.0-opt into magare.gmz:/home/kgeorge/mysql/work/B27417-5.1-opt
| | * (pushing for Andrei)gkodinov/kgeorge@magare.gmz2007-07-301-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack Once had been set the flag might later got reset inside of a stored routine execution stack. The reason was in that there was no check if a new statement started at time of resetting. The artifact affects most of binlogable DML queries. Notice, that multi-update is wrapped up within bug@27716 fix, multi-delete bug@29136. Fixed with saving parent's statement flag of whether the statement modified non-transactional table, and unioning (merging) the value with that was gained in mysql_execute_command. Resettling thd->no_trans_update members into thd->transaction.`member`; Asserting code; Effectively the following properties are held. 1. At the end of a substatement thd->transaction.stmt.modified_non_trans_table reflects the fact if such a table got modified by the substatement. That also respects THD::really_abort_on_warnin() requirements. 2. Eventually thd->transaction.stmt.modified_non_trans_table will be computed as the union of the values of all invoked sub-statements. That fixes this bug#27417; Computing of thd->transaction.all.modified_non_trans_table is refined to base to the stmt's value for all the case including insert .. select statement which before the patch had an extra issue bug@28960. Minor issues are covered with mysql_load, mysql_delete, and binloggin of insert in to temp_table select. The supplied test verifies limitely, mostly asserts. The ultimate testing is defered for bug@13270, bug@23333.
* | | Merge bodhi.(none):/opt/local/work/mysql-5.0-runtimekostja@bodhi.(none)2007-07-311-3/+31
|\ \ \ | | | | | | | | | | | | into bodhi.(none):/opt/local/work/mysql-5.1-runtime
| * | | Fix a compilation warning.kostja@bodhi.(none)2007-07-301-1/+0
| | | |
| * | | A fix and a test case for Bug#24918 drop table and lock / inconsistentkostja@bodhi.(none)2007-07-271-3/+37
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | between perm and temp tables. Review fixes. The original bug report complains that if we locked a temporary table with LOCK TABLES statement, we would not leave LOCK TABLES mode when this temporary table is dropped. Additionally, the bug was escalated when it was discovered than when a temporary transactional table that was previously locked with LOCK TABLES statement was dropped, futher actions with this table, such as UNLOCK TABLES, would lead to a crash. The problem originates from incomplete support of transactional temporary tables. When we added calls to handler::store_lock()/handler::external_lock() to operations that work with such tables, we only covered the normal server code flow and did not cover LOCK TABLES mode. In LOCK TABLES mode, ::external_lock(LOCK) would sometimes be called without matching ::external_lock(UNLOCK), e.g. when a transactional temporary table was dropped. Additionally, this table would be left in the list of LOCKed TABLES. The patch aims to address this inadequacy. Now, whenever an instance of 'handler' is destroyed, we assert that it was priorly external_lock(UNLOCK)-ed. All the places that violate this assert were fixed. This patch introduces no changes in behavior -- the discrepancy in behavior will be fixed when we start calling ::store_lock()/::external_lock() for all tables, regardless whether they are transactional or not, temporary or not.
* | | handler::ha_write_row_no_binlog() hack removed,serg@janus.mylan2007-07-301-1/+0
| | | | | | | | | | | | existing table->no_replicate code is used instead
* | | WL#3984 (Revise locking of mysql.general_log and mysql.slow_log)malff/marcsql@weblab.(none)2007-07-271-38/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug#25422 (Hang with log tables) Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the thread) Bug 23044 (Warnings on flush of a log table) Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes a deadlock) Prior to this fix, the server would hang when performing concurrent ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES, which are mysql.general_log and mysql.slow_log. The root cause traces to the following code: in sql_base.cc, open_table() if (table->in_use != thd) { /* wait_for_condition will unlock LOCK_open for us */ wait_for_condition(thd, &LOCK_open, &COND_refresh); } The problem with this code is that the current implementation of the LOGGER creates 'fake' THD objects, like - Log_to_csv_event_handler::general_log_thd - Log_to_csv_event_handler::slow_log_thd which are not associated to a real thread running in the server, so that waiting for these non-existing threads to release table locks cause the dead lock. In general, the design of Log_to_csv_event_handler does not fit into the general architecture of the server, so that the concept of general_log_thd and slow_log_thd has to be abandoned: - this implementation does not work with table locking - it will not work with commands like SHOW PROCESSLIST - having the log tables always opened does not integrate well with DDL operations / FLUSH TABLES / SET GLOBAL READ_ONLY With this patch, the fundamental design of the LOGGER has been changed to: - always open and close a log table when writing a log - remove totally the usage of fake THD objects - clarify how locking of log tables is implemented in general. See WL#3984 for details related to the new locking design. Additional changes (misc bugs exposed and fixed): 1) mysqldump which would ignore some tables in dump_all_tables_in_db(), but forget to ignore the same in dump_all_views_in_db(). 2) mysqldump would also issue an empty "LOCK TABLE" command when all the tables to lock are to be ignored (numrows == 0), instead of not issuing the query. 3) Internal errors handlers could intercept errors but not warnings (see sql_error.cc). 4) Implementing a nested call to open tables, for the performance schema tables, exposed an existing bug in remove_table_from_cache(), which would perform: in_use->some_tables_deleted=1; against another thread, without any consideration about thread locking. This call inside remove_table_from_cache() was not required anyway, since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads that might hold a lock on a table. This line (in_use->some_tables_deleted=1) has been removed.