[MDEV-25108] Running of the EXPLAIN EXTENDED statement produces extra warning in case it is executed in PS (prepared statement) mode Created: 2021-03-10  Updated: 2021-04-13  Resolved: 2021-04-12

Status: Closed
Project: MariaDB Server
Component/s: Prepared Statements
Affects Version/s: None
Fix Version/s: 10.2.38, 10.3.29, 10.4.19, 10.5.10, 10.6.0

Type: Bug Priority: Critical
Reporter: Dmitry Shulga Assignee: Dmitry Shulga
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-16708 Unsupported commands for prepared sta... Closed

 Description   

The following EXPLAIN EXTENDED statement produces different number of warning in case it is executed as a regular statement or as a prepared statement. In the later case one extra warning is generated.

CREATE TABLE t1 (c int);
CREATE TABLE t2 (d int);
EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1;

id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00  
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 100.00 Using where

2 rows in set, 2 warnings (0,020 sec)
^^^^^^^^ 2 Warnings produced

SHOW WARNINGS;

Level Code Message
Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1
Note 1003 select <expr_cache><`test`.`t1`.`c`>((select 1 from `test`.`t2` where `test`.`t2`.`d` = `test`.`t1`.`c`)) AS `(SELECT 1 FROM t2 WHERE d = c)` from `test`.`t1`

PREPARE stmt FROM "EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1";
EXECUTE stmt;

id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00  
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 100.00 Using where

2 rows in set, 3 warnings (0,001 sec)
^^^^^^^^ 3 Warnings produced (1 extra warning)

SHOW WARNINGS;

Level Code Message
Note 1276 Field or reference 'c' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1
Note 1003 select <expr_cache><`test`.`t1`.`c`>((select 1 from `test`.`t2` where `test`.`t2`.`d` = `test`.`t1`.`c`)) AS `(SELECT 1 FROM t2 WHERE d = c)` from `test`.`t1`

The same behavior (one extra warning generated in case the statement executed in PS mode) can be observed if the following test case is run:

CREATE TABLE t1 (a INT, b INT);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 AS x1 WHERE (t1.b IS NULL));
PREPARE stmt FROM "EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 AS x1 WHERE (t1.b IS NULL))";
EXECUTE stmt;



 Comments   
Comment by Oleksandr Byelkin [ 2021-04-07 ]

OK to push

Generated at Thu Feb 08 09:35:12 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.