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

UPPER(key_col) IN (constant subquery) does not use the index

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Major
    • Resolution: Unresolved
    • 13.2
    • 13.2
    • Optimizer
    • None
    • Q4/2026 Server Maintenance, Q1/2027 Server Development

    Description

      Item_func_in::varchar_upper_cmp_transformer() rewrites
      UPPER(key_col) IN (const, ...) into key_col IN (const, ...).

      It needs a copy of the IN predicate to put the new first argument into, it used deep_copy_with_checks(). A deep copy copies every node of the tree and refuses as a whole if any node cannot be copied, so an IN list holding an uncorrelated scalar subquery, which is constant but has no copy, silently lost the rewrite: UPPER(a) IN ((SELECT MAX(c) FROM t2),'A-2') read the whole table instead of using a range on the index on a. After copying, the rewrite walked the copy with cleanup_excluding_const_fields_processor and re-fixed it, which would also have cleaned up a subquery had one been copied.

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              Johnston Rex Johnston
              Rex Johnston Rex Johnston
              Sergei Petrunia Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h Original Estimate - 1h
                  1h
                  Remaining:
                  Time Spent - 0.25d Remaining Estimate - 40m
                  40m
                  Logged:
                  Time Spent - 0.25d Remaining Estimate - 40m
                  0.25d

                  Git Integration

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