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

The query returns incorrect results when using LPAD and ABS

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • 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.

      When I executed it in other databases (such as MySQL), I obtained the following results:

      +--------------------+
      | c0                 |
      +--------------------+
      | 0.8702339126741298 |
      | 1481051462         |
      | -436558251         |
      | q1M8               |
      +--------------------+
      

      However, when I executed it in MariaDB 12.2.2, incorrect results were returned:

      +--------------------+
      | c0                 |
      +--------------------+
      | 0.8702339126741298 |
      | 1481051462         |
      | -436558251         |
      +--------------------+
      

      How to repeat:

      -- create table
      DROP TABLE IF EXISTS `t0`;
      CREATE TABLE `t0` ( `c0` longtext COMMENT 'asdf' );
      INSERT INTO `t0` VALUES ('0.8702339126741298'),('1481051462'),('-436558251'),('q1M8');
      DROP TABLE IF EXISTS `t1`;
      CREATE TABLE `t1` ( `c0` longtext COMMENT 'asdf', UNIQUE KEY `i1` (`c0`(4)), KEY `i0` (`c0`(4)) USING BTREE );
      INSERT INTO `t1` VALUES (NULL),('496420813'),(NULL),('77920684'),('-359793400'),('0.8702339126741298');
       
      -- bug-triggering query
      SELECT
        t_filter_sub_1.c0 AS `c0`
      FROM `t0` AS t_filter_sub_1
      WHERE
        LPAD(
          '123',
          ABS(
            (
              0 IN (
                '1',
                1,
                t_filter_sub_1.c0 % (-29.17)
              )
            )
          ) + 1,
          t_filter_sub_1.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.