An addition to 8c441c08279
authorAlexander Korotkov <akorotkov@postgresql.org>
Tue, 9 Jan 2024 08:12:14 +0000 (10:12 +0200)
committerAlexander Korotkov <akorotkov@postgresql.org>
Tue, 9 Jan 2024 08:12:14 +0000 (10:12 +0200)
Given that now SJE doesn't work with result relation, turn a code dealing with
that into an assert that it shouldn't happen.

src/backend/optimizer/plan/analyzejoins.c

index 1f2167a11de9af42c7fb2b02c0adfef8a3c93ef5..8a2ccbb6047152607180ac0269a12217d461a9b5 100644 (file)
@@ -1900,8 +1900,10 @@ remove_self_join_rel(PlannerInfo *root, PlanRowMark *kmark, PlanRowMark *rmark,
        /* Replace varno in all the query structures */
        query_tree_walker(root->parse, replace_varno_walker, &ctx,
                                          QTW_EXAMINE_SORTGROUP);
-       if (root->parse->resultRelation == toRemove->relid)
-               root->parse->resultRelation = toKeep->relid;
+
+       /* See remove_self_joins_one_group() */
+       Assert(root->parse->resultRelation != toRemove->relid);
+       Assert(root->parse->resultRelation != toKeep->relid);
 
        /* Replace links in the planner info */
        remove_rel_from_query(root, toRemove, toKeep->relid, NULL, NULL);