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

rewrite Item_subselect::recalc_used_tables

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      Under certain circumstances, the table map returned by Item_subselect::recalc_used_tables is incorrect on the second execution of a prepared statement or procedure.

      An example from outer_reference.test where the current used_tables_cache is re-calculated incorrectly.

          prepare s from 'select * from t1, v2 where t1a<=v2a and t1b in
          (
          select t3b from t3
          where
          (
          select t3b <= v2b and t3a <= v2a
          )
          )';
      

      Watching the value of used_tables_cache of the Item_subselect representing "select t3b from...",
      Initialized to 0 during parsing.
      Set to 0b11 (t5,t7} during mysql_test_select///setup_fields
      Set to OUTER_REF_TABLE_BIT + 0b11 during prepare of first execute
      calculated as 0b110 in Item_subselect::recalc_used_tables() during optimize phase of first execution.
      0b111 when t1 (left expression) is added in.
      used_tables_cache is not cleaned up at the end of execution.
      During the prepare of the next execution we accumulate the view fields of v2 into this table map and end up with OUTER_REF_TABLE_BIT + 0b111.
      It remains this way for the rest of the execution, leading to the wrong result.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Johnston Rex Johnston
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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