回复: are the 2 if-statements in join_is_legal() removable?

From: g l <orangegrove(at)live(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: 回复: are the 2 if-statements in join_is_legal() removable?
Date: 2025-05-11 08:26:38
Message-ID: SY6P282MB3797A6DF372EAB398EFA5D6EDA94A@SY6P282MB3797.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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 <tgl(at)sss(dot)pgh(dot)pa(dot)us>
发送时间: 2025年5月10日 18:47
收件人: g l <orangegrove(at)live(dot)com>
抄送: pgsql-general(at)postgresql(dot)org <pgsql-general(at)postgresql(dot)org>
主题: Re: are the 2 if-statements in join_is_legal() removable?

g l <orangegrove(at)live(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Goldberg 2025-05-11 14:02:49 Proposed Japanese Translation of Code of Conduct Policy
Previous Message Tom Lane 2025-05-10 15:47:24 Re: are the 2 if-statements in join_is_legal() removable?