forked from laiweijian4/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
66 lines
16 KiB
HTML
66 lines
16 KiB
HTML
<a name="EN-US_TOPIC_0000001098671138"></a><a name="EN-US_TOPIC_0000001098671138"></a>
|
|
|
|
<h1 class="topictitle1">Advisory Lock Functions</h1>
|
|
<div id="body1553151203304"><p id="EN-US_TOPIC_0000001098671138__acc7b359026004593892769d9af6ad1a7">Advisory lock functions manage advisory locks. These functions are only for internal use currently.</p>
|
|
<ul id="EN-US_TOPIC_0000001098671138__u3d4aa49f2a234787b5689b6d8dd90e75"><li id="EN-US_TOPIC_0000001098671138__l68b468958ca54ad2b625963c91b39686">pg_advisory_lock(key bigint)<p id="EN-US_TOPIC_0000001098671138__a04155deb3fd54bb691123d566a74854a"><a name="EN-US_TOPIC_0000001098671138__l68b468958ca54ad2b625963c91b39686"></a><a name="l68b468958ca54ad2b625963c91b39686"></a>Description: Obtains an exclusive session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__afcfbc656c7064b7980f342d551b92fbd">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__ad29cea6f501b46f891b74d47dcc06984">Note: <strong id="EN-US_TOPIC_0000001098671138__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>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l397f6a07c8ea44c19643cfd75d7f83b2">pg_advisory_lock(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__ad246a331342e45eca58743dddf6747c8"><a name="EN-US_TOPIC_0000001098671138__l397f6a07c8ea44c19643cfd75d7f83b2"></a><a name="l397f6a07c8ea44c19643cfd75d7f83b2"></a>Description: Obtains an exclusive session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a9675410a74744830a2c15ed4f4ff5740">Return type: void</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__la87007421c134940afcd4c3782e9abcd">pg_advisory_lock_shared(key bigint)<p id="EN-US_TOPIC_0000001098671138__a2a695f3cde9e4babb8953fe46058fc52"><a name="EN-US_TOPIC_0000001098671138__la87007421c134940afcd4c3782e9abcd"></a><a name="la87007421c134940afcd4c3782e9abcd"></a>Description: Obtains a shared session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a71e45ec325ac44ba806f7a566e6c1c97">Return type: void</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__ledfaee902e0a4f03a240465a48c4f82c">pg_advisory_lock_shared(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__af93fb04231bf4438a80ed257dc6352c9"><a name="EN-US_TOPIC_0000001098671138__ledfaee902e0a4f03a240465a48c4f82c"></a><a name="ledfaee902e0a4f03a240465a48c4f82c"></a>Description: Obtains a shared session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__ade4464f51efc496ba54058dc480559f6">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__afd3cad5b52154ba289cb2c47d777fd7e">Note: <strong id="EN-US_TOPIC_0000001098671138__ad669ab0a70bc48609f2fab99de31373f">pg_advisory_lock_shared</strong> works in the same way as <strong id="EN-US_TOPIC_0000001098671138__a6bc16755ba36426a978eea196afb6de3">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>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l1c3d5a1e11934291ab5fe3641d947549">pg_advisory_unlock(key bigint)<p id="EN-US_TOPIC_0000001098671138__a89e439543d49499b99824574f1eacbd4"><a name="EN-US_TOPIC_0000001098671138__l1c3d5a1e11934291ab5fe3641d947549"></a><a name="l1c3d5a1e11934291ab5fe3641d947549"></a>Description: Releases an exclusive session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__ad0063edfe8664fd49245bb6c1313ca48">Return type: <span id="EN-US_TOPIC_0000001098671138__text5168464227">boolean</span></p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__lceb165e0ff6c446fbc3fd1902f1da893">pg_advisory_unlock(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__a6e5f4c71f3034443a304af16b088f2e5"><a name="EN-US_TOPIC_0000001098671138__lceb165e0ff6c446fbc3fd1902f1da893"></a><a name="lceb165e0ff6c446fbc3fd1902f1da893"></a>Description: Releases an exclusive session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__adfcd8d0e05fd4071a9607299b0442e33">Return type: <span id="EN-US_TOPIC_0000001098671138__text676504619222">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001098671138__ae449733192324bc187c633daf83fc959">Note: <strong id="EN-US_TOPIC_0000001098671138__b19940194117225">pg_advisory_unlock</strong> releases the obtained exclusive advisory lock. If the release is successful, the function returns <strong id="EN-US_TOPIC_0000001098671138__b13760195518227">true</strong>. If the lock was not held, it will return <strong id="EN-US_TOPIC_0000001098671138__b842352706141627">false</strong>. In addition, a SQL warning will be reported by the server.</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__lac954fb2189d412d84d9bb40fd75df0b">pg_advisory_unlock_shared(key bigint)<p id="EN-US_TOPIC_0000001098671138__ad81a953192904865939c8d25f9b16e1b"><a name="EN-US_TOPIC_0000001098671138__lac954fb2189d412d84d9bb40fd75df0b"></a><a name="lac954fb2189d412d84d9bb40fd75df0b"></a>Description: Releases a shared session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__ae885c6e899f640ddabf52e2b7b503608">Return type: <span id="EN-US_TOPIC_0000001098671138__text3427947102213">boolean</span></p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l73069227299d421f9a1a2f2bd34c3a96">pg_advisory_unlock_shared(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__ae86f3d8b5fd34ab5ae07573d80de1e98"><a name="EN-US_TOPIC_0000001098671138__l73069227299d421f9a1a2f2bd34c3a96"></a><a name="l73069227299d421f9a1a2f2bd34c3a96"></a>Description: Releases a shared session-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a2a4644e392b547b8886d8b1fafdedbe5">Return type: <span id="EN-US_TOPIC_0000001098671138__text14924816222">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001098671138__aa31196bc2cd645f58f342a0aa06e4fb1">Note: <strong id="EN-US_TOPIC_0000001098671138__a28eae39a5ec54502b6885f62eb443471">pg_advisory_unlock_shared</strong> works in the same way as <strong id="EN-US_TOPIC_0000001098671138__ac89d2acb8fb1452eb674ce5be9943bd2">pg_advisory_unlock</strong>, except it releases a shared session-level advisory lock.</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l9b2229087e2247efb8727f19212c9c4a">pg_advisory_unlock_all()<p id="EN-US_TOPIC_0000001098671138__a5243f267c3b94c7a9c0b2a3f89d8aec1"><a name="EN-US_TOPIC_0000001098671138__l9b2229087e2247efb8727f19212c9c4a"></a><a name="l9b2229087e2247efb8727f19212c9c4a"></a>Description: Releases all advisory locks owned by the current session.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__afe71137c0d9a498fa6ec719df67e830c">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a68e718999af44d96907c3a8e72486398">Note: <strong id="EN-US_TOPIC_0000001098671138__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>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l15b350c49f2948e596b89ac8c88862dc">pg_advisory_xact_lock(key bigint)<p id="EN-US_TOPIC_0000001098671138__a9db4a9f1fd2c4e5088457664d89d1fa1"><a name="EN-US_TOPIC_0000001098671138__l15b350c49f2948e596b89ac8c88862dc"></a><a name="l15b350c49f2948e596b89ac8c88862dc"></a>Description: Obtains an exclusive transaction-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__aaa55b3ca1d7143a8ad2af8113f07288c">Return type: void</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__lf5fbdc75788a4def9a49e6c7deb7e5ed">pg_advisory_xact_lock(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__ae5f63f1579e947fbb07db25255f041bf"><a name="EN-US_TOPIC_0000001098671138__lf5fbdc75788a4def9a49e6c7deb7e5ed"></a><a name="lf5fbdc75788a4def9a49e6c7deb7e5ed"></a>Description: Obtains an exclusive transaction-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a7952a76ddbdd4db39015f192ae4b6404">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__ae46e1629b4e24d81abbf0ecdf1399a2b">Note: <strong id="EN-US_TOPIC_0000001098671138__ac4bf543b7c2240e7a42954b1d4fdcb74">pg_advisory_xact_lock</strong> works in the same way as <strong id="EN-US_TOPIC_0000001098671138__ac32cb79688e242b8ab7f7dd2975f5507">pg_advisory_lock</strong>, except the lock is automatically released at the end of the current transaction and cannot be released explicitly.</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__lf76d09d188794318ab28c26646a10c96">pg_advisory_xact_lock_shared(key bigint)<p id="EN-US_TOPIC_0000001098671138__a9da4221960ce4a339cf2fee28a3af992"><a name="EN-US_TOPIC_0000001098671138__lf76d09d188794318ab28c26646a10c96"></a><a name="lf76d09d188794318ab28c26646a10c96"></a>Description: Obtains a shared transaction-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a51bdccd563f2442d943cbc419525bd04">Return type: void</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l3fc6b5cf102c451c8831854040d3a354">pg_advisory_xact_lock_shared(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__a35b7a2ef66964aa69ecf02e28e3440d4"><a name="EN-US_TOPIC_0000001098671138__l3fc6b5cf102c451c8831854040d3a354"></a><a name="l3fc6b5cf102c451c8831854040d3a354"></a>Description: Obtains a shared transaction-level advisory lock.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__abf49c8ac8dc0474cad7f6609e9381c93">Return type: void</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a9b4837fe88f6402b9e664826d42893fd">Note: <strong id="EN-US_TOPIC_0000001098671138__a4c4b8f73189942808dadbaaf0de31f57">pg_advisory_xact_lock_shared</strong> works in the same way as <strong id="EN-US_TOPIC_0000001098671138__a2e72d6a1c0ad4837b2fb6dc45202026e">pg_advisory_lock_shared</strong>, except the lock is automatically released at the end of the current transaction and cannot be released explicitly.</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l06118f2fa9324eca84e76fba50dd587f">pg_try_advisory_lock(key bigint)<p id="EN-US_TOPIC_0000001098671138__a7b6477a6090e4572af119a9e5017ed30"><a name="EN-US_TOPIC_0000001098671138__l06118f2fa9324eca84e76fba50dd587f"></a><a name="l06118f2fa9324eca84e76fba50dd587f"></a>Description: Obtains an exclusive session-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__ad05837b91c7d4aeda71ba34b98044482">Return type: <span id="EN-US_TOPIC_0000001098671138__text36684482222">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a0d8768719ebc4f32b1c07366c9f4e775">Note: <strong id="EN-US_TOPIC_0000001098671138__b1812132362812">pg_try_advisory_lock</strong> is similar to <strong id="EN-US_TOPIC_0000001098671138__b118141923122817">pg_advisory_lock</strong>, except <strong id="EN-US_TOPIC_0000001098671138__b17816202382818">pg_try_advisory_lock</strong> does not block the resource until the resource is released. <strong id="EN-US_TOPIC_0000001098671138__b394216352912">pg_try_advisory_lock</strong> either immediately obtains the lock and returns <strong id="EN-US_TOPIC_0000001098671138__b11943631295">true</strong> or returns <strong id="EN-US_TOPIC_0000001098671138__b694414319293">false</strong>, which indicates the lock cannot be performed currently.</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__laf2ac8de71104c69bfa04cf7cbb6eeb0">pg_try_advisory_lock(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__afab58c68a27c4582ad8471313d5bc4c9"><a name="EN-US_TOPIC_0000001098671138__laf2ac8de71104c69bfa04cf7cbb6eeb0"></a><a name="laf2ac8de71104c69bfa04cf7cbb6eeb0"></a>Description: Obtains an exclusive session-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a86476d71d0d04d0e98e7a44ba1cde7d1">Return type: <span id="EN-US_TOPIC_0000001098671138__text724954914227">boolean</span></p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__laa95d1da4f264611b85bdcba49828cef">pg_try_advisory_lock_shared(key bigint)<p id="EN-US_TOPIC_0000001098671138__a80878c11182d4a99af71bc2db1e0c6ad"><a name="EN-US_TOPIC_0000001098671138__laa95d1da4f264611b85bdcba49828cef"></a><a name="laa95d1da4f264611b85bdcba49828cef"></a>Description: Obtains a shared session-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a7d41969799204dd491663f979bb563bf">Return type: <span id="EN-US_TOPIC_0000001098671138__text10840134912224">boolean</span></p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l261675ad854d47ba91f78119fe6daf84">pg_try_advisory_lock_shared(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__a6f7f5354bff343c9b6628fa53999778c"><a name="EN-US_TOPIC_0000001098671138__l261675ad854d47ba91f78119fe6daf84"></a><a name="l261675ad854d47ba91f78119fe6daf84"></a>Description: Obtains a shared session-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a6dc4f0ac4b15483d8f2b5cc2f84b2f6f">Return type: <span id="EN-US_TOPIC_0000001098671138__text1644212507222">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a5351ab85c5024fe6bb41259d01f7fbeb">Note: <strong id="EN-US_TOPIC_0000001098671138__b1915917414300">pg_try_advisory_lock_shared</strong> is similar to <strong id="EN-US_TOPIC_0000001098671138__b516019483014">pg_try_advisory_lock</strong>, except <strong id="EN-US_TOPIC_0000001098671138__b151617412307">pg_try_advisory_lock_shared</strong> attempts to obtain a shared lock instead of an exclusive lock.</p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l5d348fa21c2647bf9779c71439f0d1d3">pg_try_advisory_xact_lock(key bigint)<p id="EN-US_TOPIC_0000001098671138__a2a4ff009290a4d03be9fa653ef4cd091"><a name="EN-US_TOPIC_0000001098671138__l5d348fa21c2647bf9779c71439f0d1d3"></a><a name="l5d348fa21c2647bf9779c71439f0d1d3"></a>Description: Obtains an exclusive transaction-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a18b4f84d4b134993851daccb0b1b5de9">Return type: <span id="EN-US_TOPIC_0000001098671138__text43811515227">boolean</span></p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l058c286e5c7e42d8b9169c925b514629">pg_try_advisory_xact_lock(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__ac826415b63e04434ac06adf7437fe198"><a name="EN-US_TOPIC_0000001098671138__l058c286e5c7e42d8b9169c925b514629"></a><a name="l058c286e5c7e42d8b9169c925b514629"></a>Description: Obtains an exclusive transaction-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a1769dfda3e7f4ec39999403b5d510319">Return type: <span id="EN-US_TOPIC_0000001098671138__text19570125118227">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a1da55d07ee3c45acaf483895d8ac56fb">Note: <strong id="EN-US_TOPIC_0000001098671138__a30ee8e192fc447c7a378387cf899416d">pg_try_advisory_xact_lock</strong> works in the same way as <strong id="EN-US_TOPIC_0000001098671138__a8628170729674a51b4c2481e35069f61">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>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__lcb6e488fae5846aea5c392804bda7499">pg_try_advisory_xact_lock_shared(key bigint)<p id="EN-US_TOPIC_0000001098671138__a58d2fc1ff204468fbab674b26c42f8e2"><a name="EN-US_TOPIC_0000001098671138__lcb6e488fae5846aea5c392804bda7499"></a><a name="lcb6e488fae5846aea5c392804bda7499"></a>Description: Obtains a shared transaction-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a3380d9620d624cc089a5ebd5ceb32e4a">Return type: <span id="EN-US_TOPIC_0000001098671138__text515145219228">boolean</span></p>
|
|
</li><li id="EN-US_TOPIC_0000001098671138__l123b01c946654683b75b9b58dec524b8">pg_try_advisory_xact_lock_shared(key1 int, key2 int)<p id="EN-US_TOPIC_0000001098671138__a51b3711111f040b49ffb7d7627bfe81c"><a name="EN-US_TOPIC_0000001098671138__l123b01c946654683b75b9b58dec524b8"></a><a name="l123b01c946654683b75b9b58dec524b8"></a>Description: Obtains a shared transaction-level advisory lock if available.</p>
|
|
<p id="EN-US_TOPIC_0000001098671138__abbf2f40ff498482eb1ea355cfd6cec12">Return type: <span id="EN-US_TOPIC_0000001098671138__text6832135215226">boolean</span></p>
|
|
<p id="EN-US_TOPIC_0000001098671138__a5a1375cf6f644731a7088ed10c7a3518">Note: <strong id="EN-US_TOPIC_0000001098671138__ae80015985b634f37b6012e09695432da">pg_try_advisory_xact_lock_shared</strong> works in the same way as <strong id="EN-US_TOPIC_0000001098671138__a44f56a8942e846c88205875f9f6af90a">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>
|
|
</li></ul>
|
|
</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>
|
|
|