Bug #6042 constants propogation works only once (prepared statements)
Description:
From the log below you can see that constants propogation for prepared
statements is done only once:
mysql> create table t1 (a int, b int);
mysql> insert into t1 (a, b) values (1,1), (1,2), (2,1), (2,2);
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> prepare stmt from "explain select * from t1 where t1.a=2 and t1.a=t1.b and t1.b > 1 + ?";
Query OK, 0 rows affected (0.00 sec)
Statement prepared
mysql> set @v=0; execute stmt using @v;
Query OK, 0 rows affected (0.00 sec)
+----+-------------+-------+------+- -+------+-------------+
| id | select_type | table | type | | rows | Extra |
+----+-------------+-------+------+- -+------+-------------+
| 1 | SIMPLE | t1 | ALL | | 4 | Using where |
+----+-------------+-------+------+- -+------+-------------+
1 row in set (0.01 sec)
mysql> set @v=5; execute stmt using @v;
Query OK, 0 rows affected (0.00 sec)
+----+-------------+-------+------+- -+------+-------------+
| id | select_type | table | type | | rows | Extra |
+----+-------------+-------+------+- -+------+-------------+
| 1 | SIMPLE | t1 | ALL | | 4 | Using where |
+----+-------------+-------+------+- -+------+-------------+
1 row in set (0.00 sec)
mysql> set @v=0; execute stmt using @v;
Query OK, 0 rows affected (0.00 sec)
+----+-------------+-------+------+- -+------+-------------+
| id | select_type | table | type | | rows | Extra |
+----+-------------+-------+------+- -+------+-------------+
| 1 | SIMPLE | t1 | ALL | | 4 | Using where |
+----+-------------+-------+------+- -+------+-------------+
1 row in set (0.00 sec)
mysql> prepare stmt from "explain select * from t1 where t1.a=2 and t1.a=t1.b and t1.b > 1 + ?";
Query OK, 0 rows affected (0.00 sec)
Statement prepared
mysql> set @v=5; execute stmt using @v;
Query OK, 0 rows affected (0.00 sec)
+----+-------------+-------+------+- -+------------------+
| id | select_type | table | type | | Extra |
+----+-------------+-------+------+- -+------------------+
| 1 | SIMPLE | NULL | NULL | | Impossible WHERE |
+----+-------------+-------+------+- -+------------------+
1 row in set (0.00 sec)
mysql> set @v=0; execute stmt using @v;
Query OK, 0 rows affected (0.00 sec)
+----+-------------+-------+------+- -+------+-------------+
| id | select_type | table | type | | rows | Extra |
+----+-------------+-------+------+- -+------+-------------+
| 1 | SIMPLE | t1 | ALL | | 4 | Using where |
+----+-------------+-------+------+- -+------+-------------+
1 row in set (0.00 sec)
mysql> set @v=5; execute stmt using @v;
Query OK, 0 rows affected (0.00 sec)
+----+-------------+-------+------+- -+------+-------------+
| id | select_type | table | type | | rows | Extra |
+----+-------------+-------+------+- -+------+-------------+
| 1 | SIMPLE | t1 | ALL | | 4 | Using where |
+----+-------------+-------+------+- -+------+-------------+
1 row in set (0.00 sec)
How to repeat:
See above.
Suggested fix:
Reset item->marker in item->cleanup
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.