Home Explore Blog CI



postgresql

66th chunk of `doc/src/sgml/ref/psql-ref.sgml`
37aaa223f284cfa750d1a08440a74b5bbcdabdc5853d61de0000000100000fa1
        <application>psql</application> to maintain a separate history for
        each database.
        </para>
        <note>
        <para>
        This feature was shamelessly plagiarized from
        <application>Bash</application>.
        </para>
        </note>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-histsize">
        <term><varname>HISTSIZE</varname></term>
        <listitem>
        <para>
        The maximum number of commands to store in the command history
        (default 500).  If set to a negative value, no limit is applied.
        </para>
        <note>
        <para>
        This feature was shamelessly plagiarized from
        <application>Bash</application>.
        </para>
        </note>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-host">
        <term><varname>HOST</varname></term>
        <listitem>
        <para>
        The database server host you are currently connected to. 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-ignoreeof">
        <term><varname>IGNOREEOF</varname></term>
        <listitem>
        <para>
         If set to 1 or less, sending an <acronym>EOF</acronym> character (usually
         <keycombo action="simul"><keycap>Control</keycap><keycap>D</keycap></keycombo>)
         to an interactive session of <application>psql</application>
         will terminate the application.  If set to a larger numeric value,
         that many consecutive <acronym>EOF</acronym> characters must be typed to
         make an interactive session terminate.  If the variable is set to a
         non-numeric value, it is interpreted as 10.  The default is 0.
        </para>
        <note>
        <para>
        This feature was shamelessly plagiarized from
        <application>Bash</application>.
        </para>
        </note>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-lastoid">
        <term><varname>LASTOID</varname></term>
        <listitem>
        <para>
        The value of the last affected OID, as returned from an
        <command>INSERT</command> or <command>\lo_import</command>
        command. This variable is only guaranteed to be valid until
        after the result of the next <acronym>SQL</acronym> command has
        been displayed.
        <productname>PostgreSQL</productname> servers since version 12 do not
        support OID system columns anymore, thus LASTOID will always be 0
        following <command>INSERT</command> when targeting such servers.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-last-error-message">
       <term><varname>LAST_ERROR_MESSAGE</varname></term>
       <term><varname>LAST_ERROR_SQLSTATE</varname></term>
       <listitem>
        <para>
         The primary error message and associated SQLSTATE code for the most
         recent failed query in the current <application>psql</application> session, or
         an empty string and <literal>00000</literal> if no error has occurred in
         the current session.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry id="app-psql-variables-on-error-rollback">
      <term>
       <varname>ON_ERROR_ROLLBACK</varname>
       <indexterm>
        <primary>rollback</primary>
        <secondary>psql</secondary>
       </indexterm>
      </term>
        <listitem>
        <para>
        When set to <literal>on</literal>, if a statement in a transaction block
        generates an error, the error is ignored and the transaction
        continues. When set to <literal>interactive</literal>, such errors are only
        ignored in interactive sessions, and not when reading script
        files. When set to <literal>off</literal> (the default),

Title: psql Special Variables: HOST, IGNOREEOF, LASTOID, LAST_ERROR_MESSAGE, LAST_ERROR_SQLSTATE, ON_ERROR_ROLLBACK
Summary
This section describes several special variables used by psql. HOST stores the database server host you are currently connected to. IGNOREEOF controls how many EOF characters are needed to terminate an interactive psql session. LASTOID holds the OID of the last affected row from INSERT or \lo_import, though it will always be 0 on servers since version 12. LAST_ERROR_MESSAGE and LAST_ERROR_SQLSTATE store the error message and SQLSTATE code of the most recent failed query. ON_ERROR_ROLLBACK controls whether errors in transaction blocks cause a rollback.