aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/tsquery_gist.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-02-06 15:44:57 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2023-02-06 15:45:03 -0500
commitcad56920513e5b7ccdd3d41b0ea893eb3383f863 (patch)
treed6e50b32e18f2a3ffca1ef7a51dcb06c90411c8c /src/backend/utils/adt/tsquery_gist.c
parent7ba09efe248fe5e15bd6d4c4d0612ea63b66a860 (diff)
downloadpostgresql-cad56920513e5b7ccdd3d41b0ea893eb3383f863.tar.gz
postgresql-cad56920513e5b7ccdd3d41b0ea893eb3383f863.zip
Fix up join removal's interaction with PlaceHolderVars.
The portion of join_is_removable() that checks PlaceHolderVars can be made a little more accurate and intelligible than it was. The key point is that we can allow join removal even if a PHV mentions the target rel in ph_eval_at, if that mention was only added as a consequence of forcing the PHV up to a join level that's at/above the outer join we're trying to get rid of. We can check that by testing for the OJ's relid appearing in ph_eval_at, indicating that it's supposed to be evaluated after the outer join, plus the existing test that the contained expression doesn't actually mention the target rel. While here, add an explicit check that there'll be something left in ph_eval_at after we remove the target rel and OJ relid. There is an Assert later on about that, and I'm not too sure that the case could happen for a PHV satisfying the other constraints, but let's just check. (There was previously a bms_is_subset test that meant to cover this risk, but it's broken now because it doesn't account for the fact that we'll also remove the OJ relid.) The real reason for revisiting this code though is that the Assert I left behind in 8538519db turns out to be easily reachable, because if a PHV of this sort appears in an upper-level qual clause then that clause's clause_relids will include the PHV's ph_eval_at relids. This is a mirage though: we have or soon will remove these relids from the PHV's ph_eval_at, and therefore they no longer belong in qual clauses' clause_relids either. Remove that Assert in join_is_removable, and replace the similar one in remove_rel_from_query with code to remove the deleted relids from clause_relids. Per bug #17773 from Robins Tharakan. Discussion: https://postgr.es/m/17773-a592e6cedbc7bac5@postgresql.org
Diffstat (limited to 'src/backend/utils/adt/tsquery_gist.c')
0 files changed, 0 insertions, 0 deletions