| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | ldm(at)apartia(dot)com |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: understanding Datum -> char * -> Datum conversions |
| Date: | 2000-05-24 21:53:57 |
| Message-ID: | 9050.959205237@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Louis-David Mitterrand <cunctator(at)apartia(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2000-05-24 21:54:24 | Re: setproctitle() |
| Previous Message | Peter Eisentraut | 2000-05-24 21:50:39 | Re: Serious problem within authentication subsystem in 7.0 |