Inconsistent results when query uses different optimization
- 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
SET GLOBAL tidb_multi_statement_mode='ON';
SET @@sql_mode='';
SET @@global.tidb_enable_clustered_index='off';
delete from mysql.opt_rule_blacklist;
admin reload opt_rule_blacklist;
create table t0(c0 decimal zerofill check ((('') is not null)) );
create table bp_cache_tmp1 (id int primary key , u int unique, v int);
replace into bp_cache_tmp1(id) values (103387549);
delete from mysql.opt_rule_blacklist;
admin reload opt_rule_blacklist;
select bp_cache_tmp1.v from t0 natural right join bp_cache_tmp1;
INSERT INTO mysql.opt_rule_blacklist VALUES("column_prune"), ("projection_eliminate");
ADMIN reload opt_rule_blacklist;
select bp_cache_tmp1.v from t0 natural right join bp_cache_tmp1;
```
### 2. What did you expect to see? (Required)
Query returns same results.
### 3. What did you see instead (Required)
```sql
mysql> delete from mysql.opt_rule_blacklist;
Query OK, 0 rows affected (0.01 sec)
mysql> admin reload opt_rule_blacklist;
Query OK, 0 rows affected (0.00 sec)
mysql> select bp_cache_tmp1.v from t0 natural right join bp_cache_tmp1;
+------+
| v |
+------+
| NULL |
+------+
1 row in set (0.01 sec)
mysql> INSERT INTO mysql.opt_rule_blacklist VALUES("column_prune"), ("projection_eliminate");
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> ADMIN reload opt_rule_blacklist;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> select bp_cache_tmp1.v from t0 natural right join bp_cache_tmp1;
+-----------+
| v |
+-----------+
| 103387549 |
+-----------+
1 row in set (0.00 sec)
```
### 4. What is your TiDB version? (Required)
```sql
8.0.11-TiDB-v9.0.0-beta.1.pre-640-g24903d6b24
```
Contributor guide
Assessment
This issue has not been assessed yet.