[MDEV-11966] Impossible to execute prepared ANALYZE SELECT Created: 2017-02-01  Updated: 2019-03-12  Resolved: 2017-03-09

Status: Closed
Project: MariaDB Server
Component/s: Prepared Statements
Affects Version/s: 10.2.2
Fix Version/s: 10.2.5

Type: Bug Priority: Major
Reporter: Lawrin Novitsky Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-11975 SQLCOM_PREPARE of EXPLAIN & ANALYZE s... Closed
Sprint: 10.2.5-1

 Description   

It's very easy to repeat the problem

check_stmt_rc(mysql_stmt_prepare(stmt, "ANALYZE SELECT 1", -1), stmt);
check_stmt_rc(mysql_stmt_execute(stmt), stmt);

mysql_stmt_execute fails. The error is
[HY000] The number of parameters in bound buffers differs from number of columns in resultset(2057)

Server version I tested against is 10.2.3

In CLI PREPARE+EXECUTE works fine
MariaDB [test]> PREPARE analyze_select FROM "ANALYZE SELECT 1";
Query OK, 0 rows affected (0.00 sec)
Statement prepared

MariaDB [test]> EXECUTE analyze_select;
+------+-------------+-------+------+---------------+------+---------+------+------+--------+----------+------------+----------------+
| id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | r_rows | filtered | r_filtered | Extra          |
+------+-------------+-------+------+---------------+------+---------+------+------+--------+----------+------------+----------------+
|    1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL |   NULL |     NULL |       NULL | No tables used |
+------+-------------+-------+------+---------------+------+---------+------+------+--------+----------+------------+----------------+
1 row in set (0.00 sec)

The query can be any, in fact. Unless it has 13 columns, like ANALAYZE output, but then we probably have issue with wrong metadata Yes, it seems that returned metadata is for analyzed query, and not for ANALYZE result itself.

I am not sure if that is not error in the server. In fact I'd imagine that is more probable



 Comments   
Comment by Georg Richter [ 2017-02-01 ]

After preparing the statement ANALYZE SELECT 1 the function mysql_stmt_field_count() returns 1 instead of 13.

Comment by Oleksandr Byelkin [ 2017-02-01 ]

It looks like EXPLAIN also return wrong number - 0.

Comment by Oleksandr Byelkin [ 2017-02-02 ]

there is processing of EXPLAIN In the set_sql_prepare() but nothing for ANALYSE. And both looks like returning wrong info (EXPLAIN do not report info).

Comment by Lawrin Novitsky [ 2017-02-05 ]

Looks like the fix works

Comment by Oleksandr Byelkin [ 2017-03-07 ]

revision-id: 0f3c1f771011c432698f3e330b5aec522591be41 (mariadb-10.2.3-153-g0f3c1f77101)
parent(s): 650ffcd3a081f0bf4e3b7de93fac72c1b67284e1
committer: Oleksandr Byelkin
timestamp: 2017-02-02 12:09:49 +0100
message:

MDEV-11966: Impossible to execute prepared ANALYZE SELECT

Prepare os ANALYZE now respond as EXPLAIN.

Comment by Oleksandr Byelkin [ 2017-03-08 ]

revision-id: c544bba6d7c2c400a288a3d2f468d4f0e84d3908 (mariadb-10.2.4-28-gc544bba)
parent(s): 0b1abc2f0f391d4e55029fa53f1e5da926f7be61
committer: Oleksandr Byelkin
timestamp: 2017-03-08 14:26:53 +0100
message:

MDEV-11966: Impossible to execute prepared ANALYZE SELECT

Prepare os ANALYZE now respond as EXPLAIN.

Comment by Oleksandr Byelkin [ 2017-03-08 ]

github branch bb-10.2-MDEV-11363

Comment by Sergei Petrunia [ 2017-03-09 ]

Ok to push

Generated at Thu Feb 08 07:54:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.