When creating an index on a column with type DECIMAL, EXPLAIN SELECT shows the indexed range it's retrieving as:
EXPLAIN SELECT decimalCol FROM t WHERE decimalCol>10;
+-------+------+------------------------------------------------------------------------------------------------+
| Level | Type | Description |
+-------+------+------------------------------------------------------------------------------------------------+
| 0 | scan | t@decimalIndex /<util/encoding/decimal.go:395: did not find terminator 0x0 in buffer 0x1401>- |
+-------+------+------------------------------------------------------------------------------------------------+
However, the SELECT statement still executes, so it looks like it's just a bug with encoding the DECIMAL value in EXPLAIN's output.
INSERT INTO t VALUES (11.1);
SELECT decimalCol FROM t WHERE decimalCol>10;
+------------+
| decimalCol |
+------------+
| 11.1 |
+------------+
NOTE: Tested indexes created with INT, FLOAT, BOOL, DATE, TIMESTAMP, INTERVAL, STRING, and BYTE columns and there were no issues.
Create table
CREATE TABLE t (decimalCol DECIMAL);
Create index on the DECIMAL column
CREATE INDEX decimalIndex ON t (decimalCol);
EXPLAIN SELECT demos bug
EXPLAIN SELECT decimalCol FROM t WHERE decimalCol>10;
+-------+------+------------------------------------------------------------------------------------------------+
| Level | Type | Description |
+-------+------+------------------------------------------------------------------------------------------------+
| 0 | scan | t@decimalIndex /<util/encoding/decimal.go:395: did not find terminator 0x0 in buffer 0x1401>- |
+-------+------+------------------------------------------------------------------------------------------------+
All of the following tables generate the same error
- Column with precision and scale specified
CREATE TABLE t (decimalCol DECIMAL(9,2));
- Table with primary key
CREATE TABLE t (id INT PRIMARY KEY, decimalCol DECIMAL);
- Table with primary key; column with precision and scale identified
CREATE TABLE t (id INT PRIMARY KEY, decimalCol DECIMAL);