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

The query returns an incorrect value when using LPAD and REPLACE

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.6, 10.11, 11.4, 11.8, 12.2.2
    • 10.11.17, 11.4.11, 11.8.7, 12.3.2
    • Optimizer
    • None
    • Docker: mariadb:12.2.2
      Server version: 12.2.2-MariaDB-ubu2404
      Source revision: d26a6f44c1f2119377e79a9540886c6d8c01472f
    • Unexpected results

    Description

      Hi, I found a logic bug in MariaDB 12.2.2.

      How to repeat:

      -- create table
      DROP TABLE IF EXISTS `t0`;
      CREATE TABLE `t0` (
        `c0` decimal(10,0) DEFAULT NULL,
        UNIQUE KEY `c0` (`c0`)
      );
      INSERT INTO `t0` VALUES (NULL), (-1453243642), (0), (959229237);
       
      DROP TABLE IF EXISTS `t1`;
      CREATE TABLE `t1` (
        `c0` decimal(10,0) DEFAULT NULL,
        UNIQUE KEY `c0` (`c0`)
      );
      INSERT INTO `t1` VALUES (NULL), (-310606044), (959229237);
       
      -- query, expect:empty set, actual:{0}
      SELECT * FROM t0
      WHERE
        (LPAD('0', c0 + 1, '1') OR REPLACE(CAST(FALSE AS CHAR), FALSE, c0))
        AND
        NOT (LPAD('0', c0 + 1, '1') OR REPLACE(CAST(FALSE AS CHAR), FALSE, c0));
      
      

      Attachments

        Activity

          People

            serg Sergei Golubchik
            Yuxiao Guo Yuxiao Guo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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