On Wed, 7 Feb 2024 at 12:05, Andy Fan <zhihuifan1...@163.com> wrote: > +static int > +pathkeys_useful_for_setop(PlannerInfo *root, List *pathkeys) > +{ > + int n_common_pathkeys; > + > + if (root->setop_pathkeys == NIL) > + return 0; /* no special setop > ordering requested */ > + > + if (pathkeys == NIL) > + return 0; /* unordered path */ > + > + (void) pathkeys_count_contained_in(root->setop_pathkeys, pathkeys, > + > &n_common_pathkeys); > + > + return n_common_pathkeys; > +} > > The two if-clauses looks unnecessary, it should be handled by > pathkeys_count_contained_in already. The same issue exists in > pathkeys_useful_for_ordering as well. Attached patch fix it in master.
I agree. I'd rather not have those redundant checks in pathkeys_useful_for_setop(), and I do want those functions to be as similar as possible. So I think adjusting it in master is a good idea. I've pushed your patch. David