Details
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
- relates to
-
MDEV-38470 Wrong Result: Inconsistent behavior between Index Lookup and Table Scan
-
- Confirmed
-