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>
86 lines
14 KiB
HTML
86 lines
14 KiB
HTML
<a name="EN-US_TOPIC_0000001233708639"></a><a name="EN-US_TOPIC_0000001233708639"></a>
|
|
|
|
<h1 class="topictitle1">Advisory Lock Functions</h1>
|
|
<div id="body1553151203304"><p id="EN-US_TOPIC_0000001233708639__a5c26ffc4d10b46cb84db39b54e059ed1">Advisory lock functions manage advisory locks. These functions are only for internal use currently.</p>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section1991104811359"><h4 class="sectiontitle">pg_advisory_lock(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p19849102710239">Description: Obtains an exclusive session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p10850152717238">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p185018272239">Note: <strong id="EN-US_TOPIC_0000001233708639__b842352706112231">pg_advisory_lock</strong> locks resources defined by an application. The resources can be identified using a 64-bit or two nonoverlapped 32-bit key values. If another session locks the resources, the function blocks the resources until they can be used. The lock is exclusive. Multiple locking requests are pushed into the stack. Therefore, if the same resource is locked three times, it must be unlocked three times so that it is released to another session.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section62151631113620"><h4 class="sectiontitle">pg_advisory_lock(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p1985252715234">Description: Obtains an exclusive session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p385262714230">Return type: void</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section750410426367"><h4 class="sectiontitle">pg_advisory_lock_shared(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p185422792310">Description: Obtains a shared session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p685492710237">Return type: void</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section1222611591364"><h4 class="sectiontitle">pg_advisory_lock_shared(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p188551927162311">Description: Obtains a shared session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p10856227152313">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p12856112782319">Note: <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b84235270614931">pg_advisory_lock_shared</strong> works in the same way as <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b84235270614938">pg_advisory_lock</strong>, except the lock can be shared with other sessions requesting shared locks. Only would-be exclusive lockers are locked out.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section17864193554012"><h4 class="sectiontitle">pg_advisory_unlock(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p1385812716232">Description: Releases an exclusive session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p7858182713238">Return type: <span id="EN-US_TOPIC_0000001233708639__text5168464227">boolean</span></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section15763193118410"><h4 class="sectiontitle">pg_advisory_unlock(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p18604276233">Description: Releases an exclusive session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p78608271232">Return type: <span id="EN-US_TOPIC_0000001233708639__text676504619222">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p10861627132317">Note: <strong id="EN-US_TOPIC_0000001233708639__b19940194117225">pg_advisory_unlock</strong> releases the obtained exclusive advisory lock. If the release is successful, the function returns <strong id="EN-US_TOPIC_0000001233708639__b13760195518227">true</strong>. If the lock was not held, it will return <strong id="EN-US_TOPIC_0000001233708639__b842352706141627">false</strong>. In addition, a SQL warning will be reported by the server.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section1622812465416"><h4 class="sectiontitle">pg_advisory_unlock_shared(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p1886312273239">Description: Releases a shared session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p1686372713230">Return type: <span id="EN-US_TOPIC_0000001233708639__text3427947102213">boolean</span></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section1621075944111"><h4 class="sectiontitle">pg_advisory_unlock_shared(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p19865162732317">Description: Releases a shared session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p2865727182311">Return type: <span id="EN-US_TOPIC_0000001233708639__text14924816222">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p14866102716237">Note: <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b84235270614171">pg_advisory_unlock_shared</strong> works in the same way as <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b84235270614177">pg_advisory_unlock</strong>, except it releases a shared session-level advisory lock.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section184151721134210"><h4 class="sectiontitle">pg_advisory_unlock_all()</h4><p id="EN-US_TOPIC_0000001233708639__p5868172782312">Description: Releases all advisory locks owned by the current session.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p9868192722311">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p15869132762320">Note: <strong id="EN-US_TOPIC_0000001233708639__b9243194111256">pg_advisory_unlock_all</strong> releases all advisory locks owned by the current session. The function is implicitly invoked when the session ends even if the client is abnormally disconnected.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section9501235164213"><h4 class="sectiontitle">pg_advisory_xact_lock(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p13870182711237">Description: Obtains an exclusive transaction-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p108703274235">Return type: void</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section17121147124211"><h4 class="sectiontitle">pg_advisory_xact_lock(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p787282713239">Description: Obtains an exclusive transaction-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p20872427122318">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p188731727142320">Note: <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b84235270614203">pg_advisory_xact_lock</strong> works in the same way as <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b84235270614209">pg_advisory_lock</strong>, except the lock is automatically released at the end of the current transaction and cannot be released explicitly.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section18898410435"><h4 class="sectiontitle">pg_advisory_xact_lock_shared(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p78741427152313">Description: Obtains a shared transaction-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p19875102722310">Return type: void</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section2790152004317"><h4 class="sectiontitle">pg_advisory_xact_lock_shared(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p287611274239">Description: Obtains a shared transaction-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p1487762772319">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p7877162717237">Note: <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b842352706142113">pg_advisory_xact_lock_shared</strong> works in the same way as <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b842352706142121">pg_advisory_lock_shared</strong>, except the lock is automatically released at the end of the current transaction and cannot be released explicitly.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section10365285442"><h4 class="sectiontitle">pg_try_advisory_lock(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p17879102772317">Description: Obtains an exclusive session-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p20879172742320">Return type: <span id="EN-US_TOPIC_0000001233708639__text36684482222">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p1688017275238">Note: <strong id="EN-US_TOPIC_0000001233708639__b1812132362812">pg_try_advisory_lock</strong> is similar to <strong id="EN-US_TOPIC_0000001233708639__b118141923122817">pg_advisory_lock</strong>, except <strong id="EN-US_TOPIC_0000001233708639__b17816202382818">pg_try_advisory_lock</strong> does not block the resource until the resource is released. <strong id="EN-US_TOPIC_0000001233708639__b394216352912">pg_try_advisory_lock</strong> either immediately obtains the lock and returns <strong id="EN-US_TOPIC_0000001233708639__b11943631295">true</strong> or returns <strong id="EN-US_TOPIC_0000001233708639__b694414319293">false</strong>, which indicates the lock cannot be performed currently.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section162125454412"><h4 class="sectiontitle">pg_try_advisory_lock(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p15881152713231">Description: Obtains an exclusive session-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p8882127122320">Return type: <span id="EN-US_TOPIC_0000001233708639__text724954914227">boolean</span></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section15168492458"><h4 class="sectiontitle">pg_try_advisory_lock_shared(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p8883142712233">Description: Obtains a shared session-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p7884122752318">Return type: <span id="EN-US_TOPIC_0000001233708639__text10840134912224">boolean</span></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section560701912456"><h4 class="sectiontitle">pg_try_advisory_lock_shared(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p128851327182312">Description: Obtains a shared session-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p88851527152316">Return type: <span id="EN-US_TOPIC_0000001233708639__text1644212507222">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p198861227192310">Note: <strong id="EN-US_TOPIC_0000001233708639__b1915917414300">pg_try_advisory_lock_shared</strong> is similar to <strong id="EN-US_TOPIC_0000001233708639__b516019483014">pg_try_advisory_lock</strong>, except <strong id="EN-US_TOPIC_0000001233708639__b151617412307">pg_try_advisory_lock_shared</strong> attempts to obtain a shared lock instead of an exclusive lock.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section4932183216459"><h4 class="sectiontitle">pg_try_advisory_xact_lock(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p68877271232">Description: Obtains an exclusive transaction-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p15888132712319">Return type: <span id="EN-US_TOPIC_0000001233708639__text43811515227">boolean</span></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section16155645154515"><h4 class="sectiontitle">pg_try_advisory_xact_lock(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p2890172714235">Description: Obtains an exclusive transaction-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p989062710236">Return type: <span id="EN-US_TOPIC_0000001233708639__text19570125118227">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p1289172716238">Note: <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b842352706142159">pg_try_advisory_xact_lock</strong> works in the same way as <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b84235270614225">pg_try_advisory_lock</strong>, except the lock, if acquired, is automatically released at the end of the current transaction and cannot be released explicitly.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section36901659194519"><h4 class="sectiontitle">pg_try_advisory_xact_lock_shared(key bigint)</h4><p id="EN-US_TOPIC_0000001233708639__p4892127122312">Description: Obtains a shared transaction-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p14892152772312">Return type: <span id="EN-US_TOPIC_0000001233708639__text515145219228">boolean</span></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001233708639__section1062914102463"><h4 class="sectiontitle">pg_try_advisory_xact_lock_shared(key1 int, key2 int)</h4><p id="EN-US_TOPIC_0000001233708639__p168941027162313">Description: Obtains a shared transaction-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p7894132762316">Return type: <span id="EN-US_TOPIC_0000001233708639__text6832135215226">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001233708639__p8895152710230">Note: <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b842352706142247">pg_try_advisory_xact_lock_shared</strong> works in the same way as <strong id="EN-US_TOPIC_0000001233708639__en-us_topic_0058965547_b842352706142253">pg_try_advisory_lock_shared</strong>, except the lock, if acquired, is automatically released at the end of the current transaction and cannot be released explicitly.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0052.html">System Administration Functions</a></div>
|
|
</div>
|
|
</div>
|
|
|