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

Wrong results with interval function pushed into derived table

    XMLWordPrintable

Details

    • Unexpected results
    • Wrong results with interval function pushed into derived table
    • Q4/2026 Server Maintenance

    Description

      INTERVAL() pushed into a materialized derived table gives a wrong result

      Item_func_interval keeps Item_row *row as an alias of args[0] and evaluates through it. Item_func_or_sum::deep_copy() copies args[0] but the copy's row still points at the original row, whose fields are the outer select's columns of the derived table. The transformed copy prints correctly but evaluates the wrong items.

      create table t1 (a int, b int); insert into t1 values (1,10),(5,20),(9,30);
      select * from (select a, b from t1 group by a, b) d where interval(d.a, 3, 7) = 1;
      -- returns no rows; with condition_pushdown_for_derived=off it returns 5,20
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0.5d
                  0.5d
                  Remaining:
                  0d
                  Logged:
                  Time Not Required
                  Not Specified

                  Git Integration

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