Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-07 Thread Tom Lane
Noah Misch writes: > I ran libedit-history-fixes-v3.patch through my previous libedit-28 test. > Now, patched psql writes ^A for newlines in any command. Here's the new > matrix of behaviors when recalling history: > master using master-written history: > oldest command: ok > rest: ok

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-06 Thread Noah Misch
On Sat, Sep 06, 2014 at 11:40:02PM -0400, Tom Lane wrote: > I only tried this directly on Tiger, Snow Leopard, and Mavericks. I > tested libedit-28 by compiling from source on a RHEL machine, so it's > possible that there's some difference between what I tested and what > Apple's really shipping.

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-06 Thread Tom Lane
I wrote: > What I'm inclined to do based on this info is to start the loop at > history_base - 1, and ignore NULL returns until we're past history_base. I poked at that for awhile and decided it was a bad approach. It emerges that libedit's history_get() is just as full of version-specific misbeh

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-06 Thread Tom Lane
Noah Misch writes: > On Thu, Sep 04, 2014 at 07:51:03AM -0700, Tom Lane wrote: >> I think you got the test cases backwards, or maybe neglected the aspect >> about how unpatched psql will only translate ^J to ^A in the oldest >> (or maybe the newest? too pressed for time to recheck right now) histo

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-05 Thread Noah Misch
On Thu, Sep 04, 2014 at 07:51:03AM -0700, Tom Lane wrote: > Noah Misch writes: > > I tried your patches against libedit-28. Wherever a command contains a > > newline, unpatched psql writes the three bytes "\^A" to the history file, > > and > > patched psql writes the four bytes "\012". Unpatche

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-05 Thread Noah Misch
On Thu, Sep 04, 2014 at 09:54:37AM -0400, Robert Haas wrote: > One point to note is that not back-patching this doesn't really fix > anything. Will a user be annoyed when .psql_history fails to reload > properly on a new minor release, but utterly indifferent to whether it > reloads in a new major

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-04 Thread Tom Lane
Noah Misch writes: > I tried your patches against libedit-28. Wherever a command contains a > newline, unpatched psql writes the three bytes "\^A" to the history file, and > patched psql writes the four bytes "\012". Unpatched psql correctly reads > either form of the history file. Patched psql

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-04 Thread Robert Haas
On Wed, Sep 3, 2014 at 12:35 AM, Noah Misch wrote: > On Tue, Sep 02, 2014 at 01:56:34AM -0400, Tom Lane wrote: >> Noah Misch writes: >> > On Mon, Sep 01, 2014 at 10:22:57PM -0400, Tom Lane wrote: >> >> Also, as best I can tell, .psql_history files from older libedit versions >> >> are not forward

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-03 Thread Stepan Rutz
Hello again, just my thoughts… in psql \s without a file is nice for me iff going through less (e.g. pager), but for the most part it doesn't work at all on mac-osx. so nothing to lose for the mac psql users. regards, stepan Am 03.09.2014 um 07:45 schrieb Noah Misch : > On Tue, Sep 02, 2014

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-02 Thread Noah Misch
On Tue, Sep 02, 2014 at 09:49:56AM -0400, Tom Lane wrote: > Noah Misch writes: > > I'm with you that far. Given a patch that does not change "\s /tmp/foo" and > > that makes "\s" equivalent to "\s /tmp/foo" + "\! cat /tmp/foo >/dev/tty", > > back-patch by all means. No patch posted on this threa

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-02 Thread Noah Misch
On Tue, Sep 02, 2014 at 01:56:34AM -0400, Tom Lane wrote: > Noah Misch writes: > > On Mon, Sep 01, 2014 at 10:22:57PM -0400, Tom Lane wrote: > >> Also, as best I can tell, .psql_history files from older libedit versions > >> are not forward-compatible to current libedit versions because of the > >

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-02 Thread Tom Lane
Noah Misch writes: > I'm with you that far. Given a patch that does not change "\s /tmp/foo" and > that makes "\s" equivalent to "\s /tmp/foo" + "\! cat /tmp/foo >/dev/tty", > back-patch by all means. No patch posted on this thread is so surgical, hence > my objection. In particular, your lates

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Tom Lane
Noah Misch writes: > On Mon, Sep 01, 2014 at 10:22:57PM -0400, Tom Lane wrote: >> Also, as best I can tell, .psql_history files from older libedit versions >> are not forward-compatible to current libedit versions because of the >> failure of the decode_history() loop to reach all lines of the fil

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Noah Misch
On Mon, Sep 01, 2014 at 10:22:57PM -0400, Tom Lane wrote: > Noah Misch writes: > > On Mon, Sep 01, 2014 at 02:05:37PM -0400, Tom Lane wrote: > >> Functionally this seems like a clear win over what we had, especially > >> since it supports using the pager. I'm inclined to think we should > >> not

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Tom Lane
I've confirmed that the attached patches work as expected in both the oldest and newest readline and libedit versions available to me. Barring further objections, I plan to commit and back-patch these changes. regards, tom lane diff --git a/doc/src/sgml/ref/psql-ref.sgml b

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Tom Lane
Noah Misch writes: > On Mon, Sep 01, 2014 at 02:05:37PM -0400, Tom Lane wrote: >> Functionally this seems like a clear win over what we had, especially >> since it supports using the pager. I'm inclined to think we should >> not only apply this change but back-patch it. > I've not used \s apart

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Noah Misch
On Mon, Sep 01, 2014 at 02:05:37PM -0400, Tom Lane wrote: > Functionally this seems like a clear win over what we had, especially > since it supports using the pager. I'm inclined to think we should > not only apply this change but back-patch it. > > One thing worth thinking about: should we use

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Tom Lane
I wrote: >> Stepan Rutz writes: >>> Anyway, I am sure the iteration used in encode_history and decode_history >>> in input.c does not work on libedit. >> Yeah, I noticed your comment about that. That seems odd; a look at the >> Apple libedit sources suggests it should work. I was just about to

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Tom Lane
I wrote: > Stepan Rutz writes: >> Anyway, I am sure the iteration used in encode_history and decode_history in >> input.c does not work on libedit. > Yeah, I noticed your comment about that. That seems odd; a look at the > Apple libedit sources suggests it should work. I was just about to trac

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Tom Lane
Stepan Rutz writes: > Anyway, I am sure the iteration used in encode_history and decode_history in > input.c does not work on libedit. Yeah, I noticed your comment about that. That seems odd; a look at the Apple libedit sources suggests it should work. I was just about to trace through the log

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Stepan Rutz
Thanks Tom. This would help the poor mac-osx guys like me. I guess this is not that important because no one runs a production server on OS-X. Back patching to 9.3 won’t work as is, some minor conflict was there. Anyway, I am sure the iteration used in encode_history and decode_history in in

Re: [HACKERS] Patch for psql History Display on MacOSX

2014-09-01 Thread Tom Lane
Stepan Rutz writes: > 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. Hm. The $64 question here is whether we can assume that history_get() exists and works compati