pgsql: Revise make_partition_pruneinfo to not use its partitioned_rels

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Revise make_partition_pruneinfo to not use its partitioned_rels
Date: 2021-02-01 19:44:19
Message-ID: E1l6f7T-0002ip-Vx@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Revise make_partition_pruneinfo to not use its partitioned_rels input.

It turns out that the calculation of [Merge]AppendPath.partitioned_rels
in allpaths.c is faulty and sometimes omits relevant non-leaf partitions,
allowing an assertion added by commit a929e17e5a8 to trigger. Rather
than fix that, it seems better to get rid of those fields altogether.
We don't really need the info until create_plan time, and calculating
it once for the selected plan should be cheaper than calculating it
for each append path we consider.

As a first step, teach make_partition_pruneinfo to collect the relevant
partitioned tables for itself. It's not hard to do so by traversing
from child tables up to parents using the AppendRelInfo links.

While here, make some minor stylistic improvements; mainly, don't use
the "Relids" alias for bitmapsets that are not identities of any
relation considered by the planner. Try to document the logic better,
too.

No backpatch, as there does not seem to be a live problem before
a929e17e5a8. Also no new regression test; the code where the bug
was will be gone at the end of this patch series, so it seems a
bit pointless to memorialize the issue.

Tom Lane and David Rowley, per reports from Andreas Seltenreich
and Jaime Casanova.

Discussion: https://postgr.es/m/87sg8tqhsl.fsf@aurora.ydns.eu
Discussion: https://postgr.es/m/CAJKUy5gCXDSmFs2c=R+VGgn7FiYcLCsEFEuDNNLGfoha=pBE_g@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fb2d645dd53ff571572d830e830fc8c368063802

Modified Files
--------------
src/backend/partitioning/partprune.c | 199 ++++++++++++++++++++++++++---------
1 file changed, 149 insertions(+), 50 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2021-02-01 19:44:20 pgsql: Remove [Merge]AppendPath.partitioned_rels.
Previous Message Peter Eisentraut 2021-02-01 13:53:37 pgsql: SEARCH and CYCLE clauses