Re: more custom C function fun

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Dan Heron Myers <heron(at)xnapid(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: more custom C function fun
Date: 2008-05-06 06:48:26
Message-ID: 20080506064826.GC19090@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, May 05, 2008 at 11:43:40PM -0600, Dan Heron Myers wrote:
> I have a custom C function that takes two text*s and returns a text*.
>
> text* calling_party = PG_GETARG_TEXT_P(0);
>
> char* thestr = VARDATA(calling_party);
> if(thestr[20] == ')')
> {
> PG_RETURN_TEXT_P(calling_party);
> }

You do realise that VARDATA does not return a null terminated string?
Try using something like text_to_cstring or using elog(NOTICE) to
display what's actually being compared.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Harald Armin Massa 2008-05-06 07:11:46 Re: Request for Materialized Views
Previous Message Alban Hertroys 2008-05-06 06:36:46 Re: operator is not unique: integer || integer