Lists: | pgsql-bugs |
---|
From: | "Andrzej Wojtaszek" <Andrzej(dot)Wojtaszek(at)pro-futuro(dot)com> |
---|---|
To: | <pgsql-bugs(at)postgresql(dot)org> |
Subject: | interval conversion bug |
Date: | 2004-11-25 07:53:25 |
Message-ID: | s1a59d97.043@poczta.pro-futuro.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Hi,
I'm afraid that operator ::interval not working propertly
example:
select 1
######################
select now() + (1||' day')::interval;
working propertly
######################
I have my function writen in plpgsql
function test(varchar) returns varchar;
select 2
######################
select my_name,
test('12')
from table1
######################
returns 'aaa', '12 MONTH'
working propertly
select 3
######################
select my_name
now() + (test('12'))::interval
from table1
######################
not working with error "cannot cast type character varying to iterval"
Facts
Database version 7.4.5
psql version 7.4.5
platform PIV
linux : Debian
Regards
Andrzej Wojtaszek
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Andrzej Wojtaszek" <Andrzej(dot)Wojtaszek(at)pro-futuro(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: interval conversion bug |
Date: | 2004-11-25 16:25:34 |
Message-ID: | 29794.1101399934@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
"Andrzej Wojtaszek" <Andrzej(dot)Wojtaszek(at)pro-futuro(dot)com> writes:
> 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
From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Andrzej Wojtaszek <Andrzej(dot)Wojtaszek(at)pro-futuro(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: interval conversion bug |
Date: | 2004-11-25 16:32:44 |
Message-ID: | 20041125082954.N43320@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
On Thu, 25 Nov 2004, Andrzej Wojtaszek wrote:
> 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
> 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.