On 26/03/2008, Tom Lane <[EMAIL PROTECTED]> wrote:
>  There are no textout/textin calls left, but I may have missed some
>  places that were doing it the hard way with direct palloc/memcpy
>  manipulations.  It might be worth trolling all the VARDATA() references
>  to see if any more are easily replaceable.

I think there are perhaps a dozen such sites, and I hope to submit a
cleanup patch that gets rid of these soon.

I did come across one site I'm not sure about in utils/adt/xml.c:291

         * We need a null-terminated string to pass to parse_xml_decl().  Rather
         * than make a separate copy, make the temporary result one byte bigger
         * than it needs to be.
        result = palloc(nbytes + 1 + VARHDRSZ);
        SET_VARSIZE(result, nbytes + VARHDRSZ);
        memcpy(VARDATA(result), str, nbytes);
        str = VARDATA(result);
        str[nbytes] = '\0';

The author seemed pretty sure he didn't want to make a separate copy
of the string, so I'm thinking there's not a whole lot I can do to
improve this site.

>  I notice in particular that xfunc.sgml contains sample C functions to
>  copy and concatenate text.  While these aren't directly replaceable
>  with the new functions, I wonder whether we ought to change the examples
>  to make them less certain to break if we ever change text's
>  representation.

Yes, these sample C functions are shown in tutorial/funcs.c and
funcs_new.c as well.  I agree that the examples could do with
changing, but don't have any keen insight on what to change them to.

Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:

Reply via email to