pingcap / pingcap/tidb

When the decimal part of the decimal type is 0, a query exception will occur

Open
#56,530 4 comments 0 reactions 0 assignees View on GitHub
component/parser fuzz/comp severity/moderate sig/sql-infra 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)

```
CREATE TABLE `PK_MULTI_COL_5048` (
`COL1` binary(10) NOT NULL,
`COL2` binary(10) NOT NULL,
`COL3` decimal(55,0) NOT NULL,
PRIMARY KEY (`COL1`(5),`COL2`,`COL3`) /*T![clustered_index] CLUSTERED */,
UNIQUE KEY `UIDXM` (`COL1`(5),`COL2`),
UNIQUE KEY `UIDX` (`COL2`),
KEY `IDX3` (`COL3`),
KEY `IDXM` (`COL3`,`COL2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
```
Query `COL3` for decimal points but no decimals:

- first query: `select * from PK_MULTI_COL_5048 where col3 <> 6.;`
- second query: `select * from PK_MULTI_COL_5048 where col3 <> 6. or col2 is not null;`

### 2. What did you expect to see? (Required)
both query success

### 3. What did you see instead (Required)

- first query success
- second query failed: `ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 51 near "or col2 is not null"`

it will not be recognized when only a decimal point and combined with other statements.

### 4. What is your TiDB version? (Required)

Release Version: v8.4.0-alpha-359-g2864508e3c
Edition: Community
Git Commit Hash: 2864508e3c89a380b0bf29b4ae3e66a8890efd30
Git Branch: HEAD
UTC Build Time: 2024-10-10 04:16:33
GoVersion: go1.23.2
Race Enabled: false
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.