Query result is not compatible with MySQL while using `if` clause
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Query result is not compatible with MySQL while using `if` clause
### 1. Minimal reproduce step (Required)
create table t1(c1 varchar(32));
insert into t1 values('sh'),('bj');
select if(1 is null,(select c1 from t1 limit 2),3);
### 2. What did you expect to see? (Required)
mysql> select if(1 is null,(select c1 from t1 limit 2),3);
+----------------------------------------------+
| if(1 is null,(select c1 from t1 limit 2),3) |
+----------------------------------------------+
| 3 |
+----------------------------------------------+
1 row in set (0.00 sec)
### 3. What did you see instead (Required)
MySQL 8.0:
mysql> select if(1 is null,(select c1 from t1 limit 2),3);
+----------------------------------------------+
| if(1 is null,(select c1 from t1 limit 2),3) |
+----------------------------------------------+
| 3 |
+----------------------------------------------+
1 row in set (0.00 sec)
TiDB:
mysql> select if(1 is null,(select c1 from t1 limit 2),3);
ERROR 1242 (21000): Subquery returns more than 1 row
### 4. What is your TiDB version? (Required)
v7.1.1, v6.5
Contributor guide
Assessment
This issue has not been assessed yet.