Home Explore Blog CI



postgresql

73th chunk of `doc/src/sgml/ref/psql-ref.sgml`
12b6140e99d5f251976cc112c4d526a5e3970da409f3fac20000000100000fa2
 Unix domain socket.
         </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-gt">
        <term><literal>%&gt;</literal></term>
        <listitem><para>The port number at which the database server is listening.</para></listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-n">
        <term><literal>%n</literal></term>
        <listitem>
         <para>
          The database session user name.  (The expansion of this
          value might change during a database session as the result
          of the command <command>SET SESSION
          AUTHORIZATION</command>.)
         </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-s">
        <term><literal>%s</literal></term>
        <listitem><para>The name of the service.</para></listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-slash">
        <term><literal>%/</literal></term>
        <listitem><para>The name of the current database.</para></listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-tilde">
        <term><literal>%~</literal></term>
        <listitem><para>Like <literal>%/</literal>, but the output is <literal>~</literal>
         (tilde) if the database is your default database.</para></listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-numbersign">
        <term><literal>%#</literal></term>
        <listitem>
         <para>
          If the session user is a database superuser, then a
          <literal>#</literal>, otherwise a <literal>&gt;</literal>.
          (The expansion of this value might change during a database
          session as the result of the command <command>SET SESSION
          AUTHORIZATION</command>.)
         </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-p">
        <term><literal>%p</literal></term>
        <listitem>
         <para>The process ID of the backend currently connected to.</para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-p-uc">
        <term><literal>%P</literal></term>
        <listitem>
        <para>
        Pipeline status: <literal>off</literal> when not in a pipeline,
        <literal>on</literal> when in an ongoing pipeline or
        <literal>abort</literal> when in an aborted pipeline.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-r">
        <term><literal>%R</literal></term>
        <listitem>
        <para>
        In prompt 1 normally <literal>=</literal>,
        but <literal>@</literal> if the session is in an inactive branch of a
        conditional block, or <literal>^</literal> if in single-line mode,
        or <literal>!</literal> if the session is disconnected from the
        database (which can happen if <command>\connect</command> fails).
        In prompt 2 <literal>%R</literal> is replaced by a character that
        depends on why <application>psql</application> expects more input:
        <literal>-</literal> if the command simply wasn't terminated yet,
        but <literal>*</literal> if there is an unfinished
        <literal>/* ... */</literal> comment,
        a single quote if there is an unfinished quoted string,
        a double quote if there is an unfinished quoted identifier,
        a dollar sign if there is an unfinished dollar-quoted string,
        or <literal>(</literal> if there is an unmatched left parenthesis.
        In prompt 3 <literal>%R</literal> doesn't produce anything.
        </para>
        </listitem>
      </varlistentry>

      <varlistentry id="app-psql-prompting-x">
        <term><literal>%x</literal></term>
        <listitem>
        <para>
        Transaction status: an empty string when not in a transaction
        block, or <literal>*</literal> when in a transaction block, or
        <literal>!</literal> when in a failed transaction block,

Title: psql Prompting Escape Sequences (Continued)
Summary
This section details the psql prompt escape sequences that can be used in PROMPT1, PROMPT2, and PROMPT3. It covers substitutions for the current database name (%/), default database indicator (~), superuser status (#), backend process ID (%), pipeline status (%P), session status (%R), and transaction status (%x).