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: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 12.2.2
    • None
    • Server
    • None
    • 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

        Activity

          People

            Unassigned Unassigned
            Yuxiao Guo Yuxiao Guo
            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.