summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.4 into 10.5Marko Mäkelä2021-04-251-11/+8
|\
| * Merge 10.3 into 10.4bb-10.4-mergeMarko Mäkelä2021-04-251-11/+8
| |\
| | * This commit adds the same call of st_select_lex::set_unique_exclude() thatIgor Babaev2021-04-241-1/+1
| | | | | | | | | | | | | | | complemented the fix for MDEV-24823 in 10.2. As it is the only call of this function in 10.3 the commit also has added the code of the function.
| | * MDEV-24823 Crash with invalid multi-table update of view in 2nd execution of SPIgor Babaev2021-04-221-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch mergeable derived tables / view used in a multi-table update / delete were merged before the preparation stage. When the merge of a derived table / view is performed the on expression attached to it is fixed and ANDed with the where condition of the select S containing this derived table / view. It happens after the specification of the derived table / view has been merged into S. If the ON expression refers to a non existing field an error is reported and some other mergeable derived tables / views remain unmerged. It's not a problem if the multi-table update / delete statement is standalone. Yet if it is used in a stored procedure the select with incompletely merged derived tables / views may cause a problem for the second call of the procedure. This does not happen for select queries using derived tables / views, because in this case their specifications are merged after the preparation stage at which all ON expressions are fixed. This patch makes sure that merging of the derived tables / views used in a multi-table update / delete statement is performed after the preparation stage. Approved by Oleksandr Byelkin <sanja@mariadb.com>
* | | Merge commit '10.4' into 10.5Oleksandr Byelkin2021-01-061-1/+9
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-12-231-1/+9
| |\ \ | | |/
| | * MDEV-23644 Assertion on evaluating foreign referential action for ↵Aleksey Midenkov2020-12-221-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | self-reference in system versioned table First part of the fix (row0mysql.cc) addresses external columns when adding history row on referential action. The full data must be retrieved before the row is inserted. Second part of the fix (the rest) avoids duplicate primary key error between the history row generated on referential action and the history row generated by SQL command. Both command and referential action can happen on same table since foreign key can be self-reference (parent and child tables are same). Moreover, the self-reference can refer multiple rows when the key is non-unique. In such case history is generated by referential action occured on first row but processed all rows by a matched key. The second round is when the next row is processed by a command but history already exists. In such case we check TRX_ID of existing history row and if it is the same we assume the above situation and skip adding one more history row or failing the command.
* | | Merge 10.4 into 10.5Marko Mäkelä2020-12-021-2/+2
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-12-011-2/+2
| |\ \ | | |/
* | | Merge 10.4 to 10.5Marko Mäkelä2020-10-221-0/+3
|\ \ \ | |/ /
| * | MDEV-19130 Assertion failed in handler::update_auto_incrementNikita Malyavin2020-10-141-0/+3
| | | | | | | | | | | | add store/restore_auto_increment in period portion insert/update functions
* | | MDEV-22535 TABLE::initialize_quick_structures() takes 0.5% in oltp_read_onlyMonty2020-07-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed by: - Make all quick_* variable allocated according to real number keys instead of MAX_KEY - Store all the quick* items in separated allocated structure (OPT_RANGE) - Ensure we don't access any quick* variable without first checking opt_range_keys.is_set(). Thanks to this, we don't need any pre-initialization of quick* variables anymore. Some renames was done to use the new structure: table->quick_keys -> table->opt_range_keys table->quick_rows[X] -> table->opt_range[X].rows table->quick_key_parts[X] -> table->opt_range[X].key_parts table->quick_costs[X] -> table->opt_range[X].cost table->quick_index_only_costs[X] -> table->opt_range[X].index_only_cost table->quick_n_ranges[X] -> table->opt_range[X].ranges table->quick_condition_rows -> table->opt_range_condition_rows This patch should both decrease memory needed for TABLE objects (3528 -> 984 + keyinfo) and increase performance, thanks to less initializations per query, and more localized memory, thanks to the opt_range structure.
* | | Aria will now register it's transactionsMonty2020-05-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-22531 Remove maria::implicit_commit() MDEV-22607 Assertion `ha_info->ht() != binlog_hton' failed in MYSQL_BIN_LOG::unlog_xa_prepare From the handler point of view, Aria now looks like a transactional engine. One effect of this is that we don't need to call maria::implicit_commit() anymore. This change also forces the server to call trans_commit_stmt() after doing any read or writes to system tables. This work will also make it easier to later allow users to have system tables in other engines than Aria. To handle the case that Aria doesn't support rollback, a new handlerton flag, HTON_NO_ROLLBACK, was added to engines that has transactions without rollback (for the moment only binlog and Aria). Other things - Moved freeing of MARIA_SHARE to a separate function as the MARIA_SHARE can be still part of a transaction even if the table has closed. - Changed Aria checkpoint to use the new MARIA_SHARE free function. This fixes a possible memory leak when using S3 tables - Changed testing of binlog_hton to instead test for HTON_NO_ROLLBACK - Removed checking of has_transaction_manager() in handler.cc as we can assume that as the transaction was started by the engine, it does support transactions. - Added new class 'start_new_trans' that can be used to start indepdendent sub transactions, for example while reading mysql.proc, using help or status tables etc. - open_system_tables...() and open_proc_table_for_Read() doesn't anymore take a Open_tables_backup list. This is now handled by 'start_new_trans'. - Split thd::has_transactions() to thd::has_transactions() and thd::has_transactions_and_rollback() - Added handlerton code to free cached transactions objects. Needed by InnoDB. squash! 2ed35999f2a2d84f1c786a21ade5db716b6f1bbc
* | | Change THD->transaction to a pointer to enable multiple transactionsMonty2020-05-231-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | All changes (except one) is of type thd->transaction. -> thd->transaction-> thd->transaction points by default to 'thd->default_transaction' This allows us to 'easily' have multiple active transactions for a THD object, like when reading data from the mysql.proc table
* | | MDEV-22424 Server crashes in handler::check_duplicate_long_entry_key or ↵Sergei Golubchik2020-05-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Assertion `inited == NONE || lookup_handler != this' failed upon DELETE FOR PORTION on table with long unique key even if we're *allowed to* convert DELETE .. FOR PERIOD OF into an update internally, doesn't think we'll *be able to*. We always have to prepare for insert.
* | | Fixed some assert crashes related to keyread.Monty2020-04-191-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | - MDEV-22062 Assertion `!table->file->keyread_enabled()' failed in close_thread_table() - MDEV-22077 table->no_keyread .. failed in join_read_first() - MDEV-22237 Assertion `!table->file->keyread_enabled()' failed in handler::ha_reset on DELETE
* | | MDEV-22218 InnoDB: Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON ↵Sergei Golubchik2020-04-121-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | upon LOAD DATA with NO_BACKSLASH_ESCAPES in SQL_MODE and unique blob in table `inited == NONE` at the initialization time does not always mean that it'll be `NONE` later, at the execution time. Use a more complex caller-specific logic to decide whether to create a cloned lookup handler. Besides LOAD (as in the original bug report) make sure that all prepare_for_insert() invocations are covered by tests. Add tests for CREATE ... SELECT, multi-UPDATE, and multi-DELETE. Don't enable write cache with long uniques.
* | | cleanup: prepare "update_handler" for WITHOUT OVERLAPSSergei Golubchik2020-03-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | * rename to a generic name * move remaning initializations from query exec to prepare time * simplify/unify key handling in open_table_from_share and delayed * remove dead code * move tests where they belong
* | | Improve update handler (long unique keys on blobs)Monty2020-03-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-21606 Improve update handler (long unique keys on blobs) MDEV-21470 MyISAM and Aria start_bulk_insert doesn't work with long unique MDEV-21606 Bug fix for previous version of this code MDEV-21819 2 Assertion `inited == NONE || update_handler != this' - Move update_handler from TABLE to handler - Move out initialization of update handler from ha_write_row() to prepare_for_insert() - Fixed that INSERT DELAYED works with update handler - Give an error if using long unique with an autoincrement column - Added handler function to check if table has long unique hash indexes - Disable write cache in MyISAM and Aria when using update_handler as if cache is used, the row will not be inserted until end of statement and update_handler would not find conflicting rows. - Removed not used handler argument from check_duplicate_long_entries_update() - Syntax cleanups - Indentation fixes - Don't use single character indentifiers for arguments
* | | MDEV-21743 Split up SUPER privilege to smaller privilegesAlexander Barkov2020-03-101-1/+0
| | |
* | | 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
| |\ \ | | |/
| | * MDEV-18929 2nd execution of SP does not detect ER_VERS_NOT_VERSIONEDAleksey Midenkov2019-12-031-1/+1
| | | | | | | | | | | | | | | | | | Wrong assertion condition. SYSTEM_TIME_ALL indicates that vers_setup_conds() is done. In case FOR SYSTEM_TIME ALL is specified in command the assertion passes but not checks anything.
| | * MDEV-18727 cleanupAleksey Midenkov2019-11-251-14/+0
| | |
| | * MDEV-18727 improve DML operation of System VersioningAleksey Midenkov2019-11-221-40/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-18957 UPDATE with LIMIT clause is wrong for versioned partitioned tables UPDATE, DELETE: replace linear search of current/historical records with vers_setup_conds(). Additional DML cases in view.test
* | | Merge 10.4 into 10.5Aleksey Midenkov2019-11-251-48/+17
|\ \ \ | |/ /
| * | MDEV-18727 improve DML operation of System Versioning (10.4)Aleksey Midenkov2019-11-251-48/+17
| | | | | | | | | | | | | | | | | | | | | UPDATE, DELETE: replace linear search of current/historical records with vers_setup_conds(). Additional DML cases in view.test
* | | MDEV-20854: ANALYZE for statements: not clear where the time is spentSergei Petrunia2019-11-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Count the "gap" time between table accesses and display it as r_other_time_ms in the "table" element. * The advantage of this approach is that it doesn't add any new my_timer_cycles() calls. * The disadvantage is that the definition of what is done during "other time" is not that clear: it includes checking the WHERE (for this table), constructing index lookup tuple (for the next table) writing to GROUP BY temporary table (as we dont account for that time separately [yet], etc)
* | | Merge 10.4 into 10.5Oleksandr Byelkin2019-11-071-2/+2
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2019-11-011-2/+2
| |\ \ | | |/
| | * Fixes for binary logging --read-only modeMonty2019-10-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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()
* | | MDEV-10014 Add RETURNING to INSERTRucha Deodhar2019-10-141-30/+18
| | | | | | | | | | | | Closes #1384
* | | cleanup st_select_lex_unit::explainableSergei Golubchik2019-10-141-13/+1
| | |
* | | cleanup: formattingSergei Golubchik2019-10-141-1/+1
| | | | | | | | | | | | comments, whitespaces
* | | cleanup: don't pass wild_num to setup_wild()Sergei Golubchik2019-10-141-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | because internally setup_wild() adjusts select_lex->with_wild directly anyway, so there is no reason to pretend that the number of '*' may be anything else but select_lex->with_wild And don't update select_lex->item_list, because fields can come from anywhere and don't necessarily have to be copied into select_lex.
* | | MDEV-18553: MDEV-16327 pre-requisits part 2: uniform of LIMIT/OFFSET handlingOleksandr Byelkin2019-10-131-0/+1
|/ / | | | | | | | | | | | | Now both offset and limit are stored and do not chenged during execution (offset is decreased during processing in versions before 10.5). (Big part of this changes made by Monty)
* | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-07-281-1/+2
|\ \ | |/
| * Merge branch '10.2' into 10.3Oleksandr Byelkin2019-07-261-1/+2
| |\
| | * Merge branch '10.1' into 10.2Oleksandr Byelkin2019-07-261-1/+2
| | |\
| | | * Merge branch '5.5' into 10.1Oleksandr Byelkin2019-07-251-2/+3
| | | |\
| | | | * BUG#28642318: POINT IN TIME RECOVERY USING MYSQLBINLOG BROKEN WITH TEMPORARY ↵Nisha Gopalakrishnan2019-07-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TABLE -> ERRORS Analysis ======== Point in time recovery using mysqlbinlog containing queries operating on temporary tables results in an error. While writing the query log event in the binary log, the thread id used for execution of DROP TABLE and DELETE commands were incorrect. The thread variable 'thread_specific_used' is used to determine whether a specific thread id is to used while executing the statements i.e using 'SET @@session.pseudo_thread_id'. This variable was not set correctly for DROP TABLE query and was never set for DELETE query. The thread id is important for temporary tables since the tables are session specific. DROP TABLE and DELETE queries executed using a wrong thread id resulted in errors while applying the queries generated by mysqlbinlog utility. Fix === Set the 'thread_specific_used' THD variable for DROP TABLE and DELETE queries. ReviewBoard: 21833
* | | | | Merge 10.3 into 10.4Eugene Kosov2019-07-261-7/+10
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-19814 Assertion `update->n_fields < ulint(table->n_cols + ↵Aleksey Midenkov2019-07-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | table->n_v_cols)' on DELETE HISTORY Turn off versioned_write for DELETE HISTORY.
| * | | | Cleanups: DELETE HISTORY [MDEV-19814]Aleksey Midenkov2019-07-251-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Made make_versioned_*() proxies inline; * Renamed truncate_history to delete_history Part of: MDEV-19814 Server crash in row_upd_del_mark_clust_rec or Assertion `update->n_fields < ulint(table->n_cols + table->n_v_cols)' failed in upd_node_t::make_versioned_helper
* | | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-7/+2
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-15458 Segfault in heap_scan() upon UPDATE after ADD SYSTEM VERSIONINGSergei Golubchik2019-05-171-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | handler::write_row() should not destroy the state of the running index_search/index_next/... or rnd_init/rnd_next/... scan
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | | |\ \ | | | | |/
| | | | * Update FSF AddressVicențiu Ciorbaru2019-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | * Update wrong zip-code