dbTalk Databases Forums  

[BUGS] Cast possible only throught a function

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] Cast possible only throught a function in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mendola Gaetano
 
Posts: n/a

Default [BUGS] Cast possible only throught a function - 07-26-2003 , 05:02 AM






Hi all,
running on Postgres 7.3.3
I seen that cast a integer to an intervall is not permitted

select 0::interval; <- give error

but

select 0::text::interval; <- works fine

but I notice that the following function return correctly
doing the integer -> interval cast in one "shot":

create or replace function foo()
returns interval as '
declare
begin
return 0;
end;
' language 'plpgsql';



this implicit cast could not be source of issue ?


Gaetano





---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Cast possible only throught a function - 07-26-2003 , 09:11 AM






"Mendola Gaetano" <mendola (AT) bigfoot (DOT) com> writes:
Quote:
but I notice that the following function return correctly
doing the integer -> interval cast in one "shot":
What plpgsql is doing is roughly comparable to

regression=# select '0'::interval;
interval
----------
00:00:00
(1 row)

This is not the same as a SQL type conversion --- that works only when a
cast function is defined in pg_cast.

plpgsql is pretty lax about datatype considerations. It is willing to
try to convert anything to anything else by running the first type's
output procedure (to get text) and then the second type's input
procedure. In straight SQL you'd have to specify a cast to text to
get the equivalent behavior.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.