| 430 | |
| 431 | |
| 432 | void TRA_commit(thread_db* tdbb, jrd_tra* transaction, const bool retaining_flag) |
| 433 | { |
| 434 | /************************************** |
| 435 | * |
| 436 | * T R A _ c o m m i t |
| 437 | * |
| 438 | ************************************** |
| 439 | * |
| 440 | * Functional description |
| 441 | * Commit a transaction. |
| 442 | * |
| 443 | **************************************/ |
| 444 | SET_TDBB(tdbb); |
| 445 | |
| 446 | TraceTransactionEnd trace(transaction, true, retaining_flag); |
| 447 | |
| 448 | EDS::Transaction::jrdTransactionEnd(tdbb, transaction, true, retaining_flag, false); |
| 449 | |
| 450 | jrd_tra* const sysTran = tdbb->getAttachment()->getSysTransaction(); |
| 451 | |
| 452 | // If this is a commit retaining, and no updates have been performed, |
| 453 | // and no events have been posted (via stored procedures etc) |
| 454 | // no-op the operation. |
| 455 | |
| 456 | if (retaining_flag && !((transaction->tra_flags & TRA_write) || transaction->tra_deferred_job)) |
| 457 | { |
| 458 | if (sysTran->tra_flags & TRA_write) |
| 459 | transaction_flush(tdbb, FLUSH_SYSTEM, 0); |
| 460 | |
| 461 | transaction->tra_flags &= ~TRA_prepared; |
| 462 | |
| 463 | // Get rid of all user savepoints |
| 464 | while (transaction->tra_save_point && !transaction->tra_save_point->isRoot()) |
| 465 | transaction->releaseSavepoint(tdbb); |
| 466 | |
| 467 | trace.finish(ITracePlugin::RESULT_SUCCESS); |
| 468 | return; |
| 469 | } |
| 470 | |
| 471 | if (transaction->tra_flags & TRA_invalidated) |
| 472 | ERR_post(Arg::Gds(isc_trans_invalid)); |
| 473 | |
| 474 | Jrd::ContextPoolHolder context(tdbb, transaction->tra_pool); |
| 475 | |
| 476 | // Get rid of all user savepoints |
| 477 | while (transaction->tra_save_point && !transaction->tra_save_point->isRoot()) |
| 478 | transaction->releaseSavepoint(tdbb); |
| 479 | |
| 480 | // Let replicator perform heavy and error-prone part of work |
| 481 | |
| 482 | REPL_trans_prepare(tdbb, transaction); |
| 483 | |
| 484 | // Perform any meta data work deferred |
| 485 | |
| 486 | if (!(transaction->tra_flags & TRA_prepared)) |
| 487 | DFW_perform_work(tdbb, transaction); |
| 488 | |
| 489 | // Commit associated transaction in security DB |
no test coverage detected