SV: [HACKERS] Re: [BUGS] agregate function sum error
От | Mattias Kregert |
---|---|
Тема | SV: [HACKERS] Re: [BUGS] agregate function sum error |
Дата | |
Msg-id | 199802241234.HAA14917@hub.org обсуждение исходный текст |
Список | 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 по дате отправления: