| 254 | */ |
| 255 | |
| 256 | bool trans_commit(THD *thd) |
| 257 | { |
| 258 | int res; |
| 259 | PSI_stage_info org_stage; |
| 260 | DBUG_ENTER("trans_commit"); |
| 261 | |
| 262 | if (trans_check(thd)) |
| 263 | DBUG_RETURN(TRUE); |
| 264 | |
| 265 | thd->backup_stage(&org_stage); |
| 266 | THD_STAGE_INFO(thd, stage_commit); |
| 267 | |
| 268 | thd->server_status&= |
| 269 | ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY); |
| 270 | DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS")); |
| 271 | res= ha_commit_trans(thd, TRUE); |
| 272 | |
| 273 | mysql_mutex_assert_not_owner(&LOCK_prepare_ordered); |
| 274 | mysql_mutex_assert_not_owner(mysql_bin_log.get_log_lock()); |
| 275 | mysql_mutex_assert_not_owner(&LOCK_after_binlog_sync); |
| 276 | mysql_mutex_assert_not_owner(&LOCK_commit_ordered); |
| 277 | |
| 278 | /* |
| 279 | if res is non-zero, then ha_commit_trans has rolled back the |
| 280 | transaction, so the hooks for rollback will be called. |
| 281 | */ |
| 282 | #ifdef HAVE_REPLICATION |
| 283 | if (res) |
| 284 | repl_semisync_master.wait_after_rollback(thd, FALSE); |
| 285 | else |
| 286 | repl_semisync_master.wait_after_commit(thd, FALSE); |
| 287 | #endif |
| 288 | thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_BINLOG_THIS_TRX); |
| 289 | thd->transaction->all.reset(); |
| 290 | thd->lex->start_transaction_opt= 0; |
| 291 | |
| 292 | /* The transaction should be marked as complete in P_S. */ |
| 293 | DBUG_ASSERT(thd->m_transaction_psi == NULL); |
| 294 | trans_track_end_trx(thd); |
| 295 | |
| 296 | THD_STAGE_INFO(thd, org_stage); |
| 297 | DBUG_RETURN(MY_TEST(res)); |
| 298 | } |
| 299 | |
| 300 | |
| 301 | /** |
no test coverage detected