Re: polymorphic types - enforce casting to most common type automatically

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: hlinnaka <hlinnaka(at)iki(dot)fi>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: polymorphic types - enforce casting to most common type automatically
Date: 2015-07-25 19:21:24
Message-ID: CAFj8pRASK21JKz-OOfE_1vL+5oh_DTj9aCUu9Y7Ru+PuW3V5OQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-07-22 10:37 GMT+02:00 Heikki Linnakangas <hlinnaka(at)iki(dot)fi>:

> On 07/11/2015 12:19 AM, Pavel Stehule wrote:
>
>> 2015-07-10 18:43 GMT+02:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>>
>> An example of what would presumably happen if we adopted this sort of
>>> rule
>>> (I've not checked whether the patch as written does this, but it would
>>> logically follow) is that appending a float to an integer array would
>>> cause the whole array to be silently promoted to float, with attendant
>>> possible loss of precision for existing array elements.
>>>
>>
>> it is based on select_common_type() - so it is use only available implicit
>> casts.
>>
>
> Without patch:
>
> postgres=# select pg_typeof(array_append('{1,2,3}'::int[], 1.2::float));
> ERROR: function array_append(integer[], double precision) does not exist
>
> With patch:
>
> postgres=# select pg_typeof(array_append('{1,2,3}'::int[], 1.2::float));
> pg_typeof
> --------------------
> double precision[]
> (1 row)
>
>
> Yeah, I agree with Tom that we don't want that change in behaviour. I'll
> mark this as rejected.
>

ok.

I accept it - it introduce incompatible changes.

Still I am sure, so this behave is some what users expect, but it should
not be introduced this way.

Any ideas how this issues can be solved?

Regards

Pavel

> - Heikki
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bill Moran 2015-07-25 19:41:10 Re: Anyone working on the TOAST items on the TODO list?
Previous Message Marc Mamin 2015-07-25 19:07:13 Re: pg_dump -Fd and compression level