diff options
Diffstat (limited to 'storage/maria/ma_trnman.h')
-rw-r--r-- | storage/maria/ma_trnman.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/storage/maria/ma_trnman.h b/storage/maria/ma_trnman.h index 9bfd1f0d047..5b6d0e9f60d 100644 --- a/storage/maria/ma_trnman.h +++ b/storage/maria/ma_trnman.h @@ -18,7 +18,7 @@ /** Sets table's trn and prints debug information - Links table into used_instances if new_trn is not 0 + Links table into new_trn->used_instances @param tbl MARIA_HA of table @param newtrn what to put into tbl->trn @@ -34,7 +34,10 @@ static inline void _ma_set_trn_for_table(MARIA_HA *tbl, TRN *newtrn) tbl->trn= newtrn; /* Link into used list */ + if (newtrn->used_instances) + ((MARIA_HA*) newtrn->used_instances)->trn_prev= &tbl->trn_next; tbl->trn_next= (MARIA_HA*) newtrn->used_instances; + tbl->trn_prev= (MARIA_HA**) &newtrn->used_instances; newtrn->used_instances= tbl; } @@ -49,6 +52,8 @@ static inline void _ma_set_tmp_trn_for_table(MARIA_HA *tbl, TRN *newtrn) DBUG_PRINT("info",("table: %p trn: %p -> %p", tbl, tbl->trn, newtrn)); tbl->trn= newtrn; + tbl->trn_prev= 0; + tbl->trn_next= 0; /* To avoid assert in ha_maria::close() */ } @@ -59,7 +64,36 @@ static inline void _ma_set_tmp_trn_for_table(MARIA_HA *tbl, TRN *newtrn) static inline void _ma_reset_trn_for_table(MARIA_HA *tbl) { DBUG_PRINT("info",("table: %p trn: %p -> NULL", tbl, tbl->trn)); + + /* The following is only false if tbl->trn == &dummy_transaction_object */ + if (tbl->trn_prev) + { + if (tbl->trn_next) + tbl->trn_next->trn_prev= tbl->trn_prev; + *tbl->trn_prev= tbl->trn_next; + tbl->trn_prev= 0; + tbl->trn_next= 0; + } tbl->trn= 0; } + +/* + Take over the used_instances link from a trn object + Reset the link in the trn object +*/ + +static inline void relink_trn_used_instances(MARIA_HA **used_tables, TRN *trn) +{ + if (likely(*used_tables= (MARIA_HA*) trn->used_instances)) + { + /* Check that first back link is correct */ + DBUG_ASSERT((*used_tables)->trn_prev == (MARIA_HA **)&trn->used_instances); + + /* Fix back link to point to new base for the list */ + (*used_tables)->trn_prev= used_tables; + trn->used_instances= 0; + } +} + #endif /* _ma_trnman_h */ |