Checks in `Preprocess` doesn't work with `PREPARE/EXECUTE`
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### 1. Minimal reproduce step (Required)
Case 1
```sql
create table t(a int primary key, b int);
select @@tidb_enable_shared_lock_promotion;
select * from t where a = 1 for share; -- expect fail
set @@tidb_enable_shared_lock_promotion = 1;
select * from t where a = 1 for share; -- expect success
prepare stmt from 'select * from t where a = 1 for share';
execute stmt; -- expect success
set @@tidb_enable_shared_lock_promotion = 0;
execute stmt; -- expect fail
select * from t where a = 1 for share; -- expect fail
```
Case 2
```sql
set sql_mode='oracle';
select count(*) from t t1 join t t1; -- expect success
prepare stmt1 from 'select count(*) from t t1 join t t1';
set sql_mode=default;
execute stmt1; -- expect fail
select count(*) from t t1 join t t1; -- expect fail
```
Case 3 (Only on the feature/active-active feature branch)
```sql
create table t1 (id int primary key, name varchar(50)) softdelete retention 7 day;
prepare stmt from 'select id from t1 where _tidb_softdelete_time > ?'; -- expect fail
set @@tidb_translate_softdelete_sql = false;
prepare stmt from 'select id from t1 where _tidb_softdelete_time > ?'; -- expect success
set @a = now();
execute stmt using @a; -- expect success
set tidb_translate_softdelete_sql = true;
execute stmt using @a; -- expect fail
```
### 2. What did you expect to see? (Required)
As said above.
### 3. What did you see instead (Required)
After `PREPARE` and then modifying system variables, checks in `Preprocess` won't be triggered again in `EXECUTE`.
Note that this issue is related to `PREPARE/EXECUTE` itself, not the plan cache. (See case 2)
### 4. What is your TiDB version? (Required)
master, v8.5
Contributor guide
Assessment
This issue has not been assessed yet.