Avoid some other O(N^2) hazards in list manipulation.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: e9d9ba2a4ddc39e331dd8461b511aa59ec0dc8af
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2021-11-01T20:24:39Z
Releases: 15.0
Avoid some other O(N^2) hazards in list manipulation.

In the same spirit as 6301c3ada, fix some more places where we were
using list_delete_first() in a loop and thereby risking O(N^2)
behavior.  It's not clear that the lists manipulated in these spots
can get long enough to be really problematic ... but it's not clear
that they can't, either, and the fixes are simple enough.

As before, back-patch to v13.

Discussion: https://postgr.es/m/CD2F0E7F-9822-45EC-A411-AE56F14DEA9F@amazon.com

Files

PathChange+/−
contrib/pg_trgm/trgm_regexp.c modified +17 −8
src/backend/executor/nodeAgg.c modified +5 −12
src/backend/jit/llvm/llvmjit.c modified +5 −5

Discussion