MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / TRA_setup_request_snapshot

Function TRA_setup_request_snapshot

src/jrd/tra.cpp:146–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146void TRA_setup_request_snapshot(Jrd::thread_db* tdbb, Jrd::Request* request)
147{
148 // This function is called whenever request is started in a transaction.
149 // Setup context to preserve read consistency in READ COMMITTED transactions.
150
151 Jrd::jrd_tra* transaction = request->req_transaction;
152
153 // We assume that request is already attached to a transaction
154 fb_assert(transaction);
155
156 // If we are not READ COMMITTED or read consistency is not needed then nothing to do here
157 if (!(transaction->tra_flags & TRA_read_committed) || !(transaction->tra_flags & TRA_read_consistency))
158 return;
159
160 // See if there is any request right above us in the call stack
161 Request* org_request = TRA_get_prior_request(tdbb);
162
163 if (org_request && org_request->req_transaction == transaction)
164 {
165 fb_assert(org_request->req_snapshot.m_owner);
166 request->req_snapshot.m_owner = org_request->req_snapshot.m_owner;
167 return;
168 }
169
170 // If we are a top-level request or caller is executed in a different transaction,
171 // we need to set up statement snapshot for read consistency and own it
172
173 request->req_snapshot.m_owner = request;
174 request->req_snapshot.m_number = 0;
175
176 request->req_snapshot.m_handle =
177 tdbb->getDatabase()->dbb_tip_cache->beginSnapshot(tdbb,
178 tdbb->getAttachment()->att_attachment_id, request->req_snapshot.m_number);
179}
180
181
182void TRA_release_request_snapshot(Jrd::thread_db* tdbb, Jrd::Request* request)

Callers 2

EXE_startFunction · 0.85
IndexExpressionMethod · 0.85

Calls 4

TRA_get_prior_requestFunction · 0.85
beginSnapshotMethod · 0.80
getDatabaseMethod · 0.80
getAttachmentMethod · 0.45

Tested by

no test coverage detected