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

      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

            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.