Thread: A mistake generates strange result
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.
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
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
Re: [GENERAL] A mistake generates strange result
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 !
Stéphane Dupille ha scritto:
Hi !This seems like a bug, because there's no a text(float8) built-in function."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 !
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 -