pingcap / pingcap/tidb

Incorrect query result when casting decimal to string

Open
#44,213 5 comments 0 reactions 0 assignees View on GitHub
severity/moderate sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```SQL
CREATE TABLE t1 (c1 DECIMAL NOT NULL);
INSERT INTO t1 VALUES (-1000000000);
SELECT c1 FROM t1 WHERE IFNULL(c1, '') = c1; -- actual: {}, expected: {-1000000000}
```
### 2. What did you expect to see? (Required)
SELECT returns the value of column c1.
### 3. What did you see instead (Required)
SELECT returns empty results and a warning.
```SQL
+---------+------+-------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------+
| Warning | 1105 | evaluation failed: Data Too Long, field len 10, data len 11 |
+---------+------+-------------------------------------------------------------+
```
### 4. What is your TiDB version? (Required)

Release Version: v7.0.0
Edition: Community
Git Commit Hash: 7376954cd868dbc44fc3015c9ef89c53749339a7
Git Branch: heads/refs/tags/v7.0.0
UTC Build Time: 2023-03-29 13:32:13
GoVersion: go1.20.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.