Commit 36779e62 authored by Varun Gupta's avatar Varun Gupta

MDEV-14623: Output of show function code does not show FETCH GROUP NEXT ROW for custom aggregates

The print() function was missing from the FETCH GROUP NEXT ROW instrunction class, so there was no
output for this particular instruction when we use the query SHOW FUNCTION CODE function_name
parent 89b1c271
......@@ -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;
......@@ -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;
......@@ -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
......
......@@ -1957,7 +1957,7 @@ class sp_instr_agg_cfetch : public sp_instr
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment