Skip to content

Commit a3eb19b

Browse files
committed
Docs: improve description of psql's %R prompt escape sequence.
Dilian Palauzov pointed out in bug #14201 that the docs failed to mention the possibility of %R producing '(' due to an unmatched parenthesis. He proposed just adding that in the same style as the other options were listed; but it seemed to me that the sentence was already nearly unintelligible, so I rewrote it a bit more extensively. Report: <20160619121113.5789.68274@wrigleys.postgresql.org>
1 parent 6fce92a commit a3eb19b

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,11 +3294,12 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
32943294
and special escape sequences that describe the appearance of the
32953295
prompt. Prompt 1 is the normal prompt that is issued when
32963296
<application>psql</application> requests a new command. Prompt 2 is
3297-
issued when more input is expected during command input because the
3298-
command was not terminated with a semicolon or a quote was not closed.
3299-
Prompt 3 is issued when you run an <acronym>SQL</acronym>
3300-
<command>COPY</command> command and you are expected to type in the
3301-
row values on the terminal.
3297+
issued when more input is expected during command entry, for example
3298+
because the command was not terminated with a semicolon or a quote
3299+
was not closed.
3300+
Prompt 3 is issued when you are running an <acronym>SQL</acronym>
3301+
<command>COPY FROM STDIN</command> command and you need to type in
3302+
a row value on the terminal.
33023303
</para>
33033304

33043305
<para>
@@ -3378,17 +3379,20 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
33783379
<term><literal>%R</literal></term>
33793380
<listitem>
33803381
<para>
3381-
In prompt 1 normally <literal>=</literal>, but <literal>^</literal> if
3382-
in single-line mode, and <literal>!</literal> if the session is
3383-
disconnected from the database (which can happen if
3384-
<command>\connect</command> fails). In prompt 2 the sequence is
3385-
replaced by <literal>-</literal>, <literal>*</literal>, a single quote,
3386-
a double quote, or a dollar sign, depending on whether
3387-
<application>psql</application> expects more input because the
3388-
command wasn't terminated yet, because you are inside a
3389-
<literal>/* ... */</literal> comment, or because you are inside
3390-
a quoted or dollar-escaped string. In prompt 3 the sequence doesn't
3391-
produce anything.
3382+
In prompt 1 normally <literal>=</literal>,
3383+
but <literal>^</literal> if in single-line mode,
3384+
or <literal>!</literal> if the session is disconnected from the
3385+
database (which can happen if <command>\connect</command> fails).
3386+
In prompt 2 <literal>%R</literal> is replaced by a character that
3387+
depends on why <application>psql</application> expects more input:
3388+
<literal>-</literal> if the command simply wasn't terminated yet,
3389+
but <literal>*</literal> if there is an unfinished
3390+
<literal>/* ... */</literal> comment,
3391+
a single quote if there is an unfinished quoted string,
3392+
a double quote if there is an unfinished quoted identifier,
3393+
a dollar sign if there is an unfinished dollar-quoted string,
3394+
or <literal>(</literal> if there is an unmatched left parenthesis.
3395+
In prompt 3 <literal>%R</literal> doesn't produce anything.
33923396
</para>
33933397
</listitem>
33943398
</varlistentry>

0 commit comments

Comments
 (0)