SV: [HACKERS] Re: [BUGS] agregate function sum error - Mailing list pgsql-hackers

From Mattias Kregert
Subject SV: [HACKERS] Re: [BUGS] agregate function sum error
Date
Msg-id 199802241234.HAA14917@hub.org
Whole thread Raw
List pgsql-hackers
> End users hate uneccessaries or non sense messages like the following
> when he/she writes a sentence like this:
>
>         UPDATE my_table SET my_int=my_small;
>
> and PostgreSQL show him/her this message ?
> ---------------------------------------------------------------------
> WARN: type of my_small does not match target column my_int
> ---------------------------------------------------------------------
> - What message is this ? If PostgreSQL understand that I want to do:
>    UPDATE my_table SET my_int=my_small::int4;
> why it doesn't do that for me?
>
>          SELECT my_small * my_float FROM my_table;
> ---------------------------------------------------------------------
> NOTICE:there is no operator * for types int2 and float8
> NOTICE:You will either have to retype this query using an
> NOTICE:explicit cast, or you will have to define the operator
> WARN:* for int2 and float8 using CREATE OPERATOR
> ---------------------------------------------------------------------
>
> - Well, if PostgreSQL know what I want why it doesn't do it for me ?
> I know that conversion is more expensive than warnning but it's more
> friendly. What do you think? ;-)

Yes, this is very annoying. If I do:
  psql=> select my_small * my_float from my_table;

then my_small should be promoted to float automagically.

PostgreSQL should rewrite this as "select my_small::float * my_float from
my_table"
so that numeric expressions always returns the "biggest" type involved.
In most programmig languages, this is done automatically, and should be
done
in PostgreSQL for all calculations.


/* m */


pgsql-hackers by date:

Previous
From: Michael Meskes
Date:
Subject: ecpg news
Next
From: jwieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] Re: [COMMITTERS] 'pgsql/src/bin/initdb initdb.sh'