Thread: Patch for psql to avoid altering the PGresult strings

Patch for psql to avoid altering the PGresult strings

From
Dennis Björklund
Date:
The mbvalidate() function was called on the PGresult strings, and it
changes the strings (removes unknown characters).

I've change the validation function to one that either returns a new
string when needed or NULL when the string already was validating. The
normal case is to have validating strings so in most cases no new strings
are created.

I have not included changes to avoid sending non validating strings to the
server. It's not clear what is the best way to solve it. Maybe one should
just do a stupid fix for 7.4 and validate the strings like above and just
delete non validating strings. It is possible to solve it in a better way,
but it's more complicated. We have 4 different charsets to think about in
psql. The server, the client, the terminal and the message catalog (the
last two usually matches, but not always). I would prefer to find a good
solution instead of just patching one small problem after another.

--
/Dennis

Attachment

Re: Patch for psql to avoid altering the PGresult strings

From
Bruce Momjian
Date:
What should be done with this patch?

---------------------------------------------------------------------------

Dennis Bj�rklund wrote:
> The mbvalidate() function was called on the PGresult strings, and it
> changes the strings (removes unknown characters).
>
> I've change the validation function to one that either returns a new
> string when needed or NULL when the string already was validating. The
> normal case is to have validating strings so in most cases no new strings
> are created.
>
> I have not included changes to avoid sending non validating strings to the
> server. It's not clear what is the best way to solve it. Maybe one should
> just do a stupid fix for 7.4 and validate the strings like above and just
> delete non validating strings. It is possible to solve it in a better way,
> but it's more complicated. We have 4 different charsets to think about in
> psql. The server, the client, the terminal and the message catalog (the
> last two usually matches, but not always). I would prefer to find a good
> solution instead of just patching one small problem after another.
>
> --
> /Dennis

Content-Description:

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Patch for psql to avoid altering the PGresult strings

From
Dennis Björklund
Date:
On Mon, 23 Jun 2003, Bruce Momjian wrote:

> What should be done with this patch?

Well, I can't tell what you should do :-) I made it in response to this:

http://archives.postgresql.org/pgsql-hackers/2003-06/msg00296.php

The patch is not very important, it works fine without. It's just that the
docs of libpq says that you are not allowed to change the things you get
back from it. And psql was doing that. In practice it's not a problem
since it happens to work anyway.

Tha plans to (try to) solve the charset problems I've put on hold until
after the release since people seems to be busy at the moment (which is
understandable since the freeze is coming up). If you have a unicode
database you just have to run the non translated psql also in 7.4.

--
/Dennis