1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Per Heikki's request make trans_register_ha tolerant to multiple registrations

This commit is contained in:
serg@serg.mylan
2005-04-05 18:42:34 +02:00
parent 680f7d3b66
commit 42277bdd2f

View File

@ -505,10 +505,16 @@ void ha_close_connection(THD* thd)
"beginning of transaction" and "beginning of statement"). "beginning of transaction" and "beginning of statement").
Only storage engines registered for the transaction/statement Only storage engines registered for the transaction/statement
will know when to commit/rollback it. will know when to commit/rollback it.
NOTE
trans_register_ha is idempotent - storage engine may register many
times per transaction.
*/ */
void trans_register_ha(THD *thd, bool all, handlerton *ht_arg) void trans_register_ha(THD *thd, bool all, handlerton *ht_arg)
{ {
THD_TRANS *trans; THD_TRANS *trans;
handlerton **ht;
DBUG_ENTER("trans_register_ha"); DBUG_ENTER("trans_register_ha");
DBUG_PRINT("enter",("%s", all ? "all" : "stmt")); DBUG_PRINT("enter",("%s", all ? "all" : "stmt"));
@ -520,15 +526,12 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg)
else else
trans= &thd->transaction.stmt; trans= &thd->transaction.stmt;
#ifndef DBUG_OFF for (ht=trans->ht; *ht; ht++)
handlerton **ht=trans->ht; if (*ht == ht_arg)
while (*ht) DBUG_VOID_RETURN;
{
DBUG_ASSERT(*ht != ht_arg);
ht++;
}
#endif
trans->ht[trans->nht++]=ht_arg; trans->ht[trans->nht++]=ht_arg;
DBUG_ASSERT(*ht == ht_arg);
trans->no_2pc|=(ht_arg->prepare==0); trans->no_2pc|=(ht_arg->prepare==0);
if (thd->transaction.xid.is_null()) if (thd->transaction.xid.is_null())
thd->transaction.xid.set(thd->query_id); thd->transaction.xid.set(thd->query_id);