Console View
|
Categories: connectors experimental galera main |
|
| connectors | experimental | galera | main | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Jan Lindström
jan.lindstrom@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-42367 : Galera test failure on galera_as_slave_wsrep_error Fixes both galera_as_slave_wsrep_error as well as mdev-41075 test cases not to use RESET MASTER directly, instead use include/reset_master.inc. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Oleksandr Byelkin
sanja@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Merge branch '11.4' into mariadb-11.4.14 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Daniel Bartholomew
db@dbart.us |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bump the VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove st_select_lex::table_join_options, get_table_join_options() The member is only zeroed in init_select(), and the accessor is declared but has no definition. The last reader and writers in the grammar were removed by bc04ded2353 ("Follow-up post JSON_TABLE merge, table_join_options is not used"). d624464b50b had earlier removed the member and accessor, but they came back with the JSON_TABLE merge. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Marko Mäkelä
marko.makela@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Merge 12.3 into 13.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
sjaakola
seppo.jaakola@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-42383 sporadic hangs with galera_sr.mysql-wsrep#215 test The test pauses the only node_1 applier at sync.wsrep_apply_cb while it applies the node_2 writeset, and expects the conflicting node_1 fragment to fail certification. At the same time, Galera delivers a COMMIT_CUT action after about every 128 committed transactions. It has only a local seqno and must pass the local monitor by an applier. When it was delivered between the node_2 writeset and the node_1 fragment, the paused applier could not process it, and the fragment waited in the local monitor until wait_condition timed out. Configuring two applier threads for node_1 fixes this deadlock, the second applier processes the COMMIT_CUT while the first one is paused. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove JOIN::no_field_update, sum_funcs2, sum_funcs_end2 JOIN::no_field_update was added in the initial import (2000) and has never been used. JOIN::sum_funcs2 and JOIN::sum_funcs_end2 were last used before: commit 2cfc450bf78c2d951729d1a0e8f731c0d987b1d5 Author: Igor Babaev <[email protected]> Date: Tue Feb 9 2016 This is the consolidated patch for mdev-8646: "Re-factor the code for post-join operations". Since then sum_funcs2 was only zeroed in JOIN::init() and sum_funcs_end2 was not referenced at all. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Alessandro Vetere
iminelink@gmail.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-41939 Rollback may leave a delete-marked secondary index record that purge does not remove row_undo_mod_sec_is_unsafe() freezes purge_sys.view across the dereference of externally stored columns, and under the freeze it tests whether purge can see the transaction whose undo log record rebuilt the older version. If the view advanced between the walk and the freeze, it reported the secondary index entry as still needed, and the rollback delete-marked the entry. No undo log record refers to that entry, so purge does not remove it, unless a later write of the same key value reuses it. CHECK TABLE ... EXTENDED reports it as missing its clustered index record once purge_sys.end_view moves past the transaction that rolled back. When purge can see that same transaction, trx_undo_prev_version_build() ends the walk with no older version, and row_purge_is_unsafe() treats the end of the versions in the same way. Report the entry as not needed in this case too, so that the rollback removes it: no read view needs the rebuilt version, and the walk found no match among the newer versions. row_undo_mod_sec_is_unsafe_keep: a debug keyword that restores the previous answer, as a negative control. With --mysqld=--debug-dbug=+d,row_undo_mod_sec_is_unsafe_keep, innodb.old_blob_purgeable fails with the orphan report. innodb.old_blob_purgeable: force a purge batch after the rollback, so that CHECK TABLE ... EXTENDED would report the orphan regardless of purge timing. Use MEDIUMTEXT, because with innodb_page_size=64k the value REPEAT('x', @@innodb_page_size) does not fit in TEXT. innodb.old_blob_updel: wait until the rows that the test inserts first are purged, before the test holds a purge batch. Otherwise purge_hold_cleanup can hold the batch that purges the history of those rows, instead of the batch that the test expects. This failed under Valgrind. Assisted-by: Claude:claude-opus-5-5 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Daniel Bartholomew
db@dbart.us |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bump the VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
sjaakola
seppo.jaakola@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-42383 sporadic hangs with galera_sr.mysql-wsrep#215 test The test pauses the only node_1 applier at sync.wsrep_apply_cb while it applies the node_2 writeset, and expects the conflicting node_1 fragment to fail certification. At the same time, Galera delivers a COMMIT_CUT action after about every 128 committed transactions. It has only a local seqno and must pass the local monitor by an applier. When it was delivered between the node_2 writeset and the node_1 fragment, the paused applier could not process it, and the fragment waited in the local monitor until wait_condition timed out. Configuring two applier threads for node_1 fixes this deadlock, the second applier processes the COMMIT_CUT while the first one is paused. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Razvan-Liviu Varzaru
razvan@mariadb.org |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-41266 Add missing procps dependency to the server RPM The RPM packaging declares no dependency on procps, although several things shipped in MariaDB-server need it: - mariadbd-safe runs ps(1): scripts/CMakeLists.txt substitutes @FIND_PROC@ into it, and every platform variant of that string is a "ps" invocation. mysqld_safe.sh additionally runs "ps xaww" to reap hung mariadbd processes before a restart - wsrep_sst_common.sh, wsrep_sst_rsync.sh and wsrep_sst_mariabackup.sh poll "ps -p $pid" to check whether the SST parent is still alive - mysql.server and mini-benchmark use pgrep(1) rpm's automatic dependency generation only covers ELF sonames, script interpreters and perl/python modules, so a command invoked inside a shell script is never picked up. The Debian packaging has declared procps for mariadb-server all along (debian/control). procps is part of the base install on RHEL, Fedora and SLES, so this goes unnoticed on a normal system; it bites in minimal containers and chroots, where "ps -p $pid" failing because ps is absent is indistinguishable from "the process is gone". Declare it on the server package only, mirroring Debian, where mariadb-server-galera picks it up transitively via its dependency on mariadb-server. Depend on the file /usr/bin/ps rather than on a package name, to avoid the procps-ng (Fedora/RHEL) versus procps (SLES) difference; pgrep comes from the same package. Co-Authored-By: Claude Opus 5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Vladislav Vaintroub
vvaintroub@gmail.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-40382 Support --ssl-crl on server builds with WolfSSL --ssl-crl was silently discarded on WolfSSL: sslopt-case.h nulled opt_ssl_crl after option parsing, and new_VioSSLFd() skipped CRL loading for HAVE_WOLFSSL. A revoked certificate could still authenticate a REQUIRE X509 / REQUIRE SUBJECT account. WolfSSL's OpenSSL-compat layer already implements X509_STORE_load_locations/X509_STORE_set_flags with real CRL enforcement, so remove both restrictions. Also fix X509_STORE_set_flags()'s success check: unlike OpenSSL, WolfSSL can return negative error codes on failure, which == 0 missed. Existing CRL tests were fixed to run with WolfSSL as well. Note: on Windows, a revoked cert sometimes surfaces as ECONNRESET instead of a TLS alert; the test's regex handles this too. The ssl_crl_clients.test GnuTLS restriction was removed once the underlying client-side crlpath bug was fixed, generalizing the test's regex to match both backends' wording. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Marko Mäkelä
marko.makela@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Merge 10.11 into 11.4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
sjaakola
seppo.jaakola@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-41597: Do privilege checks of triggers and views before TOI CREATE TRIGGER, CREATE VIEW and ALTER VIEW did some of their privilege checks only after TOI had replicated the statement. The applier runs with all privileges, so a statement refused on the originating node was still applied by the other nodes: - the DEFINER clause (sp_process_definer(), which requires SET USER for a DEFINER other than the current user), for all three statements, creating the trigger or view with a DEFINER the user was not allowed to use - the column privileges of a view (ER_COLUMNACCESS_DENIED_ERROR), creating a view that gives more privileges than the user has on the underlying tables ALTER VIEW without a DEFINER clause also replicated the wrong definition. fill_defined_view_parts(), which takes DEFINER, ALGORITHM and SQL SECURITY from the existing view, ran after the replicated statement had been built, so the other nodes got the current user as DEFINER and the default SQL SECURITY. Do the checks before TOI begins, as is already done for stored routines and events: - mysql_create_or_drop_trigger() calls sp_process_definer() for CREATE TRIGGER before WSREP_TO_ISOLATION_BEGIN, and Table_triggers_list::create_trigger() no longer calls it. - mysql_create_view() calls fill_defined_view_parts() (ALTER VIEW) and sp_process_definer() early, and begins TOI only after all checks, just before mysql_register_view(). The order of checks changes for all builds: the DEFINER error is now reported before some errors that were found later in the statement. The test galera.galera_toi_definer_check checks that: - CREATE TRIGGER, CREATE VIEW and ALTER VIEW refused for a foreign DEFINER on node_1 are not applied on node_2 - CREATE VIEW refused for missing column privileges on node_1 is not applied on node_2 - ALTER VIEW without a DEFINER clause keeps the same DEFINER and SQL SECURITY on both nodes Assisted By: Claude Opus 5.5 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Marko Mäkelä
marko.makela@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Merge 11.4 into 11.8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Khaled Riyad
khaled57.dev@gmail.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-31844 PS ALTER crashes after character_set_collations change A prepared statement that resolved a character set through @@character_set_collations must be re-prepared when the map changes. Prepared_statement::execute() detected the change and reported it to thd->m_reprepare_observer, but the observer is only installed for CF_REEXECUTION_FRAGILE commands. For ALTER TABLE and other DDL it is NULL, so the server crashed. Check the map version at the start of execute_loop() and re-prepare the statement there, as is already done for lex->needs_reprepare. This works with or without an observer. Bulk execution is not affected, because it only accepts fragile commands, which always have an observer. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove JOIN::select_list_used_tables, eval_select_list_used_tables() JOIN::select_list_used_tables is computed by JOIN::eval_select_list_used_tables(), but never read. Its last reads (in the code that optimizes DISTINCT on a subset of the tables, and in JOIN_TAB::save_explain_data()) were removed by: commit 2cfc450bf78c2d951729d1a0e8f731c0d987b1d5 Author: Igor Babaev <[email protected]> Date: Tue Feb 9 2016 This is the consolidated patch for mdev-8646: "Re-factor the code for post-join operations". Remove the member and the function that computes it. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Alexander Barkov
bar@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-39563 Implement UPDATE ... RETURNING ... INTO Adding support for UPDATE .. RETURNING .. INTO queries. For example: UPDATE t1 SET a=10,b=20 RETURNING a,b INTO va,vb; UPDATE t1 SET a=10,b=20 RETURNING a,b INTO @a,@b; Limitations: 1. These types of queries: - REPLACE .. RETURNING .. INTO - DELETE .. RETURNING .. INTO - INSERT .. RETURNING .. INTO are not supported yet, and ER_NOT_SUPPORTED_YET is raised with 'REPLACE..RETURNING..INTO', 'DELETE..RETURNING..INTO' or 'INSERT..RETURNING..INTO' as the argument. The same is for the INSERT..SELECT and REPLACE..SELECT forms. They will be implemented separately, when needed. 2. UPDATE..RETURNING..INTO is rejected with ER_WRONG_USAGE if it would be written to the binary log in the statement format (--binlog_format=statement), as the order of the rows is not predictable, like in SELECT..LIMIT without ORDER BY. With --binlog_format=mixed it is written in the row format. No warning "Unsafe statement written to the binary log" is raised for it, as the statement is rejected and is not written. Supporting the statement format is tracked in MDEV-42398. 3. Using OLD_VALUE(col) in the RETURNING list of UPDATE..RETURNING..INTO is not allowed and an error is raised. 4. Multi-table updates do not work, and neither do single table updates that get converted to multi-table: - UPDATE t1,t2 ..: ER_NOT_SUPPORTED_YET ('RETURNING for multi-table UPDATE') - an UPDATE of a view over several tables, or with an IN subquery converted to a semi-join (even on another table): ER_NOT_SUPPORTED_YET ('multi-table UPDATE..RETURNING..INTO') - a subquery on the updated table in WHERE: ER_UPDATE_TABLE_USED. With ORDER BY .. LIMIT the statement is not converted to multi-table, so it works. 5. UPDATE IGNORE .. RETURNING .. INTO is not supported yet and ER_NOT_SUPPORTED_YET is raised (MDEV-42381). A row rejected by the engine (a duplicate key, no partition found) is ignored by IGNORE, so it is not known before ha_update_row() whether the row is a second changed row. UPDATE IGNORE .. RETURNING without INTO works as before. Notes: 1. ANALYZE and EXPLAIN Both ANALYZE UPDATE .. RETURNING .. INTO .. EXPLAIN UPDATE .. RETURNING .. INTO .. return this error: 'RETURNING..INTO' is not allowed in this context 2. Behavior on no data and on multiple rows Only the rows that were actually changed are processed. A row that matches the WHERE condition but needs no update is not changed, so it is not returned by plain RETURNING either. Situation | RETURNING | RETURNING .. INTO --------------------------+-------------+----------------------------- Empty table, WHERE | empty set | Warning ER_SP_FETCH_NO_DATA, matches nothing (1=0), | | target is not changed LIMIT 0 | | One row matches, needs | empty set | Warning ER_SP_FETCH_NO_DATA, no update | | target is not changed Several rows match, none | empty set | Warning ER_SP_FETCH_NO_DATA, needs an update | | target is not changed | | (no ER_TOO_MANY_ROWS) One row matches and is | that row | Target is assigned changed | | Several rows match, | that row | Target is assigned from exactly one changes | | that row Two or more rows change | all changed | ER_TOO_MANY_ROWS at the 2nd | | changed row (not updated) Notes: - The warning is never an error: not in the strict mode and not with sql_mode=''. The INTO targets keep their old values. In stored routines the warning activates NOT FOUND handlers. - This is the same for all storage engines, including those that quickly know the table is empty and use a degenerated plan (e.g. MyISAM). - After ER_TOO_MANY_ROWS, transactional engines roll back the statement, non-transactional engines keep the rows updated before the error (the second changed row is not updated). - The targets can be user variables, SP variables, ROW variables and ROW fields. - For a system-versioned table, an update that sets the same values still creates a new row version, so such a row counts as changed: plain RETURNING returns it, and RETURNING .. INTO assigns it (or raises ER_TOO_MANY_ROWS if two rows match). 3. Behavior on VIEW with CHECK OPTION The "too many rows" check is done after the view's CHECK OPTION check, so a row rejected by WITH CHECK OPTION raises the CHECK OPTION error and not ER_TOO_MANY_ROWS. 4. The OK packet UPDATE .. RETURNING .. INTO sends the same OK packet as a plain UPDATE. The affected rows are the changed rows (the matched rows with CLIENT_FOUND_ROWS), and the info is: Rows matched: N Changed: M Warnings: W with "Inserted: K" added for system versioned and period tables. The "No data" warning is counted in Warnings. ROW_COUNT() in a stored routine is the number of the changed rows, not of the assigned rows. If there is nothing to read (WHERE 1=0, LIMIT 0, an empty table on some engines), a plain OK without the info is sent, as for UPDATE. Helper changes: 1. The grammar in analyze_stmt_command was changed to have LEX::analyze_stmt set to true earlier, so LEX::set_returning_into_result() already knows if this is an ANALYZE statement. 2. The Sql_cmd_update constructor is now called earlier in the grammar, to be able to call Sql_cmd_update::set_with_old_value_items() in the SET and RETURNING clauses. 3. Sql_cmd_dml::lex is now set during the constructor time. It makes things easier: - Sql_cmd_update::returns_result_set() needs the lex. - Sql_cmd_delete::orig_multitable and Sql_cmd_update::orig_multitable are not needed any more. They were used only in Sql_cmd_delete::sql_command_code() and Sql_cmd_update::sql_command_code(). Sql_cmd_dml::sql_command_code() now returns lex->sql_command. The overrides Sql_cmd_delete::sql_command_code() and Sql_cmd_update::sql_command_code() were removed. 4. A new unsafe statement type BINLOG_STMT_UNSAFE_RETURNING_INTO is set for RETURNING..INTO. decide_logging_format() rejects the statement in the statement format, and logs it in the row format in MIXED. A new error message ER_BINLOG_UNSAFE_CLAUSE ("... because it uses %s ...") explains the unsafeness when a statement-only engine is used. It is filled by the new helper class Binlog_unsafe_explanation. A new debug injection point binlog_stmt_only_engine simulates such an engine in tests. This commit also fixes bugs found during testing: - MDEV-41262 ER_TOO_MANY_ROWS should be checked after CHECK OPTION in view while Update Returning Into - MDEV-41265 SELECT/ UPDATE RETURNING INTO a single row-field fails with ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, even though the column count matches This bug was also fixed in 12.3.4. - MDEV-41260 Misleading message text "uses a LIMIT clause" after Update Returning Into - MDEV-42212 UPDATE ... RETURNING ... INTO raises ER_TOO_MANY_ROWS on InnoDB when the second found row needs no update - MDEV-41448 Update Returning Into expected to produce warning/error for zero-row plan (a test was added; the warning is now raised consistently) - MDEV-41443 Update Returning into produces error when values don't change (a test was added; a warning is raised instead of an error) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Kristian Nielsen
knielsen@knielsen-hq.org |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Fix help Signed-off-by: Kristian Nielsen <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Oleksandr Byelkin
sanja@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Merge branch '11.8' into mariadb-11.8.10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Kristian Nielsen
knielsen@knielsen-hq.org |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Fix build when sizeof(bool) != 1 Signed-off-by: Kristian Nielsen <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Daniel Bartholomew
db@dbart.us |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bump the VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Alexander Barkov
bar@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-39563 Implement UPDATE ... RETURNING ... INTO Adding support for UPDATE .. RETURNING .. INTO queries. For example: UPDATE t1 SET a=10,b=20 RETURNING a,b INTO va,vb; UPDATE t1 SET a=10,b=20 RETURNING a,b INTO @a,@b; Limitations: 1. These types of queries: - REPLACE .. RETURNING .. INTO - DELETE .. RETURNING .. INTO - INSERT .. RETURNING .. INTO are not supported yet, and ER_NOT_SUPPORTED_YET is raised with 'REPLACE..RETURNING..INTO', 'DELETE..RETURNING..INTO' or 'INSERT..RETURNING..INTO' as the argument. The same is for the INSERT..SELECT and REPLACE..SELECT forms. They will be implemented separately, when needed. 2. UPDATE..RETURNING..INTO is rejected with ER_WRONG_USAGE if it would be written to the binary log in the statement format (--binlog_format=statement), as the order of the rows is not predictable, like in SELECT..LIMIT without ORDER BY. With --binlog_format=mixed it is written in the row format. No warning "Unsafe statement written to the binary log" is raised for it, as the statement is rejected and is not written. Supporting the statement format is tracked in MDEV-42398. 3. Using OLD_VALUE(col) in the RETURNING list of UPDATE..RETURNING..INTO is not allowed and an error is raised. 4. Multi-table updates do not work, and neither do single table updates that get converted to multi-table: - UPDATE t1,t2 ..: ER_NOT_SUPPORTED_YET ('RETURNING for multi-table UPDATE') - an UPDATE of a view over several tables, or with an IN subquery converted to a semi-join (even on another table): ER_NOT_SUPPORTED_YET ('multi-table UPDATE..RETURNING..INTO') - a subquery on the updated table in WHERE: ER_UPDATE_TABLE_USED. With ORDER BY .. LIMIT the statement is not converted to multi-table, so it works. 5. UPDATE IGNORE .. RETURNING .. INTO is not supported yet and ER_NOT_SUPPORTED_YET is raised (MDEV-42381). A row rejected by the engine (a duplicate key, no partition found) is ignored by IGNORE, so it is not known before ha_update_row() whether the row is a second changed row. UPDATE IGNORE .. RETURNING without INTO works as before. Notes: 1. ANALYZE and EXPLAIN Both ANALYZE UPDATE .. RETURNING .. INTO .. EXPLAIN UPDATE .. RETURNING .. INTO .. return this error: 'RETURNING..INTO' is not allowed in this context 2. Behavior on no data and on multiple rows Only the rows that were actually changed are processed. A row that matches the WHERE condition but needs no update is not changed, so it is not returned by plain RETURNING either. Situation | RETURNING | RETURNING .. INTO --------------------------+-------------+----------------------------- Empty table, WHERE | empty set | Warning ER_SP_FETCH_NO_DATA, matches nothing (1=0), | | target is not changed LIMIT 0 | | One row matches, needs | empty set | Warning ER_SP_FETCH_NO_DATA, no update | | target is not changed Several rows match, none | empty set | Warning ER_SP_FETCH_NO_DATA, needs an update | | target is not changed | | (no ER_TOO_MANY_ROWS) One row matches and is | that row | Target is assigned changed | | Several rows match, | that row | Target is assigned from exactly one changes | | that row Two or more rows change | all changed | ER_TOO_MANY_ROWS at the 2nd | | changed row (not updated) Notes: - The warning is never an error: not in the strict mode and not with sql_mode=''. The INTO targets keep their old values. In stored routines the warning activates NOT FOUND handlers. - This is the same for all storage engines, including those that quickly know the table is empty and use a degenerated plan (e.g. MyISAM). - After ER_TOO_MANY_ROWS, transactional engines roll back the statement, non-transactional engines keep the rows updated before the error (the second changed row is not updated). - The targets can be user variables, SP variables, ROW variables and ROW fields. - For a system-versioned table, an update that sets the same values still creates a new row version, so such a row counts as changed: plain RETURNING returns it, and RETURNING .. INTO assigns it (or raises ER_TOO_MANY_ROWS if two rows match). 3. Behavior on VIEW with CHECK OPTION The "too many rows" check is done after the view's CHECK OPTION check, so a row rejected by WITH CHECK OPTION raises the CHECK OPTION error and not ER_TOO_MANY_ROWS. 4. The OK packet UPDATE .. RETURNING .. INTO sends the same OK packet as a plain UPDATE. The affected rows are the changed rows (the matched rows with CLIENT_FOUND_ROWS), and the info is: Rows matched: N Changed: M Warnings: W with "Inserted: K" added for system versioned and period tables. The "No data" warning is counted in Warnings. ROW_COUNT() in a stored routine is the number of the changed rows, not of the assigned rows. If there is nothing to read (WHERE 1=0, LIMIT 0, an empty table on some engines), a plain OK without the info is sent, as for UPDATE. Helper changes: 1. The grammar in analyze_stmt_command was changed to have LEX::analyze_stmt set to true earlier, so LEX::set_returning_into_result() already knows if this is an ANALYZE statement. 2. The Sql_cmd_update constructor is now called earlier in the grammar, to be able to call Sql_cmd_update::set_with_old_value_items() in the SET and RETURNING clauses. 3. Sql_cmd_dml::lex is now set during the constructor time. It makes things easier: - Sql_cmd_update::returns_result_set() needs the lex. - Sql_cmd_delete::orig_multitable and Sql_cmd_update::orig_multitable are not needed any more. They were used only in Sql_cmd_delete::sql_command_code() and Sql_cmd_update::sql_command_code(). Sql_cmd_dml::sql_command_code() now returns lex->sql_command. The overrides Sql_cmd_delete::sql_command_code() and Sql_cmd_update::sql_command_code() were removed. 4. A new unsafe statement type BINLOG_STMT_UNSAFE_RETURNING_INTO is set for RETURNING..INTO. decide_logging_format() rejects the statement in the statement format, and logs it in the row format in MIXED. A new error message ER_BINLOG_UNSAFE_CLAUSE ("... because it uses %s ...") explains the unsafeness when a statement-only engine is used. It is filled by the new helper class Binlog_unsafe_explanation. A new debug injection point binlog_stmt_only_engine simulates such an engine in tests. This commit also fixes bugs found during testing: - MDEV-41262 ER_TOO_MANY_ROWS should be checked after CHECK OPTION in view while Update Returning Into - MDEV-41265 SELECT/ UPDATE RETURNING INTO a single row-field fails with ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, even though the column count matches This bug was also fixed in 12.3.4. - MDEV-41260 Misleading message text "uses a LIMIT clause" after Update Returning Into - MDEV-42212 UPDATE ... RETURNING ... INTO raises ER_TOO_MANY_ROWS on InnoDB when the second found row needs no update - MDEV-41448 Update Returning Into expected to produce warning/error for zero-row plan (a test was added; the warning is now raised consistently) - MDEV-41443 Update Returning into produces error when values don't change (a test was added; a warning is raised instead of an error) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove JOIN::union_part The member is assigned in JOIN::prepare() but never read. Its last reads (in the EXPLAIN code) were removed by: commit 46a22a5be75 Author: [email protected] Date: Thu Sep 26 2002 new EXPLAIN fixed bug in mysql-test/create-test-result fixed bug in union-subselect engine Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Marko Mäkelä
marko.makela@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Merge 12.3 into 13.2 Table_triggers_list::check_n_load(): Plug a memory leak that would be introduced by MDEV-41849. This is a logical conflict between that and the 13.1 commit 0ee34e07bdc10abf32a535d7234c6f5e0bb9ed55 (MDEV-39587). Assisted-by: Claude:claude-opus-5-5 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thirunarayanan Balathandayuthapani
thiru@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-37708 Assertion `!trx->is_bulk_insert()' failed or HA_ERR_KEY_NOT_FOUND Problem: ======= A multi-row REPLACE into an empty InnoDB table, replicated in ROW format with unique_checks=0 and foreign_key_checks=0, stops the slave SQL thread with HA_ERR_KEY_NOT_FOUND (error 1032). The master logs the statement as WRITE_ROWS, DELETE_ROWS, WRITE_ROWS. On the slave, the first WRITE_ROWS goes to InnoDB's bulk insert buffer, because the event is applied like a plain INSERT into an empty table. The buffered row is applied to the table only at the end of the statement. DELETE_ROWS searches for that row in the index and cannot find it. Solution: ======== Added a new flag, HA_EXTRA_FLUSH_BULK_INSERT. The row event applier sends it before a DELETE_ROWS or UPDATE_ROWS event that continues a statement, that is, when an earlier row event of the same statement has already been executed. InnoDB then applies the buffered rows and stops buffering, so the following search finds them. The flag is not sent for the first event of a statement, where nothing can be buffered, so ordinary deletes and updates are not affected. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove JOIN::need_distinct The member was assigned in JOIN::init(), JOIN::optimize_inner() and JOIN::optimize_stage2(), but never read. Its last reads, the arguments of prepare_sum_aggregators() calls, were removed by: commit 2cfc450bf78c2d951729d1a0e8f731c0d987b1d5 Author: Igor Babaev <[email protected]> Date: Tue Feb 9 2016 This is the consolidated patch for mdev-8646: "Re-factor the code for post-join operations". Since then the callers compute the value themselves from is_using_agg_loose_index_scan(). JOIN::prepare_sum_aggregators() has a parameter of the same name, which is unrelated and is kept. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Oleksandr Byelkin
sanja@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Merge branch '10.11' into mariadb-10.11.20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Jan Lindström
jan.lindstrom@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-42284 fix galera_sr.mysql-wsrep#215 ER_LOCK_WAIT_TIMEOUT Node_1's own causality wait (wsrep_sync_wait, on by default) blocked its plain SELECT on t1 while the test held node_1's applier paused at the sync.wsrep_apply_cb debug sync point, so the SELECT could not reach the GTID the paused applier had not yet reached and timed out with ER_LOCK_WAIT_TIMEOUT instead of returning. Set wsrep_sync_wait = 0 on node_1 for that SELECT and the INSERT that follows it, saved and restored around each of the test's three blocks. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Marko Mäkelä
marko.makela@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Merge 11.8 into 12.3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove JOIN_TAB::related_tables The member was added by: commit 1d82e5daf71 Author: Monty Date: Mon Jun 13 2022 Move join->emb_smj_nest setting to choose_plan() and has never been used, neither read nor assigned. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove st_select_lex::udf_list The member is declared but never used. Its last uses (the parser's udf call stack and the udf_list.empty() initializers) were removed by the fix for Bug#24736 (88ba7676c1a, also applied as 1f695dbf7d0). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove JOIN_TAB::all_fields JOIN_TAB::all_fields is only assigned (in JOIN::make_aggr_tables_info()) and is never read. It was added, together with JOIN_TAB::fields, by: commit 2cfc450bf78c2d951729d1a0e8f731c0d987b1d5 Author: Igor Babaev <[email protected]> Date: Tue Feb 9 2016 This is the consolidated patch for mdev-8646: "Re-factor the code for post-join operations". That commit never read it, and no later commit has either, so there was no last use to remove. JOIN_TAB::fields is read (by end_send() and end_send_group()) and is kept. Update its comment, which also described all_fields. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Kristian Nielsen
knielsen@knielsen-hq.org |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-42237: Fix integer overflow of relay log position The off_t type is 32-bit signed on Windows, casting the relay log position to off_t will overflow when >= 2**31. Signed-off-by: Kristian Nielsen <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Swayam-code
swayam123code@gmail.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-34654: Use a hex literal for backslash in relaylog test Replace char(92) with 0x5c in the path normalization expressions and matching expected output, as suggested in review. Assisted-by: Codex:GPT-6 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thirunarayanan Balathandayuthapani
thiru@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-37708 Assertion `!trx->is_bulk_insert()' failed or HA_ERR_KEY_NOT_FOUND Problem: ======= A multi-row REPLACE into an empty InnoDB table loses its rows when the table has an AFTER DELETE trigger and the session has unique_checks=0 and foreign_key_checks=0. Normal REPLACE does not use bulk insert, because the SQL layer needs the duplicate-key error right away. InnoDB knows it is a REPLACE only from HA_EXTRA_WRITE_CAN_REPLACE, which sets trx->duplicates. The server does not send that flag when DELETE triggers exist. So InnoDB buffers the first row, the duplicate is never reported for the second row, and the old row is not deleted. The buffered rows are applied at statement end. In this case, table ends up empty and the trigger count is 0. Solution: ======== Added a new flag, HA_EXTRA_WRITE_IS_REPLACE, it is sent only for a REPLACE on a table that has DELETE triggers. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Swayam-code
swayam123code@gmail.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-34654 perfschema.relaylog can fail based on the path of the build directory Match and display log basenames after normalizing path separators, so parent directory names cannot affect file selection or filename output. Use misleading datadir names to exercise filtering, extraction and relay-log rotation. Assisted-by: Codex:GPT-6 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Alexander Barkov
bar@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MDEV-39563 Implement UPDATE ... RETURNING ... INTO Adding support for UPDATE .. RETURNING .. INTO queries. For example: UPDATE t1 SET a=10,b=20 RETURNING a,b INTO va,vb; UPDATE t1 SET a=10,b=20 RETURNING a,b INTO @a,@b; Limitations: 1. These types of queries: - REPLACE .. RETURNING .. INTO - DELETE .. RETURNING .. INTO - INSERT .. RETURNING .. INTO are not supported yet, and ER_NOT_SUPPORTED_YET is raised with 'REPLACE..RETURNING..INTO', 'DELETE..RETURNING..INTO' or 'INSERT..RETURNING..INTO' as the argument. The same is for the INSERT..SELECT and REPLACE..SELECT forms. They will be implemented separately, when needed. 2. UPDATE..RETURNING..INTO with --binlog_format=statement is not allowed and an error is raised. No warning "Unsafe statement written to the binary log" is raised for it, as the statement is rejected and is not written. 3. Using OLD_VALUE(col) in the RETURNING list of UPDATE..RETURNING..INTO is not allowed and an error is raised. 4. Multi-table updates do not work, and neither do single table updates that get converted to multi-table: - UPDATE t1,t2 ..: ER_NOT_SUPPORTED_YET ('RETURNING for multi-table UPDATE') - an UPDATE of a view over several tables, or with an IN subquery converted to a semi-join (even on another table): ER_NOT_SUPPORTED_YET ('multi-table UPDATE..RETURNING..INTO') - a subquery on the updated table in WHERE: ER_UPDATE_TABLE_USED. With ORDER BY .. LIMIT the statement is not converted to multi-table, so it works. 5. UPDATE IGNORE .. RETURNING .. INTO is not supported yet and ER_NOT_SUPPORTED_YET is raised (MDEV-42156). A row rejected by the engine (a duplicate key, no partition found) is ignored by IGNORE, so it is not known before ha_update_row() whether the row is a second changed row. UPDATE IGNORE .. RETURNING without INTO works as before. Notes: 1. ANALYZE and EXPLAIN Both ANALYZE UPDATE .. RETURNING .. INTO .. EXPLAIN UPDATE .. RETURNING .. INTO .. return this error: 'RETURNING..INTO' is not allowed in this context 2. Behavior on no data and on multiple rows Only the rows that were actually changed are processed. A row that matches the WHERE condition but needs no update is not changed, so it is not returned by plain RETURNING either. Situation | RETURNING | RETURNING .. INTO --------------------------+-------------+----------------------------- Empty table, WHERE | empty set | Warning ER_SP_FETCH_NO_DATA, matches nothing (1=0), | | target is not changed LIMIT 0 | | One row matches, needs | empty set | Warning ER_SP_FETCH_NO_DATA, no update | | target is not changed Several rows match, none | empty set | Warning ER_SP_FETCH_NO_DATA, needs an update | | target is not changed | | (no ER_TOO_MANY_ROWS) One row matches and is | that row | Target is assigned changed | | Several rows match, | that row | Target is assigned from exactly one changes | | that row Two or more rows change | all changed | ER_TOO_MANY_ROWS at the 2nd | | changed row (not updated) Notes: - The warning is never an error: not in the strict mode and not with sql_mode=''. The INTO targets keep their old values. In stored routines the warning activates NOT FOUND handlers. - This is the same for all storage engines, including those that quickly know the table is empty and use a degenerated plan (e.g. MyISAM). - After ER_TOO_MANY_ROWS, transactional engines roll back the statement, non-transactional engines keep the rows updated before the error (the second changed row is not updated). - The targets can be user variables, SP variables, ROW variables and ROW fields. - For a system-versioned table, an update that sets the same values still creates a new row version, so such a row counts as changed: plain RETURNING returns it, and RETURNING .. INTO assigns it (or raises ER_TOO_MANY_ROWS if two rows match). 3. Behavior on VIEW with CHECK OPTION The "too many rows" check is done after the view's CHECK OPTION check, so a row rejected by WITH CHECK OPTION raises the CHECK OPTION error and not ER_TOO_MANY_ROWS. 4. The OK packet UPDATE .. RETURNING .. INTO sends the same OK packet as a plain UPDATE. The affected rows are the changed rows (the matched rows with CLIENT_FOUND_ROWS), and the info is: Rows matched: N Changed: M Warnings: W with "Inserted: K" added for system versioned and period tables. The "No data" warning is counted in Warnings. ROW_COUNT() in a stored routine is the number of the changed rows, not of the assigned rows. If there is nothing to read (WHERE 1=0, LIMIT 0, an empty table on some engines), a plain OK without the info is sent, as for UPDATE. Helper changes: 1. The grammar in analyze_stmt_command was changed to have LEX::analyze_stmt set to true earlier, so LEX::set_returning_into_result() already knows if this is an ANALYZE statement. 2. The Sql_cmd_update constructor is now called earlier in the grammar, to be able to call Sql_cmd_update::set_with_old_value_items() in the SET and RETURNING clauses. 3. Sql_cmd_dml::lex is now set during the constructor time. It makes things easier: - Sql_cmd_update::returns_result_set() needs the lex. - Sql_cmd_delete::orig_multitable and Sql_cmd_update::orig_multitable are not needed any more. They were used only in Sql_cmd_delete::sql_command_code() and Sql_cmd_update::sql_command_code(). Sql_cmd_dml::sql_command_code() now returns lex->sql_command. The overrides Sql_cmd_delete::sql_command_code() and Sql_cmd_update::sql_command_code() were removed. 4. UPDATE..RETURNING..INTO is marked as unsafe for the statement based replication, like SELECT..LIMIT without ORDER BY: the order of rows is not predictable. With the MIXED format it is logged in the row format. A new error message ER_BINLOG_UNSAFE_CLAUSE ("... because it uses %s ...") explains the unsafeness when a statement-only engine is used. It is filled by the new helper class Binlog_unsafe_explanation. A new debug injection point binlog_stmt_only_engine simulates such an engine in tests. This commit also fixes bugs found during testing: - MDEV-41262 ER_TOO_MANY_ROWS should be checked after CHECK OPTION in view while Update Returning Into - MDEV-41265 SELECT/ UPDATE RETURNING INTO a single row-field fails with ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, even though the column count matches This bug was also fixed in 12.3.4. - MDEV-41260 Misleading message text "uses a LIMIT clause" after Update Returning Into - MDEV-42212 UPDATE ... RETURNING ... INTO raises ER_TOO_MANY_ROWS on InnoDB when the second found row needs no update - MDEV-41448 Update Returning Into expected to produce warning/error for zero-row plan (a test was added; the warning is now raised consistently) - MDEV-41443 Update Returning into produces error when values don't change (a test was added; a warning is raised instead of an error) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove JOIN::original_join_tab, original_table_count These were added by cf50e13fbd1 (MDEV-6080: Allowing storage engine to shortcut group by queries) to remember the join_tab array and table_count before the group_by_handler replaced them. The last assignment of non-NULL values to them was removed by: commit 2cfc450bf78c2d951729d1a0e8f731c0d987b1d5 Author: Igor Babaev <[email protected]> Date: Tue Feb 9 2016 This is the consolidated patch for mdev-8646: "Re-factor the code for post-join operations". Since then original_join_tab was only set to 0, so the block in JOIN::cleanup() that restored join_tab and table_count from them never ran. Remove the block and both members. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei Petrunia
sergey@mariadb.com |
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Remove JOIN::filesort_found_rows Last use was removed by: commit 2cfc450bf78c2d951729d1a0e8f731c0d987b1d5 Author: Igor Babaev <[email protected]> Date: Tue Feb 9 12:35:59 2016 -0800 This is the consolidated patch for mdev-8646: "Re-factor the code for post-join operations". |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||