1- <!-- $PostgreSQL: pgsql/doc/src/sgml/ref/set_transaction.sgml,v 1.19 2003/11/29 19:51:39 pgsql Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/ref/set_transaction.sgml,v 1.20 2004/08/12 21:00:22 tgl Exp $ -->
22<refentry id="SQL-SET-TRANSACTION">
33 <refmeta>
44 <refentrytitle id="SQL-SET-TRANSACTION-TITLE">SET TRANSACTION</refentrytitle>
1616
1717 <refsynopsisdiv>
1818<synopsis>
19- SET TRANSACTION
20- [ ISOLATION LEVEL { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE } ]
21- [ READ WRITE | READ ONLY ]
19+ SET TRANSACTION <replaceable class="parameter">transaction_mode</replaceable> [, ...]
20+ SET SESSION CHARACTERISTICS AS TRANSACTION <replaceable class="parameter">transaction_mode</replaceable> [, ...]
2221
23- SET SESSION CHARACTERISTICS AS TRANSACTION
24- [ ISOLATION LEVEL { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE } ]
25- [ READ WRITE | READ ONLY ]
22+ where <replaceable class="parameter">transaction_mode</replaceable> is one of:
23+
24+ ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }
25+ READ WRITE | READ ONLY
2626</synopsis>
2727 </refsynopsisdiv>
2828
@@ -34,7 +34,7 @@ SET SESSION CHARACTERISTICS AS TRANSACTION
3434 characteristics of the current transaction. It has no effect on any
3535 subsequent transactions. <command>SET SESSION
3636 CHARACTERISTICS</command> sets the default transaction
37- characteristics foreach transaction of a session. <command>SET
37+ characteristics forsubsequent transactions of a session. <command>SET
3838 TRANSACTION</command> can override it for an individual
3939 transaction.
4040 </para>
@@ -47,7 +47,7 @@ SET SESSION CHARACTERISTICS AS TRANSACTION
4747
4848 <para>
4949 The isolation level of a transaction determines what data the
50- transaction can see when other transactions are running concurrently.
50+ transaction can see when other transactions are running concurrently:
5151
5252 <variablelist>
5353 <varlistentry>
@@ -64,28 +64,35 @@ SET SESSION CHARACTERISTICS AS TRANSACTION
6464 <term><literal>SERIALIZABLE</literal></term>
6565 <listitem>
6666 <para>
67- The current transaction can only see rows committed before
68- first query or data-modification statement was executed in this transaction.
67+ All statements of the current transaction can only see rows committed
68+ before the first query or data-modification statement was executed in
69+ this transaction.
6970 </para>
7071 <tip>
7172 <para>
7273 Intuitively, serializable means that two concurrent
7374 transactions will leave the database in the same state as if
74- the twohas been executed strictly afterone another ineither
75- order.
75+ the twohad been executed strictlyone afterthe other ( inone
76+ order or the other) .
7677 </para>
7778 </tip>
7879 </listitem>
7980 </varlistentry>
8081 </variablelist>
8182
82- The level <literal>READ UNCOMMITTED</literal> is mapped to
83- <literal>READ COMMITTED</literal>, the level <literal>REPEATABLE
84- READ</literal> is mapped to <literal>SERIALIZABLE</literal>, The
85- transaction isolation level cannot be set after the first query or
83+ The SQL standard defines two additional levels, <literal>READ
84+ UNCOMMITTED</literal> and <literal>REPEATABLE READ</literal>.
85+ In <productname>PostgreSQL</productname> <literal>READ
86+ UNCOMMITTED</literal> is treated as
87+ <literal>READ COMMITTED</literal>, while <literal>REPEATABLE
88+ READ</literal> is treated as <literal>SERIALIZABLE</literal>.
89+ </para>
90+
91+ <para>
92+ The transaction isolation level cannot be changed after the first query or
8693 data-modification statement (<command>SELECT</command>,
8794 <command>INSERT</command>, <command>DELETE</command>,
88- <command>UPDATE</command>, <command>FETCH</command>,
95+ <command>UPDATE</command>, <command>FETCH</command>, or
8996 <command>COPY</command>) of a transaction has been executed. See
9097 <xref linkend="mvcc"> for more information about transaction
9198 isolation and concurrency control.
@@ -112,13 +119,27 @@ SET SESSION CHARACTERISTICS AS TRANSACTION
112119 <title>Notes</title>
113120
114121 <para>
115- The session default transaction isolation level can also be set
116- with the command
117- <programlisting>
118- SET default_transaction_isolation = '<replaceable>value</replaceable>'
119- </programlisting>
120- and in the configuration file. Consult <xref linkend="runtime-config"> for more
121- information.
122+ If <command>SET TRANSACTION</command> is executed without a prior
123+ <command>START TRANSACTION</command> or <command>BEGIN</command>,
124+ it will appear to have no effect, since the transaction will immediately
125+ end.
126+ </para>
127+
128+ <para>
129+ It is possible to dispense with <command>SET TRANSACTION</command> by
130+ instead specifying the desired <replaceable
131+ class="parameter">transaction_modes</replaceable> in
132+ <command>START TRANSACTION</command>.
133+ </para>
134+
135+ <para>
136+ The session default transaction modes can also be set by setting the
137+ configuration parameters <xref linkend="guc-default-transaction-isolation">
138+ and <xref linkend="guc-default-transaction-read-only">.
139+ (In fact <command>SET SESSION CHARACTERISTICS</command> is just a
140+ verbose equivalent for setting these variables with <command>SET</>.)
141+ This allows them to be set in the configuration file. Consult <xref
142+ linkend="runtime-config"> for more information.
122143 </para>
123144 </refsect1>
124145
@@ -131,15 +152,23 @@ SET default_transaction_isolation = '<replaceable>value</replaceable>'
131152 isolation level in the standard; in
132153 <productname>PostgreSQL</productname> the default is ordinarily
133154 <literal>READ COMMITTED</literal>, but you can change it as
134- described above. Because of multiversion concurrency control, the
155+ mentioned above. Because of multiversion concurrency control, the
135156 <literal>SERIALIZABLE</literal> level is not truly
136157 serializable. See <xref linkend="mvcc"> for details.
137158 </para>
138159
139160 <para>
140161 In the SQL standard, there is one other transaction characteristic
141162 that can be set with these commands: the size of the diagnostics
142- area. This concept is only for use in embedded SQL.
163+ area. This concept is specific to embedded SQL, and therefore is
164+ not implemented in the <productname>PostgreSQL</productname> server.
165+ </para>
166+
167+ <para>
168+ The SQL standard requires commas between successive <replaceable
169+ class="parameter">transaction_modes</replaceable>, but for historical
170+ reasons <productname>PostgreSQL</productname> allows the commas to be
171+ omitted.
143172 </para>
144173 </refsect1>
145174</refentry>