aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-12-01 12:24:50 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2021-12-01 12:24:50 -0500
commit3d858af07ee67efda3778bdd655852afabf4a125 (patch)
tree99663f86ab6ad59bd4481e15628af08ef104cc0d
parentc2f654930e9f8119b9ed12caab6192d0aafe5ebd (diff)
downloadpostgresql-3d858af07ee67efda3778bdd655852afabf4a125.tar.gz
postgresql-3d858af07ee67efda3778bdd655852afabf4a125.zip
psql: initialize comment-begin setting to a useful value by default.
Readline's meta-# command is supposed to insert a comment marker at the start of the current line. However, the default marker is "#" which is entirely unhelpful for SQL. Set it to "-- " instead. (This setting can still be overridden in one's ~/.inputrc file, so this change won't affect people who have already taken steps to make the command useful.) Discussion: https://postgr.es/m/CAJcOf-cAdMVr7azeYR7nWKsNp7qhORzc84rV6d7m7knG5Hrtsw@mail.gmail.com
-rw-r--r--src/bin/psql/input.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index f926bc98dc2..1dcd95a7b9e 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -353,8 +353,13 @@ initializeInput(int flags)
useReadline = true;
- /* these two things must be done in this order: */
+ /* set appropriate values for Readline's global variables */
initialize_readline();
+
+ /* set comment-begin to a useful value for SQL */
+ (void) rl_variable_bind("comment-begin", "-- ");
+
+ /* this reads ~/.inputrc, so do it after rl_variable_bind */
rl_initialize();
useHistory = true;