Home Explore Blog CI



postgresql

69th chunk of `doc/src/sgml/ref/psql-ref.sgml`
c8f613c819f0403a195a9fa516fbb609af04be01cdaa53280000000100000fb7
 <term><varname>SHELL_ERROR</varname></term>
       <listitem>
        <para>
         <literal>true</literal> if the last shell command
         failed, <literal>false</literal> if it succeeded.
         This applies to shell commands invoked via the <literal>\!</literal>,
         <literal>\g</literal>, <literal>\o</literal>, <literal>\w</literal>,
         and <literal>\copy</literal> meta-commands, as well as backquote
         (<literal>`</literal>) expansion.  Note that
         for <literal>\o</literal>, this variable is updated when the output
         pipe is closed by the next <literal>\o</literal> command.
         See also <varname>SHELL_EXIT_CODE</varname>.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-shell-exit-code">
       <term><varname>SHELL_EXIT_CODE</varname></term>
       <listitem>
        <para>
         The exit status returned by the last shell command.
         0&ndash;127 represent program exit codes, 128&ndash;255
         indicate termination by a signal, and -1 indicates failure
         to launch a program or to collect its exit status.
         This applies to shell commands invoked via the <literal>\!</literal>,
         <literal>\g</literal>, <literal>\o</literal>, <literal>\w</literal>,
         and <literal>\copy</literal> meta-commands, as well as backquote
         (<literal>`</literal>) expansion.  Note that
         for <literal>\o</literal>, this variable is updated when the output
         pipe is closed by the next <literal>\o</literal> command.
         See also <varname>SHELL_ERROR</varname>.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-show-all-results">
        <term><varname>SHOW_ALL_RESULTS</varname></term>
        <listitem>
        <para>
        When this variable is set to <literal>off</literal>, only the last
        result of a combined query (<literal>\;</literal>) is shown instead of
        all of them.  The default is <literal>on</literal>.  The off behavior
        is for compatibility with older versions of
        <application>psql</application>.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-show-context">
        <term><varname>SHOW_CONTEXT</varname></term>
        <listitem>
        <para>
        This variable can be set to the
        values <literal>never</literal>, <literal>errors</literal>, or <literal>always</literal>
        to control whether <literal>CONTEXT</literal> fields are displayed in
        messages from the server. The default is <literal>errors</literal> (meaning
        that context will be shown in error messages, but not in notice or
        warning messages).  This setting has no effect
        when <varname>VERBOSITY</varname> is set to <literal>terse</literal>
        or <literal>sqlstate</literal>.
        (See also <command>\errverbose</command>, for use when you want a verbose
        version of the error you just got.)
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-singleline">
        <term><varname>SINGLELINE</varname></term>
        <listitem>
        <para>
        Setting this variable to <literal>on</literal> is equivalent to the command
        line option <option>-S</option>.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-singlestep">
        <term><varname>SINGLESTEP</varname></term>
        <listitem>
        <para>
        Setting this variable to <literal>on</literal> is equivalent to the command
        line option <option>-s</option>.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-sqlstate">
       <term><varname>SQLSTATE</varname></term>
       <listitem>
        <para>
         The error code (see <xref linkend="errcodes-appendix"/>) associated
         with the last SQL query's failure, or <literal>00000</literal>

Title: psql Special Variables: SHELL_ERROR, SHELL_EXIT_CODE, SHOW_ALL_RESULTS, SHOW_CONTEXT, SINGLELINE, SINGLESTEP, SQLSTATE
Summary
This section describes more special variables in psql. SHELL_ERROR indicates if the last shell command failed. SHELL_EXIT_CODE stores the exit status of the last shell command. SHOW_ALL_RESULTS controls whether all results or just the last result of a combined query are shown. SHOW_CONTEXT controls whether CONTEXT fields are displayed in messages. SINGLELINE mirrors the -S command-line option. SINGLESTEP mirrors the -s command-line option. SQLSTATE stores the error code associated with the last SQL query's failure.