Re: understanding Datum -> char * -> Datum conversions
От | Louis-David Mitterrand |
---|---|
Тема | Re: understanding Datum -> char * -> Datum conversions |
Дата | |
Msg-id | 20000525124440.A11202@styx обсуждение исходный текст |
Ответ на | Re: understanding Datum -> char * -> Datum conversions (Karel Zak <zakkr@zf.jcu.cz>) |
Ответы |
Re: understanding Datum -> char * -> Datum conversions
|
Список | pgsql-hackers |
On Thu, May 25, 2000 at 12:03:55PM +0200, Karel Zak wrote: > > The problem is converting the Datum to a base C type in order to be able > > to modify it. > > > > in pgsql/contrib/spi/timetravel.c there is an example which modifies > > date columns and uses DatumGetInt32 to convert them. But this is > > confusing because (1) Tom Lane says that datetime columns are double and > > one should use DatumGetPointer (how do I use the pointer after?) and (2) > > DatumGetInt32 doesn't seem to return the number of seconds. > > See in PG's backend source files: > > c.h - for datetype definition and Datum macros, > we have Datum macros for double/float types too. > > buildin.h - for datetype conversion. > utils/timestamp.h ...etc. > > and directory utils/adt for inspiration "how work > with pg types :-) I'm reading these files but still got a problem: Datum price_datum; float new_price; new_price = 10.5; price_datum = Float32GetDatum(&new_price); SPI_modifytuple(relation, tupdesc, &attnum, &price_datum, NULL); ... and when I check the DB the new_price field contains a negative number, even though elog(NOTICE, ..., new_price) displays the correct value. If I could just understand how to correctly insert new_price it would really help a great deal in understanding. Thanks again, -- Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.fr There are three types of people in the world: those who can count, and those who can't.
В списке pgsql-hackers по дате отправления: