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 !!!!!!

If you use: select ('12345678'::float8)::text;        everything runs well.



Mon, 8 Feb 1999 20:21:11 -0200
"Ricardo J.C.Coelho" <pulsar@truenet-ce.com.br>
A mistake generates strange result

How do I unsubscribe?

Sorry to post this to the entire list, but it your messages don't
have unsubscription info at the bottom, and the person who subscribed
(ckhui@school.net) isn't a valid user here (I am the postmaster).

-Joel Henderson
 postmaster@school.net




Mon, 8 Feb 1999 17:57:03 -0800 (PST)
Joel Parker Henderson <joel@school.net>
How do I unsubscribe?
I have a parallel inheritance going on,
so I was wondering if there was a way
to re-name a derived column?  This would
make my design clearer.
-----------------

CREATE TABLE B
( NAME VARCHAR(10) );

CREATE TABLE C
( ... ) INHERITS(B);

CREATE TABLE X
( 
   A VARCHAR(10),
   B VARCHAR(10),
   CONSTRAINT FOREIGN KEY (B) REFERENCES B(OID)
);

CREATE TABLE Y 
(  B AS C,              /* Syntatic Sugar */
   D VARCHAR(10),
   CONSTRAINT FOREIGN KEY (C) REFERENCES C(OID)
) INHERITS(X)


Here, I've added the syntax "AS" to show that
column A in table X, is called B in the 
derived table Y.

Thank you for your thoughts.

:) Clark Evans

Tue, 09 Feb 1999 04:40:06 +0000
Clark Evans <clark.evans@manhattanproject.com>
Using As with Inheritance?

	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 !

09 Feb 1999 09:55:23 +0100
sdupille@i-france.com (=?ISO-8859-1?Q?St=E9phane?= Dupille)
Re: [GENERAL] A mistake generates strange result
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 !
> 
> 


Wed, 10 Feb 1999 15:31:01 +0200 (IST)
Postgres DBA <postgres@nest.bistbn.com>
Re: [GENERAL] A mistake generates strange result
>>>> 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

Wed, 10 Feb 1999 10:11:26 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] Re: [GENERAL] A mistake generates strange result 
> 
> 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, Pennsylvania 19026

Wed, 10 Feb 1999 10:25:44 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] Re: [GENERAL] A mistake generates strange result
> 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' Soares
 when trying to cast a float to text.

                         - Tom

Wed, 10 Feb 1999 15:26:49 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [HACKERS] Re: [GENERAL] A mistake generates strange result
> 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

Wed, 10 Feb 1999 15:38:15 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [HACKERS] Re: [GENERAL] A mistake generates strange result
Stï¿½phane Dupille ha scritto:

>         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 !

This seems like a bug, because there's  no a text(float8) built-in function.

hygea=> select text('12345678'::float8);
text
----------------------
2000-05-22 23:21:18+02

but if you create the function like:

create function text(float8) returns text as
'
begin
        return $1;
end;
' language 'plpgsql';
CREATE

select text('12345678.2'::float8);
      text
----------
12345678.2
(1 row)


                               - Jose' -

And behold, I tell you these things that ye may learn wisdom; that ye may
learn that when ye are in the service of your fellow beings ye are only
in the service of your God.                - Mosiah 2:17 -



 
Stéphane Dupille ha scritto:
        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 !
This seems like a bug, because there's  no a text(float8) built-in
function.
hygea=> select text('12345678'::float8);
text
----------------------
2000-05-22 23:21:18+02
but if you create the function like:
create function text(float8) returns text as
'
begin
        return $1;
end;
' language 'plpgsql';
CREATE
select text('12345678.2'::float8);
      text
----------
12345678.2
(1 row)
 
                              
- Jose' -
And behold, I tell you these things that ye may learn wisdom; that
ye may
learn that when ye are in the service of your fellow beings ye
are only
in the service of your God.               
- Mosiah 2:17 -
Fri, 12 Feb 1999 15:06:50 +0100
"jose' soares" <sferac@bo.nettuno.it>
Re: [GENERAL] A mistake generates strange result