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

MDEV-18875 Assertion `thd->transaction.stmt.ha_list == __null || trans == &thd->transaction.stmt' failed or bogus ER_DUP_ENTRY upon ALTER TABLE with versioning

Cause:
* when autocommit=0 (or transaction is issued by user),
 `ha_commit_trans` is called twice on ALTER TABLE, causing a duplicated
 insert into `transaction_registry` (ER_DUP_ENTRY).

Solution:
* ALTER TABLE makes an implicit commit by a second call. We actually
 need to make an insert only when it is a real commit. So is_real
 variable is additionally checked.
This commit is contained in:
Nikita Malyavin
2019-03-22 16:26:42 +10:00
committed by Marko Mäkelä
parent 808bc919eb
commit 720e9bd5be
3 changed files with 30 additions and 1 deletions

View File

@ -1446,7 +1446,8 @@ int ha_commit_trans(THD *thd, bool all)
#if 1 // FIXME: This should be done in ha_prepare().
if (rw_trans || (thd->lex->sql_command == SQLCOM_ALTER_TABLE &&
thd->lex->alter_info.flags & ALTER_ADD_SYSTEM_VERSIONING))
thd->lex->alter_info.flags & ALTER_ADD_SYSTEM_VERSIONING &&
is_real_trans))
{
ulonglong trx_start_id= 0, trx_end_id= 0;
for (Ha_trx_info *ha_info= trans->ha_list; ha_info; ha_info= ha_info->next())