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
This commit is contained in:
Varun Gupta 2019-07-08 11:37:34 +05:30
parent 838bb9fad4
commit fd08f95322
3 changed files with 35 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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;