11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.89 2003/05/14 03:26:00 tgl Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.90 2003/06/28 00:12:39 tgl Exp $
33PostgreSQL documentation
44-->
55
@@ -1200,13 +1200,6 @@ Tue Oct 26 21:40:57 CEST 1999
12001200<acronym>OID</acronym>.
12011201</para>
12021202</tip>
1203- <note>
1204- <para>
1205- See the description of the <varname>LO_TRANSACTION</varname>
1206- variable for important information concerning all large object
1207- operations.
1208- </para>
1209- </note>
12101203</listitem>
12111204 </varlistentry>
12121205
@@ -1236,14 +1229,6 @@ lo_import 152801
12361229on the local file system, rather than the server's user and file
12371230system.
12381231</para>
1239-
1240- <note>
1241- <para>
1242- See the description of the <varname>LO_TRANSACTION</varname>
1243- variable for important information concerning all large object
1244- operations.
1245- </para>
1246- </note>
12471232</listitem>
12481233 </varlistentry>
12491234
@@ -1274,13 +1259,6 @@ lo_import 152801
12741259<acronym>OID</acronym>.
12751260</para>
12761261</tip>
1277- <note>
1278- <para>
1279- See the description of the <varname>LO_TRANSACTION</varname>
1280- variable for important information concerning all large object
1281- operations.
1282- </para>
1283- </note>
12841262</listitem>
12851263 </varlistentry>
12861264
@@ -1809,14 +1787,14 @@ bar
18091787
18101788 <para>
18111789 If you call <command>\set</command> without a second argument, the
1812- variable issimply set,but has no value. To unset (or delete) a
1790+ variable is set,with an empty string as value. To unset (or delete) a
18131791 variable, use the command <command>\unset</command>.
18141792 </para>
18151793
18161794 <para>
18171795 <application>psql</application>'s internal variable names can
18181796 consist of letters, numbers, and underscores in any order and any
1819- number of them. A number ofregular variables are treated specially
1797+ number of them. A number ofthese variables are treated specially
18201798 by <application>psql</application>. They indicate certain option
18211799 settings that can be changed at run time by altering the value of
18221800 the variable or represent some state of the application. Although
@@ -1825,10 +1803,47 @@ bar
18251803 really quickly. By convention, all specially treated variables
18261804 consist of all upper-case letters (and possibly numbers and
18271805 underscores). To ensure maximum compatibility in the future, avoid
1828- such variables. A list of all specially treated variables follows.
1806+ using such variable names for your own purposes. A list of all specially
1807+ treated variables follows.
18291808 </para>
18301809
18311810 <variablelist>
1811+ <varlistentry>
1812+ <term><varname>AUTOCOMMIT</varname></term>
1813+ <listitem>
1814+ <para>
1815+ When <literal>on</> (the default), each SQL command is automatically
1816+ committed upon successful completion. To postpone commit in this
1817+ mode, you must enter a <command>BEGIN</> or <command>START
1818+ TRANSACTION</> SQL command. When <literal>off</> or unset, SQL
1819+ commands are not committed until you explicitly issue
1820+ <command>COMMIT</> or <command>END</>. The autocommit-off
1821+ mode works by issuing an implicit <command>BEGIN</> for you, just
1822+ before any command that is not already in a transaction block and
1823+ is not itself a <command>BEGIN</> or other transaction-control
1824+ command.
1825+ </para>
1826+
1827+ <note>
1828+ <para>
1829+ In autocommit-off mode, you must explicitly abandon any failed
1830+ transaction by entering <command>ABORT</> or <command>ROLLBACK</>.
1831+ Also keep in mind that if you exit the session
1832+ without committing, your work will be lost.
1833+ </para>
1834+ </note>
1835+
1836+ <note>
1837+ <para>
1838+ The autocommit-on mode is <productname>PostgreSQL</>'s traditional
1839+ behavior, but autocommit-off is closer to the SQL spec. If you
1840+ prefer autocommit-off, you may wish to set it in
1841+ your <filename>.psqlrc</filename> file.
1842+ </para>
1843+ </note>
1844+ </listitem>
1845+ </varlistentry>
1846+
18321847 <varlistentry>
18331848 <term><varname>DBNAME</varname></term>
18341849<listitem>
@@ -1846,11 +1861,11 @@ bar
18461861<para>
18471862If set to <literal>all</literal>, all lines
18481863entered or from a script are written to the standard output
1849- before they are parsed or executed. Tospecify this on program
1864+ before they are parsed or executed. Toselect this behavior on program
18501865start-up, use the switch <option>-a</option>. If set to
18511866<literal>queries</literal>,
18521867<application>psql</application> merely prints all queries as
1853- they are sent to the server. Theoption for this is
1868+ they are sent to the server. Theswitch for this is
18541869<option>-e</option>.
18551870</para>
18561871</listitem>
@@ -1863,10 +1878,10 @@ bar
18631878When this variable is set and a backslash command queries the
18641879database, the query is first shown. This way you can study the
18651880<productname>PostgreSQL</productname> internals and provide
1866- similar functionality in your own programs.If you set the
1867- variable to thevalue <literal>noexec</literal>, the queries are
1868- just shown but are not actually sent to theserver and
1869- executed.
1881+ similar functionality in your own programs.(To select this behavior
1882+ on program start-up, use theswitch <option>-E</option>.) If you set
1883+ the variable to the value <literal>noexec</literal>, thequeries are
1884+ just shown but are not actually sent to the server and executed.
18701885</para>
18711886</listitem>
18721887 </varlistentry>
@@ -1962,39 +1977,6 @@ bar
19621977</listitem>
19631978 </varlistentry>
19641979
1965- <varlistentry>
1966- <term><varname>LO_TRANSACTION</varname></term>
1967- <listitem>
1968- <para>
1969- If you use the <productname>PostgreSQL</productname> large
1970- object interface to specially store data that does not fit into
1971- one row, all the operations must be contained in a transaction
1972- block. (See the documentation of the large object interface for
1973- more information.) Since <application>psql</application> has no
1974- way to tell if you already have a transaction in progress when
1975- you call one of its internal commands
1976- (<command>\lo_export</command>, <command>\lo_import</command>,
1977- <command>\lo_unlink</command>) it must take some arbitrary
1978- action. This action could either be to roll back any transaction
1979- that might already be in progress, or to commit any such
1980- transaction, or to do nothing at all. In the last case you must
1981- provide your own <command>BEGIN</command>/<command>COMMIT</command> block or the
1982- results will be unpredictable (usually resulting in the desired
1983- action's not being performed in any case).
1984- </para>
1985-
1986- <para>
1987- To choose what you want to do you set this variable to one of
1988- <literal>rollback</literal>, <literal>commit</literal>, or
1989- <literal>nothing</literal>. The default is to roll back the
1990- transaction. If you just want to load one or a few objects this
1991- is fine. However, if you intend to transfer many large objects,
1992- it might be advisable to provide one explicit transaction block
1993- around all commands.
1994- </para>
1995- </listitem>
1996- </varlistentry>
1997-
19981980 <varlistentry>
19991981 <term><varname>ON_ERROR_STOP</varname></term>
20001982<listitem>
@@ -2032,8 +2014,8 @@ bar
20322014 <term><varname>PROMPT3</varname></term>
20332015<listitem>
20342016<para>
2035- These specify what theprompt <application>psql</application>
2036- issuesis supposed to look like. See <xref
2017+ These specify what theprompts <application>psql</application>
2018+ issuesshould look like. See <xref
20372019linkend="APP-PSQL-prompting"
20382020endterm="APP-PSQL-prompting-title"> below.
20392021</para>
@@ -2055,8 +2037,8 @@ bar
20552037 <term><varname>SINGLELINE</varname></term>
20562038<listitem>
20572039<para>
2058- This variable isset by the command line option
2059- <option>-S</option>. You can unset or reset it at run time.
2040+ This variable isequivalent to the command line option
2041+ <option>-S</option>.
20602042</para>
20612043</listitem>
20622044 </varlistentry>
@@ -2082,6 +2064,17 @@ bar
20822064</listitem>
20832065 </varlistentry>
20842066
2067+ <varlistentry>
2068+ <term><varname>VERBOSE</varname></term>
2069+ <listitem>
2070+ <para>
2071+ This variable can be set to the values <literal>default</>,
2072+ <literal>verbose</>, or <literal>terse</> to control the verbosity
2073+ of error reports.
2074+ </para>
2075+ </listitem>
2076+ </varlistentry>
2077+
20852078 </variablelist>
20862079
20872080 </refsect3>
@@ -2123,7 +2116,7 @@ testdb=> <userinput>INSERT INTO my_table VALUES (:content);</userinput>
21232116<programlisting>
21242117testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\''</userinput>
21252118</programlisting>
2126- Observe the correct number of backslashes (6)!You can resolve it
2119+ Observe the correct number of backslashes (6)!It works
21272120 this way: After <application>psql</application> has parsed this
21282121 line, it passes <literal>sed -e "s/'/\\\'/g" < my_file.txt</literal>
21292122 to the shell. The shell will do its own thing inside the double
@@ -2141,9 +2134,10 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
21412134
21422135 <para>
21432136 Since colons may legally appear in SQL commands, the following rule
2144- applies: If the variable is not set, the character sequence
2145- <quote>colon+name</quote> is not changed. In any case you can escape
2146- a colon with a backslash to protect it from interpretation. (The
2137+ applies: the character sequence
2138+ <quote>:name</quote> is not changed unless <quote>name</> is the name
2139+ of a variable that is currently set. In any case you can escape
2140+ a colon with a backslash to protect it from substitution. (The
21472141 colon syntax for variables is standard <acronym>SQL</acronym> for
21482142 embedded query languages, such as <application>ECPG</application>.
21492143 The colon syntax for array slices and type casts are
@@ -2171,7 +2165,7 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
21712165 </para>
21722166
21732167 <para>
2174- The value of therespective prompt variable is printed literally,
2168+ The value of theselected prompt variable is printed literally,
21752169 except where a percent sign (<literal>%</literal>) is encountered.
21762170 Depending on the next character, certain other text is substituted
21772171 instead. Defined substitutions are:
@@ -2243,7 +2237,20 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
22432237<application>psql</application> expects more input because the
22442238command wasn't terminated yet, because you are inside a
22452239<literal>/* ... */</literal> comment, or because you are inside
2246- a quote. In prompt 3 the sequence doesn't resolve to anything.
2240+ a quote. In prompt 3 the sequence doesn't produce anything.
2241+ </para>
2242+ </listitem>
2243+ </varlistentry>
2244+
2245+ <varlistentry>
2246+ <term><literal>%T</literal></term>
2247+ <listitem>
2248+ <para>
2249+ Transaction status: an empty string when not in a transaction
2250+ block, or <literal>*</> when in a transaction block, or
2251+ <literal>!</> when in a failed transaction block, or <literal>?</>
2252+ when the transaction state is indeterminate (for example, because
2253+ there is no connection).
22472254</para>
22482255</listitem>
22492256 </varlistentry>
@@ -2252,13 +2259,12 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
22522259 <term><literal>%</literal><replaceable class="parameter">digits</replaceable></term>
22532260<listitem>
22542261<para>
2262+ The character with the indicated numeric code is substituted.
22552263If <replaceable class="parameter">digits</replaceable> starts
22562264with <literal>0x</literal> the rest of the characters are
2257- interpreted as a hexadecimal digit and the character with the
2258- corresponding code is substituted. If the first digit is
2259- <literal>0</literal> the characters are interpreted as on octal
2260- number and the corresponding character is substituted. Otherwise
2261- a decimal number is assumed.
2265+ interpreted as hexadecimal; otherwise if the first digit is
2266+ <literal>0</literal> the digits are interpreted as octal;
2267+ otherwise the digits are read as a decimal number.
22622268</para>
22632269</listitem>
22642270 </varlistentry>
@@ -2289,7 +2295,7 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
22892295 </variablelist>
22902296
22912297 To insert a percent sign into your prompt, write
2292- <literal>%%</literal>. The default prompts are equivalent to
2298+ <literal>%%</literal>. The default prompts are
22932299 <literal>'%/%R%# '</literal> for prompts 1 and 2, and
22942300 <literal>'>> '</literal> for prompt 3.
22952301 </para>
@@ -2473,17 +2479,6 @@ Field separator is "oo".
24732479 </para>
24742480 </listitem>
24752481
2476- <listitem>
2477- <para>
2478- Pressing <keycombo action="simul"><keycap>Control</><keycap>C</></>
2479- during a <quote>copy in</quote> (data sent to
2480- the server) doesn't show the most ideal of behaviors. If you get a
2481- message such as <errorname>COPY state must be terminated
2482- first</errorname>, simply reset the connection by entering <literal>\c
2483- - -</literal>.
2484- </para>
2485- </listitem>
2486-
24872482 </itemizedlist>
24882483 </refsect1>
24892484