Bug #12713 | Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem | ||
---|---|---|---|
Submitted: | 22 Aug 2005 7:26 | Modified: | 5 Mar 2008 16:12 |
Reporter: | Alexey Kopytov | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S3 (Non-critical) |
Version: | 5.0.11 | OS: | Any |
Assigned to: | Konstantin Osipov | CPU Architecture: | Any |
[22 Aug 2005 7:26]
Alexey Kopytov
[16 Sep 2005 17:29]
Valeriy Kravchuk
In 5.0.14-rc (after autocommit became not allowed in SPs), I've got: mysql> CREATE FUNCTION func1() RETURNS INTEGER -> DETERMINISTIC -> BEGIN -> SET AUTOCOMMIT=1; -> INSERT INTO tbl1(col1) VALUES(100); -> INSERT INTO tbl1(col1) VALUES(100); -- Duplicate-key -> RETURN 100; -> END -> // ERROR 1445 (HY000): Not allowed to set autocommit from a stored function or trigger mysql> CREATE FUNCTION func1() RETURNS INTEGER -> DETERMINISTIC -> BEGIN -> INSERT INTO tbl1(col1) VALUES(100); -> INSERT INTO tbl1(col1) VALUES(100); -- Duplicate-key -> RETURN 100; -> END -> // Query OK, 0 rows affected (0.00 sec) mysql> select func1()// ERROR 1062 (23000): Duplicate entry '100' for key 1 mysql> select * from tbl1// +------+ | col1 | +------+ | 100 | +------+ 1 row in set (0.00 sec) Now, functions works in a same manner as individual statements (both with autocommit on or off): mysql> set autocommit=0// Query OK, 0 rows affected (0.00 sec) mysql> delete from tbl1// Query OK, 1 row affected (0.01 sec) mysql> select * from tbl1// Empty set (0.00 sec) mysql> commit// Query OK, 0 rows affected (0.01 sec) mysql> insert into tbl1(col1) VALUES(100)// Query OK, 1 row affected (0.00 sec) mysql> insert into tbl1(col1) VALUES(100)// ERROR 1062 (23000): Duplicate entry '100' for key 1 Only this, last statement rolled back, not the whole transaction (just as in Oracle): mysql> select * from tbl1// +------+ | col1 | +------+ | 100 | +------+ 1 row in set (0.00 sec) mysql> rollback// Query OK, 0 rows affected (0.00 sec) mysql> select * from tbl1// Empty set (0.01 sec) mysql> set autocommit=1// Query OK, 0 rows affected (0.00 sec) mysql> insert into tbl1(col1) VALUES(100)// Query OK, 1 row affected (0.00 sec) This transaction was commited. mysql> insert into tbl1(col1) VALUES(100)// ERROR 1062 (23000): Duplicate entry '100' for key 1 And this was not, because of duplicate entry... mysql> select * from tbl1// +------+ | col1 | +------+ | 100 | +------+ 1 row in set (0.00 sec) So, it's not abuf any more - it is consistent behaviour.
[7 Feb 2006 13:37]
Konstantin Osipov
A test case for the problem: set autocommit=0; create table t1 (a int unique) engine=innodb; create table t2 (a int) engine=innodb; insert into t2 (a) values (1),(2); commit; delimiter // create function f1() returns int begin insert into t1 (a) values (1); return 1; end// delimiter ; -- statement rollback is expected and is properly executed update t2 set a=a+f1(); select * from t1; rollback; select * from t1; -- statement rollback is expected and does not happen select f1() from t2; select * from t1; rollback; -- the data is not committed either select * from t1; It's output: mysql> drop table if exists t1,t2; Query OK, 0 rows affected (0.00 sec) mysql> drop function f1; Query OK, 0 rows affected (0.00 sec) mysql> create table t1 (a int unique) engine=innodb; Query OK, 0 rows affected (0.01 sec) mysql> create table t2 (a int) engine=innodb; Query OK, 0 rows affected (0.00 sec) mysql> insert into t2 (a) values (1),(2); Query OK, 2 rows affected (0.00 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> commit; Query OK, 0 rows affected (0.00 sec) mysql> delimiter // mysql> create function f1() returns int -> begin -> insert into t1 (a) values (1); -> return 1; -> end// Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> -- statement rollback is expected and is properly executed mysql> update t2 set a=a+f1(); ERROR 1062 (23000): Duplicate entry '1' for key 1 mysql> select * from t1; Empty set (0.00 sec) mysql> rollback; Query OK, 0 rows affected (0.00 sec) mysql> select * from t1; Empty set (0.00 sec) mysql> -- statement rollback is expected and does not happen mysql> select f1() from t2; ERROR 1062 (23000): Duplicate entry '1' for key 1 mysql> select * from t1; +------+ | a | +------+ | 1 | +------+ 1 row in set (0.00 sec) mysql> rollback; Query OK, 0 rows affected (0.00 sec) mysql> select * from t1; Empty set (0.00 sec)
[7 Feb 2006 16:06]
MySQL Verification Team
Hi! It is of the vital interest that, if autocommit=1 prior to the call of the stored routine, it should be restored at the end of the stored routine execution !!!
[16 Aug 2006 4:51]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/10521 ChangeSet@1.2236, 2006-08-15 22:51:11-07:00, malff@weblab.(none) +46 -0 Bug#12713 (Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem) Investigating this bug in depth revealed several issues. As a result, the following was done: 1) The usage of "if (transactional_table)" before calling ha_autocommit_or_rollback is flawed, as only 1 table is considered, which breaks integrity for statements involving many tables with a mix of transactional and non transactional engines. The serie of tests t/engine_mix_<xxx>_<yyy>.test has been written to cover this area. Existing calls to ha_commit_or_rollback() have been adjusted. 2) Executing these tests also exposed some limitations in the BDB and NDB engines, for which the handlerton call backs have been fixed. 3) After a very carefull investigation, the list of statements that can modify transactional data has been identified, and documented in mysql_execute_command (See the comments there). 4) All the statements that can cause side effects have been fixed to properly call ha_commit_or_rollback(). 5) While doing 4), a flaw has been found for the DO command. The code has been fixed and the related tests cases adjusted. Also, a flaw in multi updates has been fixed. 6) A serie of tests t/autocommit_<xxx>.test has been written to verify that statement crollback *and* transaction rollback occur properly. 7) All the new tests have been organized in a manner consistent with the test reorganization performed recently in 5.1 for falcon. 8) Two unrelated issues have been found and documented for NDB, the tests written with the expected output (unverified), and disabled in t/disable.def
[26 Aug 2006 0:16]
Konstantin Osipov
Sent a few review comments by email.
[9 Sep 2006 2:14]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/11646 ChangeSet@1.2263, 2006-09-08 20:14:16-07:00, malff@weblab.(none) +50 -0 Bug#12713 (Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem) This is a revised patch, that fixes comments from the first review. 1) The usage of "if (transactional_table)" before calling ha_autocommit_or_rollback is flawed, as only 1 table is considered, which breaks integrity for statements involving many tables with a mix of transactional and non transactional engines. The serie of tests t/engine_mix_<xxx>_<yyy>.test has been written to cover this area. (tests naming pending decision) Existing calls to ha_commit_or_rollback() have been adjusted. 2) Implementation of "implicit non-updating commits" in BDB and NDB has been adjusted to unregister these engines so that autocommit/rollback can be performed properly for selects. 3) After a very carefull investigation, the list of statements that can modify transactional data has been identified, and documented in mysql_execute_command (See the comments there). 4) All the statements that can cause side effects have been fixed to properly call ha_commit_or_rollback(). 5) Fixed the DO, MULTI-UPDATE, and MULTI-DELETE to call ha_autocommit_or_rollback 6) A serie of tests t/autocommit_<xxx>.test has been written to verify that statement rollback *and* transaction rollback occur properly. (test naming pending decision) 7) All the new tests have been organized in a manner consistent with the test reorganization performed recently in 5.1 for falcon. 8) One unrelated issues has been found and documented for NDB, the tests written with the expected output (unverified), and disabled in t/disable.def 9) The select_result class hierarchy has been changed, so that send_error() and send_eof() methods can perform a statement ha_autocommit_or_rollback() before sending a reply to the client. This implementation is the least intrusive to the existing design.
[15 Nov 2006 18:57]
Tomash Brechko
Bug#23802 is a duplicate of this bug.
[27 Jun 2007 16:52]
Konstantin Osipov
Will re-apply the patch and implement post-review comments.
[30 Oct 2007 19:32]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36692 ChangeSet@1.2598, 2007-10-30 22:32:20+03:00, kostja@bodhi.(none) +7 -0 In ha_delete_table, use a standard mechanism to intercept the error message and convert it to a warning instead of direct manipulation with the thread error stack. Fix a bug in handler::print_erorr when a garbled message was printed for HA_ERR_NO_SUCH_TABLE. This is a pre-requisite patch for the fix for Bug#12713 Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem"
[30 Oct 2007 19:39]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36694 ChangeSet@1.2598, 2007-10-30 22:39:37+03:00, kostja@bodhi.(none) +4 -0 Cleanup: use helper functions to set an error in MYSQL or MYSQL_STMT. No functionality added or changed. This is a pre-requisite for the fix for Bug#12713 Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem
[31 Oct 2007 13:50]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36755 ChangeSet@1.2599, 2007-10-31 16:49:13+03:00, kostja@bodhi.(none) +6 -0 Remove net_printf_error(). Do not talk to network directly in check_user/check_connection/check_for_max_user_connections. This is a pre-requisite patch for the fix for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem"
[31 Oct 2007 14:17]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36758 ChangeSet@1.2598, 2007-10-31 17:16:53+03:00, kostja@bodhi.(none) +4 -0 Cleanup: use helper functions to set an error in MYSQL or MYSQL_STMT. No functionality added or changed. This is a pre-requisite for the fix for Bug#12713 Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem Address post-review comments.
[31 Oct 2007 15:33]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36767 ChangeSet@1.2605, 2007-10-31 18:33:13+03:00, kostja@bodhi.(none) +3 -0 Cleanup: rename select_send::status to select_send::is_result_set_started. Add select_send::cleanup. Fix a compilation warning. Issues spotted while working on the fix for Bug#12713.
[31 Oct 2007 21:12]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36804 ChangeSet@1.2599, 2007-11-01 00:10:58+03:00, kostja@bodhi.(none) +6 -0 Remove net_printf_error(). Do not talk to network directly in check_user()/check_connection()/check_for_max_user_connections(). This is a pre-requisite patch for the fix for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem" Implement review comments.
[31 Oct 2007 22:40]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36811 ChangeSet@1.2610, 2007-11-01 01:40:22+03:00, kostja@bodhi.(none) +5 -0 Implement review requests (Serg) for the patch that deploys Internal_error_handler in ha_delete_table(). This patch was produced while working on Bug#12713.
[1 Nov 2007 14:08]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36875 ChangeSet@1.2612, 2007-11-01 17:08:02+03:00, kostja@bodhi.(none) +1 -0 Use thd->is_error() instead of direct access to thd->net.report_error in evaluate_join_record(). A minor cleanup required for the fix for Bug#12713.
[1 Nov 2007 14:52]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36887 ChangeSet@1.2613, 2007-11-01 17:52:03+03:00, kostja@bodhi.(none) +1 -0 Use Internal_error_handler mechanism to silence ER_TOO_MANY_FIELDS error in mysql_create_frm instead of direct access to my_error() members. This is a pre-requisite for the patch for Bug#12713.
[1 Nov 2007 14:54]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36888 ChangeSet@1.2613, 2007-11-01 17:54:22+03:00, kostja@bodhi.(none) +1 -0 Use Internal_error_handler mechanism to silence ER_TOO_MANY_FIELDS error in mysql_create_frm instead of direct access to my_error() members. This is a pre-requisite for the patch for Bug#12713.
[1 Nov 2007 15:06]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36891 ChangeSet@1.2613, 2007-11-01 18:06:46+03:00, kostja@bodhi.(none) +1 -0 Use Internal_error_handler mechanism to silence ER_TOO_MANY_FIELDS error in mysql_create_frm instead of direct access to my_error() members. This is a pre-requisite for the patch for Bug#12713.
[1 Nov 2007 15:34]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/36896 ChangeSet@1.2602, 2007-11-01 18:33:51+03:00, kostja@bodhi.(none) +1 -0 Cleanup execute_ddl_log_recovery() to not generate an error if there is nothing to recover. Discovered while working on Bug#12713
[3 Nov 2007 12:26]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/37039 ChangeSet@1.2606, 2007-11-03 15:26:04+03:00, kostja@bodhi.(none) +45 -0 Do not send OK/EOF packets to the client till the end of statement. Massive change to use an API instead of direct access to private members of the error stack in THD. Draft, and that applies to the changeset comments as well. This is a pre-requisite for Bug#12713.
[3 Nov 2007 13:15]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/37041 ChangeSet@1.2606, 2007-11-03 16:14:55+03:00, kostja@bodhi.(none) +45 -0 Do not send OK/EOF packets to the client till the end of statement. Massive change to use an API instead of direct access to private members of the error stack in THD. Draft, and that applies to the changeset comments as well. This is a pre-requisite for Bug#12713.
[4 Nov 2007 10:35]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/37060 ChangeSet@1.2606, 2007-11-04 13:35:24+03:00, kostja@bodhi.(none) +45 -0 Do not send OK/EOF packets to the client until we reached the end of the current statement. This is a consolidation, to keep the functionality that is shared by all SQL statements in one place in the server. Currently this functionality includes: - close_thread_tables() - log_slow_statement(). After this patch and the subsequent patch for Bug#12713, it shall also include: - ha_autocommit_or_rollback() - net_end_statement() - query_cache_end_of_result(). In future it may also include: - mysql_reset_thd_for_next_command(). Massive change to use an API instead of direct access to private members of the error stack in THD. This is a pre-requisite for Bug#12713.
[7 Nov 2007 22:00]
Bugs System
Pushed into 6.0.4-alpha
[7 Nov 2007 22:01]
Bugs System
Pushed into 5.1.23-rc
[14 Nov 2007 14:46]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/37751 ChangeSet@1.2607, 2007-11-14 17:46:40+03:00, kostja@bodhi.(none) +9 -0 Bug#12713. This patch fixes the bug. No test cases, changeset comments, or review comments. An intermediate commit for the passing test suite.
[16 Nov 2007 16:34]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/37967 ChangeSet@1.2608, 2007-11-16 19:32:51+03:00, kostja@bodhi.(none) +5 -0 Bug#12713. Changes to make the test suite pass after an explicit statement commit was added after every and each statement.
[22 Nov 2007 23:14]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/38320 ChangeSet@1.2607, 2007-11-23 02:14:20+03:00, kostja@bodhi.(none) +20 -0 A fix and a test case for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem" Initial test coverage. Full test coverage is last remaining issue that is left.
[12 Dec 2007 15:22]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/39784 ChangeSet@1.2679, 2007-12-12 18:21:01+03:00, kostja@bodhi.(none) +51 -0 Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statement", part 1. Review fixes. Do not send OK/EOF packets to the client until we reached the end of the current statement. This is a consolidation, to keep the functionality that is shared by all SQL statements in one place in the server. Currently this functionality includes: - close_thread_tables() - log_slow_statement(). After this patch and the subsequent patch for Bug#12713, it shall also include: - ha_autocommit_or_rollback() - net_end_statement() - query_cache_end_of_result(). In future it may also include: - mysql_reset_thd_for_next_command().
[13 Dec 2007 2:38]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/39851 ChangeSet@1.2642, 2007-12-13 05:37:38+03:00, kostja@bodhi.(none) +2 -0 Fix a compilation warning and a subtle bug with truncation of the last_insert_id introduced by the patch for Bug#12713 (part 1)
[13 Dec 2007 17:17]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/39914 ChangeSet@1.2760, 2007-12-13 20:17:28+03:00, kostja@bodhi.(none) +5 -0 Fix a compilation failure introduced by the merge of the first patch for Bug#12713. Update the ABI compatibility file to reflect recent (compatible) changes.
[13 Dec 2007 20:59]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/39941 ChangeSet@1.2643, 2007-12-13 23:58:55+03:00, kostja@bodhi.(none) +6 -0 Fix broken embedded build (broken by the patch for Bug#12713, first part).
[16 Dec 2007 11:43]
Bugs System
Pushed into 5.1.23-rc
[16 Dec 2007 11:45]
Bugs System
Pushed into 6.0.5-alpha
[19 Dec 2007 19:16]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/40228 ChangeSet@1.2650, 2007-12-19 22:15:02+03:00, kostja@bodhi.(none) +4 -0 Make handler::{write,delete,update}_row private. It's critical that the entire server uses their public ha_* counterparts instead, since only then we can ensure proper tracing of these calls that is necessary for Bug#12713. A pre-requisite for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem"
[20 Dec 2007 14:47]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/40274 ChangeSet@1.2651, 2007-12-20 17:47:04+03:00, kostja@bodhi.(none) +13 -0 A pre-requisite for the fix for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of state" Make private all class handler methods (PSEA API) that may modify data. Introduce and deploy public ha_* wrappers for these methods in all sql/. This necessary to keep track of all data modifications in sql/, which is in turn necessary to be able to optimize two-phase commit of those transactions that do not modify data.
[20 Dec 2007 16:44]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/40281 ChangeSet@1.2651, 2007-12-20 19:44:04+03:00, kostja@bodhi.(none) +13 -0 A pre-requisite for the fix for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of state" Make private all class handler methods (PSEA API) that may modify data. Introduce and deploy public ha_* wrappers for these methods in all sql/. This necessary to keep track of all data modifications in sql/, which is in turn necessary to be able to optimize two-phase commit of those transactions that do not modify data.
[20 Dec 2007 17:20]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/40287 ChangeSet@1.2651, 2007-12-20 20:19:49+03:00, kostja@bodhi.(none) +13 -0 A pre-requisite for the fix for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of state" Make private all class handler methods (PSEA API) that may modify data. Introduce and deploy public ha_* wrappers for these methods in all sql/. This necessary to keep track of all data modifications in sql/, which is in turn necessary to be able to optimize two-phase commit of those transactions that do not modify data.
[29 Dec 2007 19:19]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/40461 ChangeSet@1.2653, 2007-12-29 22:18:31+03:00, kostja@bodhi.(none) +27 -0 A fix and a test case for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem" The latest changeset for a code review.
[25 Jan 2008 12:36]
Bugs System
Pushed into 5.1.24-rc
[25 Jan 2008 12:40]
Bugs System
Pushed into 6.0.5-alpha
[7 Feb 2008 14:17]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/41868 ChangeSet@1.2518, 2008-02-07 17:17:09+03:00, kostja@dipika.(none) +26 -0 A fix and a test case for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem". The idea of the fix is to ensure that we always commit the current statement at the end of dispatch_command(). In order to not issue redundant disc syncs, an optimization of the two-phase commit protocol is implemented to bypass the two phase commit if the transaction is read-only.
[19 Feb 2008 11:43]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/42541 ChangeSet@1.2518, 2008-02-19 14:43:01+03:00, kostja@dipika.(none) +27 -0 A fix and a test case for Bug#12713 "Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem". The idea of the fix is to ensure that we always commit the current statement at the end of dispatch_command(). In order to not issue redundant disc syncs, an optimization of the two-phase commit protocol is implemented to bypass the two phase commit if the transaction is read-only.
[19 Feb 2008 12:06]
Konstantin Osipov
Queued in 5.1-runtime, 6.0-runtime.
[22 Feb 2008 18:49]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/42860 ChangeSet@1.2575, 2008-02-22 21:49:16+03:00, kostja@dipika.(none) +1 -0 Update new test results after merge (Bug#12713)
[27 Feb 2008 15:39]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/43074 ChangeSet@1.2545, 2008-02-27 18:38:17+03:00, kostja@dipika.(none) +2 -0 Update Bug#12713 test results to take into account fixed bugs (29157, 33846)
[3 Mar 2008 18:19]
Bugs System
Pushed into 5.1.24-rc
[3 Mar 2008 18:19]
Bugs System
Pushed into 6.0.5-alpha
[5 Mar 2008 16:12]
Jon Stephens
Documented in the 5.1.23-ndb-6.2.14, 5.1.24, and 6.0.5 changelogs as follows: Transactions were not rolled back when selecting a stored function with AUTOCOMMIT set to 1 where the function yielded an error.
[14 Mar 2008 2:05]
Paul DuBois
Revised changelog entry: If a SELECT calls a stored function in a transaction, and a statement within the function fails, that statement should roll back. Furthermore, if ROLLBACK is executed after that, the entire transaction should be rolled back. Before this fix, the failed statement did not roll back when it failed (even though it might ultimately get rolled back by a ROLLBACK later that rolls back the entire transaction).
[29 Mar 2008 19:39]
Jon Stephens
Fix also noted for 5.1.23-ndb-6.3.11.
[9 Apr 2008 13:57]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/45137 ChangeSet@1.2588, 2008-04-09 15:56:25+02:00, mleich@five.local.lan +2 -0 Additional tests inspired by Bug #12713 Error in a stored function called from a SELECT doesn't cause ROLLBACK of statem
[9 Apr 2008 20:00]
Matthias Leich
I did some additional QA tests around this Bug. Final results: 1. t/function_rollback.test which was pushed to mysql-5.1-build and mysql-6.0-build 2. Bug#35877 Update .. WHERE with function, constraint violation, crash (affects MySQL 5.1 and 6.0 but not 5.0) Regards, Matthias
[1 May 2008 10:05]
Bugs System
Pushed into 5.1.25-rc
[1 May 2008 10:07]
Bugs System
Pushed into 6.0.6-alpha
[8 May 2008 17:16]
Paul DuBois
Changelog entry: If a SELECT calls a stored function in a transaction, and a statement within the function fails, that statement should roll back. Furthermore, if ROLLBACK is executed after that, the entire transaction should be rolled back. Before this fix, the failed statement did not roll back when it failed (even though it might ultimately get rolled back by a ROLLBACK later that rolls back the entire transaction).
[25 Dec 2008 11:03]
Sveta Smirnova
Bug #40788 was marked as duplicate of this one.
[15 Sep 2009 4:35]
James Day
The fix for this bug caused new bug #45309 which was fixed in 5.1.37 and 5.4.4.