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.
> 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.
regards, tom lane