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

wrong resultset with having and or condition

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.4, 12.1(EOL), 11.8
    • 11.4, 11.8
    • Optimizer
    • None
    • Unexpected results

    Description

      To reproduce

      docker run -d -p4401:3306 --name np1148 --env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 mariadb:11.4.8
      mysql -h127.0.0.1 -uroot -P4401 < mocked.sql
      mysql -h127.0.0.1 -uroot -P4401 d1 < query.sql
      

      t1c1	qac1	qac2	qac3	qac4	qac5
      3	14	14	0	0	2025-11-06 10:24:27
      5	17	17	0	0	2025-11-06 10:24:27
      

      docker run -d -p4402:3306 --name np106 --env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 mariadb:106
      mysql -h127.0.0.1 -uroot -P4402 < mocked.sql
      mysql -h127.0.0.1 -uroot -P4402 d1 < query.sql
      

      t1c1	qac1	qac2	qac3	qac4	qac5
      3	14	14	0	0	2025-11-06 10:24:27
      5	17	17	0	0	2025-11-06 10:24:27
      6	15	15	0	2	2025-11-06 10:24:27
      

      The result in

      The result without having is

      +------+------+------+------+------+------+
      | t1c1 | qac1 | qac2 | qac3 | qac4 | qac5 |
      +------+------+------+------+------+------+
      |    3 |   14 |   14 |    0 |    0 | 2025-11-06 10:24:27 |
      |    4 |   10 |   10 |    1 |    0 | 2025-11-06 10:24:27 |
      |    5 |   17 |   17 |    0 |    0 | 2025-11-06 10:24:27 |
      |    6 |   15 |   15 |    0 |    2 | 2025-11-06 10:24:27 |
      |    7 |   20 |   20 |    0 |    2 | 2025-11-06 12:24:27 |
      +------+------+------+------+------+------+
      

      We have in having the condition

      AND (t2dp.`qac4` = 0 
                          OR t2dp.`qac5` < '2025-11-06 11:40:00' )
      

      row 6 matches the or condition "`qac5` < '2025-11-06 11:40:00'" ,
      so `qac4` = 0 can be false.

      Bug in all 11.4 releases, but not 10.6 and 10.11

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              Richard Richard Stracke
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.