Re: Unused CTE affects result set

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Unused CTE affects result set
Дата
Msg-id c535bd22-690f-418a-b956-a4d3602a7af4@aklaver.com
обсуждение исходный текст
Ответ на Unused CTE affects result set  (Gabriel Sánchez <gabrielesanchez@gmail.com>)
Ответы Re: Unused CTE affects result set
Список pgsql-general


On 11/17/23 10:30 AM, Gabriel Sánchez wrote:
Dear Postgres community,

I'm seeing unintuitive behavior with a query structured as follows:

WITH used_cte (SELECT a, b, c FROM t1 ...)
, unused_cte (SELECT d, e, f FROM t2 ...)
SELECT * FROM used_cte ...
-- returns no results

WITH used_cte (SELECT a, b, c FROM t1 ...)
-- , unused_cte (SELECT d, e, f FROM t2 ...)
SELECT * FROM used_cte ...
-- returns results

I don't understand why the presence of a CTE that ends up not being included in the final query affects the result set.  Could this be a bug, or is there something I don't understand?


I would say it has to do with what '...' is doing?

In other words I don't see this behavior here for a simple case.


PostgreSQL 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit

Thanks,
Gabriel


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

Предыдущее
От: Gabriel Sánchez
Дата:
Сообщение: Unused CTE affects result set
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Unused CTE affects result set