Failure to coerce unknown type to specific type

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема Failure to coerce unknown type to specific type
Дата
Msg-id CAMp0ubdECGUJWpQKyUM36PxQWoKe0VfTbHGHgn+w2H_5q1Nmow@mail.gmail.com
обсуждение исходный текст
Ответы Re: Failure to coerce unknown type to specific type  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Original report and patch by Karl Schnaitter.

create table a(u) as select '1';
create table b(i int);
insert into b select u from a;
ERROR:  failed to find conversion function from unknown to integer

SELECT a=b FROM (SELECT ''::text, '  ') x(a,b);
ERROR:  failed to find conversion function from unknown to text

The strange thing about these cases are that can_coerce_type returns
true, but coerce_type fails.

This can be fixed by a small change (attached) to find_coercion_pathway to add:

    else if (sourceTypeId == UNKNOWNOID)
        result = COERCION_PATH_COERCEVIAIO;

I don't see any big problem with doing this, because we've already
done the type inference; it's just a question of whether we succeed or
fail when we try to apply it. I don't see any reason to fail a cast
from unknown to something else.

However, this still doesn't fix a more complex case like:

create table tt(x text primary key);
create table ut(x unknown, foreign key(x) references tt);
insert into tt values('');
insert into ut values('');
update ut set x = x;

Regards,
     Jeff Davis

Вложения

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

Предыдущее
От: Jeff Janes
Дата:
Сообщение: Re: BUG #13002: VACUUM to prevent wraparound blocks TRUNCATE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Failure to coerce unknown type to specific type