11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/ref/lock.sgml,v 1.23 2000/12/25 23:15:26 petere Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/lock.sgml,v 1.24 2001/07/09 22:18:33 tgl Exp $
33Postgres documentation
44-->
55
@@ -20,20 +20,23 @@ Postgres documentation
2020 </refnamediv>
2121 <refsynopsisdiv>
2222 <refsynopsisdivinfo>
23- <date>1999 -07-20 </date>
23+ <date>2001 -07-09 </date>
2424 </refsynopsisdivinfo>
2525 <synopsis>
2626LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable>
27- LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN [ ROW | ACCESS ] { SHARE | EXCLUSIVE } MODE
28- LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN SHARE ROW EXCLUSIVE MODE
27+ LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN <replaceable class="PARAMETER">lockmode</replaceable> MODE
28+
29+ where <replaceable class="PARAMETER">lockmode</replaceable> is one of:
30+
31+ ACCESS SHARE | ROW SHARE | ROW EXCLUSIVE | SHARE UPDATE EXCLUSIVE |
32+ SHARE | SHARE ROW EXCLUSIVE | EXCLUSIVE | ACCESS EXCLUSIVE
2933 </synopsis>
3034
3135 <refsect2 id="R2-SQL-LOCK-1">
3236 <refsect2info>
3337 <date>1999-06-09</date>
3438 </refsect2info>
3539
36-
3740 <title>
3841 Inputs
3942 </title>
@@ -62,7 +65,7 @@ LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN SHARE ROW EX
6265This is the least restrictive lock mode. It conflicts only with
6366ACCESS EXCLUSIVE mode. It is used to protect a table from being
6467modified by concurrent <command>ALTER TABLE</command>,
65- <command>DROP TABLE</command> and <command>VACUUM</command>
68+ <command>DROP TABLE</command> and <command>VACUUM FULL </command>
6669commands.
6770 </para>
6871 </listitem>
@@ -102,6 +105,25 @@ LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN SHARE ROW EX
102105 </listitem>
103106 </varlistentry>
104107
108+ <varlistentry>
109+ <term>SHARE UPDATE EXCLUSIVE MODE</term>
110+ <listitem>
111+ <note>
112+ <para>
113+ Automatically acquired by <command>VACUUM</command> (without
114+ <option>FULL</option>).
115+ </para>
116+ </note>
117+
118+ <para>
119+ Conflicts with SHARE UPDATE EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE,
120+ EXCLUSIVE and
121+ ACCESS EXCLUSIVE modes. This mode protects a table against
122+ concurrent schema changes and VACUUMs.
123+ </para>
124+ </listitem>
125+ </varlistentry>
126+
105127 <varlistentry>
106128 <term>SHARE MODE</term>
107129 <listitem>
@@ -113,9 +135,10 @@ LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN SHARE ROW EX
113135 </note>
114136
115137 <para>
116- Conflicts with ROW EXCLUSIVE, SHARE ROW EXCLUSIVE, EXCLUSIVE and
138+ Conflicts with ROW EXCLUSIVE, SHARE UPDATE EXCLUSIVE,
139+ SHARE ROW EXCLUSIVE, EXCLUSIVE and
117140ACCESS EXCLUSIVE modes. This mode protects a table against
118- concurrent updates.
141+ concurrentdata updates.
119142 </para>
120143 </listitem>
121144 </varlistentry>
@@ -125,14 +148,14 @@ LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN SHARE ROW EX
125148 <listitem>
126149 <note>
127150 <para>
128- This is like EXCLUSIVE MODE, but allowsSHARE ROW locks
151+ This is like EXCLUSIVE MODE, but allows ROW SHARE locks
129152 by others.
130153 </para>
131154 </note>
132155
133156 <para>
134- Conflicts with ROW EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE,
135- EXCLUSIVE and ACCESS EXCLUSIVE modes.
157+ Conflicts with ROW EXCLUSIVE, SHARE UPDATE EXCLUSIVE, SHARE ,
158+ SHARE ROW EXCLUSIVE, EXCLUSIVE and ACCESS EXCLUSIVE modes.
136159 </para>
137160 </listitem>
138161 </varlistentry>
@@ -149,7 +172,8 @@ LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN SHARE ROW EX
149172 </note>
150173
151174 <para>
152- Conflicts with ROW SHARE, ROW EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE,
175+ Conflicts with ROW SHARE, ROW EXCLUSIVE, SHARE UPDATE EXCLUSIVE,
176+ SHARE, SHARE ROW EXCLUSIVE,
153177EXCLUSIVE and ACCESS EXCLUSIVE modes.
154178 </para>
155179 </listitem>
@@ -161,9 +185,10 @@ LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN SHARE ROW EX
161185 <note>
162186<para>
163187 Automatically acquired by <command>ALTER TABLE</command>,
164- <command>DROP TABLE</command>, <command>VACUUM</command> statements.
165- This is the most restrictive lock mode which conflicts with all other
166- lock modes and protects a locked table from any concurrent operations.
188+ <command>DROP TABLE</command>, <command>VACUUM FULL</command>
189+ statements.
190+ This is the most restrictive lock mode which
191+ protects a locked table from any concurrent operations.
167192</para>
168193 </note>
169194
@@ -174,6 +199,10 @@ LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN SHARE ROW EX
174199 lock mode option).
175200</para>
176201 </note>
202+
203+ <para>
204+ Conflicts with all lock modes.
205+ </para>
177206 </listitem>
178207 </varlistentry>
179208 </variablelist>
@@ -241,7 +270,11 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
241270 <term>EXCLUSIVE</term>
242271 <listitem>
243272 <para>
244- Exclusive lock that prevents other locks from being granted.
273+ An exclusive lock prevents other locks of the same type from being
274+ granted. (Note: ROW EXCLUSIVE mode does not follow this naming
275+ convention perfectly, since it is shared at the level of the table;
276+ it is exclusive only with respect to specific rows that are being
277+ updated.)
245278 </para>
246279 </listitem>
247280 </varlistentry>
@@ -250,7 +283,8 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
250283 <term>SHARE</term>
251284 <listitem>
252285 <para>
253- Allows others to share lock. Prevents EXCLUSIVE locks.
286+ A shared lock allows others to also hold the same type of lock,
287+ but prevents the corresponding EXCLUSIVE lock from being granted.
254288 </para>
255289 </listitem>
256290 </varlistentry>
@@ -273,13 +307,6 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
273307 </listitem>
274308 </varlistentry>
275309 </variablelist>
276-
277- <note>
278- <para>
279- If EXCLUSIVE or SHARE are not specified, EXCLUSIVE is assumed.
280- Locks exist for the duration of the transaction.
281- </para>
282- </note>
283310 </para>
284311
285312 <para>
@@ -370,8 +397,8 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
370397 </para>
371398
372399 <para>
373- Except for ACCESS SHARE/EXCLUSIVE lock modes, all other
374- <productname>Postgres</productname> lock modes and the
400+ Except for ACCESS SHARE, ACCESS EXCLUSIVE, and SHARE UPDATE EXCLUSIVE lock
401+ modes, the <productname>Postgres</productname> lock modes and the
375402 <command>LOCK TABLE</command> syntax are compatible with those
376403 present in <productname>Oracle</productname>.
377404 </para>