pg_plan_advice: Add CHECK_FOR_INTERRUPTS() and check_stack_depth()

Without CHECK_FOR_INTERRUPTS(), backends might not respond to query
cancellations in a timely fashion, especially for JOIN_ORDER()
specifications, where matching against each join can take O(n^2) time
in the length of the join order list in degenerate cases.

Recursive functions should check_stack_depth().

Reported-by: Noah Misch <[email protected]>
Discussion: 
https://postgr.es/m/ca+tgmoymxy-jip5qdhqneiyfebzqsaro6o2d9e8sznzqi1b...@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1129570f654e96d45bbc63397079171af29710b9

Modified Files
--------------
contrib/pg_plan_advice/pgpa_ast.c     | 14 ++++++++++++++
contrib/pg_plan_advice/pgpa_planner.c |  7 +++++++
contrib/pg_plan_advice/pgpa_trove.c   |  3 +++
3 files changed, 24 insertions(+)

Reply via email to