postgresql/src/bin/psql
Tom Lane 2ec477dc81 Cope with Readline's failure to track SIGWINCH events outside of input.
It emerges that libreadline doesn't notice terminal window size change
events unless they occur while collecting input.  This is easy to stumble
over if you resize the window while using a pager to look at query output,
but it can be demonstrated without any pager involvement.  The symptom is
that queries exceeding one line are misdisplayed during subsequent input
cycles, because libreadline has the wrong idea of the screen dimensions.

The safest, simplest way to fix this is to call rl_reset_screen_size()
just before calling readline().  That causes an extra ioctl(TIOCGWINSZ)
for every command; but since it only happens when reading from a tty, the
performance impact should be negligible.  A more valid objection is that
this still leaves a tiny window during entry to readline() wherein delivery
of SIGWINCH will be missed; but the practical consequences of that are
probably negligible.  In any case, there doesn't seem to be any good way to
avoid the race, since readline exposes no functions that seem safe to call
from a generic signal handler --- rl_reset_screen_size() certainly isn't.

It turns out that we also need an explicit rl_initialize() call, else
rl_reset_screen_size() dumps core when called before the first readline()
call.

rl_reset_screen_size() is not present in old versions of libreadline,
so we need a configure test for that.  (rl_initialize() is present at
least back to readline 4.0, so we won't bother with a test for it.)
We would need a configure test anyway since libedit's emulation of
libreadline doesn't currently include such a function.  Fortunately,
libedit seems not to have any corresponding bug.

Merlin Moncure, adjusted a bit by me
2015-12-16 16:59:35 -05:00
..
po Translation updates 2015-06-28 23:56:55 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
command.c psql: Support multiple -c and -f options, and allow mixing them. 2015-12-08 14:04:08 -05:00
command.h psql: Support multiple -c and -f options, and allow mixing them. 2015-12-08 14:04:08 -05:00
common.c Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
common.h Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
copy.c Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
copy.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
create_help.pl Update copyright for 2015 2015-01-06 11:43:47 -05:00
describe.c Fix behavior of printTable() and friends with externally-invoked pager. 2015-12-02 18:20:41 -05:00
describe.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
help.c Review program help output for wording and formatting 2015-09-16 00:59:28 -04:00
help.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
input.c Cope with Readline's failure to track SIGWINCH events outside of input. 2015-12-16 16:59:35 -05:00
input.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
large_obj.c Fix behavior of printTable() and friends with externally-invoked pager. 2015-12-02 18:20:41 -05:00
large_obj.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
mainloop.c Fix documentation of psql's ECHO all mode. 2015-01-31 18:35:13 -05:00
mainloop.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
Makefile Update copyright for 2015 2015-01-06 11:43:47 -05:00
mbprint.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
mbprint.h Fix indentation of \d footers for non-ASCII cases. 2012-03-07 19:25:59 -05:00
nls.mk Add missing source files to nls.mk 2014-07-15 10:10:42 -04:00
print.c Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
print.h Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:28 -05:00
prompt.c Add psql PROMPT variable showing the pid of the connected to backend. 2015-07-07 13:40:44 +02:00
prompt.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
psqlrc.sample Improve FILES section of psql reference page. 2014-01-14 19:27:57 -05:00
psqlscan.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
psqlscan.l Remove a couple other vestigial yylex() declarations. 2015-03-29 13:12:28 -04:00
settings.h Rearrange the handling of error context reports. 2015-09-05 11:58:33 -04:00
startup.c Code and docs review for multiple -c and -f options in psql. 2015-12-13 14:52:07 -05:00
stringutils.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
stringutils.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
tab-complete.c Improve ALTER POLICY tab completion. 2015-12-10 12:28:46 -05:00
tab-complete.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
variables.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
variables.h Update copyright for 2015 2015-01-06 11:43:47 -05:00