Re: [PATCHES] Text <-> C string - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCHES] Text <-> C string
Date
Msg-id 22724.1209919755@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCHES] Text <-> C string  ("Brendan Jurd" <direvus@gmail.com>)
List pgsql-hackers
"Brendan Jurd" <direvus@gmail.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

pgsql-hackers by date:

Previous
From: Robert Treat
Date:
Subject: Re: [PATCHES] GUC parameter cursors_tuple_fraction
Next
From: Tom Lane
Date:
Subject: Re: Proposed Patch - LDAPS support for servers on port 636 w/o TLS