Improve spelling of lock names, and some other editing.

This commit is contained in:
Peter Eisentraut 2002-03-27 02:36:51 +00:00
parent 1dbf8aa7a8
commit e68eb63e8c

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/mvcc.sgml,v 2.23 2002/02/18 16:13:10 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/mvcc.sgml,v 2.24 2002/03/27 02:36:51 petere Exp $
--> -->
<chapter id="mvcc"> <chapter id="mvcc">
@ -376,24 +376,28 @@ ERROR: Can't serialize access due to concurrent update
</indexterm> </indexterm>
<para> <para>
<productname>PostgreSQL</productname> <productname>PostgreSQL</productname> provides various lock modes
provides various lock modes to control concurrent to control concurrent access to data in tables. Users normally
access to data in tables. Some of these lock modes are acquired by need not be concerned about the different lock modes because
<productname>PostgreSQL</productname> <productname>PostgreSQL</productname> commands automatically
automatically before statement execution, while others are acquire locks of appropriate modes to ensure data integrity while
provided to be used by applications. All lock modes acquired in a permitting an appropriate level of concurrent access.
transaction are held for the duration Nevertheless, a user can manually lock a table in any of the
of the transaction. available modes using the <command>LOCK TABLE</command> command.
</para> </para>
<sect2> <para>
<title>Table-level locks</title> The list below shows the available lock modes and the contexts in
which they are used. Remember that all of these lock modes are
table-level locks, even if the name contains the word
<quote>row</quote>. The names of the lock modes are historical.
</para>
<para>
<variablelist> <variablelist>
<title>Table-level lock modes</title>
<varlistentry> <varlistentry>
<term> <term>
AccessShareLock <literal>ACCESS SHARE</literal>
</term> </term>
<listitem> <listitem>
<para> <para>
@ -402,139 +406,141 @@ ERROR: Can't serialize access due to concurrent update
</para> </para>
<para> <para>
Conflicts with AccessExclusiveLock only. Conflicts with the <literal>ACCESS EXCLUSIVE</literal> lock
mode only.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>
RowShareLock <literal>ROW SHARE</literal>
</term> </term>
<listitem> <listitem>
<para> <para>
Acquired by <command>SELECT FOR UPDATE</command> The <command>SELECT FOR UPDATE</command> command acquires a
and <command>LOCK TABLE</command> lock of this mode.
<option>IN ROW SHARE MODE</option> statements.
</para> </para>
<para> <para>
Conflicts with ExclusiveLock and AccessExclusiveLock modes. Conflicts with the <literal>EXCLUSIVE</literal> and
<literal>ACCESS EXCLUSIVE</literal> lock modes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>
RowExclusiveLock <literal>ROW EXCLUSIVE</literal>
</term> </term>
<listitem> <listitem>
<para> <para>
Acquired by <command>UPDATE</command>, <command>DELETE</command>, The commands <command>UPDATE</command>,
<command>INSERT</command> and <command>LOCK TABLE</command> <command>DELETE</command>, and <command>INSERT</command>
<option>IN ROW EXCLUSIVE MODE</option> statements. automatically acquire this lock mode.
</para> </para>
<para> <para>
Conflicts with ShareLock, ShareRowExclusiveLock, ExclusiveLock and Conflicts with the <literal>SHARE</literal>, <literal>SHARE ROW
AccessExclusiveLock modes. EXCLUSIVE</literal>, <literal>EXCLUSIVE</literal>, and
<literal>ACCESS EXCLUSIVE</literal> lock modes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>
ShareUpdateExclusiveLock <literal>SHARE UPDATE EXCLUSIVE</literal>
</term> </term>
<listitem> <listitem>
<para> <para>
Acquired by <command>VACUUM</command> (without <option>FULL</option>) Acquired by <command>VACUUM</command> (without <option>FULL</option>).
and <command>LOCK TABLE</command>
<option>IN SHARE UPDATE EXCLUSIVE MODE</option>
statements.
</para> </para>
<para> <para>
Conflicts with ShareUpdateExclusiveLock, ShareLock, Conflicts with the <literal>SHARE UPDATE EXCLUSIVE</literal>,
ShareRowExclusiveLock, ExclusiveLock and AccessExclusiveLock modes. <literal>SHARE</literal>, <literal>SHARE ROW
EXCLUSIVE</literal>, <literal>EXCLUSIVE</literal>, and
<literal>ACCESS EXCLUSIVE</literal> lock modes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>
ShareLock <literal>SHARE</literal>
</term> </term>
<listitem> <listitem>
<para> <para>
Acquired by <command>CREATE INDEX</command> Acquired by <command>CREATE INDEX</command>.
and <command>LOCK TABLE</command>
<option>IN SHARE MODE</option>
statements.
</para> </para>
<para> <para>
Conflicts with RowExclusiveLock, ShareUpdateExclusiveLock, Conflicts with the <literal>ROW EXCLUSIVE</literal>,
ShareRowExclusiveLock, <literal>SHARE UPDATE EXCLUSIVE</literal>, <literal>SHARE ROW
ExclusiveLock and AccessExclusiveLock modes. EXCLUSIVE</literal>, <literal>EXCLUSIVE</literal>, and
<literal>ACCESS EXCLUSIVE</literal> lock modes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>
ShareRowExclusiveLock <literal>SHARE ROW EXCLUSIVE</literal>
</term> </term>
<listitem> <listitem>
<para> <para>
Acquired by <command>LOCK TABLE</command> This lock mode is not automatically acquired by any command.
<option>IN SHARE ROW EXCLUSIVE MODE</option> statements.
</para> </para>
<para> <para>
Conflicts with RowExclusiveLock, ShareUpdateExclusiveLock, Conflicts with the <literal>ROW EXCLUSIVE</literal>,
ShareLock, ShareRowExclusiveLock, <literal>SHARE UPDATE EXCLUSIVE</literal>,
ExclusiveLock and AccessExclusiveLock modes. <literal>SHARE</literal>, <literal>SHARE ROW
EXCLUSIVE</literal>, <literal>EXCLUSIVE</literal>, and
<literal>ACCESS EXCLUSIVE</literal> lock modes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>
ExclusiveLock <literal>EXCLUSIVE LOCK</literal>
</term> </term>
<listitem> <listitem>
<para> <para>
Acquired by <command>LOCK TABLE</command> This lock mode is not automatically acquired by any command.
<option>IN EXCLUSIVE MODE</option> statements.
</para> </para>
<para> <para>
Conflicts with RowShareLock, RowExclusiveLock, Conflicts with the <literal>ROW SHARE</literal>, <literal>ROW
ShareUpdateExclusiveLock, ShareLock, EXCLUSIVE</literal>, <literal>SHARE UPDATE
ShareRowExclusiveLock, ExclusiveLock and AccessExclusiveLock EXCLUSIVE</literal>, <literal>SHARE</literal>, <literal>SHARE
modes. ROW EXCLUSIVE</literal>, <literal>EXCLUSIVE</literal>, and
<literal>ACCESS EXCLUSIVE</literal> lock modes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>
AccessExclusiveLock <literal>ACCESS EXCLUSIVE</literal>
</term> </term>
<listitem> <listitem>
<para> <para>
Acquired by <command>ALTER TABLE</command>, Acquired by the <command>ALTER TABLE</command>, <command>DROP
<command>DROP TABLE</command>, TABLE</command>, and <command>VACUUM FULL</command> commands.
<command>VACUUM FULL</command> and <command>LOCK TABLE</command> This is also the default lock mode for <command>LOCK TABLE</command>
<option>IN ACCESS EXCLUSIVE MODE</option> (or plain statements that do not specify a mode explicitly.
<command>LOCK TABLE</command>) statements.
</para> </para>
<para> <para>
Conflicts with all modes (AccessShareLock, RowShareLock, Conflicts with locks of all modes ( <literal>ACCESS
RowExclusiveLock, ShareUpdateExclusiveLock, ShareLock, SHARE</literal>, <literal>ROW SHARE</literal>, <literal>ROW
ShareRowExclusiveLock, ExclusiveLock and AccessExclusiveLock). EXCLUSIVE</literal>, <literal>SHARE UPDATE
EXCLUSIVE</literal>, <literal>SHARE</literal>, <literal>SHARE
ROW EXCLUSIVE</literal>, <literal>EXCLUSIVE</literal>, and
<literal>ACCESS EXCLUSIVE</literal>).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -542,30 +548,27 @@ ERROR: Can't serialize access due to concurrent update
<note> <note>
<para> <para>
Only AccessExclusiveLock blocks <command>SELECT</command> (without Only an <literal>ACCESS EXCLUSIVE</literal> lock blocks a
<option>FOR UPDATE</option>) statement. <command>SELECT</command> (without <option>FOR UPDATE</option>)
statement.
</para> </para>
</note> </note>
</para>
</sect2>
<sect2>
<title>Row-level locks</title>
<para> <para>
Row-level locks are acquired when rows are being updated (or deleted or In addition to table-level locks, there are row-level locks.
marked for update). Row-level locks are acquired when rows are being updated (or
Row-level locks don't affect data querying. They block deleted or marked for update). Row-level locks don't affect data
writers to <emphasis>the same row</emphasis> only. querying; they block writers to <emphasis>the same row</emphasis>
only. Row-level locks cannot be acquired explicitly by the user.
</para> </para>
<para> <para>
<productname>PostgreSQL</productname> <productname>PostgreSQL</productname> doesn't remember any
doesn't remember any information about modified rows in memory and information about modified rows in memory, so is has no limit to
so has no limit to the number of rows locked at one time. However, the number of rows locked at one time. However, locking a row
locking a row may cause a disk write; thus, for example, may cause a disk write; thus, for example, <command>SELECT FOR
<command>SELECT FOR UPDATE</command> will modify UPDATE</command> will modify selected rows to mark them and so
selected rows to mark them and so will result in disk writes. will result in disk writes.
</para> </para>
<para> <para>
@ -575,7 +578,6 @@ ERROR: Can't serialize access due to concurrent update
updated. Application writers normally need not be concerned with updated. Application writers normally need not be concerned with
page-level locks, but we mention them for completeness. page-level locks, but we mention them for completeness.
</para> </para>
</sect2>
</sect1> </sect1>
<sect1 id="locking-indexes"> <sect1 id="locking-indexes">