summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.5 into 10.6Marko Mäkelä2021-02-021-6/+7
|\
| * MDEV-24564 Statistics are lost after ALTER TABLEbb-10.5-MDEV-24564Marko Mäkelä2021-01-281-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ever since commit 007f68c37f6b77588866a04d7515aca084ab950d, ALTER TABLE no longer invokes handler::open() after handler::commit_inplace_alter_table(). ha_innobase::reload_statistics(): Reload or recompute statistics after ALTER TABLE. innodb_notify_tabledef_changed(): A new function to invoke ha_innobase::reload_statistics(). handlerton::notify_tabledef_changed(): Add the parameter handler* so that ha_innobase::reload_statistics() can be invoked. ha_partition::notify_tabledef_changed(), partition_notify_tabledef_changed(): Pass through the call to any partitions or subpartitions. This is based on code that was supplied by Monty.
* | MDEV-20008: Galera strict modebb-10.6-MDEV-20008mkaruza2021-01-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Added new enum variable `wsrep_mode` which can be used to turn on WSREP features which are not part of default behaviour. Added enum `BINLOG_ROW_FORMAT_ONLY`, `REQUIRED_PRIMARY_KEY` and `STRICT_REPLICATION`. `wsrep-mode=STRICT_REPLICATION` behaves like variable `wsrep_strict_ddl`. Variable wsrep_strict_ddl is deprecated and if set we use new wsrep_mode setting instead. Reviewed and improved by: Jan Lindström <jan.lindstrom@mariadb.com>
* | MDEV-515 Reduce InnoDB undo logging for insert into empty tableMarko Mäkelä2021-01-251-1/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We implement an idea that was suggested by Michael 'Monty' Widenius in October 2017: When InnoDB is inserting into an empty table or partition, we can write a single undo log record TRX_UNDO_EMPTY, which will cause ROLLBACK to clear the table. For this to work, the insert into an empty table or partition must be covered by an exclusive table lock that will be held until the transaction has been committed or rolled back, or the INSERT operation has been rolled back (and the table is empty again), in lock_table_x_unlock(). Clustered index records that are covered by the TRX_UNDO_EMPTY record will carry DB_TRX_ID=0 and DB_ROLL_PTR=1<<55, and thus they cannot be distinguished from what MDEV-12288 leaves behind after purging the history of row-logged operations. Concurrent non-locking reads must be adjusted: If the read view was created before the INSERT into an empty table, then we must continue to imagine that the table is empty, and not try to read any records. If the read view was created after the INSERT was committed, then all records must be visible normally. To implement this, we introduce the field dict_table_t::bulk_trx_id. This special handling only applies to the very first INSERT statement of a transaction for the empty table or partition. If a subsequent statement in the transaction is modifying the initially empty table again, we must enable row-level undo logging, so that we will be able to roll back to the start of the statement in case of an error (such as duplicate key). INSERT IGNORE will continue to use row-level logging and locking, because implementing it would require the ability to roll back the latest row. Since the undo log that we write only allows us to roll back the entire statement, we cannot support INSERT IGNORE. We will introduce a handler::extra() parameter HA_EXTRA_IGNORE_INSERT to indicate to storage engines that INSERT IGNORE is being executed. In many test cases, we add an extra record to the table, so that during the 'interesting' part of the test, row-level locking and logging will be used. Replicas will continue to use row-level logging and locking until MDEV-24622 has been addressed. Likewise, this optimization will be disabled in Galera cluster until MDEV-24623 enables it. dict_table_t::bulk_trx_id: The latest active or committed transaction that initiated an insert into an empty table or partition. Protected by exclusive table lock and a clustered index leaf page latch. ins_node_t::bulk_insert: Whether bulk insert was initiated. trx_t::mod_tables: Use C++11 style accessors (emplace instead of insert). Unlike earlier, this collection will cover also temporary tables. trx_mod_table_time_t: Add start_bulk_insert(), end_bulk_insert(), is_bulk_insert(), was_bulk_insert(). trx_undo_report_row_operation(): Before accessing any undo log pages, invoke trx->mod_tables.emplace() in order to determine whether undo logging was disabled, or whether this is the first INSERT and we are supposed to write a TRX_UNDO_EMPTY record. row_ins_clust_index_entry_low(): If we are inserting into an empty clustered index leaf page, set the ins_node_t::bulk_insert flag for the subsequent trx_undo_report_row_operation() call. lock_rec_insert_check_and_lock(), lock_prdt_insert_check_and_lock(): Remove the redundant parameter 'flags' that can be checked in the caller. btr_cur_ins_lock_and_undo(): Simplify the logic. Correctly write DB_TRX_ID,DB_ROLL_PTR after invoking trx_undo_report_row_operation(). trx_mark_sql_stat_end(), ha_innobase::extra(HA_EXTRA_IGNORE_INSERT), ha_innobase::external_lock(): Invoke trx_t::end_bulk_insert() so that the next statement will not be covered by table-level undo logging. ReadView::changes_visible(trx_id_t) const: New accessor for the case where the trx_id_t is not read from a potentially corrupted index page but directly from the memory. In this case, we can skip a sanity check. row_sel(), row_sel_try_search_shortcut(), row_search_mvcc(): row_sel_try_search_shortcut_for_mysql(), row_merge_read_clustered_index(): Check dict_table_t::bulk_trx_id. row_sel_clust_sees(): Replaces lock_clust_rec_cons_read_sees(). lock_sec_rec_cons_read_sees(): Replaced with lower-level code. btr_root_page_init(): Refactored from btr_create(). dict_index_t::clear(), dict_table_t::clear(): Empty an index or table, for the ROLLBACK of an INSERT operation. ROW_T_EMPTY, ROW_OP_EMPTY: Note a concurrent ROLLBACK of an INSERT into an empty table. This is joint work with Thirunarayanan Balathandayuthapani, who created a working prototype. Thanks to Matthias Leich for extensive testing.
* Merge commit '10.4' into 10.5Oleksandr Byelkin2021-01-061-3/+35
|\
| * Merge 10.3 into 10.4Marko Mäkelä2020-12-231-12/+45
| |\
| | * MDEV-22178 Assertion `info->alias.str' failed in ↵Aleksey Midenkov2020-12-221-0/+1
| | | | | | | | | | | | | | | | | | | | | partition_info::check_partition_info instead of ER_VERS_WRONG_PARTS Assign create_info->alias for ALTER TABLE since it is NULL and later accessed for printing error message.
| | * MDEV-19273: Server crash in MDL_ticket::has_stronger_or_equal_type or ↵bb-10.3-MDEV-19273Oleksandr Byelkin2020-12-091-12/+44
| | | | | | | | | | | | | | | | | | | | | | | | Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str, table->table_name.str, MDL_SHARED)' failed in mysql_rm_table_no_locks Early report error in case of DROP SEQUENCE <non-sequence> Do not use error variable for other purposes except error.
* | | MDEV-24364 Alter rename table does not remove PFS shareAleksey Midenkov2020-12-221-0/+2
| | | | | | | | | | | | Add missed PSI_CALL_drop_table_share().
* | | MDEV-24351: S3, same-backend replication: Dropping a table on master...Sergei Petrunia2020-12-081-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ..causes error on slave. Cause: if the master doesn't have the frm file for the table, DROP TABLE code will call ha_delete_table_force() to drop the table in all available storage engines. The issue was that this code path didn't check for HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE flag for the storage engine, and so did not add "... IF EXISTS" to the statement that's written to the binary log. This can cause error on the slave when it tries to drop a table that's already gone.
* | | Merge 10.4 into 10.5Marko Mäkelä2020-12-021-3/+1
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-12-011-3/+1
| |\ \ | | |/
| | * cleanup: RAII helper for changing thd->count_cuted_rowsSergei Golubchik2020-11-251-3/+1
| | |
* | | MDEV-22506 Malformed error message for ER_KEY_CONTAINS_PERIOD_FIELDSNikita Malyavin2020-11-021-88/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Though this is an error message task, the problem was deep in the `mysql_prepare_create_table` implementation. The problem is described as follows: 1. `append_system_key_parts` was called before `mysql_prepare_create_table`, though key name generation was done close to the latest stage of the latter. 2. We can't move `append_system_key_parts` in the end, because system keys should be appended before some checks done. 3. If the checks from `append_system_key_parts` are moved to the end of `mysql_prepare_create_table`, then some other inappropriate errors are issued. like `ER_DUP_FIELDNAME`. To have key name specified in error message, name generation should be done before the checks, which consequenced in more changes. The final design for key initialization in `mysql_prepare_create_table` follows. The initialization is done in three phases: 1. Calculate a total number of keys created with respect to keys ignored. Allocate KEY* buffer. 2. Generate unique names; calculate a total number of key parts. Make early checks. Allocate KEY_PART_INFO* buffer. 3. Initialize key parts, make the rest of the checks.
* | | Fix memory leak on Alter_drop allocationAleksey Midenkov2020-10-221-1/+1
| | | | | | | | | | | | Fixes 7f613ebdb686 (MDEV-7284 INDEX: CREATE OR REPLACE).
* | | Merge 10.4 to 10.5Marko Mäkelä2020-10-221-10/+13
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-10-221-7/+9
| |\ \ | | |/
| | * MDEV-23968 CREATE TEMPORARY TABLE .. LIKE (system versioned table) returns ↵Aleksey Midenkov2020-10-201-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | error if unique index is defined in the table - Remove row_start/row_end from keys in fix_create_like(); - Disable manual adding of implicit row_start/row_end to indexes on CREATE TABLE. INVISIBLE_SYSTEM fields are unoperable by user; - Fix memory leak on allocation of Key_part_spec.
* | | Trivial fixups, no code changesMonty2020-10-211-4/+12
| | | | | | | | | | | | | | | | | | - Indentation changes - Fixed wrong name for used in DBUG_ENTER - Added some code comments
* | | MDEV-23730 s3.replication_partition 'innodb,mix' segvMonty2020-10-211-10/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This failure was caused because of several bugs: - Someone had removed s3-slave-ignore-updates=1 from slave.cnf, which caused the slave to remove files that the master was working on. - Bug in ha_partition::change_partitions() that didn't reset m_new_file in case of errors. This caused crashes in ha_maria::extra() as the maria handler was called on files that was already closed. - In ma_pagecache there was a bug that when one got a read error one a big block (s3 block), it left the flag PCBLOCK_BIG_READ on for the page which cased an assert when the page where flushed. - Flush all cached tables in case of ignored ALTER TABLE Note that when merging code from 10.3, that fixes the partition bug, use the code from this patch instead. Changes to ma_pagecache.cc written or reviewed by Sanja
* | | MDEV-23691 S3 storage engine: delayed slave can drop the tableMonty2020-10-211-7/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixed the problems with S3 after the "DROP TABLE FORCE" changes. It also fixes all failing replication S3 tests. A slave is delayed if it is trying to execute replicated queries on a table that is already converted to S3 by the master later in the binlog. Fixes for replication events on S3 tables for delayed slaves: - INSERT and INSERT ... SELECT and CREATE TABLE are ignored but written to the binary log. UPDATE & DELETE will be fixed in a future commit. Other things: - On slaves with --s3-slave-ignore-updates set, allow S3 tables to be opened in read-write mode. This was done to be able to ignore-but-replicate queries like insert. Without this change any open of an S3 table failed with 'Table is read only' which is too early to be able to replicate the original query. - Errors are now printed if handler::extra() call fails in wait_while_tables_are_used(). - Error message for row changes are changed from HA_ERR_WRONG_COMMAND to HA_ERR_TABLE_READONLY. - Disable some maria_extra() calls for S3 tables. This could cause S3 tables to fail in some cases. - Added missing thr_lock_delete() to ma_open() in case of failure. - Removed from mysql_prepare_insert() the not needed argument 'table'.
* | | MDEV-23852 alter table rename column to uppercase doesn't workAleksey Midenkov2020-10-201-3/+2
| | | | | | | | | | | | | | | Case-sensitive compare to detect column name case change in inplace alter rename.
* | | Merge branch '10.4' into 10.5Sujatha2020-09-291-1/+7
|\ \ \ | |/ /
| * | MDEV-17665 Assertion `!share and other errors on concurrent Aria operationsMonty2020-09-251-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes also: MDEV-22674 Server crash in compare_bin ... restore_table_state_after_repair The bug was that the 'can_enable_index' variable in MyISAM and Aria was not properly set and reset for bulk insert. Because of this, insert...select was trying to recreate indexes while another thread was using it, causing crashes in page cache.
* | | MDEV-23549 CREATE fails after DROP without FRMAleksey Midenkov2020-09-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Related to 7c2ba9e: ha_table_exists() is replaced by dd_frm_type(). ha_table_exists() checked the existence of share and that succeeded to enter the execution branch of ha_delete_table() where tdc_remove_table() was called. Now it is skipped because dd_frm_type() returns TABLE_TYPE_UNKNOWN. Fix it by calling tdc_remove_table() in this case as well.
* | | Merge 10.4 into 10.5Marko Mäkelä2020-09-041-1/+1
|\ \ \ | |/ /
* | | Merge 10.4 into 10.5Marko Mäkelä2020-08-011-14/+20
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-07-311-2/+3
| |\ \ | | |/
| | * Merge 10.2 into 10.3Marko Mäkelä2020-07-311-1/+2
| | |\
| | | * MDEV-18042 Server crashes upon adding a non-null date column under ↵Nikita Malyavin2020-07-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | NO_ZERO_DATE with ALGORITHM=INPLACE accept table_name and db_name instead of table_share in make_truncated_value_warning
| * | | MDEV-23295 ROW_FORMAT mismatch in instant ALTER TABLEMarko Mäkelä2020-07-271-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An instant ADD/DROP/reorder column could create a dummy table object with the wrong ROW_FORMAT when innodb_default_row_format was changed between CREATE TABLE and ALTER TABLE. prepare_inplace_alter_table_dict(): If we had promised that ALGORITHM=INPLACE is supported, we must preserve the ROW_FORMAT. dict_table_t::prepare_instant(): Add debug assertions to catch ROW_FORMAT mismatch. The rest of the changes are related to adding Alter_inplace_info::inplace_supported to cache the return value of handler::check_if_supported_inplace_alter().
* | | | continue DROP TEMPORARY TABLE t1, t2, t3 after error.Sergei Golubchik2020-07-041-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | normal DROP TABLE with many tables continues after an error, trying to drop as many tables as possible. But DROP TEMPORARY TABLE was aborting on the first error. Change it to behave as DROP TABLE does.
* | | | MDEV-11412 Ensure that table is truly dropped when using DROP TABLESergei Golubchik2020-07-041-45/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | don't do table discovery on DROP. DROP falls back to "force" approach when a table isn't found and will try to drop in all engines anyway. That is, trying to discover in all engines before the drop is redundant and may be expensive.
* | | | small cleanupSergei Golubchik2020-07-041-24/+20
| | | |
* | | | MDEV-11412 Ensure that table is truly dropped when using DROP TABLESergei Golubchik2020-07-041-31/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | minor post-review fixes * remove duplicate tests * first file indicates table existance even with discovery * don't duplicate trigger dropping code
* | | | introduce hton->drop_table() methodSergei Golubchik2020-07-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | first step in moving drop table out of the handler. todo: other methods that don't need an open table for now hton->drop_table is optional, for backward compatibility reasons
* | | | cleanup, less #ifdef'sSergei Golubchik2020-07-041-4/+1
| | | |
* | | | Merge 10.4 into 10.5Marko Mäkelä2020-07-021-0/+7
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2020-07-021-0/+7
| |\ \ \ | | |/ /
| | * | Merge 10.2 into 10.3Marko Mäkelä2020-07-021-0/+7
| | |\ \ | | | |/
| | | * MDEV-22726: Add check that one can't change general or slow log to aVlad Lesin2020-06-241-0/+7
| | | | | | | | | | | | | | | | transactional engine
| | | * MDEV-21695 Server crashes in TABLE::evaluate_update_default_function upon ↵Alexander Barkov2020-06-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UPDATE on temporary table copy_data_between_tables() sets to->s->default_fields to 0, as a part of the code disabling ON UPDATE actions for all old fields (so ON UPDATE is enable only for new fields during copying). After the actual copying, copy_data_between_tables() did not restore to->s->default_fields to the original value. As a result, the TABLE_SHARE to->s was left in a wrong state after copy_data_between_tables() and further open_table_from_share() using this TABLE_SHARE did not populate TABLE::default_field, which further made TABLE::evaluate_update_default_function() crash on access to NULL pointer. Fix: Changing copy_data_between_tables() to restore to->s->default_fields to its original value after the copying loop.
* | | | MDEV-22925 ALTER TABLE s3_table ENGINE=Aria can cause failure on slaveMonty2020-06-191-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When converting a table (test.s3_table) from S3 to another engine, the following will be logged to the binary log: DROP TABLE IF EXISTS test.t1; CREATE OR REPLACE TABLE test.t1 (...) ENGINE=new_engine INSERT rows to test.t1 in binary-row-log-format The bug is that the above statements are logged one by one to the binary log. This means that a fast slave, configured to use the same S3 storage as the master, would be able to execute the DROP and CREATE from the binary log before the master has finished the ALTER TABLE. In this case the slave would ignore the DROP (as it's on a S3 table) but it will stop on CREATE of the local tale, as the table is still exists in S3. The REPLACE part will be ignored by the slave as it can't touch the S3 table. The fix is to ensure that all the above statements is written to binary log AFTER the table has been deleted from S3.
* | | | Added THD::binlog_table_should_be_logged() to simplify some codeMonty2020-06-191-2/+1
| | | | | | | | | | | | | | | | - Added missing test for binlog_filter to ALTER TABLE
* | | | Updated code commentsMonty2020-06-141-1/+1
| | | |
* | | | Make error messages from DROP TABLE and DROP TABLE IF EXISTS consistentMonty2020-06-141-75/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - IF EXISTS ends with a list of all not existing object, instead of a separate note for every not existing object - Produce a "Note" for all wrongly dropped objects (like trying to do DROP SEQUENCE for a normal table) - Do not write existing tables that could not be dropped to binlog Other things: MDEV-22820 Bogus "Unknown table" warnings produced upon attempt to drop parent table referenced by FK This was caused by an older version of this commit patch and later fixed
* | | | MDEV-11412 Ensure that table is truly dropped when using DROP TABLEMonty2020-06-141-83/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The used code is largely based on code from Tencent The problem is that in some rare cases there may be a conflict between .frm files and the files in the storage engine. In this case the DROP TABLE was not able to properly drop the table. Some MariaDB/MySQL forks has solved this by adding a FORCE option to DROP TABLE. After some discussion among MariaDB developers, we concluded that users expects that DROP TABLE should always work, even if the table would not be consistent. There should not be a need to use a separate keyword to ensure that the table is really deleted. The used solution is: - If a .frm table doesn't exists, try dropping the table from all storage engines. - If the .frm table exists but the table does not exist in the engine try dropping the table from all storage engines. - Update storage engines using many table files (.CVS, MyISAM, Aria) to succeed with the drop even if some of the files are missing. - Add HTON_AUTOMATIC_DELETE_TABLE to handlerton's where delete_table() is not needed and always succeed. This is used by ha_delete_table_force() to know which handlers to ignore when trying to drop a table without a .frm file. The disadvantage of this solution is that a DROP TABLE on a non existing table will be a bit slower as we have to ask all active storage engines if they know anything about the table. Other things: - Added a new flag MY_IGNORE_ENOENT to my_delete() to not give an error if the file doesn't exist. This simplifies some of the code. - Don't clear thd->error in ha_delete_table() if there was an active error. This is a bug fix. - handler::delete_table() will not abort if first file doesn't exists. This is bug fix to handle the case when a drop table was aborted in the middle. - Cleaned up mysql_rm_table_no_locks() to ensure that if_exists uses same code path as when it's not used. - Use non_existing_Table_error() to detect if table didn't exists. Old code used different errors tests in different position. - Table_triggers_list::drop_all_triggers() now drops trigger file if it can't be parsed instead of leaving it hanging around (bug fix) - InnoDB doesn't anymore print error about .frm file out of sync with InnoDB directory if .frm file does not exists. This change was required to be able to try to drop an InnoDB file when .frm doesn't exists. - Fixed bug in mi_delete_table() where the .MYD file would not be dropped if the .MYI file didn't exists. - Fixed memory leak in Mroonga when deleting non existing table - Fixed memory leak in Connect when deleting non existing table Bugs fixed introduced by the original version of this commit: MDEV-22826 Presence of Spider prevents tables from being force-deleted from other engines
* | | | MDEV-22602 Disable UPDATE CASCADE for SQL constraintsAleksey Midenkov2020-06-121-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CHECK constraint is checked by check_expression() which walks its items and gets into Item_field::check_vcol_func_processor() to check for conformity with foreign key list. WITHOUT OVERLAPS is checked for same conformity in mysql_prepare_create_table(). Long uniques are already impossible with InnoDB foreign keys. See ER_CANT_CREATE_TABLE in test case. 2 accompanying bugs fixed (test main.constraints failed): 1. check->name.str lived on SP execute mem_root while "check" obj itself lives on SP main mem_root. On second SP execute check->name.str had garbage data. Fixed by allocating from thd->stmt_arena->mem_root which is SP main mem_root. 2. CHECK_CONSTRAINT_IF_NOT_EXISTS value was mixed with VCOL_FIELD_REF. VCOL_FIELD_REF is assigned in check_expression() and then detected as CHECK_CONSTRAINT_IF_NOT_EXISTS in handle_if_exists_options(). Existing cases for MDEV-16932 in main.constraints cover both fixes.
* | | | Merge 10.4 into 10.5Marko Mäkelä2020-06-071-0/+2
|\ \ \ \ | |/ / /
| * | | MDEV-22719 Long unique keys are not created when individual key_part->length ↵Sachin2020-06-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | < max_key_length but SUM(key_parts->length) > max_key_length Make UNIQUE HASH key in case when key_info->key_length > max_key_length