1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

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.
This commit is contained in:
dlenev@brandersnatch.localdomain
2005-06-07 14:53:08 +04:00
parent 329d974df7
commit 270b695f59
10 changed files with 433 additions and 5 deletions

View File

@@ -595,6 +595,27 @@ int ha_commit_trans(THD *thd, bool all)
handlerton **ht= trans->ht;
my_xid xid= thd->transaction.xid.get_my_xid();
DBUG_ENTER("ha_commit_trans");
if (thd->transaction.in_sub_stmt)
{
/*
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.
TODO: This should be fixed in later ( >= 5.1) releases.
*/
if (!all)
DBUG_RETURN(0);
/*
We assume that all statements which commit or rollback main transaction
are prohibited inside of stored functions or triggers. So they should
bail out with error even before ha_commit_trans() call. To be 100% safe
let us throw error in non-debug builds.
*/
DBUG_ASSERT(0);
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
DBUG_RETURN(2);
}
#ifdef USING_TRANSACTIONS
if (trans->nht)
{
@@ -689,6 +710,19 @@ int ha_rollback_trans(THD *thd, bool all)
THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt;
bool is_real_trans=all || thd->transaction.all.nht == 0;
DBUG_ENTER("ha_rollback_trans");
if (thd->transaction.in_sub_stmt)
{
/*
If we are inside stored function or trigger we should not commit or
rollback current statement transaction. See comment in ha_commit_trans()
call for more information.
*/
if (!all)
DBUG_RETURN(0);
DBUG_ASSERT(0);
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
DBUG_RETURN(1);
}
#ifdef USING_TRANSACTIONS
if (trans->nht)
{