I found an example of a casting problem in our source code now that we're
running 7.3:

SELECT CURRENT_DATE - EXTRACT(DOW FROM CURRENT_DATE);

(Get's the start of the week);

This worked in 7.2, but fails in 7.3 with:

ERROR: Unable to identify an operator '-' for types 'date' and 'double
precision' You will have to retype this query using an explicit cast

I'm not sure really why DOW needs to be double precision, but hey...

I guess this isn't so important, as there are workarounds (which are
complicated...)

Chris




Mon, 3 Feb 2003 10:54:07 +0800
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
7.2 -> 7.3 incompatibility
Christopher Kings-Lynne writes:

> I found an example of a casting problem in our source code now that we're
> running 7.3:
>
> SELECT CURRENT_DATE - EXTRACT(DOW FROM CURRENT_DATE);

A mathematically sound way to write this would be:

select current_date - extract(dow from current_data) * interval '1 day';

> I'm not sure really why DOW needs to be double precision, but hey...

Extract returns double precision.  It can't morph itself based on the
argument type at run time.

-- 
Peter Eisentraut   peter_e@gmx.net


Mon, 10 Feb 2003 20:13:12 +0100 (CET)
Peter Eisentraut <peter_e@gmx.net>
Re: 7.2 -> 7.3 incompatibility
On Mon, 2003-02-10 at 19:13, Peter Eisentraut wrote:
> Christopher Kings-Lynne writes:
> 
> > I found an example of a casting problem in our source code now that we're
> > running 7.3:
> >
> > SELECT CURRENT_DATE - EXTRACT(DOW FROM CURRENT_DATE);
> 
> A mathematically sound way to write this would be:
> 
> select current_date - extract(dow from current_data) * interval '1 day';
> 
> > I'm not sure really why DOW needs to be double precision, but hey...
> 
> Extract returns double precision.  It can't morph itself based on the
> argument type at run time.

Is this mandates by ANSI ?

PostgreSQL _does_ select function based on argument type

hannu=# create function f(int) returns int as 'select 1' language 'sql';
CREATE
hannu=# create function f(int,int) returns float as 'select 3.1415927'
language 'sql';
CREATE
hannu=# select f(1),f(1,1);
 f |     f     
---+-----------
 1 | 3.1415927
(1 row)

-- 
Hannu Krosing <hannu@tm.ee>

11 Feb 2003 11:15:33 +0000
Hannu Krosing <hannu@tm.ee>
Re: 7.2 -> 7.3 incompatibility