Re: [GENERAL] more custom C function fun

2008-05-06 Thread Martijn van Oosterhout
On Tue, May 06, 2008 at 09:39:50AM -0600, Dan Heron Myers wrote: > Using DatumToCString(mytextvariable), I get single-character-length > strings that do not match the data actually in the fields. Correct, because it's not a cstring. Pretending it is one gives you garbage. > Using VARDATA(mytextv

Re: [GENERAL] more custom C function fun

2008-05-06 Thread Dan "Heron" Myers
Martijn van Oosterhout wrote: You do realise that VARDATA does not return a null terminated string? I did not realize that... but it led me in the right direction. Try using something like text_to_cstring or using elog(NOTICE) to display what's actually being compared. I've outputted some

Re: [GENERAL] more custom C function fun

2008-05-05 Thread Martijn van Oosterhout
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] == ')') >

Re: [GENERAL] more custom C function fun

2008-05-05 Thread Dan "Heron" Myers
Harvey, Allan AC wrote: Try if(thestr[20] == 0x29) might reveal something in the parsing if it works. No effect. - Dan -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] more custom C function fun

2008-05-05 Thread Dan "Heron" Myers
I have a custom C function that takes two text*s and returns a text*. My problem is with this code: PG_FUNCTION_INFO_V1(get_agent); PGMODULEEXPORT Datum get_agent(PG_FUNCTION_ARGS) { if(!PG_ARGISNULL(0)) { text* calling_party = PG_GETARG_TEXT_P(0);