diff --git a/mysql-test/main/sp-code.result b/mysql-test/main/sp-code.result index 3a4dc9db6f8..001b03a0e3b 100644 --- a/mysql-test/main/sp-code.result +++ b/mysql-test/main/sp-code.result @@ -1301,3 +1301,24 @@ Pos Instruction 28 jump 4 29 cpop 1 DROP PROCEDURE p1; +# +# MDEV-14623: Output of show function code does not show FETCH GROUP NEXT ROW +# for custom aggregates +# +create aggregate function f1(x INT) returns int +begin +declare continue handler for not found return 0; +loop +fetch group next row; +insert into t2 (sal) values (x); +end loop; +end| +show function code f1; +Pos Instruction +0 hpush_jump 2 1 CONTINUE +1 freturn int 0 +2 agg_cfetch +3 stmt 5 "insert into t2 (sal) values (x)" +4 jump 2 +5 hpop 1 +drop function f1; diff --git a/mysql-test/main/sp-code.test b/mysql-test/main/sp-code.test index 1f2f5191f0a..f8c1b4f0a92 100644 --- a/mysql-test/main/sp-code.test +++ b/mysql-test/main/sp-code.test @@ -927,3 +927,22 @@ $$ DELIMITER ;$$ SHOW PROCEDURE CODE p1; DROP PROCEDURE p1; + +--echo # +--echo # MDEV-14623: Output of show function code does not show FETCH GROUP NEXT ROW +--echo # for custom aggregates +--echo # + +delimiter |; +create aggregate function f1(x INT) returns int +begin + declare continue handler for not found return 0; + loop + fetch group next row; + insert into t2 (sal) values (x); + end loop; +end| + +delimiter ;| +show function code f1; +drop function f1; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 1514689d8b3..ac88f05a866 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -4409,7 +4409,7 @@ sp_instr_cfetch::print(String *str) int sp_instr_agg_cfetch::execute(THD *thd, uint *nextp) { - DBUG_ENTER("sp_instr_cfetch::execute"); + DBUG_ENTER("sp_instr_agg_cfetch::execute"); int res= 0; if (!thd->spcont->instr_ptr) { @@ -4434,7 +4434,16 @@ sp_instr_agg_cfetch::execute(THD *thd, uint *nextp) DBUG_RETURN(res); } +void +sp_instr_agg_cfetch::print(String *str) +{ + uint rsrv= SP_INSTR_UINT_MAXLEN+11; + + if (str->reserve(rsrv)) + return; + str->qs_append(STRING_WITH_LEN("agg_cfetch")); +} /* sp_instr_cursor_copy_struct class functions diff --git a/sql/sp_head.h b/sql/sp_head.h index f588f79b599..c0c0c83b77e 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -1957,7 +1957,7 @@ public: virtual int execute(THD *thd, uint *nextp); - virtual void print(String *str){}; + virtual void print(String *str); }; // class sp_instr_agg_cfetch : public sp_instr