@@ -4455,6 +4455,25 @@ innobase_commit_ordered(
44554455DBUG_VOID_RETURN;
44564456}
44574457
4458+ /** Mark the end of a statement.
4459+ @param trx transaction
4460+ @return whether an error occurred */
4461+ static bool end_of_statement(trx_t *trx)
4462+ {
4463+ trx_mark_sql_stat_end(trx);
4464+ if (UNIV_LIKELY(trx->error_state == DB_SUCCESS))
4465+ return false;
4466+
4467+ trx_savept_t savept;
4468+ savept.least_undo_no= 0;
4469+ trx->rollback(&savept);
4470+ /* MariaDB will roll back the entire transaction. */
4471+ trx->bulk_insert= false;
4472+ trx->last_sql_stat_start.least_undo_no= 0;
4473+ trx->savepoints_discard();
4474+ return true;
4475+ }
4476+
44584477/*****************************************************************//**
44594478Commits a transaction in an InnoDB database or marks an SQL statement
44604479ended.
@@ -4531,10 +4550,7 @@ innobase_commit(
45314550/* Store the current undo_no of the transaction so that we
45324551know where to roll back if we have to roll back the next
45334552SQL statement */
4534-
4535- trx_mark_sql_stat_end(trx);
4536- if (UNIV_UNLIKELY(trx->error_state != DB_SUCCESS)) {
4537- trx_rollback_for_mysql(trx);
4553+ if (UNIV_UNLIKELY(end_of_statement(trx))) {
45384554DBUG_RETURN(1);
45394555}
45404556}
@@ -16954,10 +16970,7 @@ innobase_xa_prepare(
1695416970/* Store the current undo_no of the transaction so that we
1695516971know where to roll back if we have to roll back the next
1695616972SQL statement */
16957-
16958- trx_mark_sql_stat_end(trx);
16959- if (UNIV_UNLIKELY(trx->error_state != DB_SUCCESS)) {
16960- trx_rollback_for_mysql(trx);
16973+ if (UNIV_UNLIKELY(end_of_statement(trx))) {
1696116974return 1;
1696216975}
1696316976}
0 commit comments