Add %x to default PROMPT1 and PROMPT2 in psql
authorMichael Paquier <michael@paquier.xyz>
Wed, 12 Feb 2020 04:31:14 +0000 (13:31 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 12 Feb 2020 04:31:14 +0000 (13:31 +0900)
%d can be used to track if the current connection is in a transaction
block or not, and adding it by default to the prompt has the advantage
to not need a modification of .psqlrc, something not possible depending
on the environment.

This discussion has happened across various sources, and there was a
strong consensus in favor of this change.

Author: Vik Fearing
Reviewed-by: Fabien Coelho
Discussion: https://postgr.es/m/09502c40-cfe1-bb29-10f9-4b3fa7b2bbb2@2ndquadrant.com

doc/src/sgml/logicaldecoding.sgml
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/settings.h

index 8db968641ee447cbc1fc643e37ed47c6cf0f37e9..bce6d379bf07ec2a2dc3fd712a8ae2f41ab7a1ec 100644 (file)
@@ -92,9 +92,9 @@ postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NU
 (0 rows)
 
 postgres=# BEGIN;
-postgres=# INSERT INTO data(data) VALUES('1');
-postgres=# INSERT INTO data(data) VALUES('2');
-postgres=# COMMIT;
+postgres=*# INSERT INTO data(data) VALUES('1');
+postgres=*# INSERT INTO data(data) VALUES('2');
+postgres=*# COMMIT;
 
 postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL);
     lsn    |  xid  |                          data                           
index 48b081fd58a27aad4c6926edad8126db7939085f..20ba10516066d6c515281cdf2baf28eb03aadb0f 100644 (file)
@@ -4332,7 +4332,7 @@ testdb=&gt; \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '
 
     To insert a percent sign into your prompt, write
     <literal>%%</literal>. The default prompts are
-    <literal>'%/%R%# '</literal> for prompts 1 and 2, and
+    <literal>'%/%R%x%# '</literal> for prompts 1 and 2, and
     <literal>'&gt;&gt; '</literal> for prompt 3.
     </para>
 
index d2a9d4836aba0a779d46e299a6dfe2b33af7d3d3..2b384a38a1b1d8a56b5b72b151b2459436b8d838 100644 (file)
@@ -23,8 +23,8 @@
 #define DEFAULT_EDITOR_LINENUMBER_ARG "+"
 #endif
 
-#define DEFAULT_PROMPT1 "%/%R%# "
-#define DEFAULT_PROMPT2 "%/%R%# "
+#define DEFAULT_PROMPT1 "%/%R%x%# "
+#define DEFAULT_PROMPT2 "%/%R%x%# "
 #define DEFAULT_PROMPT3 ">> "
 
 /*