Skip to content

Commit

Permalink
MDEV-17963: Assertion `field_pos < field_count' failed in Protocol_te…
Browse files Browse the repository at this point in the history
…xt::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
  • Loading branch information
Varun Gupta committed Jul 9, 2019
1 parent 838bb9f commit fd08f95
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
14 changes: 14 additions & 0 deletions mysql-test/r/sp.result
Expand Up @@ -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
20 changes: 20 additions & 0 deletions mysql-test/t/sp.test
Expand Up @@ -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
2 changes: 1 addition & 1 deletion sql/sp_head.cc
Expand Up @@ -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;
Expand Down

0 comments on commit fd08f95

Please sign in to comment.