Hi everbody,

My first mail to this one, so please be mild. I fired up the debugger to get 
this item going, which is also on the Todo List. 

Attached is a very trivial patch as a basis for discussion that at least makes 
\s (show history) work in psql on Macs. Macs uses libedit, which has a 
libreadline interface. 

A short investigation showed that the way psql iterates over the history does 
not work with libedit. I changed the iteration scheme to an index based loop 
(see code and comments), which seemed to be the only working option for both 
readline and libedit. In any case, i have tested and compiled this on MacOX 
10.9.3 and Linux. Windows doesn’t have the pager in the first place. 

As noted in the todo I have made this code pay attention to the pager 
configuration from psql. The odd part is when your history opens in less you 
see the top part rather then the bottom part, but the bottom is just a single 
keystroke away. If pager is disabled history is just printed fine. Please note 
that this didn’t work at all on Mac before. Could this go into 
…./regress/sql/psql.sql at all? I am not sure on that one.

Regards, Stepan





Attachment: psql_pager_history_libedit_and_readline.patch
Description: Binary data

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to