Re: [HACKERS] Text <-> C string

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Text <-> C string
Date: 2008-05-04 16:49:15
Message-ID: 22724.1209919755@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

"Brendan Jurd" <direvus(at)gmail(dot)com> writes:
> Well ... if somebody does want to change the representation of xml
> down the road, he's going to have to touch all the sites where the
> code converts to and from cstring anyway, right?

True.

> With that in mind, please find attached my followup patch. It cleans
> up another 21 sites manually copying between cstring and varlena, for
> a net reduction of 115 lines of code.

I applied most of this, but not the parts that were dependent on the
assumption that bytea and text are the same. That is unlikely to remain
true if we ever get around to putting locale/encoding information into
text values. Furthermore it's a horrid type pun, because bytea can
contain embedded nulls whereas cstrings can't; you were making
unwarranted assumptions about whether, say, cstring_to_text_with_len
would allow embedded nulls to go by. And lastly, quite a few of those
changes were just plain broken, eg several places in selfuncs.c where
you allowed strlen() to be applied to a "bytea converted to cstring".

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-05-04 17:29:28 Re: Proposed Patch - LDAPS support for servers on port 636 w/o TLS
Previous Message Robert Treat 2008-05-04 15:13:47 Re: [PATCHES] GUC parameter cursors_tuple_fraction

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2008-05-04 17:55:29 Re: Patch for Prevent pg_dump/pg_restore from being affected by statement_timeout
Previous Message Robert Treat 2008-05-04 15:13:47 Re: [PATCHES] GUC parameter cursors_tuple_fraction