Re: understanding Datum -> char * -> Datum conversions

Поиск
Список
Период
Сортировка
От Louis-David Mitterrand
Тема Re: understanding Datum -> char * -> Datum conversions
Дата
Msg-id 20000525114056.A10653@styx
обсуждение исходный текст
Ответ на Re: understanding Datum -> char * -> Datum conversions  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: understanding Datum -> char * -> Datum conversions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Wed, May 24, 2000 at 05:53:57PM -0400, Tom Lane wrote:
> Louis-David Mitterrand <cunctator@apartia.ch> writes:
> > What I am trying to do for instance is:
> > - read a ::text colum with SPI_getbinval(),
> > - convert it to a char*,
> > - modify it,
> > - convert it back to a Datum,
> > - reinsert it into the tuple through SPI_modifytuple,
> 
> > The conversions involve some pointer magic and casting that I really
> > don't grasp.
> 
> Casting doesn't do it.  Use text_out() to produce a null-terminated C
> string from a text Datum, and use text_in() to create a new text Datum
> after you've modified the string.

I can't find these functions anywhere in the included .h files. Where
should I look?

> > Also I am trying to read a timestamp with SPI_getbinval and get the
> > number of seconds contained. Using DatumGetInt32 doens't seem to do it.
> 
> Timestamp is a double not an int ... and the datum is actually a pointer
> to it.

But for example I am trying to read the result from a "SELECT
date_part('epoch', now())" which returns a number of seconds since the
epoch and I can't find a way to obtain that value through SPI_getbinval,
I have to retrieve it through SPI_getvalue and use atoi() to convert it.
I'd rather access directly the native type instead.

Which DatumGet* function should I use there?

Thanks,

-- 
Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.fr


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

Предыдущее
От: Zeugswetter Andreas SB
Дата:
Сообщение: AW: Last call for comments: fmgr rewrite [LONG]
Следующее
От: Zeugswetter Andreas SB
Дата:
Сообщение: AW: SQL3 UNDER