div function pushed down to tikv does not respect sql mode
- 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 reproduction step (Required)
```
> create table t1(a int);
> create table t2 like t1;
> insert into t1 values(0);
> insert into t2 select a from t1 where 100/a > 0;
```
### 2. What did you expect to see? (Required)
In mysql
```
mysql> insert into t2 select a from t1 where 100/a>0;
ERROR 1365 (22012): Division by 0
```
### 3. What did you see instead (Required)
```
mysql> insert into t2 select a from t1 where 100/a>0;
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0
```
The div function is pushed to tikv layer, but not return an error
```
mysql> explain insert into t2 select a from t1 where 100/a>0;
+---------------------------+---------+-----------+---------------+--------------------------------------------------------+
| id | estRows | task | access object | operator info |
+---------------------------+---------+-----------+---------------+--------------------------------------------------------+
| Insert_1 | N/A | root | | N/A |
| └─TableReader_9 | 0.80 | root | | data:Selection_8 |
| └─Selection_8 | 0.80 | cop[tikv] | | gt(div(100, cast(test.t1.a, decimal(10,0) BINARY)), 0) |
| └─TableFullScan_7 | 1.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+---------------------------+---------+-----------+---------------+--------------------------------------------------------+
```
### 4. What is your TiDB version? (Required)
master
Contributor guide
Assessment
This issue has not been assessed yet.