Home Explore Blog CI



postgresql

68th chunk of `doc/src/sgml/ref/psql-ref.sgml`
dfc7820d97df57ec9eb878611f4c5094e1ed787d848ea0160000000100000fa7
 <command>\syncpipeline</command>, forcing the server to send the
        results. These results can be retrieved with
        <command>\getresults</command>.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-pipeline-sync-count">
        <term><varname>PIPELINE_SYNC_COUNT</varname></term>
        <listitem>
        <para>
        The number of sync messages queued in an ongoing pipeline.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-port">
        <term><varname>PORT</varname></term>
        <listitem>
        <para>
        The database server port to which you are currently connected.
        This is set every time you connect to a database (including
        program start-up), but can be changed or unset.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-prompt">
        <term><varname>PROMPT1</varname></term>
        <term><varname>PROMPT2</varname></term>
        <term><varname>PROMPT3</varname></term>
        <listitem>
        <para>
        These specify what the prompts <application>psql</application>
        issues should look like. See <xref
        linkend="app-psql-prompting"/> below.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-quiet">
        <term><varname>QUIET</varname></term>
        <listitem>
        <para>
        Setting this variable to <literal>on</literal> is equivalent to the command
        line option <option>-q</option>. It is probably not too useful in
        interactive mode.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-row-count">
       <term><varname>ROW_COUNT</varname></term>
       <listitem>
        <para>
         The number of rows returned or affected by the last SQL query, or 0
         if the query failed or did not report a row count.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-server-version-name">
        <term><varname>SERVER_VERSION_NAME</varname></term>
        <term><varname>SERVER_VERSION_NUM</varname></term>
        <listitem>
        <para>
        The server's version number as a string, for
        example <literal>9.6.2</literal>, <literal>10.1</literal> or <literal>11beta1</literal>,
        and in numeric form, for
        example <literal>90602</literal> or <literal>100001</literal>.
        These are set every time you connect to a database
        (including program start-up), but can be changed or unset.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-service">
        <term><varname>SERVICE</varname></term>
        <listitem>
        <para>
        The service name, if applicable.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-shell-error">
       <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

Title: psql Special Variables: PIPELINE_SYNC_COUNT, PORT, PROMPT1/2/3, QUIET, ROW_COUNT, SERVER_VERSION_NAME/NUM, SERVICE, SHELL_ERROR, SHELL_EXIT_CODE
Summary
This section describes more special variables in psql. PIPELINE_SYNC_COUNT stores the number of sync messages in a pipeline. PORT stores the database port. PROMPT1, PROMPT2, and PROMPT3 define the psql prompts. QUIET mirrors the -q command-line option. ROW_COUNT stores the rows affected by the last SQL query. SERVER_VERSION_NAME and SERVER_VERSION_NUM store the server version. SERVICE stores the service name. SHELL_ERROR indicates if the last shell command failed. SHELL_EXIT_CODE stores the exit status of the last shell command.