Postgres 10 problem with UNION ALL of null value in "subselect"

Поиск
Список
Период
Сортировка
От Martin Swiech
Тема Postgres 10 problem with UNION ALL of null value in "subselect"
Дата
Msg-id CAGtQ-WpqM=BPiNZQK66wtHaxvFxYdPZ68-baKiS26UZDg5HxQA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Postgres 10 problem with UNION ALL of null value in "subselect"  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Список pgsql-hackers
Hi folks,

I got some complex query which works on PostgreSQL 9.6 , but fails on PostgreSQL 10.

Version of PostgreSQL:
PostgreSQL 10.3 on x86_64-apple-darwin14.5.0, compiled by Apple LLVM version 7.0.0 (clang-700.1.76), 64-bit

Simplified core of the problematic query looks like this:
```
select * from (
   select 1::integer as a
) t1
union all 
select * from (
   select null as a
) t2;
```

It fails with this error message:
```
ERROR:  UNION types integer and text cannot be matched
LINE 5: select * from (
               ^
SQL state: 42804
Character: 66
```


It worked on PostgreSQL 9.6.


Query without wrapping subselects (t1 and t2) works on both versions of PostgreSQL (9.6 and 10) well:
```
select 1::integer as a
union all 
select null as a;
```


Is there some new optimization of query processing in PostgreSQL 10, which needs some "early type determination", but named subselects (t1 and t2) shades the type from first query?

Or could it be some regression bug?

Thanks for answer.

Martin Swiech

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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: very slow queries when max_parallel_workers_per_gather is higher than zero
Следующее
От: Emre Hasegeli
Дата:
Сообщение: Re: Prefix operator for text and spgist support