diff options
author | unknown <dlenev@brandersnatch.localdomain> | 2005-06-07 14:53:08 +0400 |
---|---|---|
committer | unknown <dlenev@brandersnatch.localdomain> | 2005-06-07 14:53:08 +0400 |
commit | 49357ae8f0643bc7828a57c5f078d8aab4d35e0c (patch) | |
tree | c7c9f9e62a48bf969fc8619952d6c3f850600695 /sql/sql_trigger.h | |
parent | 1c7b61e3aef5227165a9957ead000e67935708b2 (diff) | |
download | mariadb-git-49357ae8f0643bc7828a57c5f078d8aab4d35e0c.tar.gz |
Fix for bug #10015 "Crash in InnoDB if stored routines are used".
We should not allow explicit or implicit transaction commits inside
of stored functions or triggers (so in autocommit mode we should not
do commits after execution of sub-statement).
Also since we don't support nested statement transactions in 5.0,
we shouldn't commit or rollback stmt transactions while we are inside
stored functions or triggers. This should be fixed in later (>=5.1)
releases.
mysql-test/r/sp_trans.result:
Added test for bug #10015 "Crash in InnoDB if stored routines are used"
and for general transaction handling inside of functions.
mysql-test/t/sp_trans.test:
Added test for bug #10015 "Crash in InnoDB if stored routines are used"
and for general transaction handling inside of functions.
sql/handler.cc:
ha_trans_commit()/ha_trans_rollback():
Since we don't support nested statement transactions in 5.0,
we can't commit or rollback stmt transactions while we are inside
stored functions or triggers. So we simply do nothing now.
This should be fixed in later ( >= 5.1) releases.
sql/item_func.cc:
Item_func_sp::execute():
Set THD::transaction.in_sub_stmt flag to TRUE during stored function
execution to prevent commits and rollbacks for statement level
transactions, since doing them will ruin such transaction for
stateemtn which calls this function.
sql/share/errmsg.txt:
Added error message which says that statements doing explicit or implicit
commits are disallowed in triggers and stored functions.
sql/sql_base.cc:
close_thread_tables():
Clarified comment about committing of statement transactions in
prelocked mode.
sql/sql_class.h:
THD::transaction:
Added in_sub_stmt method which indicates that we are executing
statements from trigger or stored function now, and thus
statement transaction belongs to statement which invoked this
routine and we should not commit or rollback it while executing
these sub-statements.
sql/sql_parse.cc:
end_active_trans()/begin_trans()/end_trans():
We should not commit or rollback global (non-stmt) transaction
if we are executing stored function or trigger. These checks will
catch situation when we are trying to do commit or rollback in stored
procedure which is called from function or trigger.
sql/sql_trigger.h:
Table_triggers_list::process_triggers():
Set THD::transaction.in_sub_stmt flag to TRUE during trigger
execution to prevent commits and rollbacks for statement level
transactions, since doing them will ruin such transaction for
stateemtn which invokes this trigger.
sql/sql_yacc.yy:
Prohibited usage of statements which do explicit or implicit commit or
rollback inside of stored functions and triggers.
Diffstat (limited to 'sql/sql_trigger.h')
-rw-r--r-- | sql/sql_trigger.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index d61da8ff06b..0547283d0c5 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -53,6 +53,7 @@ public: if (bodies[event][time_type]) { + bool save_in_sub_stmt= thd->transaction.in_sub_stmt; #ifndef EMBEDDED_LIBRARY /* Surpress OK packets in case if we will execute statements */ my_bool nsok= thd->net.no_send_ok; @@ -81,7 +82,11 @@ public: does NOT go into binlog. */ tmp_disable_binlog(thd); + thd->transaction.in_sub_stmt= TRUE; + res= bodies[event][time_type]->execute_function(thd, 0, 0, 0); + + thd->transaction.in_sub_stmt= save_in_sub_stmt; reenable_binlog(thd); #ifndef EMBEDDED_LIBRARY |