diff options
Diffstat (limited to 'src/backend/optimizer/path/equivclass.c')
-rw-r--r-- | src/backend/optimizer/path/equivclass.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c index 70e048c6e9c..2c2f5ca8144 100644 --- a/src/backend/optimizer/path/equivclass.c +++ b/src/backend/optimizer/path/equivclass.c @@ -285,11 +285,19 @@ process_equivalence(PlannerInfo *root, RestrictInfo *restrictinfo, } /* - * Case 2: need to merge ec1 and ec2. We add ec2's items to ec1, then - * set ec2's ec_merged link to point to ec1 and remove ec2 from the - * eq_classes list. We cannot simply delete ec2 because that could - * leave dangling pointers in existing PathKeys. We leave it behind - * with a link so that the merged EC can be found. + * Case 2: need to merge ec1 and ec2. This should never happen after + * we've built any canonical pathkeys; if it did, those pathkeys might + * be rendered non-canonical by the merge. + */ + if (root->canon_pathkeys != NIL) + elog(ERROR, "too late to merge equivalence classes"); + + /* + * We add ec2's items to ec1, then set ec2's ec_merged link to point + * to ec1 and remove ec2 from the eq_classes list. We cannot simply + * delete ec2 because that could leave dangling pointers in existing + * PathKeys. We leave it behind with a link so that the merged EC can + * be found. */ ec1->ec_members = list_concat(ec1->ec_members, ec2->ec_members); ec1->ec_sources = list_concat(ec1->ec_sources, ec2->ec_sources); |