From: | Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu> |
---|---|
To: | Jim Mercer <jim(at)reptiles(dot)org> |
Cc: | "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu>, pgsql-general(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] getting at the actual int4 value of an abstime |
Date: | 1999-08-18 06:34:41 |
Message-ID: | 37BA5401.8C13B4EB@alumni.caltech.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general 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(at)alumni(dot)caltech(dot)edu
South Pasadena, California
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Boyle | 1999-08-18 06:45:54 | Re: [GENERAL] what is PgUpT ? |
Previous Message | Dan Wilson | 1999-08-18 02:03:16 | Re: [GENERAL] Never ending (for) loop |
From | Date | Subject | |
---|---|---|---|
Next Message | Ansley, Michael | 1999-08-18 07:55:21 | RE: [HACKERS] Problem with query length |
Previous Message | Bruce Momjian | 1999-08-18 03:31:48 | Re: [HACKERS] Re: [CORE] Re: tomorrow |