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

Incorrect type inference for INTERSECT ALL causes precision loss

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 12.2.2
    • 10.11, 11.4, 11.8, 12.3
    • Data types, Server
    • Docker: mariadb:12.2.2
      Server version: 12.2.2-MariaDB-ubu2404
      Source revision: d26a6f44c1f2119377e79a9540886c6d8c01472f

    Description

      Hi, I found a logic bug in MariaDB 12.2.2.

      These two queries are equivalent, yet they yield different execution results.

      How to repeat:

      -- create table
      DROP TABLE IF EXISTS t0;
      CREATE TABLE t0 ( c0 float DEFAULT NULL );
      INSERT INTO t0 VALUES (1657020000);
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 ( c0 mediumtext COMMENT 'asdf', c1 varchar(500) DEFAULT NULL );
      INSERT INTO t1 VALUES ('-1254578240','664505778');
       
       
      -- query1, result:{1657020032, -1254578240}
      SELECT COALESCE(t1.c0, t1.c0) AS c1 FROM t0 AS t1 UNION SELECT COALESCE(t2.c0, t2.c0) AS c1 FROM t1 AS t2;
       
      -- query 2, expected result:{1657020032, -1254578240}, actual result:{1657020000, -1254578240}
      SELECT c1 FROM (
          SELECT c0 AS c1 FROM t0
          INTERSECT ALL
          SELECT c0 AS c1 FROM t0
      ) AS t_bug
      UNION
      SELECT c0 FROM t1;
      

      Attachments

        Issue Links

          Activity

            People

              raghunandan.bhat Raghunandan Bhat
              Yuxiao Guo Yuxiao Guo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0d
                  0d
                  Remaining:
                  Remaining Estimate - 2d
                  2d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                  Git Integration

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