Re: type text in c functions - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: type text in c functions
Date
Msg-id 8230.1103426467@sss.pgh.pa.us
Whole thread Raw
In response to type text in c functions  ("Robert Wimmer" <seppwimmer@hotmail.com>)
List pgsql-interfaces
"Robert Wimmer" <seppwimmer@hotmail.com> writes:
>   text *t = PG_GETARG_TEXT_P(0);

>   l = VARSIZE(t) - VARHDRSZ;

>   for (i = 0; i < l; i++) { if ( (t->vl_dat[i] < '0') || (t->vl_dat[i] > 
> '9')) break; }

>   if (i==l) ret = 0;
>   else ret = i;

I think you need to rethink your return convention --- success and
failure at the first character both return 0.

Directly using the vl_dat field doesn't seem like good style (you won't
find it anywhere in the backend sources) but it works.
        regards, tom lane


pgsql-interfaces by date:

Previous
From: "Robert Wimmer"
Date:
Subject: type text in c functions
Next
From: atanu ghosh
Date:
Subject: which front - end tools will support in PostgreSQL