Обсуждение: Re: [GENERAL] A mistake generates strange result

Поиск
Список
Период
Сортировка

Re: [GENERAL] A mistake generates strange result

От
Postgres DBA
Дата:
Unfortunately, that is true, at least for Postgres 6.4.0:
template1=> select text('12345678'::float8);

text                         
-----------------------------
Tue May 23 00:21:18 2000 EEST
(1 row)

Please, guys, take care of this small bug:-)
Aleksey

On 9 Feb 1999, [ISO-8859-1] St�phane Dupille wrote:

> 
>     Hi !
> 
> "Ricardo J.C.Coelho" <pulsar@truenet-ce.com.br> writes:
> > Just for PgSQL's development group think about....
> > I made a mistake typing a query that generates a strange result
> > (Very strange). 
> 
> > The query: select text('12345678'::float8);
> > It returns a date in datetime format !!!!!!
> 
>     I didn't found any function of name "text" that converts
> float8 to text. So I think Postgres made an implicit cast of the data
> to datatime. So: String->Float8->DateTime->Text. Stranger : I didn't
> found any function to cinvert float to text !
> 
> > If you use: select ('12345678'::float8)::text;        everything runs well.
> 
>     Here, you made an explicit cast, without the use of any
> function. So your data is casted well.
> 
>     Hope this helps !
> 
> 



Re: [HACKERS] Re: [GENERAL] A mistake generates strange result

От
Tom Lane
Дата:
>>>> The query: select text('12345678'::float8);
>>>> It returns a date in datetime format !!!!!!

Yup, I see it here also with 6.4.2.

The current development sources seem OK however:

regression=> select text('12345678'::float8);   text
--------
12345678
(1 row)

So it should be fixed in 6.5.  (Thomas, could this be back-patched
into 6.4.3?)
        regards, tom lane


Re: [HACKERS] Re: [GENERAL] A mistake generates strange result

От
"Thomas G. Lockhart"
Дата:
> Unfortunately, that is true, at least for Postgres 6.4.0:
> template1=> select text('12345678'::float8);
> -----------------------------
> Tue May 23 00:21:18 2000 EEST
> Please, guys, take care of this small bug:-)

tgl=> select text('12345678'::float8);   text
--------
12345678
(1 row)

Already done. From the cvs log:

revision 1.84
date: 1998/11/17 14:36:51;  author: thomas;  state: Exp;  lines: +34 -15
Add text<->float8 and text<->float4 conversion functions.
This will fix the problem reported by Jose' Soareswhen trying to cast a float to text.
                        - Tom


Re: [HACKERS] Re: [GENERAL] A mistake generates strange result

От
Bruce Momjian
Дата:
> 
> Unfortunately, that is true, at least for Postgres 6.4.0:
> template1=> select text('12345678'::float8);
> 
> text                         
> -----------------------------
> Tue May 23 00:21:18 2000 EEST
> (1 row)
> 
> Please, guys, take care of this small bug:-)
> Aleksey

Works in the current tree:

test=> select text('12345678'::float8);   text
--------
12345678
(1 row)

test=>


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


Re: [HACKERS] Re: [GENERAL] A mistake generates strange result

От
"Thomas G. Lockhart"
Дата:
> So it should be fixed in 6.5.  (Thomas, could this be back-patched
> into 6.4.3?)

Not likely, since it defined a couple of new procedures in the system
tables to do explicit string to float8 conversions. 

The only v6.4.3-compatible patch we can make is to remove the "binary
equivalence" between datetime and float8, which I had put in to allow
more date arithmetic (a lazy solution, but it seemed a good idea at the
time :/ I have a patch to do that, but have not applied it to either
tree yet.
                   - Tom