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

Inconsistent between normal and prepared SELECT on 0 and -0

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3
    • 10.11, 11.4, 11.8, 12.3
    • None
    • None

    Description

      Hi,

      In the following test case, there are two equivalent SELECT, one is a normal SELECT and the other is a prepared SELECT. However, these two queries have different results: the normal SELECT returns 0 and -0, but the prepared SELECT only returns 0:

      CREATE TABLE IF NOT EXISTS t0(c0 CHAR(100));
      CREATE OR REPLACE TABLE t1(c0 REAL  UNIQUE NOT NULL, c1 MEDIUMINT SIGNED  UNIQUE NOT NULL, c2 BOOLEAN , PRIMARY KEY(c0, c1, c2)) engine=MyISAM;
      INSERT INTO t0 VALUES ('0');
      INSERT INTO t0 VALUES ('-0.0');
      SELECT (SELECT '' FROM t1 WHERE t1.c0), (- (- t0.c0)) FROM t0 WHERE (SELECT CAST(-211359420 AS DECIMAL) FROM t0 GROUP BY CAST(-211359420 AS DECIMAL)) GROUP BY (SELECT '' FROM t1 WHERE t1.c0), (- (- t0.c0));
      -- NULL, 0
      -- NULL, -0
      SET @a = '';
      SET @b = -211359420;
      SET @c = -211359420;
      SET @d = '';
      PREPARE prepare_query FROM 'SELECT (SELECT ? FROM t1 WHERE t1.c0), (- (- t0.c0)) FROM t0 WHERE (SELECT CAST(? AS DECIMAL) FROM t0 GROUP BY CAST(? AS DECIMAL)) GROUP BY (SELECT ? FROM t1 WHERE t1.c0), (- (- t0.c0))';
      EXECUTE prepare_query USING @a,@b,@c,@d;
      -- NULL, 0
      

      I can reproduce this on 12.1.2-MariaDB-ubu2404

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            ChiZhang Chi Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.