Skip to content

Commit 51feb6f

Browse files
committed
MDEV-7023: Error 2027: Malformed packet and assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_INT24 || field_types[field_pos] == MYSQL_TYPE_LONG' failure in Protocol_text::store_long
The problem was that sp_head::MULTI_RESULTS was not set correctly for ANALYZE statement.
1 parent 0b049b4 commit 51feb6f

File tree

3 files changed

+123
-3
lines changed

3 files changed

+123
-3
lines changed

mysql-test/r/sp.result

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7880,3 +7880,60 @@ DECLARE f2 VARCHAR(64) COLLATE latin1_german2_ci;
78807880
RETURN 'str';
78817881
END|
78827882
DROP FUNCTION f|
7883+
#
7884+
# MDEV-7023: Error 2027: Malformed packet and assertion
7885+
# `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_INT24 ||
7886+
#field_types[field_pos] == MYSQL_TYPE_LONG' failure in
7887+
#Protocol_text::store_long
7888+
#
7889+
create table t1 (i int);
7890+
create table t2 (i int);
7891+
create function f() returns int
7892+
begin
7893+
analyze insert into t1 values (1);
7894+
return 1;
7895+
end |
7896+
ERROR 0A000: Not allowed to return a result set from a function
7897+
create function f() returns int
7898+
begin
7899+
analyze insert t1 select * from t2;
7900+
return 1;
7901+
end |
7902+
ERROR 0A000: Not allowed to return a result set from a function
7903+
create function f() returns int
7904+
begin
7905+
analyze delete from t1;
7906+
return 1;
7907+
end |
7908+
ERROR 0A000: Not allowed to return a result set from a function
7909+
create function f() returns int
7910+
begin
7911+
analyze delete t1 from t1,t2;
7912+
return 1;
7913+
end |
7914+
ERROR 0A000: Not allowed to return a result set from a function
7915+
create function f() returns int
7916+
begin
7917+
analyze update t1 set i=1;
7918+
return 1;
7919+
end |
7920+
ERROR 0A000: Not allowed to return a result set from a function
7921+
create function f() returns int
7922+
begin
7923+
analyze update t1,t2 set i=1;
7924+
return 1;
7925+
end |
7926+
ERROR 0A000: Not allowed to return a result set from a function
7927+
create function f() returns int
7928+
begin
7929+
analyze replace t1 set i=1;
7930+
return 1;
7931+
end |
7932+
ERROR 0A000: Not allowed to return a result set from a function
7933+
create function f() returns int
7934+
begin
7935+
analyze replace t1 select * from t2;
7936+
return 1;
7937+
end |
7938+
ERROR 0A000: Not allowed to return a result set from a function
7939+
drop table t1,t2;

mysql-test/t/sp.test

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9324,3 +9324,64 @@ BEGIN
93249324
END|
93259325
DROP FUNCTION f|
93269326
DELIMITER ;|
9327+
9328+
--echo #
9329+
--echo # MDEV-7023: Error 2027: Malformed packet and assertion
9330+
--echo # `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_INT24 ||
9331+
--echo #field_types[field_pos] == MYSQL_TYPE_LONG' failure in
9332+
--echo #Protocol_text::store_long
9333+
--echo #
9334+
create table t1 (i int);
9335+
create table t2 (i int);
9336+
--delimiter |
9337+
--error ER_SP_NO_RETSET
9338+
create function f() returns int
9339+
begin
9340+
analyze insert into t1 values (1);
9341+
return 1;
9342+
end |
9343+
--error ER_SP_NO_RETSET
9344+
create function f() returns int
9345+
begin
9346+
analyze insert t1 select * from t2;
9347+
return 1;
9348+
end |
9349+
--error ER_SP_NO_RETSET
9350+
create function f() returns int
9351+
begin
9352+
analyze delete from t1;
9353+
return 1;
9354+
end |
9355+
--error ER_SP_NO_RETSET
9356+
create function f() returns int
9357+
begin
9358+
analyze delete t1 from t1,t2;
9359+
return 1;
9360+
end |
9361+
--error ER_SP_NO_RETSET
9362+
create function f() returns int
9363+
begin
9364+
analyze update t1 set i=1;
9365+
return 1;
9366+
end |
9367+
--error ER_SP_NO_RETSET
9368+
create function f() returns int
9369+
begin
9370+
analyze update t1,t2 set i=1;
9371+
return 1;
9372+
end |
9373+
--error ER_SP_NO_RETSET
9374+
create function f() returns int
9375+
begin
9376+
analyze replace t1 set i=1;
9377+
return 1;
9378+
end |
9379+
--error ER_SP_NO_RETSET
9380+
create function f() returns int
9381+
begin
9382+
analyze replace t1 select * from t2;
9383+
return 1;
9384+
end |
9385+
--delimiter ;
9386+
9387+
drop table t1,t2;

sql/sp_head.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,13 @@ sp_get_flags_for_command(LEX *lex)
341341
case SQLCOM_DELETE_MULTI:
342342
{
343343
/*
344-
DELETE normally doesn't return resultset, but there are two exceptions:
344+
DELETE normally doesn't return resultset, but there are 3 exceptions:
345345
- DELETE ... RETURNING
346346
- EXPLAIN DELETE ...
347+
- ANALYZE DELETE ...
347348
*/
348-
if (lex->select_lex.item_list.is_empty() && !lex->describe)
349+
if (lex->select_lex.item_list.is_empty() &&
350+
!lex->describe && !lex->analyze_stmt)
349351
flags= 0;
350352
else
351353
flags= sp_head::MULTI_RESULTS;
@@ -358,7 +360,7 @@ sp_get_flags_for_command(LEX *lex)
358360
case SQLCOM_REPLACE_SELECT:
359361
case SQLCOM_INSERT_SELECT:
360362
{
361-
if (!lex->describe)
363+
if (!lex->describe && !lex->analyze_stmt)
362364
flags= 0;
363365
else
364366
flags= sp_head::MULTI_RESULTS;

0 commit comments

Comments
 (0)