Re: Patch for psql History Display on MacOSX

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Patch for psql History Display on MacOSX
Дата
Msg-id 3096.1409665796@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Patch for psql History Display on MacOSX  (Noah Misch <noah@leadboat.com>)
Ответы Re: Patch for psql History Display on MacOSX  (Noah Misch <noah@leadboat.com>)
Список pgsql-hackers
Noah Misch <noah@leadboat.com> 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 latest patch revision changes "\s /tmp/foo"
> to match the novel output the patch introduces for plain "\s".  "\s /tmp/foo"
> would no longer write data that libedit can reload as a history file.

BTW, I failed last night to produce a coherent argument against that
particular point, but consider this.  What are the main use-cases for
\s to a file?  I argue that they are
1. Create a human-readable record of what you did.2. Create the starting point for a SQL script file.

I do not deny it's possible that somebody out there is also using \s for
3. Create a file that I can overwrite ~/.psql_history with later.

But if this is being done in the field at all, surely it is miles behind
the applications listed above.

Now, if you are using libreadline, the output of \s has always been
perfectly fit for purposes 1 and 2, because it's plain text of the
history entries.  Moreover, it is *not* particularly fit for purpose 3,
because intra-command newlines aren't encoded.  Yes, you could get
libreadline to read the file, but multiline SQL commands will be seen
as multiple history entries which is very far from convenient to use.
(This adds to my suspicion that nobody is doing #3 in practice.)

On the other hand, if you are using libedit, purpose 3 works great
but the output is utterly unfit for either purpose 1 or 2.  Here
are the first few lines of ~/.psql_history on one of my Macs:

_HiStOrY_V2_
explain\040verbose\^A\040\040select\0401\^Aunion\^A\040\040select\0402;
\\q
select\0404;
explain\040verbose\^A\040\040select\0401\^Aunion\^A\040\040select\0402;
select\04044;
\\q
\\s
\\s\040foobar
\\q

What the proposed patch does is ensure that \s produces plain text
regardless of which history library you are using.  I think arguing
that we shouldn't do that is stretching the concept of backwards
compatibility well past the breaking point.  Moreover, output like
the above doesn't satisfy the existing description of \s, namely
that it prints your history.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: On partitioning
Следующее
От: Joel Jacobson
Дата:
Сообщение: Re: PL/pgSQL 2