Re: Creating server-side functions: one simple error

Поиск
Список
Период
Сортировка
От Ruslan A Dautkhanov
Тема Re: Creating server-side functions: one simple error
Дата
Msg-id 3DA54B87.A1929305@scn.ru
обсуждение исходный текст
Ответ на Creating server-side functions: one simple error  (Ruslan A Dautkhanov <rusland@scn.ru>)
Ответы Re: Creating server-side functions: one simple error  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Joe Conway wrote:

> Ruslan A Dautkhanov wrote:
> > Btw, how I can convert TEXT field to a CString one? I had tried to use
> >   char *cnum = PG_GETARG_CSTRING(0)  instead of
> >   text tnum = PG_GETARG_NAME(0),   but it's not worked properly. Is any function
> > to convert text object to a null-terminated string??? Thanks again.
> >
>
> I like to use the following macros:
>
> /* convert C string to text pointer */
> #define GET_TEXT(cstrp) \
>      DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(cstrp)))
> /* convert text pointer to C string */
> #define GET_STR(textp) \
>      DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp)))
>
> then you can do, e.g.
>    char   *cnum = GET_STR(PG_GETARG_TEXT_P(0));

    Thanks, this worked good. I had finished testing of creating
server-side functions and starts creating my business-oriented things on
SPI, and I have trap again - I can't translate datetime column, which
pass to my procedure. I must convert it to UNIX 1970-seconds counter for
my internal needs, but I havn't found _any_ PG_GETARG_* function in fmgr.h,
which can read time types as procedure's arguments. Sorry for this question,
but PG_GETARG_* function is not documented anywhere...


---
  best regards,
Ruslan A Dautkhanov   rusland@scn.ru

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: Creating server-side functions: one simple error
Следующее
От: Elielson Fontanezi
Дата:
Сообщение: user name lost from dictionary