Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-31715

dbug_print(select_lex) prints inequivalent query when const table is involved

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 11.0
    • N/A
    • Server
    • None

    Description

      Assuming the query printed by dbug_print(select_lex) should produce the same result as the original query, the following example shows dbug_print does not always follow this rule:

      CREATE TABLE tbl_a (
        a int,
        primary key (a)
      );
       
      CREATE TABLE tbl_b (
        c int,
        d int,
        primary key (c, d)
      );
       
      INSERT INTO tbl_a VALUES (1), (2), (3);
      INSERT INTO tbl_b VALUES (1, 11), (2, 22), (3, 33);
       
      # original query
      SELECT d FROM tbl_a JOIN tbl_b ON a = c WHERE a IN (1);
      # dbug_print(join->select_lex) before join->optimize(), ok: prduces one row
      select tbl_b.d AS d from (tbl_a join tbl_b on(tbl_a.a = tbl_b.c)) where tbl_a.a = 1;
      # dbug_print(join->select_lex) before join->exec(), not equivalent: produces three rows
      select tbl_b.d AS d from tbl_a join tbl_b where tbl_b.c = 1;
       
      drop table tbl_a,tbl_b;
      

      The table tbl_a was optimised into a const table, which might be why dbug_print prints a inequivalent query because the query does not capture this piece of information.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ycp Yuchen Pei
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.