Patch for psql History Display on MacOSX

From: Stepan Rutz <stepan(dot)rutz(at)gmx(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Patch for psql History Display on MacOSX
Date: 2014-08-29 22:15:02
Message-ID: 7D95025B-E8D3-4FF7-AAC2-3B947F57DE64@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 Content-Type Size
psql_pager_history_libedit_and_readline.patch application/octet-stream 2.9 KB
smime.p7s application/pkcs7-signature 1.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Brightwell, Adam 2014-08-30 00:16:46 Re: RLS Design
Previous Message Andres Freund 2014-08-29 22:08:34 Re: [RFC, POC] Don't require a NBuffer sized PrivateRefCount array of local buffer pins