Re: TODO item -- Improve psql's handling of multi-line

From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andreas Seltenreich <seltenreich(at)gmx(dot)de>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: TODO item -- Improve psql's handling of multi-line
Date: 2006-02-12 03:31:13
Message-ID: Pine.LNX.4.44.0602120546550.15708-100000@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Sat, 11 Feb 2006, Bruce Momjian wrote:
>
> Modified patch attached and applied. Thanks.
>
> I adjusted based on Tom's comments to use a zero byte, and to clean up
> the formatting. I didn't see any extra non-readline overhead, just
> calls to functions that are no-ops in non-readline cases.

Thank you, Bruce for modifying and applying the patch (during 2 months I
didn't find time to do that formatting corrections by myself).

> Tom Lane wrote:
> > "Sergey E. Koposov" <math(at)sai(dot)msu(dot)ru> writes:
> > > On Wed, 7 Dec 2005, Andrew Dunstan wrote:
> > >> A zero byte is probably a pretty bad choice. Some other low valued byte
> > >> (e.g. \x01 ) would probably work better.
> >
> > > Currently I replace '\n' with the '\x01' as Andrew suggested.
> >
> > Won't this get confused by some of the Far Eastern encodings we support?
> > The zero-byte approach is at least proof against that. But what we need
> > to ask is whether we can expect readline to cope with either.

But concerning to your zero byte change, it currently just broke
everything (as I thought, and that's why I didn't implemented it). The
problem with using zero byte is that it breaks all the readline functions
read_history and write_history. Those functions deal with usual C
strings, so putting zero byte inside them will just truncate everything.
(that's exactly what occur with the psql from CVS).

So, I don't know. There are two alternatives. One is to use 0x01 byte
instead: (at least I don't really agree with Tom's comments about possible
problems with using 0x01 with some exotic encodings) (for example I did a
test like this
cat ./pgsql/src/backend/utils/mb/Unicode/*.map |grep 01
cat ./pgsql/src/backend/utils/mb/Unicode/*.map |grep '0x1'
and it didn't produce any output, so it seems to me that 0x01 byte is not
used by any encoding... and UTF encodings are not using 0x01 byte for
certain)
The second alternative is to write our own implementations of read_history
and write_history functions instead of standart readline implementations to
deal with zero bytes in the strings. But it seems to be a rather bad
solution....

Regards,
Sergey

*****************************************************
Sergey E. Koposov
Max Planck Institute for Astronomy
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math(at)sai(dot)msu(dot)ru

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-02-12 03:34:41 Re: [COMMITTERS] pgsql: Allow ALTER TABLE ...
Previous Message Bruce Momjian 2006-02-12 03:22:02 Re: shared description table.