pgsql: Add some recursion and looping defenses in prepjointree.c. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Add some recursion and looping defenses in prepjointree.c.
Date
Msg-id E1p8NbP-004t6l-4x@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Add some recursion and looping defenses in prepjointree.c.

Andrey Lepikhov demonstrated a case where we spend an unreasonable
amount of time in pull_up_subqueries().  Not only is that recursing
with no explicit check for stack overrun, but the code seems not
interruptable by control-C.  Let's stick a CHECK_FOR_INTERRUPTS
there, along with sprinkling some stack depth checks.

An actual fix for the excessive time consumption seems a bit
risky to back-patch; but this isn't, so let's do so.

Discussion: https://postgr.es/m/703c09a2-08f3-d2ec-b33d-dbecd62428b8@postgrespro.ru

Branch
------
REL_12_STABLE

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

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 12 ++++++++++++
1 file changed, 12 insertions(+)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Add some recursion and looping defenses in prepjointree.c.
Next
From: Tom Lane
Date:
Subject: pgsql: Avoid O(N^2) cost when pulling up lots of UNION ALL subqueries.