1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/ref/set.sgml,v 1.90 2006 /09/22 16:20:00 tgl Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/ref/set.sgml,v 1.91 2007 /09/11 00:06:41 tgl Exp $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -40,13 +40,10 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="PARAMETER">timezone</rep
40
40
</para>
41
41
42
42
<para>
43
- If <command>SET</command> or <command>SET SESSION</command> is issued
44
- within a transaction that is later aborted, the effects of the
43
+ If <command>SET</command>( orequivalently <command>SET SESSION</command>)
44
+ is issued within a transaction that is later aborted, the effects of the
45
45
<command>SET</command> command disappear when the transaction is rolled
46
- back. (This behavior represents a change from
47
- <productname>PostgreSQL</productname> versions prior to 7.3, where
48
- the effects of <command>SET</command> would not roll back after a later
49
- error.) Once the surrounding transaction is committed, the effects
46
+ back. Once the surrounding transaction is committed, the effects
50
47
will persist until the end of the session, unless overridden by another
51
48
<command>SET</command>.
52
49
</para>
@@ -59,6 +56,36 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="PARAMETER">timezone</rep
59
56
seen until the end of the transaction, but afterwards (if the transaction
60
57
is committed) the <command>SET</command> value will take effect.
61
58
</para>
59
+
60
+ <para>
61
+ The effects of <command>SET</command> or <command>SET LOCAL</command> are
62
+ also canceled by rolling back to a savepoint that is earlier than the
63
+ command.
64
+ </para>
65
+
66
+ <para>
67
+ If <command>SET LOCAL</command> is used within a function that has a
68
+ <literal>SET</> option for the same variable (see
69
+ <xref linkend="sql-createfunction" endterm="sql-createfunction-title">),
70
+ the effects of the <command>SET LOCAL</command> command disappear at
71
+ function exit; that is, the value in effect when the function was called is
72
+ restored anyway. This allows <command>SET LOCAL</command> to be used for
73
+ dynamic or repeated changes of a parameter within a function, while still
74
+ having the convenience of using the <literal>SET</> option to save and
75
+ restore the caller's value. However, a regular <command>SET</> command
76
+ overrides any surrounding function's <literal>SET</> option; its effects
77
+ will persist unless rolled back.
78
+ </para>
79
+
80
+ <note>
81
+ <para>
82
+ In <productname>PostgreSQL</productname> versions 8.0 through 8.2,
83
+ the effects of a <command>SET LOCAL</command> would be canceled by
84
+ releasing an earlier savepoint, or by successful exit from a
85
+ <application>PL/pgSQL</application> exception block. This behavior
86
+ has been changed because it was deemed unintuitive.
87
+ </para>
88
+ </note>
62
89
</refsect1>
63
90
64
91
<refsect1>
@@ -106,8 +133,11 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="PARAMETER">timezone</rep
106
133
<para>
107
134
New value of parameter. Values can be specified as string
108
135
constants, identifiers, numbers, or comma-separated lists of
109
- these. <literal>DEFAULT</literal> can be used to specify
110
- resetting the parameter to its default value.
136
+ these, as appropriate for the particular parameter.
137
+ <literal>DEFAULT</literal> can be written to specify
138
+ resetting the parameter to its default value (that is, whatever
139
+ value it would have had if no <command>SET</> had been executed
140
+ in the current session).
111
141
</para>
112
142
</listitem>
113
143
</varlistentry>
@@ -200,7 +230,9 @@ SELECT setseed(<replaceable>value</replaceable>);
200
230
<term><literal>DEFAULT</literal></term>
201
231
<listitem>
202
232
<para>
203
- Set the time zone to your local time zone (the one that
233
+ Set the time zone to your local time zone (that is, the
234
+ server's default value of <varname>timezone</>; if this
235
+ has not been explicitly set anywhere, it will be the zone that
204
236
the server's operating system defaults to).
205
237
</para>
206
238
</listitem>
@@ -221,7 +253,10 @@ SELECT setseed(<replaceable>value</replaceable>);
221
253
222
254
<para>
223
255
The function <function>set_config</function> provides equivalent
224
- functionality. See <xref linkend="functions-admin">.
256
+ functionality; see <xref linkend="functions-admin">.
257
+ Also, it is possible to UPDATE the
258
+ <link linkend="view-pg-settings"><structname>pg_settings</structname></link>
259
+ system view to perform the equivalent of <command>SET</>.
225
260
</para>
226
261
</refsect1>
227
262