Skip site navigation (1) Skip section navigation (2)

Re: [PATCH] Formatting patch for psql

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCH] Formatting patch for psql
Date: 2005-11-25 10:42:26
Message-ID: 20051125104222.GA16970@svana.org (view raw or flat)
Thread:
Lists: pgsql-patches
On Thu, Nov 24, 2005 at 09:23:55PM -0500, Tom Lane wrote:
> Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> > And what I'm saying is that you can only do that if all single byte
> > encodings are ASCII compatable and I'm not prepared to say that...
> 
> psql already assumes that; see the flex processor.

Hmm, Ok, I didn't realise that.

> > So in the switch statement I listed the encodings I know to be ASCII
> > compatable and at some point someone who actually knows the other
> > encodings will explain what needs to be done.
> 
> Even if this were an appropriate solution, the formatting code is not
> the place to put such knowledge...

It adds two functions to mbprint.c:

pg_wcssize   - To calculate the screen size required by the string (rows&cols)
pg_wcsformat - To actually format the text in the given lines

I agree that these should actually be operating system functions but we
can't rely on them. psql already has functions there for validating
UTF-8 and converting UTF-8 to UCS so it's in the right place in that
sense.

If you think it's better moved to libpq I can do that. There is a fair
bit of encoding code in there already but the information you need here
is specifically: is this char a control character and in particular, is
it a newline.

Most standard encoding implementations return a screen width of zero
for control characters, but we dont do that. I am hopeful once we have
ICU support we can do away with the enumeration since we can simply
read the Unicode Character database and get consistant results
everywhere for all encodings. But until that is done I think this is
the best we can do.

Have a nice day,
-- 
Martijn van Oosterhout   <kleptog(at)svana(dot)org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

pgsql-patches by date

Next:From: Tom LaneDate: 2005-11-25 14:58:21
Subject: Re: [PATCH] Formatting patch for psql
Previous:From: Tom LaneDate: 2005-11-25 02:23:55
Subject: Re: [PATCH] Formatting patch for psql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group