[Commits] 29df44a3665: MDEV-17963: Assertion `field_pos < field_count' failed in Protocol_text::store, Assertion `field_handlers == 0 || field_pos < field_count'
revision-id: 29df44a3665c40a464c1a39659ae7566bac5d41c (mariadb-10.1.39-88-g29df44a3665) parent(s): 02a0ebc613bf51fd4a943f4f216f1d5220c947be author: Varun Gupta committer: Varun Gupta timestamp: 2019-07-08 11:37:34 +0530 message: MDEV-17963: Assertion `field_pos < field_count' failed in Protocol_text::store, Assertion `field_handlers == 0 || field_pos < field_count' The problem was that sp_head::MULTI_RESULTS was not set correctly for ANALYZE statement with SELECT ... INTO variable. This is a follow up fix for MDEV-7023 --- mysql-test/r/sp.result | 14 ++++++++++++++ mysql-test/t/sp.test | 20 ++++++++++++++++++++ sql/sp_head.cc | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index e39754159fb..1704e7cd214 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -8319,4 +8319,18 @@ UNION SELECT * FROM INFORMATION_SCHEMA.TABLES JOIN INFORMATION_SCHEMA.PARAMETERS; DROP FUNCTION f; DROP VIEW v; +# +# MDEV-17963: Assertion `field_pos < field_count' failed in Protocol_text::store, +# Assertion `field_handlers == 0 || field_pos < field_count' +# +CREATE TABLE t1 (ct time); +INSERT INTO t1 VALUES ('16:11:28'); +CREATE FUNCTION f1 () RETURNS varchar(100) +BEGIN +DECLARE xxx varchar(100); +ANALYZE SELECT sum(ct) FROM t1 INTO xxx ; +RETURN xxx; +END| +ERROR 0A000: Not allowed to return a result set from a function +drop table t1; #End of 10.1 tests diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 0e95fb5c271..a2a40f87ef0 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -9840,4 +9840,24 @@ SELECT * FROM INFORMATION_SCHEMA.TABLES JOIN INFORMATION_SCHEMA.PARAMETERS; DROP FUNCTION f; DROP VIEW v; +--echo # +--echo # MDEV-17963: Assertion `field_pos < field_count' failed in Protocol_text::store, +--echo # Assertion `field_handlers == 0 || field_pos < field_count' +--echo # + +CREATE TABLE t1 (ct time); +INSERT INTO t1 VALUES ('16:11:28'); + +DELIMITER |; +--error ER_SP_NO_RETSET +CREATE FUNCTION f1 () RETURNS varchar(100) +BEGIN +DECLARE xxx varchar(100); +ANALYZE SELECT sum(ct) FROM t1 INTO xxx ; +RETURN xxx; +END| + +DELIMITER ;| +drop table t1; + --echo #End of 10.1 tests diff --git a/sql/sp_head.cc b/sql/sp_head.cc index c3274e2cecd..5c5688be4a3 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -212,7 +212,7 @@ sp_get_flags_for_command(LEX *lex) switch (lex->sql_command) { case SQLCOM_SELECT: - if (lex->result) + if (lex->result && !lex->analyze_stmt) { flags= 0; /* This is a SELECT with INTO clause */ break;
participants (1)
-
Varun