| From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
|---|---|
| To: | Alexander Lakhin <exclusion(at)gmail(dot)com> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs |
| Date: | 2025-11-04 09:54:37 |
| Message-ID: | CAApHDvrHPnPFYHprOBSAVZp8BjNBoFtbPuKZrJt8tvSRR6SV4Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, 4 Nov 2025 at 21:00, Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:
> Please look at a new anomaly, introduced with 03d40e4b5:
> CREATE TABLE t(i integer);
> CREATE TABLE pt(i integer) PARTITION BY LIST(i);
>
> SET enable_seqscan = 'off';
> SELECT * FROM t UNION SELECT * FROM t
> UNION ALL
> SELECT * FROM pt;
> produces:
> ERROR: XX000: unrecognized node type: 0
Thanks for the report.
This seems to be due to the fact that the same UPPERREL_SETOP
RelOptInfo is being used for the UNION and UNION ALL. When doing the
add_path() for the UNION ALL at prepunion.c:1030, the sole child path
of the Append being added is an AggPath for the previous UNION
operation. When we add_path() the AppendPath, the previous AggPath is
already in the pathlist of the result_rel. add_path() ends up freeing
the old Path due to the new AppendPath being better and the end result
is the Append's subpath is free'd.
The reason we end up with the same result_rel is that we're not
passing all the relids in fetch_upper_rel(root, UPPERREL_SETOP,
relids) due to having removed dummy rels. I guess the fix might be
something like record the relids even when skipping dummy relations.
I'll go and explore that as an option.
David
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2025-11-04 09:59:27 | Re: pg_createsubscriber --dry-run logging concerns |
| Previous Message | shveta malik | 2025-11-04 09:47:18 | Re: How can end users know the cause of LR slot sync delays? |