Re: Text <-> C string

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: "Gregory Stark" <stark(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Text <-> C string
Date: 2007-09-21 23:09:02
Message-ID: 27654.1190416142@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:
> I just noticed a couple of macros defined in src/include/tsearch/ts_utils.h:

> #define TextPGetCString(t)
> DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(t)))
> #define CStringGetTextP(c) DatumGetTextP(DirectFunctionCall1(textin,
> CStringGetDatum(c)))

> Seems these would actually be convenient in quite a lot of places in
> the backend. Is there any downside to moving these two into
> src/include/postgres.h?

I think if you look around you'll find several similar things in various
contrib modules. It would make some sense to try to unify all this.
I'm not particularly for making it macros in postgres.h though ---
that's no help if the macros require referencing stuff in builtins.h.

On grounds of code-space savings I think it might be worth making
these things be simple functions declared in builtins.h; that would
also make it much easier to change their implementations.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Guillaume Smet 2007-09-22 08:37:22 Re: like/ilike improvements
Previous Message Tom Lane 2007-09-21 22:53:56 Re: Eliminate more detoast copies for packed varlenas

Browse pgsql-patches by date

  From Date Subject
Next Message Guillaume Smet 2007-09-22 08:37:22 Re: like/ilike improvements
Previous Message Tom Lane 2007-09-21 22:53:56 Re: Eliminate more detoast copies for packed varlenas