Re: [HACKERS] getting at the actual int4 value of an abstime
От | Thomas Lockhart |
---|---|
Тема | Re: [HACKERS] getting at the actual int4 value of an abstime |
Дата | |
Msg-id | 37BA5401.8C13B4EB@alumni.caltech.edu обсуждение исходный текст |
Ответ на | getting at the actual int4 value of an abstime (jim@reptiles.org (Jim Mercer)) |
Ответы |
Re: [HACKERS] getting at the actual int4 value of an abstime
|
Список | pgsql-hackers |
> > i have a table which uses an abstime to store a time/date. > > the data originates as unix time_t > > i want to get the results of a select as unix time_t, without having > > to use the expensive mktime()/strptime() unix C calls. > > is there a way to get the int4 value that postgres is storing raw > > for abstime? postgres=> select date_part('epoch', timefield) from timetest; date_part --------- 934957840 (1 rows) > test=> select timefield::int4 from timetest; > ?column? > ---------------------------- > Tue Aug 17 18:13:23 1999 CDT > Hmm, this looks like a bug. I'm guessing we're storing and int8, and the > conversion fails, so falls back to the default text output? Probably not. Abstime is internally stored as 4 bytes, roughly the same as int4, and so Postgres is swallowing the conversion since it thinks they are equivalent. But the output conversion is not equivalent. > test=> select timefield::int8 from timetest; > int8 > --------- > 934931603 > What version of PostgreSQL, BTW? This is 6.5: int8 and numeric support got a > lot better vs. 6.4 Trying to force a conversion to some other data type works, since the conversion isn't swallowed by Postgres. The int4 behavior should count as a bug... - Thomas -- Thomas Lockhart lockhart@alumni.caltech.edu South Pasadena, California
В списке pgsql-hackers по дате отправления: