summaryrefslogtreecommitdiff
path: root/mysql-test/t/multi_update.test
Commit message (Collapse)AuthorAgeFilesLines
* Create 'main' test directory and move 't' and 'r' thereMichael Widenius2018-03-291-916/+0
|
* MDEV-12874 UPDATE statements with the same source and targethalfspawn2017-10-031-1/+0
|
* MDEV-13911 Support ORDER BY and LIMIT in multi-table updateSergei Golubchik2017-10-031-0/+14
|
* cleanup: split multi_update test in twoSergei Golubchik2017-10-031-84/+1
| | | | | | | move binlog-dependent part (~6%) into a separate file, to be able to run the rest of multi_update with embedded server (include/have_log_bin.inc disables embedded)
* MDEV-7635: Update tests to adapt to the new default sql_modeNirbhay Choubey2017-02-101-2/+2
|
* enable tests that were skipped because of have_xtradbSergei Golubchik2016-12-291-124/+0
| | | | | | | | | * some of these tests run just fine with InnoDB: -> s/have_xtradb/have_innodb/ * sys_var tests did basic tests for xtradb only variables -> remove them, they're useless anyway (sysvar_innodb does it better) * multi_update had innodb specific tests -> move to multi_update_innodb.test
* Merge branch '10.0' into 10.1Sergei Golubchik2016-06-281-0/+24
|\
| * MDEV-5973: MySQL Bug#11757486:49539: NON-DESCRIPTIVE ERR (ERROR 0 FROM ↵Oleksandr Byelkin2016-06-211-0/+24
| | | | | | | | | | | | STORAGE ENGINE) WITH MULTI-TABLE UPDATE Condition in processing IGNORE clause for UPDATE & multi-table UPDATE made the same.
* | MDEV-3929 Add system variable explicit_defaults_for_timestamp for ↵Alexander Barkov2015-09-221-2/+2
| | | | | | | | compatibility with MySQL
* | MDEV-6066: Merge new defaults from 5.6 and 5.7 (defaults changed, QC can be ↵Oleksandr Byelkin2015-09-041-0/+1
|/ | | | stopped with no-zero size)
* Merge branch '5.5' into 10.0Sergei Golubchik2015-05-041-0/+206
|\
| * MDEV-8018: main.multi_update fails with --ps-protocolOleksandr Byelkin2015-04-221-0/+6
| | | | | | | | | | | | save_prep_leaf_tables() made recursive to work with underlying view Arena restoiring fixed in case of EOM.
| * MDEV-7613: MariaDB 5.5.40 server crash on update table left join with a viewOleksandr Byelkin2015-04-151-0/+200
| | | | | | | | Multi-update do not need full list of leaf tables. It also do not use it on prepare (mysql_multi_update_prepare()).
* | 5.5 mergeSergei Golubchik2014-05-091-0/+41
|\ \ | |/
| * MDEV-6193: Problems with multi-table updates that JOIN against read-only tableunknown2014-05-081-1/+10
| | | | | | | | All underlying tables should share the same lock type.
| * MDEV-6139: UPDATE w/ join against MRG_MyISAM table with read-only sub-table ↵unknown2014-04-281-0/+32
| | | | | | | | | | | | | | | | | | | | failsUPDATE w/ join against MRG_MyISAM table with read-only sub-table fails The problem was that on opening all tables TL_WRITE, than local tables which is not updated set to TL_READ, but underlying tables of MyISAMmrg left untouched. Prartition engine has not this problem. All cases where lock_type assigned is not changed because call of virtual function is not cheap.
* | Fixed the problem of mdev-5970: Igor Babaev2014-04-171-0/+26
|/ | | | | | | | | | | | | | | | | | | | | | | back-ported the patch for bug #13256831 from mysql-5.6 code line. Here's the comment this patch was provided with: Fixed bug#13256831 - ERROR 1032 (HY000): CAN'T FIND RECORD. This bug only occurs if a user tries to update a base table using an updatable view and this view was created as a join for which the clause 'WITH CHECK OPTION' was specified. The reason for the bug was that when such an update was executed, row positions were not properly handled for tables that were not updated but had constraints that had to be checked due to the 'WITH CHECK OPTION' clause. The reason for the bug was that when such update is executed then for tables specified in the view definition and also listed in the 'WITH CHECK OPTION' clause the positioning to row being updated is not performed.
* 5.3->5.5 mergeSergei Golubchik2013-02-281-2/+50
|\
| * MDEV-4123 fix.unknown2013-02-111-0/+47
| | | | | | | | Missed update_used_tables() call for multi-update values.
* | mysql-5.5.22 mergeSergei Golubchik2012-03-281-0/+5
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mysql-test/suite/innodb/t/group_commit_crash.test: remove autoincrement to avoid rbr being used for insert ... select mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test: remove autoincrement to avoid rbr being used for insert ... select mysys/my_addr_resolve.c: a pointer to a buffer is returned to the caller -> the buffer cannot be on the stack mysys/stacktrace.c: my_vsnprintf() is ok here, in 5.5
| * | fixing test failure on pb2.Rohit Kalhans2012-02-131-0/+2
| | |
| * | BUG#11758263: Modification of indentation in the added code.Rohit Kalhans2012-02-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed a typo in the comment. Fixing test cases which were previouslyno throwing due disable warnings macro. sql/sql_base.cc: Change in indentation and fixing a typo in the comment.
| * | BUG#11758263 50440: MARK UNORDERED UPDATE WITH AUTOINC UNSAFERohit Kalhans2012-02-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Statements that write to tables with auto_increment columns based on the selection from another table, may lead to master and slave going out of sync, as the order in which the rows are retrieved from the table may differ on master and slave. Solution: We mark writing to a table with auto_increment table based on the rows selected from another table as unsafe. This will cause the execution of such statements to throw a warning and forces the statement to be logged in ROW if the logging format is mixed. Changes: 1. All the statements that writes to a table with auto_increment column(s) based on the rows fetched from another table, will now be unsafe. 2. CREATE TABLE with SELECT will now be unsafe. sql/share/errmsg-utf8.txt: Added new warning messages. sql/sql_base.cc: -Created function to check statements that write to tables with auto_increment column and has select. -Marked all the statements that write to a table with auto_increment column based on rows fetched from other table(s) as unsafe. sql/sql_table.cc: mark CREATE TABLE[with auto_increment column] as unsafe.
| * | Backout the patch for bug#11758263.Rohit Kalhans2012-02-081-1/+0
| | |
| * | BUG#11758263 50440: MARK UNORDERED UPDATE WITH AUTOINC UNSAFERohit Kalhans2012-02-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Statements that write to tables with auto_increment columns based on the selection from another table, may lead to master and slave going out of sync, as the order in which the rows are retrived from the table may differ on master and slave. Solution: We mark writing to a table with auto_increment table as unsafe. This will cause the execution of such statements to throw a warning and forces the statement to be logged in ROW if the logging format is mixed. Changes: 1. All the statements that writes to a table with auto_increment column(s) based on the rows fetched from another table, will now be unsafe. 2. CREATE TABLE with SELECT will now be unsafe. sql/share/errmsg-utf8.txt: Added new Warning messages sql/sql_base.cc: created a new function that checks for select + write on a autoinc table made all such statements to be unsafe. sql/sql_parse.cc: made create autoincremnet tabble + select unsafe
* | | merge with 5.3Sergei Golubchik2011-10-191-0/+3
|\ \ \ | | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sql/sql_insert.cc: CREATE ... IF NOT EXISTS may do nothing, but it is still not a failure. don't forget to my_ok it. ****** CREATE ... IF NOT EXISTS may do nothing, but it is still not a failure. don't forget to my_ok it. sql/sql_table.cc: small cleanup ****** small cleanup
| * | Applied Sanja's patch to fix LP bug #784297 in the tree for mwl106.Igor Babaev2011-05-271-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The patch imposes unconditional materialization for derived tables used in update and multi-update statements. Fixed a bug with a wrong order of processing derived tables/views at the prepare stage that caused a crash for the variant of the query from test case for bug 52157.
| * | Fixed 3 valgrind bugs.Igor Babaev2011-05-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two of them (in the function make_join_statistics and in the function sort_and_filter_keyuse) were due to bad merges while the third bug was triggered by uninitialized values of the field JOIN_TAB::preread_init_done. Fixed a compiler warning in mysql_priv.h. Commented out some queries from the funcs_1 suite returning wrong errors due to bugs concerning updatable views (see bugs 784297 and 784303). Adjusted some results for the test cases with derived tables from different suites.
| * | Merged the code of MWL#106 into 5.3Igor Babaev2011-05-161-1/+3
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolved all conflicts, bad merges and fixed a few minor bugs in the code. Commented out the queries from multi_update, view, subselect_sj, func_str, derived_view, view_grant that failed either with crashes in ps-protocol or with wrong results. The failures are clear indications of some bugs in the code and these bugs are to be fixed.
| * \ \ Merge with 5.2Michael Widenius2011-03-091-0/+11
| |\ \ \
| | * \ \ Merge with MySQL 5.1.55Michael Widenius2011-02-201-0/+11
| | |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fixed some issues with partitions and connection_string, which also fixed lp:716890 "Pre- and post-recovery crash in Aria" - Fixed wrong assert in Aria Now need to merge with latest xtradb before pushing sql/ha_partition.cc: Ensure that m_ordered_rec_buffer is not freed before close. sql/mysqld.cc: Changed to use opt_stack_trace instead of opt_pstack. Removed references to pstack sql/partition_element.h: Ensure that connect_string is initialized storage/maria/ma_key_recover.c: Fixed wrong assert
| * | | | | Implementation of MWL#172: Add support for prepared statements to HANDLER READMichael Widenius2011-01-041-4/+4
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It includes speed optimizations for HANDLER READ by caching as much as possible in HANDLER OPEN Other things: - Added mysqld option --disable-thr-alarm to be able to benchmark things without thr_alarm - Changed 'Locked' state to 'System lock' and 'Table lock' (these where used in the code but never shown to end user) - Better error message if mysql_install_db.sh fails - Moved handler function prototypes to sql_handler.h - Remove not anymore used 'thd->locked' member include/thr_alarm.h: Added my_disable_thr_alarm include/thr_lock.h: Add new member to THR_LOCK_DATA to remember original lock type state. This is needed as thr_unlock() resets type to TL_UNLOCK. mysql-test/include/check_no_concurrent_insert.inc: Locked -> Table lock mysql-test/include/handler.inc: Locked -> Table lock mysql-test/r/handler_innodb.result: Updated results for new tests mysql-test/r/handler_myisam.result: Updated results for new tests mysql-test/r/sp-threads.result: Locked -> Table lock mysql-test/suite/binlog/t/binlog_stm_row.test: Locked -> Table lock mysql-test/suite/funcs_1/datadict/processlist_val.inc: Locked -> Table lock mysql-test/suite/pbxt/t/lock_multi.test: Locked -> Table lock mysql-test/suite/sys_vars/r/concurrent_insert_func.result: Locked -> Table lock mysql-test/suite/sys_vars/t/concurrent_insert_func.test: Locked -> Table lock mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test: Locked -> Table lock mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test: Locked -> Table lock mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test: Locked -> Table lock mysql-test/t/insert_notembedded.test: Locked -> Table lock mysql-test/t/lock_multi.test: Locked -> Table lock mysql-test/t/merge-big.test: Locked -> Table lock mysql-test/t/multi_update.test: Locked -> Table lock mysql-test/t/query_cache_28249.test: Locked -> Table lock mysql-test/t/sp_notembedded.test: Locked -> Table lock mysql-test/t/sp_sync.test: Locked -> Table lock mysql-test/t/status.test: Locked -> Table lock mysql-test/t/trigger_notembedded.test: Locked -> Table lock mysys/thr_alarm.c: Added option to disable thr_alarm mysys/thr_lock.c: Detect loops scripts/mysql_install_db.sh: Give better error message if something goes wrong sql/Makefile.am: Added sql_handler.h sql/lock.cc: Split functions to allow one to cache value if store_lock() (for HANDLER functions). - Split mysql_lock_tables() into two functions, where first one allocates MYSQL_LOCK and other other one uses it. - Made get_lock_data() an external function. - Added argument to mysql_unlock_tables() to not free sql_lock. - Added argument to reset_lock_data() to reset lock structure to initial state (as after get_lock_data()) sql/mysql_priv.h: Moved handler function prototypes to sql_handler.h Added new lock functions. sql/mysqld.cc: Added --thread-alarm startup option sql/net_serv.cc: Don't call vio_blocking() if not needed sql/sql_base.cc: include sql_handler.h sql/sql_class.cc: include sql_handler.h Remove not anymore used 'thd->locked' member sql/sql_class.h: Remove not anymore used 'thd->locked' member sql/sql_db.cc: include sql_handler.h sql/sql_delete.cc: include sql_handler.h sql/sql_handler.cc: Rewrote all code to use SQL_HANDLER instead of TABLE_LIST (original interface) Rewrote mysql_ha_open() to cache all things from TABLE_LIST and items for field list, where etc. In mysql_ha_open() also cache MYSQL_LOCK structure from get_lock_data(). Split functions into smaller sub functions (needed to be able to implement mysql_ha_read_prepare()) Added mysql_ha_read_prepare() to allow one to prepare HANDLER READ. sql/sql_handler.h: Interface to sql_handler.cc sql/sql_parse.cc: include sql_handler.h sql/sql_prepare.cc: Added mysql_test_handler_read(), prepare for HANDLER READ sql/sql_rename.cc: include sql_handler.h sql/sql_show.cc: Removed usage of thd->locked sql/sql_table.cc: include sql_handler.h sql/sql_trigger.cc: include sql_handler.h
| * | | | Merge with MySQL 5.1.52Michael Widenius2010-11-231-0/+21
| |\ \ \ \
* | \ \ \ \ 5.5-mergeSergei Golubchik2011-07-021-1/+78
|\ \ \ \ \ \ | | |_|_|_|/ | |/| | | |
| * | | | | BUG#11882110: UPDATE REPORTS ER_KEY_NOT_FOUND IF TABLE IS Jorgen Loland2011-06-161-1/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UPDATED TWICE For multi update it is not allowed to update a column of a table if that table is accessed through multiple aliases and either 1) the updated column is used as partitioning key 2) the updated column is part of the primary key and the primary key is clustered This check is done in unsafe_key_update(). The bug was that for case 2), it was checked whether updated_column_number == table_share->primary_key However, the primary_key variable is the index number of the primary key, not a column number. Prior to this bugfix, the first column was wrongly believed to be the primary key. The columns covered by an index is found in table->key_info[idx_number]->key_part. The bugfix is to check if any of the columns in the keyparts of the primary key are updated. The user-visible effect is that for storage engines with clustered primary key (e.g. InnoDB but not MyISAM) queries like "UPDATE t1 AS A JOIN t2 AS B SET A.primkey=..." will now error with "ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'." instead of "ERROR 1032 (HY000): Can't find record in 't1_tb'" even if primkey is not the first column in the table. This was the intended behavior of bugfix 11764529. mysql-test/r/multi_update.result: Add test for bug#11882110 mysql-test/r/multi_update_innodb.result: Add test for bug#11882110 mysql-test/t/multi_update.test: Add test for bug#11882110 mysql-test/t/multi_update_innodb.test: Add test for bug#11882110 sql/sql_update.cc: unsafe_key_update() wrongly checked if the primary key index number was the same as updated column number. Now it is checked whether any of the columns making up the primary key is updated. sql/table.h: Fix comment on TABLE_SHARE::primary_key. Incorrect comment was introduced by an earlier merge conflict (as per dlenev)
| * | | | | BUG#11762751: UPDATE STATEMENT THROWS AN ERROR, BUT STILL Jorgen Loland2011-02-211-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UPDATES THE TABLE ENTRIES (formerly 55385) BUG#11764529: MULTI UPDATE+INNODB REPORTS ER_KEY_NOT_FOUND IF A TABLE IS UPDATED TWICE (formerly 57373) If multiple-table update updates a row through two aliases and the first update physically moves the row, the second update will fail to locate the row. This results in different errors depending on storage engine: * MyISAM: Got error 134 from storage engine * InnoDB: Can't find record in 'tbl' None of these errors accurately describe the problem. Furthermore, since MyISAM is non-transactional, the update executed first will be performed while the second will not. In addition, for two equal multiple-table update statements, one could succeed and the other fail based on whether or not the record actually moved or not. This was inconsistent. Two update operations may physically move a row: 1) Update of a column in a clustered primary key 2) Update of a column used to calculate which partition the row belongs to BUG#11764529 is about case 1) above, BUG#11762751 was about case 2). The fix for these bugs is to return with an error if multiple-table update is about to: a) Update a table through multiple aliases, and b) Perform an update that may physically more the row in at least one of these aliases This avoids * partial updates as described for MyISAM above, * provides the same error message that describes the actual problem for all SEs * inconsistent behavior where a statement fails or succeeds based on e.g. the partitioning algorithm of the table. mysql-test/r/multi_update.result: Add test for bug#57373 mysql-test/r/multi_update_innodb.result: Add test for bug#57373 mysql-test/r/partition.result: Add test for bug#55385 mysql-test/t/multi_update.test: Add test for bug#57373 mysql-test/t/multi_update_innodb.test: Add test for bug#57373 mysql-test/t/partition.test: Add test for bug#55385 sql/handler.cc: Translate handler error HA_ERR_RECORD_DELETED to server error sql/share/errmsg-utf8.txt: New error message for multi-table update where the same table is updated multiple times. sql/sql_update.cc: Add function unsafe_key_update()
| * | | | | 5.1-bugteam->5.5-bugteam mergeSergey Glukhov2010-12-141-0/+11
| |\ \ \ \ \ | | | |_|/ / | | |/| | |
| | * | | | Fixed following problems:Sergey Glukhov2010-12-141-0/+11
| | | |/ / | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --Bug#52157 various crashes and assertions with multi-table update, stored function --Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb --Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846 --Bug#57352 valgrind warnings when creating view --Recently discovered problem when a nested materialized derived table is used before being populated and it leads to incorrect result We have several modes when we should disable subquery evaluation. The reasons for disabling are different. It could be uselessness of the evaluation as in case of 'CREATE VIEW' or 'PREPARE stmt', or we should disable subquery evaluation if tables are not locked yet as it happens in bug#54475, or too early evaluation of subqueries can lead to wrong result as it happened in Bug#19077. Main problem is that if subquery items are treated as const they are evaluated in ::fix_fields(), ::fix_length_and_dec() of the parental items as a lot of these methods have Item::val_...() calls inside. We have to make subqueries non-const to prevent unnecessary subquery evaluation. At the moment we have different methods for this. Here is a list of these modes: 1. PREPARE stmt; We use UNCACHEABLE_PREPARE flag. It is set during parsing in sql_parse.cc, mysql_new_select() for each SELECT_LEX object and cleared at the end of PREPARE in sql_prepare.cc, init_stmt_after_parse(). If this flag is set subquery becomes non-const and evaluation does not happen. 2. CREATE|ALTER VIEW, SHOW CREATE VIEW, I_S tables which process FRM files We use LEX::view_prepare_mode field. We set it before view preparation and check this flag in ::fix_fields(), ::fix_length_and_dec(). Some bugs are fixed using this approach, some are not(Bug#57352, Bug#57703). The problem here is that we have a lot of ::fix_fields(), ::fix_length_and_dec() where we use Item::val_...() calls for const items. 3. Derived tables with subquery = wrong result(Bug19077) The reason of this bug is too early subquery evaluation. It was fixed by adding Item::with_subselect field The check of this field in appropriate places prevents const item evaluation if the item have subquery. The fix for Bug19077 fixes only the problem with convert_constant_item() function and does not cover other places(::fix_fields(), ::fix_length_and_dec() again) where subqueries could be evaluated. Example: CREATE TABLE t1 (i INT, j BIGINT); INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2); SELECT * FROM (SELECT MIN(i) FROM t1 WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3; DROP TABLE t1; 4. Derived tables with subquery where subquery is evaluated before table locking(Bug#54475, Bug#52157) Suggested solution is following: -Introduce new field LEX::context_analysis_only with the following possible flags: #define CONTEXT_ANALYSIS_ONLY_PREPARE 1 #define CONTEXT_ANALYSIS_ONLY_VIEW 2 #define CONTEXT_ANALYSIS_ONLY_DERIVED 4 -Set/clean these flags when we perform context analysis operation -Item_subselect::const_item() returns result depending on LEX::context_analysis_only. If context_analysis_only is set then we return FALSE that means that subquery is non-const. As all subquery types are wrapped by Item_subselect it allow as to make subquery non-const when it's necessary. mysql-test/r/derived.result: test case mysql-test/r/multi_update.result: test case mysql-test/r/view.result: test case mysql-test/suite/innodb/r/innodb_multi_update.result: test case mysql-test/suite/innodb/t/innodb_multi_update.test: test case mysql-test/suite/innodb_plugin/r/innodb_multi_update.result: test case mysql-test/suite/innodb_plugin/t/innodb_multi_update.test: test case mysql-test/t/derived.test: test case mysql-test/t/multi_update.test: test case mysql-test/t/view.test: test case sql/item.cc: --removed unnecessary code sql/item_cmpfunc.cc: --removed unnecessary checks --THD::is_context_analysis_only() is replaced with LEX::is_ps_or_view_context_analysis() sql/item_func.cc: --refactored context analysis checks sql/item_row.cc: --removed unnecessary checks sql/item_subselect.cc: --removed unnecessary code --added DBUG_ASSERT into Item_subselect::exec() which asserts that subquery execution can not happen if LEX::context_analysis_only is set, i.e. at context analysis stage. --Item_subselect::const_item() Return FALSE if LEX::context_analysis_only is set. It prevents subquery evaluation in ::fix_fields & ::fix_length_and_dec at context analysis stage. sql/item_subselect.h: --removed unnecessary code sql/mysql_priv.h: --Added new set of flags. sql/sql_class.h: --removed unnecessary code sql/sql_derived.cc: --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_lex.cc: --init LEX::context_analysis_only field sql/sql_lex.h: --New LEX::context_analysis_only field sql/sql_parse.cc: --removed unnecessary code sql/sql_prepare.cc: --removed unnecessary code --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_select.cc: --refactored context analysis checks sql/sql_show.cc: --added LEX::context_analysis_only analysis intialization/cleanup sql/sql_view.cc: --added LEX::context_analysis_only analysis intialization/cleanup
* | | | | merge.Sergei Golubchik2010-11-251-4/+8
|\ \ \ \ \ | |/ / / / |/| | / / | | |/ / | |/| | | | | | checkpoint. does not compile.
| * | | Merge with MySQL 5.1.49Michael Widenius2010-08-021-2/+4
| |\ \ \ | | |_|/ | |/| | | | | | Fixed Bug#52005 'JOIN_TAB->dependent' may be incorrectly propageted for multilevel outer joins' in a better way (patch from Sergey Petrunya)
| * | | Merge MySQL 5.1.46 into MariaDB.unknown2010-04-281-0/+12
| |\ \ \ | | | | | | | | | | | | | | | Still two test failures to be solved: main.myisam and main.subselect.
| * | | | Speed up of test suite:Michael Widenius2009-10-281-4/+8
| | | | | | | | | | | | | | | | | | | | - Added --disable_query_log ; begin ; .... commit; --enable_query_log around all while loops that does insert
* | | | | Merge of fix for Bug#54543. Test case only (bug is not present in this tree).Martin Hansson2010-09-071-0/+21
|\ \ \ \ \ | | |_|_|/ | |/| | |
| * | | | Bug#54543: update ignore with incorrect subquery leads to assertion failure:Martin Hansson2010-09-071-0/+21
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | inited==INDEX When an error occurs while sending the data in a temporary table there was no cleanup performed. This caused a failed assertion in the case when different access methods were used for populating the table vs. retrieving the data from the table if IGNORE was specified and sql_safe_updates = 0. In this case execution continues, but the handler expects to continue with the access method used for row retrieval. Fixed by doing the cleanup even if errors occur.
* | | | Part of fix for bug#52044 "FLUSH TABLES WITH READ LOCK andDmitry Lenev2010-08-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FLUSH TABLES <list> WITH READ LOCK are incompatible" to be pushed as separate patch. Replaced thread state name "Waiting for table", which was used by threads waiting for a metadata lock or table flush, with a set of names which better reflect types of resources being waited for. Also replaced "Table lock" thread state name, which was used by threads waiting on thr_lock.c table level lock, with more elaborate "Waiting for table level lock", to make it more consistent with other thread state names. Updated test cases and their results according to these changes. Fixed sys_vars.query_cache_wlock_invalidate_func test to not to wait for timeout of wait_condition.inc script. mysql-test/r/query_cache.result: Added test coverage for query_cache_wlock_invalidate behavior for implicitly locked tables. mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result: Fixed sys_vars.query_cache_wlock_invalidate_func test to not to wait for timeout of wait_condition.inc script. Reverted changes to test which introduced timeout and replaced waiting condition with a more appropriate one. Test coverage for query_cache_wlock_invalidate behavior for implicitly locked tables was added to query_cache.test. mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test: Fixed sys_vars.query_cache_wlock_invalidate_func test to not to wait for timeout of wait_condition.inc script. Reverted changes to test which introduced timeout and replaced waiting condition with a more appropriate one. Test coverage for query_cache_wlock_invalidate behavior for implicitly locked tables was added to query_cache.test. mysql-test/t/query_cache.test: Added test coverage for query_cache_wlock_invalidate behavior for implicitly locked tables. mysys/thr_lock.c: Replaced "Table lock" thread state name, which was used by threads waiting on thr_lock.c table level lock, with more elaborate "Waiting for table level lock", to make it consistent with thread state names which are used while waiting for metadata locks and table flush. sql/mdl.cc: Replaced thread state name "Waiting for table", which was used by threads waiting for a metadata lock or table flush, with a set of names which better reflect types of resources being waited for. To implement this: - Adjusted MDL_wait::timed_wait() to take thread state name as parameter. - Introduced method of MDL_key class which allows to get thread state name to be used while waiting for resource corresponding to the key and changed code to use it. Added array translating namespaces to thread state names as part of this change. sql/mdl.h: To implement this: - Adjusted MDL_wait::timed_wait() to take thread state name as parameter. - Introduced method of MDL_key class which allows to get thread state name to be used while waiting for resource corresponding to the key and changed code to use it. Added array translating namespaces to thread state names as part of this change. sql/sql_base.cc: Replaced thread state name "Waiting for table", which was used by threads waiting for table flush, with a more elaborate "Waiting for table flush".
* | | | Manual mergeunknown2010-05-261-2/+2
|\ \ \ \ | |/ / /
| * | | Bug #49741 test files contain explicit references to bin/relay-log positionsunknown2010-05-241-2/+4
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the test cases reference to binlog position and these position numbers are written into result explicitly. It is difficult to maintain if log event format changes. There are a couple of cases explicit position number appears, we handle them in different ways A. 'CHANGE MASTER ...' with MASTER_LOG_POS or/and RELAY_LOG_POS options Use --replace_result to mask them. B. 'SHOW BINLOG EVENT ...' Replaced by show_binlog_events.inc or wait_for_binlog_event.inc. show_binlog_events.inc file's function is enhanced by given $binlog_file and $binlog_limit. C. 'SHOW SLAVE STATUS', 'show_slave_status.inc' and 'show_slave_status2.inc' For the test cases just care a few items in the result of 'SHOW SLAVE STATUS', only the items related to each test case are showed. 'show_slave_status.inc' is rebuild, only the given items in $status_items will be showed. 'check_slave_is_running.inc' and 'check_slave_no_error.inc' and 'check_slave_param.inc' are auxiliary files helping to show running status and error information easily. mysql-test/extra/binlog_tests/binlog.test: It only cares whether current binlog file index is changed, so it is ok with 'show_master_status.inc' instead of 'show mater status'. mysql-test/extra/binlog_tests/blackhole.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/extra/rpl_tests/rpl_deadlock.test: Use 'check_slave_is_running.inc' instead of 'show_slave_status2.inc'. mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test: Use 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test: Use 'wait_for_slave_sql_error.inc' and 'ait_for_slave_sql_error_and_skip.inc' instead of 'show slave status'. mysql-test/extra/rpl_tests/rpl_flsh_tbls.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test: It is need now to give a error number, so use 'wait_for_slave_io_to_stop.inc' instead of 'wait_for_slave_io_error.inc'. mysql-test/extra/rpl_tests/rpl_insert_delayed.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/extra/rpl_tests/rpl_log.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. se 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/extra/rpl_tests/rpl_max_relay_size.test: se 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/extra/rpl_tests/rpl_ndb_apply_status.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/extra/rpl_tests/rpl_reset_slave.test: Use 'show_slave_status.inc' instead of 'show_slave_status2.inc' statement. Use 'check_slave_no_error.inc' to simplify the check that there is no error. mysql-test/extra/rpl_tests/rpl_row_basic.test: Use 'check_slave_is_running.inc' to verify that Slave threads are running well. Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. mysql-test/extra/rpl_tests/rpl_row_tabledefs.test: Use 'show_slave_error_status_and_skip.inc' instead of 'show slave status'. mysql-test/include/check_slave_is_running.inc: To make sure both sql and io thread are running well. If not, the test will be aborted. mysql-test/include/check_slave_no_error.inc: To make sure both sql and io thread have no error. If not, the test will be aborted. mysql-test/include/get_relay_log_pos.inc: According to the position of a log event in master binlog file, find the peer position of a log event in relay log file. mysql-test/include/rpl_stmt_seq.inc: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/include/show_binlog_events.inc: Add two options $binlog_file and $binlog_limit for showing binlog events from different binlog files or/and given different limits on position or row number. mysql-test/include/show_rpl_debug_info.inc: Add 'SELECT NOW()' in the debug information. mysql-test/include/show_slave_status.inc: It's more clean and tidy Only the given columns of slave status are printed. mysql-test/include/test_fieldsize.inc: Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave stutus'. mysql-test/include/wait_for_binlog_event.inc: Use show_rpl_debug_info.inc instead of 'SHOW BINLOG EVENTS'. mysql-test/include/wait_for_slave_io_error.inc: Add $slave_io_errno and $show_slave_io_error, it waits only a given error. mysql-test/include/wait_for_slave_param.inc: Use die instead of exit. mysql-test/include/wait_for_slave_sql_error.inc: Add $slave_sql_errno and $show_slave_sql_error, it waits only a given error. mysql-test/include/wait_for_status_var.inc: Use die instead of exit. mysql-test/r/flush_block_commit_notembedded.result: It checks whether somethings are binlogged, so we using 'show_binlog_event.inc' instead of 'show master status'. mysql-test/r/multi_update.result: It checks whether somethings are binlogged, so we using 'show_binlog_event.inc' instead of 'show master status'. mysql-test/suite/binlog/r/binlog_innodb.result: It checks whether somethings are binlogged, so we using 'show_binlog_event.inc' instead of 'show master status'. mysql-test/suite/binlog/r/binlog_row_binlog.result: Position in the result of 'show master status' is replaced by '#'. mysql-test/suite/binlog/r/binlog_stm_binlog.result: Position in the result of 'show master status' is replaced by '#'. mysql-test/suite/binlog/t/binlog_innodb.test: It checks whether somethings are binlogged, so we use 'show_binlog_event.inc' instead of 'show master status'. mysql-test/suite/binlog/t/binlog_stm_binlog.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/bugs/r/rpl_bug36391.result: Position in the result of 'show master status' is replaced by '#'. mysql-test/suite/bugs/t/rpl_bug12691.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/bugs/t/rpl_bug36391.test: 'show master status' is replaced by 'show_master_status.inc'. Position in the result of 'show master status' is replaced by '#'. mysql-test/suite/engines/funcs/r/rpl_000015.result: It checks whether somethings are binlogged, so we using 'show_binlog_event.inc' instead of 'show master status'. mysql-test/suite/engines/funcs/t/rpl_000015.test: Use 'check_slave_is_running.inc' to verify that Slave threads are running well. mysql-test/suite/engines/funcs/t/rpl_REDIRECT.test: Use 'query_vertical SHOW SLAVE STATUS' instead of 'show slave status'. There is no status columns in the result file, for no slave exists on master's server. mysql-test/suite/engines/funcs/t/rpl_change_master.test: This test just care whether Read_Master_Log_Pos is equal to Exec_Master_Log_Pos after 'CHANGE MASTER ..'. So 'show slave status' is removed and just check the value of Read_Master_Log_Pos and Exec_Master_Log_Pos. mysql-test/suite/engines/funcs/t/rpl_empty_master_crash.test: We doesn't really need the statement. mysql-test/suite/engines/funcs/t/rpl_flushlog_loop.test: Just show Relay_Log_File, running status and error informations. Use 'check_slave_is_running.inc' to verify that Slave threads are running well. mysql-test/suite/engines/funcs/t/rpl_loaddata_s.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/engines/funcs/t/rpl_log_pos.test: Mask the explicit positions in the result file. Use 'check_slave_no_error.inc' to simplify the check that there is no error. Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave stutus'. mysql-test/suite/engines/funcs/t/rpl_rbr_to_sbr.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/engines/funcs/t/rpl_row_drop.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/engines/funcs/t/rpl_row_inexist_tbl.test: Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave stutus'. mysql-test/suite/engines/funcs/t/rpl_row_until.test: Use 'check_slave_param.inc' to check whether SQL Thread stop at a right position, and use binlog position variables instead of explicit number in the 'CHANGE MASTER' statements. Mask the explicit binary log positions in the result file. mysql-test/suite/engines/funcs/t/rpl_server_id1.test: Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave stutus'. Use 'check_slave_no_error.inc' to simplify the check that there is no error. mysql-test/suite/engines/funcs/t/rpl_server_id2.test: It doesn't really need in this test. mysql-test/suite/engines/funcs/t/rpl_slave_status.test: Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave stutus'. mysql-test/suite/engines/funcs/t/rpl_switch_stm_row_mixed.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/manual/t/rpl_replication_delay.test: Use 'show_slave_status.inc' instead of 'show slave status'. mysql-test/suite/parts/t/rpl_partition.test: Use 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/suite/rpl/include/rpl_mixed_ddl.inc: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/rpl/include/rpl_mixed_dml.inc: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/rpl/t/rpl_000015.test: Use 'show_slave_status.inc' instead of 'show_slave_status2.inc'. mysql-test/suite/rpl/t/rpl_binlog_grant.test: Use 'wait_for_binlog_event.inc' instead of 'show binlog events' statement. mysql-test/suite/rpl/t/rpl_bug33931.test: Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave stutus'. mysql-test/suite/rpl/t/rpl_change_master.test: This test just care whether Read_Master_Log_Pos is equal to Exec_Master_Log_Pos after 'CHANGE MASTER ..'. So 'show slave status' is removed and just check the value of Read_Master_Log_Pos and Exec_Master_Log_Pos. mysql-test/suite/rpl/t/rpl_critical_errors.test: Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave stutus'. mysql-test/suite/rpl/t/rpl_dual_pos_advance.test: Mask the explicit position numbers in result file. It is restricted running on SBR, for it want to binlog 'set @a=1' statement. mysql-test/suite/rpl/t/rpl_empty_master_crash.test: It doesn't need in this test. mysql-test/suite/rpl/t/rpl_flushlog_loop.test: UUse 'check_slave_is_running.inc' and 'show_slave_status.inc' instead of 'show slave status' statement. mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test: Use 'wait_for_slave_io_error.inc' to wait the given io thread error happening. mysql-test/suite/rpl/t/rpl_grant.test: It doesn't need in this test. mysql-test/suite/rpl/t/rpl_incident.test: Use 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/suite/rpl/t/rpl_known_bugs_detection.test: Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave stutus'. mysql-test/suite/rpl/t/rpl_loaddata_fatal.test: Use 'wait_for_slave_sql_error_and_skip.inc' to wait the given sql thread error happening and then skip the event. There is no need to print the result of 'show slave stutus'. mysql-test/suite/rpl/t/rpl_log_pos.test: Use 'wait_for_slave_io_error.inc' to wait the given io thread error happening. There is no need to print the result of 'show slave status'. mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/rpl/t/rpl_replicate_do.test: Use 'show_slave_status.inc' instead of 'show slave status'. mysql-test/suite/rpl/t/rpl_rotate_logs.test: Use 'show_slave_status.inc' instead of 'show_slave_status2.inc'. mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/rpl/t/rpl_row_create_table.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/rpl/t/rpl_row_drop.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/rpl/t/rpl_row_until.test: Use 'check_slave_param.inc' to check whether SQL Thread stop at a right position, and use binlog position variables instead of explicit number in the 'CHANGE MASTER' statements. mysql-test/suite/rpl/t/rpl_skip_error.test: Use 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test: Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave status'. mysql-test/suite/rpl/t/rpl_slave_skip.test: Use 'check_slave_param.inc' to check whether SQL Thread stop at a right position, and mask the explicit position number in the 'CHANGE MASTER' statements. mysql-test/suite/rpl/t/rpl_sp.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/suite/rpl/t/rpl_ssl.test: Use 'show_slave_status.inc' instead of 'show slave status'. mysql-test/suite/rpl/t/rpl_ssl1.test: Use 'show_slave_status.inc' instead of 'show slave status'. mysql-test/suite/rpl/t/rpl_stm_until.test: Use 'check_slave_param.inc' to check whether SQL Thread stop at a right position, and use binlog position variables instead of explicit number in the 'CHANGE MASTER' statements. mysql-test/suite/rpl/t/rpl_temporary_errors.test: Use 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test: Use 'wait_for_slave_sql_error.inc' to wait the given sql thread error happening. There is no need to print the result of 'show slave status'. mysql-test/suite/rpl_ndb/t/rpl_ndb_circular.test: Use 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/suite/rpl_ndb/t/rpl_ndb_circular_simplex.test: Use 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/suite/rpl_ndb/t/rpl_ndb_idempotent.test: Use 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test: Mask master_log_pos and master_log_file mysql-test/suite/rpl_ndb/t/rpl_ndb_sync.test: Use 'check_slave_is_running.inc' instead of 'show slave status' statement. mysql-test/suite/rpl_ndb/t/rpl_truncate_7ndb.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/t/alter_table-big.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/t/create-big.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/t/ctype_cp932_binlog_stm.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement. mysql-test/t/flush_block_commit_notembedded.test: It checks whether somethings are binlogged, so we using 'show_binlog_event.inc' instead of 'show master status'. mysql-test/t/multi_update.test: It checks whether somethings are binlogged, so we using 'wait_binlog_event.inc' instead of 'show master status'. mysql-test/t/sp_trans_log.test: Use 'show_binlog_events.inc' instead of 'show binlog events' statement.
* | | Manual merge from mysql-trunk-merge.Alexander Nozdrin2010-02-241-0/+12
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: - client/mysql.cc - client/mysqldump.c - configure.in - mysql-test/r/csv.result - mysql-test/r/func_time.result - mysql-test/r/show_check.result - mysql-test/r/sp-error.result - mysql-test/r/sp.result - mysql-test/r/sp_trans.result - mysql-test/r/type_blob.result - mysql-test/r/type_timestamp.result - mysql-test/r/warnings.result - mysql-test/suite/rpl/r/rpl_sp.result - sql/mysql_priv.h - sql/mysqld.cc - sql/sp.cc - sql/sql_base.cc - sql/sql_table.cc - sql/sql_trigger.cc - sql/sql_view.cc - sql/table.h - sql/share/errmsg.txt - mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result
| * | Bug#49534: multitable IGNORE update with sql_safe_updatesMartin Hansson2010-02-101-0/+12
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | error causes debug assertion The IGNORE option of the multiple-table UPDATE command was not intended to suppress errors caused by the sql_safe_updates mode. This flag will raise an error if the execution of UPDATE does not use a key for row retrieval, and should continue do so regardless of the IGNORE option. However the implementation of IGNORE does not support exceptions to the rule; it always converts errors to warnings and cannot be extended. The Internal_error_handler interface offers the infrastructure to handle individual errors, making sure that the error raised by sql_safe_updates is not silenced. Fixed by implementing an Internal_error_handler and using it for UPDATE IGNORE commands.
* | Implement new type-of-operation-aware metadata locks.Dmitry Lenev2010-02-011-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a wait-for graph based deadlock detector to the MDL subsystem. Fixes bug #46272 "MySQL 5.4.4, new MDL: unnecessary deadlock" and bug #37346 "innodb does not detect deadlock between update and alter table". The first bug manifested itself as an unwarranted abort of a transaction with ER_LOCK_DEADLOCK error by a concurrent ALTER statement, when this transaction tried to repeat use of a table, which it has already used in a similar fashion before ALTER started. The second bug showed up as a deadlock between table-level locks and InnoDB row locks, which was "detected" only after innodb_lock_wait_timeout timeout. A transaction would start using the table and modify a few rows. Then ALTER TABLE would come in, and start copying rows into a temporary table. Eventually it would stumble on the modified records and get blocked on a row lock. The first transaction would try to do more updates, and get blocked on thr_lock.c lock. This situation of circular wait would only get resolved by a timeout. Both these bugs stemmed from inadequate solutions to the problem of deadlocks occurring between different locking subsystems. In the first case we tried to avoid deadlocks between metadata locking and table-level locking subsystems, when upgrading shared metadata lock to exclusive one. Transactions holding the shared lock on the table and waiting for some table-level lock used to be aborted too aggressively. We also allowed ALTER TABLE to start in presence of transactions that modify the subject table. ALTER TABLE acquires TL_WRITE_ALLOW_READ lock at start, and that block all writes against the table (naturally, we don't want any writes to be lost when switching the old and the new table). TL_WRITE_ALLOW_READ lock, in turn, would block the started transaction on thr_lock.c lock, should they do more updates. This, again, lead to the need to abort such transactions. The second bug occurred simply because we didn't have any mechanism to detect deadlocks between the table-level locks in thr_lock.c and row-level locks in InnoDB, other than innodb_lock_wait_timeout. This patch solves both these problems by moving lock conflicts which are causing these deadlocks into the metadata locking subsystem, thus making it possible to avoid or detect such deadlocks inside MDL. To do this we introduce new type-of-operation-aware metadata locks, which allow MDL subsystem to know not only the fact that transaction has used or is going to use some object but also what kind of operation it has carried out or going to carry out on the object. This, along with the addition of a special kind of upgradable metadata lock, allows ALTER TABLE to wait until all transactions which has updated the table to go away. This solves the second issue. Another special type of upgradable metadata lock is acquired by LOCK TABLE WRITE. This second lock type allows to solve the first issue, since abortion of table-level locks in event of DDL under LOCK TABLES becomes also unnecessary. Below follows the list of incompatible changes introduced by this patch: - From now on, ALTER TABLE and CREATE/DROP TRIGGER SQL (i.e. those statements that acquire TL_WRITE_ALLOW_READ lock) wait for all transactions which has *updated* the table to complete. - From now on, LOCK TABLES ... WRITE, REPAIR/OPTIMIZE TABLE (i.e. all statements which acquire TL_WRITE table-level lock) wait for all transaction which *updated or read* from the table to complete. As a consequence, innodb_table_locks=0 option no longer applies to LOCK TABLES ... WRITE. - DROP DATABASE, DROP TABLE, RENAME TABLE no longer abort statements or transactions which use tables being dropped or renamed, and instead wait for these transactions to complete. - Since LOCK TABLES WRITE now takes a special metadata lock, not compatible with with reads or writes against the subject table and transaction-wide, thr_lock.c deadlock avoidance algorithm that used to ensure absence of deadlocks between LOCK TABLES WRITE and other statements is no longer sufficient, even for MyISAM. The wait-for graph based deadlock detector of MDL subsystem may sometimes be necessary and is involved. This may lead to ER_LOCK_DEADLOCK error produced for multi-statement transactions even if these only use MyISAM: session 1: session 2: begin; update t1 ... lock table t2 write, t1 write; -- gets a lock on t2, blocks on t1 update t2 ... (ER_LOCK_DEADLOCK) - Finally, support of LOW_PRIORITY option for LOCK TABLES ... WRITE was abandoned. LOCK TABLE ... LOW_PRIORITY WRITE from now on has the same priority as the usual LOCK TABLE ... WRITE. SELECT HIGH PRIORITY no longer trumps LOCK TABLE ... WRITE in the wait queue. - We do not take upgradable metadata locks on implicitly locked tables. So if one has, say, a view v1 that uses table t1, and issues: LOCK TABLE v1 WRITE; FLUSH TABLE t1; -- (or just 'FLUSH TABLES'), an error is produced. In order to be able to perform DDL on a table under LOCK TABLES, the table must be locked explicitly in the LOCK TABLES list. mysql-test/include/handler.inc: Adjusted test case to trigger an execution path on which bug 41110 "crash with handler command when used concurrently with alter table" and bug 41112 "crash in mysql_ha_close_table/get_lock_data with alter table" were originally discovered. Left old test case which no longer triggers this execution path for the sake of coverage. Added test coverage for HANDLER SQL statements and type-aware metadata locks. Added a test for the global shared lock and HANDLER SQL. Updated tests to take into account that the old simple deadlock detection heuristics was replaced with a graph-based deadlock detector. mysql-test/r/debug_sync.result: Updated results (see debug_sync.test). mysql-test/r/handler_innodb.result: Updated results (see handler.inc test). mysql-test/r/handler_myisam.result: Updated results (see handler.inc test). mysql-test/r/innodb-lock.result: Updated results (see innodb-lock.test). mysql-test/r/innodb_mysql_lock.result: Updated results (see innodb_mysql_lock.test). mysql-test/r/lock.result: Updated results (see lock.test). mysql-test/r/lock_multi.result: Updated results (see lock_multi.test). mysql-test/r/lock_sync.result: Updated results (see lock_sync.test). mysql-test/r/mdl_sync.result: Updated results (see mdl_sync.test). mysql-test/r/sp-threads.result: SHOW PROCESSLIST output has changed due to the fact that waiting for LOCK TABLES WRITE now happens within metadata locking subsystem. mysql-test/r/truncate_coverage.result: Updated results (see truncate_coverage.test). mysql-test/suite/funcs_1/datadict/processlist_val.inc: SELECT FROM I_S.PROCESSLIST output has changed due to fact that waiting for LOCK TABLES WRITE now happens within metadata locking subsystem. mysql-test/suite/funcs_1/r/processlist_val_no_prot.result: SELECT FROM I_S.PROCESSLIST output has changed due to fact that waiting for LOCK TABLES WRITE now happens within metadata locking subsystem. mysql-test/suite/rpl/t/rpl_sp.test: Updated to a new SHOW PROCESSLIST state name. mysql-test/t/debug_sync.test: Use LOCK TABLES READ instead of LOCK TABLES WRITE as the latter no longer allows to trigger execution path involving waiting on thr_lock.c lock and therefore reaching debug sync-point covered by this test. mysql-test/t/innodb-lock.test: Adjusted test case to the fact that innodb_table_locks=0 option is no longer supported, since LOCK TABLES WRITE handles all its conflicts within MDL subsystem. mysql-test/t/innodb_mysql_lock.test: Added test for bug #37346 "innodb does not detect deadlock between update and alter table". mysql-test/t/lock.test: Added test coverage which checks the fact that we no longer support DDL under LOCK TABLES on tables which were locked implicitly. Adjusted existing test cases accordingly. mysql-test/t/lock_multi.test: Added test for bug #46272 "MySQL 5.4.4, new MDL: unnecessary deadlock". Adjusted other test cases to take into account the fact that waiting for LOCK TABLES ... WRITE now happens within MDL subsystem. mysql-test/t/lock_sync.test: Since LOCK TABLES ... WRITE now takes SNRW metadata lock for tables locked explicitly we have to implicitly lock InnoDB tables (through view) to trigger the table-level lock conflict between TL_WRITE and TL_WRITE_ALLOW_WRITE. mysql-test/t/mdl_sync.test: Added basic test coverage for type-of-operation-aware metadata locks. Also covered with tests some use cases involving HANDLER statements in which a deadlock could arise. Adjusted existing tests to take type-of-operation-aware MDL into account. mysql-test/t/multi_update.test: Update to a new SHOW PROCESSLIST state name. mysql-test/t/truncate_coverage.test: Adjusted test case after making LOCK TABLES WRITE to wait until transactions that use the table to be locked are completed. Updated to the changed name of DEBUG_SYNC point. sql/handler.cc: Global read lock functionality has been moved into a class. sql/lock.cc: Global read lock functionality has been moved into a class. Updated code to use the new MDL API. sql/mdl.cc: Introduced new type-of-operation aware metadata locks. To do this: - Changed MDL_lock to use one list for waiting requests and one list for granted requests. For each list, added a bitmap that holds information what lock types a list contains. Added a helper class MDL_lock::List to manipulate with granted and waited lists while keeping the bitmaps in sync with list contents. - Changed lock-compatibility functions to use bitmaps that define compatibility. - Introduced a graph based deadlock detector inspired by waiting_threads.c from Maria implementation. - Now that we have a deadlock detector, and no longer have a global lock to protect individual lock objects, but rather use an rw lock per object, removed redundant code for upgrade, and the global read lock. Changed the MDL API to no longer require the caller to acquire the global intention exclusive lock by means of a separate method. Removed a few more methods that became redundant. - Removed deadlock detection heuristic, it has been made obsolete by the deadlock detector. - With operation-type-aware metadata locks, MDL subsystem has become aware of potential conflicts between DDL and open transactions. This made it possible to remove calls to mysql_abort_transactions_with_shared_lock() from acquisition paths for exclusive lock and lock upgrade. Now we can simply wait for these transactions to complete without fear of deadlock. Function mysql_lock_abort() has also become unnecessary for all conflicting cases except when a DDL conflicts with a connection that has an open HANDLER. sql/mdl.h: Introduced new type-of-operation aware metadata locks. Introduced a graph based deadlock detector and supporting methods. Added comments. God rid of redundant API calls. Renamed m_lt_or_ha_sentinel to m_trans_sentinel, since now it guards the global read lock as well as LOCK TABLES and HANDLER locks. sql/mysql_priv.h: Moved the global read lock functionality into a class. Added MYSQL_OPEN_FORCE_SHARED_MDL flag which forces open_tables() to take MDL_SHARED on tables instead of metadata locks specified in the parser. We use this to allow PREPARE run concurrently in presence of LOCK TABLES ... WRITE. Added signature for find_table_for_mdl_ugprade(). sql/set_var.cc: Global read lock functionality has been moved into a class. sql/sp_head.cc: When creating TABLE_LIST elements for prelocking or system tables set the type of request for metadata lock according to the operation that will be performed on the table. sql/sql_base.cc: - Updated code to use the new MDL API. - In order to avoid locks starvation we take upgradable locks all at once. As result implicitly locked tables no longer get an upgradable lock. Consequently DDL and FLUSH TABLES for such tables is prohibited. find_write_locked_table() was replaced by find_table_for_mdl_upgrade() function. open_table() was adjusted to return TABLE instance with upgradable ticket when necessary. - We no longer wait for all locks on OT_WAIT back off action -- only on the lock that caused the wait conflict. Moreover, now we distinguish cases when we have to wait due to conflict in MDL and old version of table in TDC. - Upate mysql_notify_threads_having_share_locks() to only abort thr_lock.c waits of threads that have open HANDLERs, since lock conflicts with only these threads now can lead to deadlocks not detectable by the MDL deadlock detector. - Remove mysql_abort_transactions_with_shared_locks() which is no longer needed. sql/sql_class.cc: Global read lock functionality has been moved into a class. Re-arranged code in THD::cleanup() to simplify assert. sql/sql_class.h: Introduced class to incapsulate global read lock functionality. Now sentinel in MDL subsystem guards the global read lock as well as LOCK TABLES and HANDLER locks. Adjusted code accordingly. sql/sql_db.cc: Global read lock functionality has been moved into a class. sql/sql_delete.cc: We no longer acquire upgradable metadata locks on tables which are locked by LOCK TABLES implicitly. As result TRUNCATE TABLE is no longer allowed for such tables. Updated code to use the new MDL API. sql/sql_handler.cc: Inform MDL_context about presence of open HANDLERs. Since HANLDERs break MDL protocol by acquiring table-level lock while holding only S metadata lock on a table MDL subsystem should take special care about such contexts (Now this is the only case when mysql_lock_abort() is used). sql/sql_parse.cc: Global read lock functionality has been moved into a class. Do not take upgradable metadata locks when opening tables for CREATE TABLE SELECT as it is not necessary and limits concurrency. When initializing TABLE_LIST objects before adding them to the table list set the type of request for metadata lock according to the operation that will be performed on the table. We no longer acquire upgradable metadata locks on tables which are locked by LOCK TABLES implicitly. As result FLUSH TABLES is no longer allowed for such tables. sql/sql_prepare.cc: Use MYSQL_OPEN_FORCE_SHARED_MDL flag when opening tables during PREPARE. This allows PREPARE to run concurrently in presence of LOCK TABLES ... WRITE. sql/sql_rename.cc: Global read lock functionality has been moved into a class. sql/sql_show.cc: Updated code to use the new MDL API. sql/sql_table.cc: Global read lock functionality has been moved into a class. We no longer acquire upgradable metadata locks on tables which are locked by LOCK TABLES implicitly. As result DROP TABLE is no longer allowed for such tables. Updated code to use the new MDL API. sql/sql_trigger.cc: Global read lock functionality has been moved into a class. We no longer acquire upgradable metadata locks on tables which are locked by LOCK TABLES implicitly. As result CREATE/DROP TRIGGER is no longer allowed for such tables. Updated code to use the new MDL API. sql/sql_view.cc: Global read lock functionality has been moved into a class. Fixed results of wrong merge that led to misuse of GLR API. CREATE VIEW statement is not a commit statement. sql/table.cc: When resetting TABLE_LIST objects for PS or SP re-execution set the type of request for metadata lock according to the operation that will be performed on the table. Do the same in auxiliary function initializing metadata lock requests in a table list. sql/table.h: When initializing TABLE_LIST objects set the type of request for metadata lock according to the operation that will be performed on the table. sql/transaction.cc: Global read lock functionality has been moved into a class.