Hi Tom:
Thanks for your reply! I add  logs like this:
            if (bms_is_subset(sjinfo->min_lefthand, rel1->relids) &&
                  bms_is_subset(sjinfo->min_righthand, rel2->relids))
            {
                  if (match_sjinfo) {
                        elog(LOG, "gunkris111111111111");
                        return false;     /* invalid join path */
                  }
                  match_sjinfo = sjinfo;
                  reversed = false;
            }
            else if (bms_is_subset(sjinfo->min_lefthand, rel2->relids) &&
                         bms_is_subset(sjinfo->min_righthand, rel1->relids))
            {
                  if (match_sjinfo) {
                        elog(LOG, "gunkris222222222222");
                        return false;     /* invalid join path */
                  }
                  match_sjinfo = sjinfo;
                  reversed = true;
            }
            else if (sjinfo->jointype == JOIN_SEMI &&
                         bms_equal(sjinfo->syn_righthand, rel2->relids) &&
                         create_unique_path(root, rel2, 
rel2->cheapest_total_path,
                                                      sjinfo) != NULL)
            {

                  if (match_sjinfo) {
                        elog(LOG, "gunkris33333333333333");
                        return false;     /* invalid join path */
                  }
                  match_sjinfo = sjinfo;
                  reversed = false;
                  unique_ified = true;
            }
            else if (sjinfo->jointype == JOIN_SEMI &&
                         bms_equal(sjinfo->syn_righthand, rel1->relids) &&
                         create_unique_path(root, rel1, 
rel1->cheapest_total_path,
                                                      sjinfo) != NULL)
            {
                  /* Reversed semijoin case */
                  if (match_sjinfo) {
                        elog(LOG, "gunkris4444444444444444");
                        return false;     /* invalid join path */
                  }
                  match_sjinfo = sjinfo;
                  reversed = true;
                  unique_ified = true;
            }
Then I run the core regression tests with "make installcheck-parallel
" for v18beta1 as the document dictates. When the regression test is done, only 
the last 2 log entries are found in logfile, the first 2 entries are not 
printed at all. I run core regression also with v14.15 and v17.2, the results 
are the same. What test suite do I need to run to cover the first 2 branches, 
or could you please show me a example query that can cover them? Thank you very 
much.

________________________________
发件人: Tom Lane <t...@sss.pgh.pa.us>
发送时间: 2025年5月10日 18:47
收件人: g l <orangegr...@live.com>
抄送: pgsql-gene...@postgresql.org <pgsql-gene...@postgresql.org>
主题: Re: are the 2 if-statements in join_is_legal() removable?

g l <orangegr...@live.com> writes:
> In join_is_legal(), there are 2 decision-making statements based on 
> match_sjinfo. I    wonder wether their conditions can ever test possitive.

The code coverage report says yes.

https://coverage.postgresql.org/src/backend/optimizer/path/joinrels.c.gcov.html#350

                        regards, tom lane

Reply via email to