pingcap / pingcap/tidb

*: incorrect result when invalid `DATE` conversion in `WHERE` condition

Open
#48,501 4 comments 0 reactions 0 assignees View on GitHub
affects-7.5 affects-8.1 affects-8.5 may-affects-5.3 may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 severity/major sig/execution 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)

Reported by the internal expression pushdown test: [example](https://do.pingcap.net/jenkins/blue/organizations/jenkins/pingcap%2Ftidb%2Fmerged_integration_copr_test/detail/merged_integration_copr_test/2727/pipeline/
).

A simple reproduce step:

```
create table t(a int, b year);
insert into t values (1, 2021)

/* with pushdown */
delete from mysql.expr_pushdown_blacklist;
admin reload expr_pushdown_blacklist;
explain select * from t where date(b);
select * from t where date(b);

/* without pushdown */
insert into mysql.expr_pushdown_blacklist(name, store_type) values ('date', 'tikv');
admin reload expr_pushdown_blacklist;
explain select * from t where date(b);
select * from t where date(b);
```

### 2. What did you expect to see? (Required)
Empty result, the same with MySQL:

```
tidb> select * from t where date(b);
Empty set, 1 warning (0.00 sec)
```

### 3. What did you see instead (Required)
```
/* with pushdown */
tidb> select * from t where date(b);
Empty set, 1 warning (0.00 sec)

/* without pushdown */
tidb> select * from t where date(b);
+------+------+
| a | b |
+------+------+
| 1 | 2021 |
+------+------+
1 row in set (0.01 sec)
```

### 4. What is your TiDB version? (Required)
Reproduced with v7.1.4, v7.4.0 and latest master: 4ae5622ef3c1b606fec9e12e4c269f4589e7a1f9

I didn't try more versions(

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.