11<!--
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 $
33PostgreSQL documentation
44-->
55
@@ -40,13 +40,10 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="PARAMETER">timezone</rep
4040 </para>
4141
4242 <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
4545 <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
5047 will persist until the end of the session, unless overridden by another
5148 <command>SET</command>.
5249 </para>
@@ -59,6 +56,36 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="PARAMETER">timezone</rep
5956 seen until the end of the transaction, but afterwards (if the transaction
6057 is committed) the <command>SET</command> value will take effect.
6158 </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>
6289 </refsect1>
6390
6491 <refsect1>
@@ -106,8 +133,11 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="PARAMETER">timezone</rep
106133 <para>
107134 New value of parameter. Values can be specified as string
108135 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).
111141 </para>
112142 </listitem>
113143 </varlistentry>
@@ -200,7 +230,9 @@ SELECT setseed(<replaceable>value</replaceable>);
200230 <term><literal>DEFAULT</literal></term>
201231 <listitem>
202232 <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
204236 the server's operating system defaults to).
205237 </para>
206238 </listitem>
@@ -221,7 +253,10 @@ SELECT setseed(<replaceable>value</replaceable>);
221253
222254 <para>
223255 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</>.
225260 </para>
226261 </refsect1>
227262