dbTalk Databases Forums  

[BUGS] interval conversion bug

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


Discuss [BUGS] interval conversion bug in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andrzej Wojtaszek
 
Posts: n/a

Default [BUGS] interval conversion bug - 11-25-2004 , 08:59 AM






Hi,
=20
I'm afraid that operator ::interval not working propertly=20
example:
=20
select 1
######################
select now() + (1||' day')::interval;
working propertly
######################

I have my function writen in plpgsql

function test(varchar) returns varchar;=20

select 2
######################
select my_name,
test('12')
from table1
######################

returns 'aaa', '12 MONTH'=20

working propertly

select 3
######################
select my_name=20
now() + (test('12'))::interval
from table1
######################

not working with error "cannot cast type character varying to iterval"



Facts=20
Database version 7.4.5
psql version 7.4.5
platform PIV
linux : Debian

Regards

Andrzej Wojtaszek




---------------------------(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] interval conversion bug - 11-25-2004 , 10:30 AM






"Andrzej Wojtaszek" <Andrzej.Wojtaszek (AT) pro-futuro (DOT) com> writes:
Quote:
not working with error "cannot cast type character varying to iterval"
8.0 is more flexible about that, but for the moment use type text
instead of varchar.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Reply With Quote
  #3  
Old   
Stephan Szabo
 
Posts: n/a

Default Re: [BUGS] interval conversion bug - 11-25-2004 , 10:36 AM



On Thu, 25 Nov 2004, Andrzej Wojtaszek wrote:

Quote:
I'm afraid that operator ::interval not working propertly
example:

select 1
######################
select now() + (1||' day')::interval;
working propertly
######################
This is a text -> interval conversion

Quote:
select 3
######################
select my_name
now() + (test('12'))::interval
from table1
######################
This is a varchar -> interval conversion.

It looks like 7.4 doesn't have the latter conversion and requires you to
go through text to make the conversion. 8.0 appears to add direct
conversions from varchar.

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


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.