Re: problem with float8 input format
От | Tom Lane |
---|---|
Тема | Re: problem with float8 input format |
Дата | |
Msg-id | 23015.966098470@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: problem with float8 input format (Louis-David Mitterrand <cunctator@apartia.ch>) |
Список | pgsql-general |
Louis-David Mitterrand <cunctator@apartia.ch> writes: > where "date_part" comes from "date_part('epoch', stopdate)" in a > previous query. The problem is the value of stop_date is not the number > of seconds since the epoch but some internal representation of the data. > So I can't compare stop_date with the output of > GetCurrentAbsoluteTime(). GetCurrentAbsoluteTime yields an "abstime", so you should coerce the "timestamp" result of date_part() to abstime and then you will get a value you can compare directly. > What function should I use to convert the Datum to a C int? > DatumGetInt32 doesn't seem to work here. No, because timestamps are really floats. (abstime is an int though.) > And what is the method for float8 Datum conversion to C double? double x = * DatumGetFloat64(datum); This is pretty grotty because it exposes the fact that float8 datums are pass-by-reference (ie, pointers). 7.1 will let you write double x = DatumGetFloat8(datum); which is much cleaner. (I am planning that on 64-bit machines it will someday be possible for float8 and int64 to be pass-by-value, so it's important to phase out explicit knowledge of the representation in user functions.) regards, tom lane
В списке pgsql-general по дате отправления: