pingcap / pingcap/tidb

User defined variable assignment in select using functions is not getting reassigned in TiDB

Open
#35,348 1 comment 0 reactions 0 assignees View on GitHub
affects-5.1 affects-5.2 affects-5.3 affects-5.4 affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 may-affects-4.0 may-affects-5.0 severity/moderate sig/planner 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)
```sql
drop table if exists t1,t2;
create table t1 (a int);
insert into t1 values (0),(1),(2),(3);
create table t2 (a int, key(a), b int);
insert into t2 values (1,1),(2,2);

set @cnt= 1;
set @str="update t2 set b=1 where a not in (";
select count(*) from (
select @str:=concat(@str, @cnt:=@cnt+1, ",")
from t1 A, t1 B, t1 C, t1 D) Z;
select @str;
```

### 2. What did you expect to see? (Required)
```sql
update t2 set b=1 where a not in (2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,.......)
```
### 3. What did you see instead (Required)
```sql
mysql> select @str;
+------------------------------------+
| @str |
+------------------------------------+
| update t2 set b=1 where a not in ( |
+------------------------------------+
1 row in set (0.00 sec)

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

```sql
mysql> select version();
+-----------------------------------------------+
| version() |
+-----------------------------------------------+
| 5.7.25-TiDB-v6.1.0-alpha-482-g81a852077-dirty |
+-----------------------------------------------+
1 row in set (0.00 sec)
```

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.