Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
1d174c30
Commit
1d174c30
authored
Jan 18, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explain privileges required for LOCK. Minor wordsmithing too.
parent
9ad73797
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
30 deletions
+40
-30
doc/src/sgml/ref/lock.sgml
doc/src/sgml/ref/lock.sgml
+40
-30
No files found.
doc/src/sgml/ref/lock.sgml
View file @
1d174c30
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/lock.sgml,v 1.
29 2001/12/08 03:24:37 thomas
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/lock.sgml,v 1.
30 2002/01/18 01:05:43 tgl
Exp $
PostgreSQL documentation
-->
...
...
@@ -76,8 +76,7 @@ where <replaceable class="PARAMETER">lockmode</replaceable> is one of:
<listitem>
<note>
<para>
Automatically acquired by <command>SELECT...FOR UPDATE</command>.
While it is a shared lock, may be upgraded later to a ROW EXCLUSIVE lock.
Automatically acquired by <command>SELECT ... FOR UPDATE</command>.
</para>
</note>
...
...
@@ -175,6 +174,9 @@ where <replaceable class="PARAMETER">lockmode</replaceable> is one of:
Conflicts with ROW SHARE, ROW EXCLUSIVE, SHARE UPDATE EXCLUSIVE,
SHARE, SHARE ROW EXCLUSIVE,
EXCLUSIVE and ACCESS EXCLUSIVE modes.
This mode allows only concurrent ACCESS SHARE, i.e., only reads
from the table can proceed in parallel with a transaction holding
this lock mode.
</para>
</listitem>
</varlistentry>
...
...
@@ -225,7 +227,7 @@ LOCK TABLE
</computeroutput></term>
<listitem>
<para>
The lock was successfully a
ppli
ed.
The lock was successfully a
cquir
ed.
</para>
</listitem>
</varlistentry>
...
...
@@ -310,23 +312,26 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
</para>
<para>
For example,
an application runs a transaction at READ COMMITTED isolation
level and needs to ensure the existence of data in a table for the
duration of the
transaction. To achieve this you could
use
SHARE lock mode over the
table before querying. This will pr
otect data from concurrent
changes
and
provide any further read operations over the table with
data in their
actual current state, because SHARE lock mode conflicts with any ROW
EXCLUSIVE
one
acquired by writers, and your
For example,
suppose an application runs a transaction at READ COMMITTED
isolation level and needs to ensure the existence of data in a table for
the
duration of the
transaction. To achieve this you could
obtain
SHARE lock mode over the
table before querying. This will pr
event concurrent data
changes
and
ensure further read operations over the table see
data in their
actual current state, because SHARE lock mode conflicts with any ROW
EXCLUSIVE lock
acquired by writers, and your
<command>LOCK TABLE <replaceable class="PARAMETER">name</replaceable> IN SHARE MODE</command>
statement will wait until any concurrent write operations commit or rollback.
statement will wait until any concurrent write operations commit or
rollback. Thus, once you obtain the lock, there are no uncommitted
writes outstanding.
<note>
<para>
To read data in their real current state when running a transaction
at the SERIALIZABLE isolation level you have to execute a LOCK TABLE
statement before executing any DML statement, when the transaction defines
what concurrent changes will be visible to itself.
To read data in their actual current state when running a transaction
at the SERIALIZABLE isolation level, you have to execute the LOCK TABLE
statement before executing any DML statement. A serializable
transaction's view of data will be frozen when its first DML statement
begins.
</para>
</note>
</para>
...
...
@@ -341,7 +346,7 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
</para>
<para>
To continue with the deadlock (when two transaction wait for one another)
To continue with the deadlock (when two transaction
s
wait for one another)
issue raised above, you should follow two general rules to prevent
deadlock conditions:
</para>
...
...
@@ -364,8 +369,8 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
<listitem>
<para>
Transactions should acquire two conflicting lock modes only if
one of them is self-conflicting (i.e., may be held by one
transaction at
time only
). If multiple lock modes are involved,
one of them is self-conflicting (i.e., may be held by on
ly on
e
transaction at
a time
). If multiple lock modes are involved,
then transactions should always acquire the most restrictive mode first.
</para>
...
...
@@ -399,19 +404,17 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
</title>
<para>
<command>LOCK</command> is a <productname>PostgreSQL</productname>
language extension.
<literal>LOCK ... IN ACCESS SHARE MODE</> requires <literal>SELECT</>
privileges on the target table. All other forms of <command>LOCK</>
require <literal>UPDATE</> and/or <literal>DELETE</> privileges.
</para>
<para>
Except for ACCESS SHARE, ACCESS EXCLUSIVE, and SHARE UPDATE EXCLUSIVE lock
modes, the <productname>PostgreSQL</productname> lock modes and the
<command>LOCK TABLE</command> syntax are compatible with those
present in <productname>Oracle</productname>.
</para>
<para>
<command>LOCK</command> works only inside transactions.
<command>LOCK</command> is useful only inside a transaction block
(<command>BEGIN</>...<command>COMMIT</>), since the lock is dropped
as soon as the transaction ends. A <command>LOCK</> command appearing
outside any transaction block forms a self-contained transaction, so the
lock will be dropped as soon as it is obtained.
</para>
</refsect2>
...
...
@@ -471,6 +474,13 @@ COMMIT WORK;
concurrency levels on transactions. We support that too; see
<xref linkend="SQL-SET-TRANSACTION" endterm="SQL-SET-TRANSACTION-TITLE"> for details.
</para>
<para>
Except for ACCESS SHARE, ACCESS EXCLUSIVE, and SHARE UPDATE EXCLUSIVE lock
modes, the <productname>PostgreSQL</productname> lock modes and the
<command>LOCK TABLE</command> syntax are compatible with those
present in <productname>Oracle</productname>(TM).
</para>
</refsect2>
</refsect1>
</refentry>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment