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 $ -->
2
2
<refentry id="SQL-SET-TRANSACTION">
3
3
<refmeta>
4
4
<refentrytitle id="SQL-SET-TRANSACTION-TITLE">SET TRANSACTION</refentrytitle>
16
16
17
17
<refsynopsisdiv>
18
18
<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> [, ...]
22
21
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
26
26
</synopsis>
27
27
</refsynopsisdiv>
28
28
@@ -34,7 +34,7 @@ SET SESSION CHARACTERISTICS AS TRANSACTION
34
34
characteristics of the current transaction. It has no effect on any
35
35
subsequent transactions. <command>SET SESSION
36
36
CHARACTERISTICS</command> sets the default transaction
37
- characteristics for each transaction of a session. <command>SET
37
+ characteristics for subsequent transactions of a session. <command>SET
38
38
TRANSACTION</command> can override it for an individual
39
39
transaction.
40
40
</para>
@@ -47,7 +47,7 @@ SET SESSION CHARACTERISTICS AS TRANSACTION
47
47
48
48
<para>
49
49
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:
51
51
52
52
<variablelist>
53
53
<varlistentry>
@@ -64,28 +64,35 @@ SET SESSION CHARACTERISTICS AS TRANSACTION
64
64
<term><literal>SERIALIZABLE</literal></term>
65
65
<listitem>
66
66
<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.
69
70
</para>
70
71
<tip>
71
72
<para>
72
73
Intuitively, serializable means that two concurrent
73
74
transactions will leave the database in the same state as if
74
- the two has been executed strictly after one another in either
75
- order.
75
+ the two had been executed strictly one after the other ( in one
76
+ order or the other) .
76
77
</para>
77
78
</tip>
78
79
</listitem>
79
80
</varlistentry>
80
81
</variablelist>
81
82
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
86
93
data-modification statement (<command>SELECT</command>,
87
94
<command>INSERT</command>, <command>DELETE</command>,
88
- <command>UPDATE</command>, <command>FETCH</command>,
95
+ <command>UPDATE</command>, <command>FETCH</command>, or
89
96
<command>COPY</command>) of a transaction has been executed. See
90
97
<xref linkend="mvcc"> for more information about transaction
91
98
isolation and concurrency control.
@@ -112,13 +119,27 @@ SET SESSION CHARACTERISTICS AS TRANSACTION
112
119
<title>Notes</title>
113
120
114
121
<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.
122
143
</para>
123
144
</refsect1>
124
145
@@ -131,15 +152,23 @@ SET default_transaction_isolation = '<replaceable>value</replaceable>'
131
152
isolation level in the standard; in
132
153
<productname>PostgreSQL</productname> the default is ordinarily
133
154
<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
135
156
<literal>SERIALIZABLE</literal> level is not truly
136
157
serializable. See <xref linkend="mvcc"> for details.
137
158
</para>
138
159
139
160
<para>
140
161
In the SQL standard, there is one other transaction characteristic
141
162
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.
143
172
</para>
144
173
</refsect1>
145
174
</refentry>
0 commit comments