diff --git a/mysql-test/r/analyze_stmt.result b/mysql-test/r/analyze_stmt.result index 628c7859e6c..0a42728c81c 100644 --- a/mysql-test/r/analyze_stmt.result +++ b/mysql-test/r/analyze_stmt.result @@ -293,3 +293,13 @@ analyze select * into outfile '../../tmp/data1.tmp' from t1; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 4 100.00 100.00 drop table t1; +# +# MDEV-7024: Assertion `! is_set()' failed in +# Diagnostics_area::set_eof_status on executing ANALYZE SELECT via PS +# +create table t1(a int); +prepare stmt from "analyze select * from t1"; +execute stmt; +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 matching row in const table +drop table t1; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 4fa43e82a1d..3f28df927b8 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -7880,3 +7880,60 @@ DECLARE f2 VARCHAR(64) COLLATE latin1_german2_ci; RETURN 'str'; END| DROP FUNCTION f| +# +# 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 +# +create table t1 (i int); +create table t2 (i int); +create function f() returns int +begin +analyze insert into t1 values (1); +return 1; +end | +ERROR 0A000: Not allowed to return a result set from a function +create function f() returns int +begin +analyze insert t1 select * from t2; +return 1; +end | +ERROR 0A000: Not allowed to return a result set from a function +create function f() returns int +begin +analyze delete from t1; +return 1; +end | +ERROR 0A000: Not allowed to return a result set from a function +create function f() returns int +begin +analyze delete t1 from t1,t2; +return 1; +end | +ERROR 0A000: Not allowed to return a result set from a function +create function f() returns int +begin +analyze update t1 set i=1; +return 1; +end | +ERROR 0A000: Not allowed to return a result set from a function +create function f() returns int +begin +analyze update t1,t2 set i=1; +return 1; +end | +ERROR 0A000: Not allowed to return a result set from a function +create function f() returns int +begin +analyze replace t1 set i=1; +return 1; +end | +ERROR 0A000: Not allowed to return a result set from a function +create function f() returns int +begin +analyze replace t1 select * from t2; +return 1; +end | +ERROR 0A000: Not allowed to return a result set from a function +drop table t1,t2; diff --git a/mysql-test/t/analyze_stmt.test b/mysql-test/t/analyze_stmt.test index f5c5c432434..4da16cf6474 100644 --- a/mysql-test/t/analyze_stmt.test +++ b/mysql-test/t/analyze_stmt.test @@ -233,3 +233,14 @@ analyze select * into outfile '../../tmp/data1.tmp' from t1; --remove_file $MYSQLTEST_VARDIR/tmp/data1.tmp drop table t1; + + +--echo # +--echo # MDEV-7024: Assertion `! is_set()' failed in +--echo # Diagnostics_area::set_eof_status on executing ANALYZE SELECT via PS +--echo # + +create table t1(a int); +prepare stmt from "analyze select * from t1"; +execute stmt; +drop table t1; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 3f635acaac9..7dda755481c 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -9324,3 +9324,64 @@ BEGIN END| DROP FUNCTION f| DELIMITER ;| + +--echo # +--echo # MDEV-7023: Error 2027: Malformed packet and assertion +--echo # `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_INT24 || +--echo #field_types[field_pos] == MYSQL_TYPE_LONG' failure in +--echo #Protocol_text::store_long +--echo # +create table t1 (i int); +create table t2 (i int); +--delimiter | +--error ER_SP_NO_RETSET +create function f() returns int +begin + analyze insert into t1 values (1); + return 1; +end | +--error ER_SP_NO_RETSET +create function f() returns int +begin + analyze insert t1 select * from t2; + return 1; +end | +--error ER_SP_NO_RETSET +create function f() returns int +begin + analyze delete from t1; + return 1; +end | +--error ER_SP_NO_RETSET +create function f() returns int +begin + analyze delete t1 from t1,t2; + return 1; +end | +--error ER_SP_NO_RETSET +create function f() returns int +begin + analyze update t1 set i=1; + return 1; +end | +--error ER_SP_NO_RETSET +create function f() returns int +begin + analyze update t1,t2 set i=1; + return 1; +end | +--error ER_SP_NO_RETSET +create function f() returns int +begin + analyze replace t1 set i=1; + return 1; +end | +--error ER_SP_NO_RETSET +create function f() returns int +begin + analyze replace t1 select * from t2; + return 1; +end | +--delimiter ; + +drop table t1,t2; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index aa0cb4a92ef..c0b1b9947da 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -341,11 +341,13 @@ sp_get_flags_for_command(LEX *lex) case SQLCOM_DELETE_MULTI: { /* - DELETE normally doesn't return resultset, but there are two exceptions: + DELETE normally doesn't return resultset, but there are 3 exceptions: - DELETE ... RETURNING - EXPLAIN DELETE ... + - ANALYZE DELETE ... */ - if (lex->select_lex.item_list.is_empty() && !lex->describe) + if (lex->select_lex.item_list.is_empty() && + !lex->describe && !lex->analyze_stmt) flags= 0; else flags= sp_head::MULTI_RESULTS; @@ -358,7 +360,7 @@ sp_get_flags_for_command(LEX *lex) case SQLCOM_REPLACE_SELECT: case SQLCOM_INSERT_SELECT: { - if (!lex->describe) + if (!lex->describe && !lex->analyze_stmt) flags= 0; else flags= sp_head::MULTI_RESULTS; diff --git a/sql/sql_class.h b/sql/sql_class.h index e6457f23a50..16913fd50b5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4116,7 +4116,7 @@ public: virtual bool check_simple_select() const { return FALSE; } void abort_result_set(); virtual void cleanup(); - bool is_result_interceptor() { return true; } + bool is_result_interceptor() { return false; } };