| 1695 | |
| 1696 | |
| 1697 | jrd_tra* TRA_start(thread_db* tdbb, ULONG flags, SSHORT lock_timeout, Jrd::jrd_tra* outer) |
| 1698 | { |
| 1699 | /************************************** |
| 1700 | * |
| 1701 | * T R A _ s t a r t |
| 1702 | * |
| 1703 | ************************************** |
| 1704 | * |
| 1705 | * Functional description |
| 1706 | * Start a user transaction. |
| 1707 | * |
| 1708 | **************************************/ |
| 1709 | SET_TDBB(tdbb); |
| 1710 | Database* const dbb = tdbb->getDatabase(); |
| 1711 | Jrd::Attachment* const attachment = tdbb->getAttachment(); |
| 1712 | |
| 1713 | // Starting new transactions should be allowed for threads which |
| 1714 | // are running purge_attachment() because it's needed for |
| 1715 | // ON DISCONNECT triggers |
| 1716 | if (dbb->dbb_ast_flags & DBB_shut_tran && |
| 1717 | attachment->att_purge_tid != Thread::getCurrentThreadId()) |
| 1718 | { |
| 1719 | ERR_post(Arg::Gds(isc_shutinprog) << Arg::Str(attachment->att_filename)); |
| 1720 | } |
| 1721 | |
| 1722 | // To handle the problems of relation locks, allocate a temporary |
| 1723 | // transaction block first, seize relation locks, then go ahead and |
| 1724 | // make up the real transaction block. |
| 1725 | MemoryPool* const pool = outer ? outer->getAutonomousPool() : attachment->createPool(); |
| 1726 | Jrd::ContextPoolHolder context(tdbb, pool); |
| 1727 | jrd_tra* const transaction = jrd_tra::create(pool, attachment, outer); |
| 1728 | |
| 1729 | transaction->tra_flags = flags & TRA_OPTIONS_MASK; |
| 1730 | transaction->tra_lock_timeout = lock_timeout; |
| 1731 | |
| 1732 | try |
| 1733 | { |
| 1734 | transaction_start(tdbb, transaction); |
| 1735 | } |
| 1736 | catch (const Exception&) |
| 1737 | { |
| 1738 | jrd_tra::destroy(attachment, transaction); |
| 1739 | throw; |
| 1740 | } |
| 1741 | |
| 1742 | if (attachment->att_trace_manager->needs(ITraceFactory::TRACE_EVENT_TRANSACTION_START)) |
| 1743 | { |
| 1744 | TraceConnectionImpl conn(attachment); |
| 1745 | TraceTransactionImpl tran(transaction); |
| 1746 | attachment->att_trace_manager->event_transaction_start(&conn, |
| 1747 | &tran, 0, NULL, ITracePlugin::RESULT_SUCCESS); |
| 1748 | } |
| 1749 | |
| 1750 | return transaction; |
| 1751 | } |
| 1752 | |
| 1753 | |
| 1754 | jrd_tra* TRA_start(thread_db* tdbb, int tpb_length, const UCHAR* tpb, Jrd::jrd_tra* outer) |
no test coverage detected