From 331118eeef315a03e89a98187ada3c207c907d40 Mon Sep 17 00:00:00 2001 From: ChenHui Mo Date: Mon, 21 Sep 2026 17:00:17 +0000 Subject: [RFC PATCH v1 1/2] Handle pre-existing anti joins in sublink pull-up A query-tree transformation can introduce an anti join before the usual SubLink pull-up pass. Currently that pass rejects a pre-existing JOIN_ANTI node as an unrecognized join type. Continue processing its inputs, but leave SubLinks in the anti join's ON condition for expression preprocessing. This follows the conservative handling already used for FULL join conditions and provides the preprocessing support needed by the following FULL join decomposition patch. --- src/backend/optimizer/prep/prepjointree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index dfe320b..aa9c39e 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -794,8 +794,9 @@ pull_up_sublinks_jointree_recurse(PlannerInfo *root, Node *jtnode, * point of the available_rels machinations is to ensure that we only * pull up quals for which that's okay. * - * We don't expect to see any pre-existing JOIN_SEMI, JOIN_ANTI, + * We don't expect to see any pre-existing JOIN_SEMI, * JOIN_RIGHT_SEMI, or JOIN_RIGHT_ANTI jointypes here. + * FULL join decomposition can introduce JOIN_ANTI before this pass. */ switch (j->jointype) { @@ -813,7 +814,8 @@ pull_up_sublinks_jointree_recurse(PlannerInfo *root, Node *jtnode, NULL, NULL); break; case JOIN_FULL: - /* can't do anything with full-join quals */ + case JOIN_ANTI: + /* Leave full/anti join SubLinks to expression preprocessing. */ break; case JOIN_RIGHT: j->quals = pull_up_sublinks_qual_recurse(root, j->quals, base-commit: 9e17d25e79d4756be08b4a5521b4b58450217137 -- 2.51.1