summaryrefslogtreecommitdiff
path: root/sql/sql_admin.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.5 into 10.6Marko Mäkelä2021-04-081-5/+6
|\
| * Merge 10.4 into 10.5Marko Mäkelä2021-04-081-5/+6
| |\
| | * MDEV-24956: ALTER TABLE not replicated with Galera in MariaDB 10.5.9bb-10.4-MDEV-25226mkaruza2021-04-051-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | `WSREP_CLIENT` is used as condition for starting ALTER/OPTIMIZE/REPAIR TOI. Using this condition async replicated affected DDL's will not be replicated. Fixed by removing this condition. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
* | | Add TL_FIRST_WRITE in SQL layer for determining R/WDaniel Black2021-04-081-1/+1
|/ / | | | | | | | | | | | | Use < TL_FIRST_WRITE for determining a READ transaction. Use TL_FIRST_WRITE as the relative operator replacing TL_WRITE_ALLOW_WRITE as the minimium WRITE lock type.
* | Merge 10.4 into 10.5Marko Mäkelä2021-03-051-0/+2
|\ \ | |/
| * MDEV-23843 Assertions in Diagnostics_area upon table operations under FTWRLMonty2021-03-021-0/+2
| | | | | | | | Fixed binary logging in ANALYZE TABLE to work as optimize table
* | Merge branch '10.4' into 10.5Sergei Golubchik2021-02-231-0/+4
|\ \ | |/
| * MDEV-23843 Assertions in Diagnostics_area upon table operations under FTWRLMonty2021-02-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | 2 different problems: - MYSQL_BIN_LOG::write() did not check if mdl_context.acquire_lock() failed - Sql_cmd_optimize_table::execute() and Sql_cmd_repair_table::execute() called write_bin_log(), which could fail if sql_admin() had already called my_eof() Fixed by adding check for aquire_lock() return status and protect write_bin_log() in the above two functions with set_overwrite_status().
* | Merge 10.4 into 10.5Marko Mäkelä2020-12-021-10/+10
|\ \ | |/
| * Merge 10.3 into 10.4Marko Mäkelä2020-12-011-11/+11
| |\
| | * Merge 10.2 into 10.3Marko Mäkelä2020-12-011-11/+11
| | |\
| | | * MDEV 15532 Assertion `!log->same_pk' failed in row_log_table_apply_deleteMonty2020-11-301-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reason for the failure is that thd->mdl_context.release_transactional_locks() was called after commit & rollback even in cases where the current transaction is still active. For 10.2, 10.3 and 10.4 the fix is simple: - Replace all calls to thd->mdl_context.release_transactional_locks() with thd->release_transactional_locks(). The thd function will only call the mdl_context function if there are no active transactional locks. In 10.6 we will better fix where we will change the return value for some trans_xxx() functions to indicate if transaction did close the transaction or not. This will avoid the need of the indirect call. Other things: - trans_xa_commit() and trans_xa_rollback() will automatically call release_transactional_locks() if the transaction is closed. - We can't do that for the other functions as the caller of many of these are doing additional work (like close_thread_tables) before calling release_transactional_locks(). - Added missing abort_result_set() and missing DBUG_RETURN in select_create::send_eof() - Fixed wrong indentation in injector::transaction::commit()
| | | * Merge branch '10.1' into 10.2mariadb-10.2.33Sergei Golubchik2020-08-061-1/+1
| | | |\
* | | | \ Merge 10.4 into 10.5Marko Mäkelä2020-11-131-27/+81
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.3 into 10.4Marko Mäkelä2020-11-121-14/+31
| |\ \ \ \ | | |/ / /
| | * | | MDEV-23824 SIGSEGV in end_io_cache on REPAIR LOCAL TABLE for Aria tableMonty2020-11-021-14/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bugs fixed: - prepare_for_repair() didn't close all open files if table opened failed because of out-of-memory - If dd_recreate_table() failed, the data file was not properly restored from it's temporary name - Aria repair initializing code didn't properly clear all used structs before calling error, which caused crashed in memory-free calls. - maria_delete_table() didn't register if table open failed. This could calls my_error() to be called without returning 1 to the caller, which cased failures in my_ok() Note when merging to 10.5: - Remove the #if MYSQL_VERSION from sql_admin.cc
| * | | | MDEV-24119 MDL BF-BF Conflict caused by TRUNCATE TABLEsjaakola2020-11-111-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR fixes same issue as MDEV-21577 for TRUNCATE TABLE. MDEV-21577 fixed TOI replication for OPTIMIZE, REPAIR and ALTER TABLE operating on FK child table. It was later found out that also TRUNCATE has similar problem and needs a fix. The actual fix is to do FK parent table lookup before TRUNCATE TOI isolation and append found FK parent table names in certification key list for the write set. PR contains also new test scenario in galera_ddl_fk_conflict test where FK child has two FK parent tables and there are two DML transactions operating on both parent tables. For development convenience, new TO isolation macro was added: WSREP_TO_ISOLATION_BEGIN_IF and WSREP_TO_ISOLATION_BEGIN_ALTER macro was changed to skip the goto statement. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
| * | | | MDEV-21577 MDL BF-BF conflictsjaakola2020-11-031-12/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some DDL statements appear to acquire MDL locks for a table referenced by foreign key constraint from the actual affected table of the DDL statement. OPTIMIZE, REPAIR and ALTER TABLE belong to this class of DDL statements. Earlier MariaDB version did not take this in consideration, and appended only affected table in the certification key list in write set. Because of missing certification information, it could happen that e.g. OPTIMIZE table for FK child table could be allowed to apply in parallel with DML operating on the foreign key parent table, and this could lead to unhandled MDL lock conflicts between two high priority appliers (BF). The fix in this patch, changes the TOI replication for OPTIMIZE, REPAIR and ALTER TABLE statements so that before the execution of respective DDL statement, there is foreign key parent search round. This FK parent search contains following steps: * open and lock the affected table (with permissive shared locks) * iterate over foreign key contstraints and collect and array of Fk parent table names * close all tables open for the THD and release MDL locks * do the actual TOI replication with the affected table and FK parent table names as key values The patch contains also new mtr test for verifying that the above mentioned DDL statements replicate without problems when operating on FK child table. The mtr test scenario #1, which can be used to check if some other DDL (on top of OPTIMIZE, REPAIR and ALTER) could cause similar excessive FK parent table locking. Reviewed-by: Aleksey Midenkov <aleksey.midenkov@mariadb.com> Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
* | | | | Merge branch '10.4' into 10.5Oleksandr Byelkin2020-08-041-0/+10
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2020-08-031-0/+10
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.2' into 10.3Oleksandr Byelkin2020-08-031-0/+10
| | |\ \ \
| | | * \ \ Merge branch '10.1' into 10.2Oleksandr Byelkin2020-08-031-1/+1
| | | |\ \ \ | | | | |/ / | | | |/| / | | | | |/
| | | | * Fix the typo in fix for MDEV-21472Sergei Petrunia2020-08-031-1/+1
| | | | |
| | | * | Merge branch '10.1' into 10.2Oleksandr Byelkin2020-08-021-0/+10
| | | |\ \ | | | | |/
| | | | * MDEV-21472: ALTER TABLE ... ANALYZE PARTITION ... with EITS reads and locks ↵Sergei Petrunia2020-07-291-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | all rows Do not collect EITS statistics for this statement: ALTER TABLE t ANALYZE PARTITION p EITS stats are currently global, not per-partition. Collecting global stats when we are asked to process just one partition causes issues for DBAs.
* | | | | MDEV-15101: Stop ANALYZE TABLE from flushing table definition cacheSergei Petrunia2020-06-121-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply this patch from Percona Server (amended for 10.5): commit cd7201514fee78aaf7d3eb2b28d2573c76f53b84 Author: Laurynas Biveinis <laurynas.biveinis@gmail.com> Date: Tue Nov 14 06:34:19 2017 +0200 Fix bug 1704195 / 87065 / TDB-83 (Stop ANALYZE TABLE from flushing table definition cache) Make ANALYZE TABLE stop flushing affected tables from the table definition cache, which has the effect of not blocking any subsequent new queries involving the table if there's a parallel long-running query: - new table flag HA_ONLINE_ANALYZE, return it for InnoDB and TokuDB tables; - in mysql_admin_table, if we are performing ANALYZE TABLE, and the table flag is set, do not remove the table from the table definition cache, do not invalidate query cache; - in partitioning handler, refresh the query optimizer statistics after ANALYZE if the underlying handler supports HA_ONLINE_ANALYZE; - new testcases main.percona_nonflushing_analyze_debug, parts.percona_nonflushing_abalyze_debug and a supporting debug sync point. For TokuDB, this change exposes bug TDB-83 (Index cardinality stats updated for handler::info(HA_STATUS_CONST), not often enough for tokudb_cardinality_scale_percent). TokuDB may return different rec_per_key values depending on dynamic variable tokudb_cardinality_scale_percent value. The server does not have a way of knowing that changing this variable invalidates the previous rec_per_key values in any opened table shares, and so does not call info(HA_STATUS_CONST) again. Fix by updating rec_per_key for both HA_STATUS_CONST and HA_STATUS_VARIABLE. This also forces a re-record of tokudb.bugs.db756_card_part_hash_1_pick, with the new output seeming to be more correct.
* | | | | Merge 10.4 into 10.5Marko Mäkelä2020-05-311-2/+2
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.3 into 10.4Marko Mäkelä2020-05-261-2/+2
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.2 into 10.3Marko Mäkelä2020-05-251-2/+2
| | |\ \ \ | | | |/ /
| | | * | Fixed deadlock with LOCK TABLES and ALTER TABLEMonty2020-05-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-21398 Deadlock (server hang) or assertion failure in Diagnostics_area::set_error_status upon ALTER under lock This failure could only happen if one locked the same table multiple times and then did an ALTER TABLE on the table. Major change is to change all instances of table->m_needs_reopen= true; to table->mark_table_for_reopen(); The main fix for the problem was to ensure that we mark all instances of the table in the locked_table_list and when we reopen the tables, we first close all tables before reopening and locking them. Other things: - Don't call thd->locked_tables_list.reopen_tables if there are no tables marked for reopen. (performance)
* | | | | Merge 10.4 into 10.5Marko Mäkelä2020-05-131-25/+21
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.3 into 10.4Marko Mäkelä2020-05-131-25/+21
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.2 into 10.3Marko Mäkelä2020-05-131-25/+21
| | |\ \ \ | | | |/ /
| | | * | MDEV-13266: Race condition in ANALYZE TABLE / statistics collectionVarun Gupta2020-05-051-25/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixing a race condition while collecting the engine independent statistics. Thread1> 1) start running "ANALYZE TABLE t PERISTENT FOR COLUMNS (..) INDEXES ($list)" 2) Walk through $list and save it in TABLE::keys_in_use_for_query 3) Close/re-open tables Thread2> 1) Make some use of table t. This involves taking table t from the table cache, and putting it back (with TABLE::keys_in_use_for_query reset to 0) Thread1> continue collecting EITS stats. Since TABLE::keys_in_use_for_query is set to 0 we will not collect statistics for indexes in $list.
* | | | | Split tdc_remove_table()Sergey Vojtovich2020-04-031-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TDC_RT_REMOVE_ALL -> tdc_remove_table(). Some occurrences replaced with TDC_element::flush() (whenver TABLE_SHARE is available). TDC_RT_REMOVE_NOT_OWN[_KEEP_SHARE] -> TDC_element::flush(). These modes assume that current thread owns TABLE_SHARE reference, which means we can avoid hash lookup and flush unused TABLE instances directly. TDC_RT_REMOVE_UNUSED -> TDC_element::flush_unused(). Only [ab]used by mysql_admin_table() currently. Should be removed eventually. Part of MDEV-17882 - Cleanup refresh version
* | | | | Clean up and speed up interfaces for binary row loggingMonty2020-03-241-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-21605 Clean up and speed up interfaces for binary row logging MDEV-21617 Bug fix for previous version of this code The intention is to have as few 'if' as possible in ha_write() and related functions. This is done by pre-calculating once per statement the row_logging state for all tables. Benefits are simpler and faster code both when binary logging is disabled and when it's enabled. Changes: - Added handler->row_logging to make it easy to check it table should be row logged. This also made it easier to disabling row logging for system, internal and temporary tables. - The tables row_logging capabilities are checked once per "statements that updates tables" in THD::binlog_prepare_for_row_logging() which is called when needed from THD::decide_logging_format(). - Removed most usage of tmp_disable_binlog(), reenable_binlog() and temporary saving and setting of thd->variables.option_bits. - Moved checks that can't change during a statement from check_table_binlog_row_based() to check_table_binlog_row_based_internal() - Removed flag row_already_logged (used by sequence engine) - Moved binlog_log_row() to a handler:: - Moved write_locked_table_maps() to THD::binlog_write_table_maps() as most other related binlog functions are in THD. - Removed binlog_write_table_map() and binlog_log_row_internal() as they are now obsolete as 'has_transactions()' is pre-calculated in prepare_for_row_logging(). - Remove 'is_transactional' argument from binlog_write_table_map() as this can now be read from handler. - Changed order of 'if's in handler::external_lock() and wsrep_mysqld.h to first evaluate fast and likely cases before more complex ones. - Added error checking in ha_write_row() and related functions if binlog_log_row() failed. - Don't clear check_table_binlog_row_based_result in clear_cached_table_binlog_row_based_flag() as it's not needed. - THD::clear_binlog_table_maps() has been replaced with THD::reset_binlog_for_next_statement() - Added 'MYSQL_OPEN_IGNORE_LOGGING_FORMAT' flag to open_and_lock_tables() to avoid calculating of binary log format for internal opens. This flag is also used to avoid reading statistics tables for internal tables. - Added OPTION_BINLOG_LOG_OFF as a simple way to turn of binlog temporary for create (instead of using THD::sql_log_bin_off. - Removed flag THD::sql_log_bin_off (not needed anymore) - Speed up THD::decide_logging_format() by remembering if blackhole engine is used and avoid a loop over all tables if it's not used (the common case). - THD::decide_logging_format() is not called anymore if no tables are used for the statement. This will speed up pure stored procedure code with about 5%+ according to some simple tests. - We now get annotated events on slave if a CREATE ... SELECT statement is transformed on the slave from statement to row logging. - In the original code, the master could come into a state where row logging is enforced for all future events if statement could be used. This is now partly fixed. Other changes: - Ensure that all tables used by a statement has query_id set. - Had to restore the row_logging flag for not used tables in THD::binlog_write_table_maps (not normal scenario) - Removed injector::transaction::use_table(server_id_type sid, table tbl) as it's not used. - Cleaned up set_slave_thread_options() - Some more DBUG_ENTER/DBUG_RETURN, code comments and minor indentation changes. - Ensure we only call THD::decide_logging_format_low() once in mysql_insert() (inefficiency). - Don't annotate INSERT DELAYED - Removed zeroing pos_in_table_list in THD::open_temporary_table() as it's already 0
* | | | | MDEV-21743 Split up SUPER privilege to smaller privilegesAlexander Barkov2020-03-101-1/+0
| | | | |
* | | | | perfschema mdl related instrumentation changesSergei Golubchik2020-03-101-7/+9
| | | | |
* | | | | Merge 10.4 into 10.5Marko Mäkelä2019-12-161-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-12-091-1/+1
| |\ \ \ \ | | |/ / /
| | * | | Lintian complains on spelling errorFaustin Lammler2019-12-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The lintian check complains on spelling error: https://salsa.debian.org/mariadb-team/mariadb-10.3/-/jobs/95739
* | | | | Removed kill_delayed_threads_for_table()Sergey Vojtovich2019-11-251-1/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After 7fb9d64 it is used only by ALTER/DROP SERVER, which most probably wasn't intentional as Federated never supported delayed inserts anyway. If delayed inserts will ever become an issue with ALTER/DROP SERVER, we should kill them by acquiring X-lock instead. Part of MDEV-17882 - Cleanup refresh version
* | | | Merge 10.3 into 10.4Marko Mäkelä2019-11-011-3/+3
|\ \ \ \ | |/ / /
| * | | read-only slave using statement replication should replicate tmp tablesMichael Widenius2019-10-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Relates to MDEV-17863 DROP TEMPORARY TABLE creates a transaction in binary log on read only server Other things: - Fixed that insert into normal_table select from tmp_table is replicated as row events if tmp_table doesn't exists on slave.
| * | | Fixes for binary logging --read-only modeMonty2019-10-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Any temporary tables created under read-only mode will never be logged to binary log. Any usage of these tables to update normal tables, even after read-only has been disabled, will use row base logging (as the temporary table will not be on the slave). - Analyze, check and repair table will not be logged in read-only mode. Other things: - Removed not used varaibles in MYSQL_BIN_LOG::flush_and_set_pending_rows_event. - Set table_share->table_creation_was_logged for all normal tables. - THD::binlog_query() now returns -1 if statement was not logged., This is used to update table_share->table_creation_was_logged. - Don't log admin statements in opt_readonly is set. - Table's that doesn't have table_creation_was_logged will set binlog format to row logging. - Removed not needed/wrong setting of table->s->table_creation_was_logged in create_table_from_items()
* | | | Merge 10.3 into 10.4Marko Mäkelä2019-06-191-12/+16
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Marko Mäkelä2019-06-191-12/+16
| |\ \ \ | | |/ /
| | * | MDEV-19055 Failures with temporary tables and AriaMichael Widenius2019-06-171-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was two separate problems: - Aria pagecache didn't properly handle re-reading of blocks that have given errors before (this triggered an assert) - temporary tables that where opened several times where not properly closed in ALTER, REPAIR or OPTIMIZE table Other things - Added a couple of asserts that will make it easier to find problems like this in the future.
* | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ \ | | |/ /