Re: printTable API (was: Show INHERIT in \du) - Mailing list pgsql-hackers

From Brendan Jurd
Subject Re: printTable API (was: Show INHERIT in \du)
Date
Msg-id 37ed240d0804030910j219a6b09x7b09fe4c4e9c2a03@mail.gmail.com
Whole thread Raw
In response to Re: printTable API (was: Show INHERIT in \du)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 31/03/2008, Tom Lane  wrote:
> "Brendan Jurd"  writes:
>  >  1. describe malloc's the cells to zero, but print just does a local
>  > calloc without any initialisation.
>
> There isn't any functional difference there.  I am not sure, but I think
>  the reason print.c has its own malloc wrappers instead of depending on
>  common.c's is that we use print.c in some bin/scripts/ programs that
>  do not want common.c too.
>

Yeah, it looks like createlang and droplang use print.c to emit a list
of installed languages.

>  >  2. describe only does an mbvalidate for WIN32, but print does it in all cases.
>
> I don't know why describe only does that for WIN32; it looks
>  inconsistent to me too.  Possibly some trolling in the CVS history would
>  give a clue about this.
>

Well, mbvalidate was originally added to print.c in 2001, as part of a
big patch to add multibyte support to psql [1].  However, it was only
added to describe much later (2003) in response to a bug report about
8-bit  characters not displaying correctly on the Windows console [2].I think that because the bug was only observed in
Windows,the patch
 
was added #ifdef WIN32, even though print.c was already using
mbvalidate for all content.

This nicely illustrates the nuisance inherent to duplication of code!

Based on this, I'm going to go ahead with using mbvalidate in all cases.

Cheers,
BJ

[1] http://repo.or.cz/w/PostgreSQL.git?a=commit;h=a428cef1
[2] http://repo.or.cz/w/PostgreSQL.git?a=commit;h=e6a16c17
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFH9QFt5YBsbHkuyV0RAv2ZAJ4/rfyjgFOh8XZo6aJo68dz5NsovQCgmf40
fCXMlsHdg1r4oTpfZD5DH+0=
=PrN1
-----END PGP SIGNATURE-----


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: psql \G command -- send query and output using extended format
Next
From: "Pavan Deolasee"
Date:
Subject: Re: [GENERAL] ANALYZE getting dead tuple count hopelessly wrong