forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
62 lines
7.0 KiB
HTML
62 lines
7.0 KiB
HTML
<a name="EN-US_TOPIC_0000001446551144"></a><a name="EN-US_TOPIC_0000001446551144"></a>
|
|
|
|
<h1 class="topictitle1">Transaction IDs and Snapshots</h1>
|
|
<div id="body0000001446551144"><p id="EN-US_TOPIC_0000001446551144__a95e2b69436f74673b759b901a8f897e0">The following functions provide server transaction information in an exportable form. The main use of these functions is to determine which transactions were committed between two snapshots.</p>
|
|
<div class="section" id="EN-US_TOPIC_0000001446551144__section82884304214"><h4 class="sectiontitle">pgxc_is_committed(transaction_id)</h4><p id="EN-US_TOPIC_0000001446551144__p102812433429">Description: Determines whether the given XID is committed or ignored. NULL indicates the unknown status (such as running, preparing, and freezing).</p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p1028164324218">Return type: Boolean</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001446551144__section218364014215"><h4 class="sectiontitle">txid_current()</h4><p id="EN-US_TOPIC_0000001446551144__p1818324013424">Description: Gets current transaction ID.</p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p141831840184213">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001446551144__section167243377425"><h4 class="sectiontitle">txid_current_snapshot()</h4><p id="EN-US_TOPIC_0000001446551144__p15724163717423">Description: Gets current snapshot.</p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p57242372421">Return type: txid_snapshot</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001446551144__section5274235114214"><h4 class="sectiontitle">txid_snapshot_xip(txid_snapshot)</h4><p id="EN-US_TOPIC_0000001446551144__p52741735154213">Description: Gets in-progress transaction IDs in snapshot.</p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p1327473518423">Return type: setof bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001446551144__section53041832124212"><h4 class="sectiontitle">txid_snapshot_xmax(txid_snapshot)</h4><p id="EN-US_TOPIC_0000001446551144__p12304193244217">Description: Gets <strong id="EN-US_TOPIC_0000001446551144__b104135989993952">xmax</strong> of snapshot.</p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p0304203210427">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001446551144__section1716633014215"><h4 class="sectiontitle">txid_snapshot_xmin(txid_snapshot)</h4><p id="EN-US_TOPIC_0000001446551144__p18166930154214">Description: Gets <strong id="EN-US_TOPIC_0000001446551144__b101783389693952">xmin</strong> of snapshot.</p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p1166430194215">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001446551144__section11685122719426"><h4 class="sectiontitle">txid_visible_in_snapshot(bigint, txid_snapshot)</h4><p id="EN-US_TOPIC_0000001446551144__p156821627144220">Description: Queries whether the transaction ID is visible in snapshot. (do not use with subtransaction IDs)</p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p1268319277423">Return type: <span id="EN-US_TOPIC_0000001446551144__text4683227134218">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p19683527194214"></p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p17683427114210">The internal transaction ID type (<strong id="EN-US_TOPIC_0000001446551144__b42931488993952">xid</strong>) is 32 bits wide and wraps around every 4 billion transactions. <strong id="EN-US_TOPIC_0000001446551144__b186188535493952">txid_snapshot</strong>, the data type used by these functions, stores information about transaction ID visibility at a particular moment in time. <a href="#EN-US_TOPIC_0000001446551144__table968413271422">Table 1</a> describes its components.</p>
|
|
|
|
<div class="tablenoborder"><a name="EN-US_TOPIC_0000001446551144__table968413271422"></a><a name="table968413271422"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001446551144__table968413271422" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Snapshot components</caption><thead align="left"><tr id="EN-US_TOPIC_0000001446551144__row13683127184219"><th align="left" class="cellrowborder" valign="top" width="12.42%" id="mcps1.3.8.6.2.3.1.1"><p id="EN-US_TOPIC_0000001446551144__p20683827154211">Name</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="87.58%" id="mcps1.3.8.6.2.3.1.2"><p id="EN-US_TOPIC_0000001446551144__p10683142794214">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001446551144__row136840271423"><td class="cellrowborder" valign="top" width="12.42%" headers="mcps1.3.8.6.2.3.1.1 "><p id="EN-US_TOPIC_0000001446551144__p17684427134214">xmin</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="87.58%" headers="mcps1.3.8.6.2.3.1.2 "><p id="EN-US_TOPIC_0000001446551144__p126840276422">Earliest transaction ID (txid) that is still active. All earlier transactions will either be committed and visible, or rolled back.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001446551144__row56841427174219"><td class="cellrowborder" valign="top" width="12.42%" headers="mcps1.3.8.6.2.3.1.1 "><p id="EN-US_TOPIC_0000001446551144__p368414278420">xmax</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="87.58%" headers="mcps1.3.8.6.2.3.1.2 "><p id="EN-US_TOPIC_0000001446551144__p186842027204218">First as-yet-unassigned txid. All txids greater than or equal to this are not yet started as of the time of the snapshot, so they are invisible.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001446551144__row8684172711425"><td class="cellrowborder" valign="top" width="12.42%" headers="mcps1.3.8.6.2.3.1.1 "><p id="EN-US_TOPIC_0000001446551144__p116841727134212">xip_list</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="87.58%" headers="mcps1.3.8.6.2.3.1.2 "><p id="EN-US_TOPIC_0000001446551144__p166841527174215">Active txids at the time of the snapshot. The list includes only those active txids between <strong id="EN-US_TOPIC_0000001446551144__b84346947993952">xmin</strong> and <strong id="EN-US_TOPIC_0000001446551144__b98192835593952">xmax</strong>; there might be active txids higher than <strong id="EN-US_TOPIC_0000001446551144__b31901363993952">xmax</strong>. A txid that is <strong id="EN-US_TOPIC_0000001446551144__b88887619493952">xmin <= txid < xmax</strong> and not in this list was already completed at the time of the snapshot, and is either visible or dead according to its commit status. The list does not include txids of subtransactions.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001446551144__p18685227124210"><strong id="EN-US_TOPIC_0000001446551144__b80850804093952">txid_snapshot</strong>'s textual representation is <strong id="EN-US_TOPIC_0000001446551144__b93701423793952">xmin:xmax:xip_list</strong>.</p>
|
|
<p id="EN-US_TOPIC_0000001446551144__p2685162714425">For example: <strong id="EN-US_TOPIC_0000001446551144__b151623266893952">10:20:10,14,15</strong> means <strong id="EN-US_TOPIC_0000001446551144__b176779363893952">xmin=10, xmax=20, xip_list=10, 14, 15</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0051.html">System Information Functions</a></div>
|
|
</div>
|
|
</div>
|
|
|