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

Re: [HACKERS] Text <-> C string

From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Text <-> C string
Date: 2008-04-16 21:19:55
Message-ID: 37ed240d0804161419h9d84f4bkfef2edb4966d23ef@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Apr 17, 2008 at 1:16 AM, Tom Lane  wrote:
> "Brendan Jurd"  writes:
>
> >> If we don't want to meddle with xmltype/bytea/VarChar at all, we'll
>  >> have to revert those changes, and I'll have to seriously scale back
>  >> the cleanup patch I was about to post.
>
>  > Still not sure where we stand on the above.  To cast, or not to cast?
>
>  I dunno.  I know there was previously some handwaving about representing
>  XML values in some more intelligent fashion than a plain text string,
>  but I have no idea if anyone is likely to do anything about it in the
>  foreseeable future.
>

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?

So the only real difference this will make is that, instead of having
to replace four lines of VARDATA/memcpy per site, he'll have to
replace a single function call.  That doesn't seem like a negative.

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 didn't attempt to work through every reference to VARDATA, but I did
look at every hit from a  `grep -Rn VARDATA . | grep memcpy`.

All regression tests passed (contrib tests included) on gentoo.

Patch added to commitfest queue.

Cheers,
BJ
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFIBm105YBsbHkuyV0RAmqfAKCfyNyFdciqX4QV81sG9MhPt+KXuACfe694
3d/ICZF6yqV6K20X3TVX+So=
=CvRM
-----END PGP SIGNATURE-----

Attachment: text-cstring-followup.diff.bz2
Description: application/x-bzip2 (3.3 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2008-04-16 21:22:17
Subject: Re: Timely reporting of COPY errors
Previous:From: Tom LaneDate: 2008-04-16 21:03:39
Subject: Re: Lessons from commit fest

pgsql-patches by date

Next:From: Alvaro HerreraDate: 2008-04-16 21:27:46
Subject: Re: printTable API (was: Show INHERIT in \du)
Previous:From: Joshua D. DrakeDate: 2008-04-16 18:21:51
Subject: Re: Patch for Prevent pg_dump/pg_restore from being affected by statement_timeout

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