pingcap / pingcap/tidb

Query produces different results after disabling some optimization rules

Open
#53,900 1 comment 0 reactions 0 assignees View on GitHub
impact/wrong-result may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 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

CREATE TABLE t1(c0 SMALLINT );
CREATE TABLE t4(c0 BIGINT DEFAULT 1383675574 , c2 BLOB(55) ) ;

INSERT IGNORE INTO t4 VALUES (NULL, '') ON DUPLICATE KEY UPDATE c0=t4.c2;

INSERT IGNORE INTO t4(c2) VALUES ('MZ');

delete from mysql.opt_rule_blacklist;
admin reload opt_rule_blacklist;
SELECT t4.c2, t4.c0 FROM t1 NATURAL RIGHT JOIN t4 WHERE t4.c0;
INSERT INTO mysql.opt_rule_blacklist VALUES("predicate_push_down"),("column_prune"),("projection_eliminate");
ADMIN reload opt_rule_blacklist;
SELECT t4.c2, t4.c0 FROM t1 NATURAL RIGHT JOIN t4 WHERE t4.c0;

```

### 2. What did you expect to see? (Required)
Two queries produce same results.

### 3. What did you see instead (Required)
```sql
MySQL [d0]> delete from mysql.opt_rule_blacklist;
Query OK, 0 rows affected (0.03 sec)

MySQL [d0]> admin reload opt_rule_blacklist;
Query OK, 0 rows affected (0.03 sec)

MySQL [d0]> SELECT t4.c2, t4.c0 FROM t1 NATURAL RIGHT JOIN t4 WHERE t4.c0;
+------+------------+
| c2 | c0 |
+------+------------+
| MZ | 1383675574 |
+------+------------+
1 row in set (0.01 sec)

MySQL [d0]> INSERT INTO mysql.opt_rule_blacklist VALUES("predicate_push_down"),("column_prune"),("projection_eliminate");
Query OK, 3 rows affected (0.02 sec)
Records: 3 Duplicates: 0 Warnings: 0

MySQL [d0]> ADMIN reload opt_rule_blacklist;
Query OK, 0 rows affected (0.04 sec)

MySQL [d0]> SELECT t4.c2, t4.c0 FROM t1 NATURAL RIGHT JOIN t4 WHERE t4.c0;
Empty set (0.00 sec)
```

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

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.