Re: Unused CTE affects result set

2023-11-17 Thread Tom Lane
Adrian Klaver writes: > On 11/17/23 10:30 AM, Gabriel Sánchez wrote: >> 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 wh

Re: Unused CTE affects result set

2023-11-17 Thread Adrian Klaver
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

Unused CTE affects result set

2023-11-17 Thread Gabriel Sánchez
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,