[MDEV-30127] The results of 2 executions of a prepared EXPLAIN statement differ Created: 2022-11-29  Updated: 2022-11-29

Status: Open
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.3

Type: Bug Priority: Major
Reporter: Igor Babaev Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

For the following testcase that is a variant of the testcase from main/explain.test for bug #11829785 one can see different results from the first and the second execution of the prepared EXPLAIN:

MariaDB [test]> CREATE TABLE t1(a INT);
Query OK, 0 rows affected (0.018 sec)
 
MariaDB [test]> 
MariaDB [test]> INSERT INTO t1 VALUES (0), (0);
Query OK, 2 rows affected (0.005 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
MariaDB [test]> PREPARE s FROM
    -> 'EXPLAIN
    '> SELECT SUBSTRING(1, (SELECT 1 FROM t1 a1 RIGHT OUTER JOIN t1 ON 0)) AS d
    '> FROM t1 WHERE 0 > ANY (SELECT @a FROM t1)';
Query OK, 0 rows affected (0.002 sec)
Statement prepared
 
MariaDB [test]> EXECUTE s;
ERROR 1242 (21000): Subquery returns more than 1 row
MariaDB [test]> EXECUTE s;
+------+----------------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
| id   | select_type          | table | type | possible_keys | key  | key_len | ref  | rows | Extra                                           |
+------+----------------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
|    1 | PRIMARY              | t1    | ALL  | NULL          | NULL | NULL    | NULL |    2 |                                                 |
|    3 | UNCACHEABLE SUBQUERY | t1    | ALL  | NULL          | NULL | NULL    | NULL |    2 |                                                 |
|    2 | SUBQUERY             | t1    | ALL  | NULL          | NULL | NULL    | NULL |    2 |                                                 |
|    2 | SUBQUERY             | a1    | ALL  | NULL          | NULL | NULL    | NULL |    2 | Using where; Using join buffer (flat, BNL join) |
+------+----------------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
4 rows in set (0.002 sec)


Generated at Thu Feb 08 10:13:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.