Re: [HACKERS] Odd behavior of type coercion for datetime

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane)
Cc: lockhart(at)alumni(dot)caltech(dot)edu, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Odd behavior of type coercion for datetime
Date: 1999-03-15 14:37:03
Message-ID: 199903151437.JAA12447@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Have we dealt with this?

> With 6.4 or current sources, I find that coercing a datetime to float8
> is a no-op:
>
> treetest=> create table dt1 (t datetime);
> CREATE
> treetest=> insert into dt1 values('now');
> INSERT 159593 1
> treetest=> select t from dt1;
> t
> ----------------------------
> Sun Jan 24 18:28:50 1999 EST
> (1 row)
>
> treetest=> select t::float8 from dt1;
> ?column?
> ----------------------------
> Sun Jan 24 18:28:50 1999 EST
> (1 row)
>
>
> I was expecting to get either some numerical equivalent to the date
> (seconds since 1970 would do nicely, but I'll take the internal rep...)
> or an error message saying "no such conversion available". I was
> certainly not expecting to find that the result was still a datetime,
> but such it appears to be. This is a bug, wouldn't you say?
>
> What's even more curious is that coercing to int4 does produce
> something numeric:
>
> treetest=> select t::int4 from dt1;
> int4
> ---------
> -29464270
> (1 row)
>
>
> regards, tom lane
>
>

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-03-15 14:37:47 Re: [HACKERS] Another speedup idea (two, even)
Previous Message Peter Mount 1999-03-15 14:32:12 RE: [HACKERS] ICQ?