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

Unexpected Result for an Index

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.6, 10.11, 11.4, 11.8, 12.3.1
    • 10.11, 11.4, 11.8, 12.3
    • Optimizer
    • None
    • ubuntu22.04

    Description

      Summary

      Wrong result with index lookup on a DECIMAL integer-scale column: predicates with non-zero fractional constants return rows after index creation, while the same predicates correctly return empty results without index.

      Product / Version

      • MariaDB Server `12.3.1-MariaDB`

      Environment

      • OS: ubuntu22.04

      Steps to Reproduce

      ```sql
      CREATE DATABASE IF NOT EXISTS logic_hunt;
      USE logic_hunt;

      DROP TABLE IF EXISTS d0;
      CREATE TABLE d0(c DECIMAL(10,0));
      INSERT INTO d0 VALUES (1),(2);

      – no index: empty result (correct)
      SELECT COUNT( * ) FROM d0 WHERE c = 1.2;
      SELECT COUNT( * ) FROM d0 WHERE c IN (1.2);

      CREATE INDEX i0 ON d0(c);

      – after index: wrong result
      SELECT COUNT( * ) FROM d0 WHERE c = 1.2;
      SELECT COUNT( * ) FROM d0 WHERE c IN (1.2);
      ```

      Expected Result

      • `c = 1.2` and `c IN (1.2)` should both return `0` rows, regardless of index presence.
      • Since `c` is `DECIMAL(10,0)`, a constant with a non-zero fractional part should not match any row under equality semantics.

      Actual Result

      • Before creating index `i0`:
      • `SELECT COUNT( * ) FROM d0 WHERE c = 1.2;` -> `0`
      • `SELECT COUNT( * ) FROM d0 WHERE c IN (1.2);` -> `0`
      • After creating index `i0`:
      • `SELECT COUNT( * ) FROM d0 WHERE c = 1.2;` -> `1` (wrong)
      • `SELECT COUNT( * ) FROM d0 WHERE c IN (1.2);` -> `1` (wrong)

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              mu mu
              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.