Re: Record returning function accept not matched columns declaration

Поиск
Список
Период
Сортировка
От PetSerAl
Тема Re: Record returning function accept not matched columns declaration
Дата
Msg-id CAKygsHQ3OiN46u+3a3_J-nCouSS4Jsvtfw-YW4=HW0rO7BTN8w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Record returning function accept not matched columns declaration  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Record returning function accept not matched columns declaration  ("Wetmore, Matthew (CTR)" <Matthew.Wetmore@evernorth.com>)
Список pgsql-bugs
postgres=# with a(b) as (values (row(1,2,3)))
postgres-# select * from a, coalesce(b);
ERROR:  a column definition list is required for functions returning "record"
LINE 2: select * from a, coalesce(b);
                         ^
postgres=#
postgres=# with a(b) as (values (row(1,2,3)))
postgres-# select * from a, nullif(b, null);
ERROR:  a column definition list is required for functions returning "record"
LINE 2: select * from a, nullif(b, null);
                         ^
postgres=#
postgres=# with a(b) as (values (row(1,2,3)))
postgres-# select * from a, unnest(array[b]);
ERROR:  a column definition list is required for functions returning "record"
LINE 2: select * from a, unnest(array[b]);
                         ^
postgres=#
postgres=# with a(b) as (values (row(1,2,3)))
postgres-# select * from a, json_populate_record(b, null);
ERROR:  a column definition list is required for functions returning "record"
LINE 2: select * from a, json_populate_record(b, null);
                         ^
postgres=#

It seems PostgreSQL does not care about function being polymorphic,
but only about return type being "record". It explicitly require
column definition list in all this cases.

пт, 1 мар. 2024 г. в 00:32, David G. Johnston <david.g.johnston@gmail.com>:
>
> On Thu, Feb 29, 2024 at 1:11 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>> "David G. Johnston" <david.g.johnston@gmail.com> writes:
>> > On Thursday, February 29, 2024, PetSerAl <petseral@gmail.com> wrote:
>> >> postgres=# with a(b) as (values (row(1,2,3)))
>> >> postgres-# select * from a, coalesce(b) as c(d int,e int, f int)
>> >> postgres-# union all
>> >> postgres-# select * from a, nullif(b, null) as c(d int,e int, f int)
>> >> postgres-# union all
>> >> postgres-# select * from a, unnest(array[b]) as c(d int,e int, f int)
>> >> postgres-# union all
>> >> postgres-# select * from a, json_populate_record(b, null) as c(d int,e
>> >> int, f int); --expect OK
>>
>> > My concern with all of this is accepting the specification of column
>> > definitions for functions that don’t return the record pseudo-type.
>>
>> Hm?  These cases all *do* return record, because that's what a.b is
>> typed as.
>
>
> I strongly dislike the seemingly overloaded terminology in this area.  Namely I was trying to distinguish these two
examplefunction signatures. 
>
> json_populate_record ( base anyelement, from_json json ) → anyelement
> jsonb_to_record ( jsonb ) → record
>
> Polymorphic functions do not require a column definition list.  The non-polymorphic function signature does require
thecolumn definition list.  That we accept a column definition list in the polymorphic case is settled code but seems
likeit led to this bug. 
>
> David J.



В списке pgsql-bugs по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Record returning function accept not matched columns declaration
Следующее
От: "Wetmore, Matthew (CTR)"
Дата:
Сообщение: Record returning function accept not matched columns declaration