pingcap / pingcap/tidb

unexpected warning: Division by 0

Open
#64,548 0 comments 0 reactions 0 assignees View on GitHub
affects-6.5 affects-7.1 affects-7.5 affects-8.1 affects-8.5 report/customer severity/moderate sig/execution type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### 1. Minimal reproduce step (Required)

```
drop table t1 ,t2;

create table t1(a decimal(20,4));
create table t2(a decimal(20,4));

insert into t1 values(0.0001),(-0.0001),(0);
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;

insert into t2 values(0.0001),(-0.0001),(0);
insert into t2 select * from t2;

-- 可能需要多次执行
explain analyze select case when t1.a<=0 then null else t2.a/t1.a end aaaa from t1,t2;
```

### 2. What did you expect to see? (Required)
Query success and no warning.
### 3. What did you see instead (Required)
Many `warning: Division by 0`, although query success.
### 4. What is your TiDB version? (Required)
nightly

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.