mirror of
https://github.com/MariaDB/server.git
synced 2025-09-11 05:52:26 +03:00
Background:
Since long, the compiled code of stored routines has been printed in the trace file when starting mysqld with the "--debug" flag. (At creation time only, and only in debug builds of course.) This has been helpful when debugging stored procedure execution, but it's a bit awkward to use. Also, the printing of some of the instructions is a bit terse, in particular for sp_instr_stmt where only the command code was printed. This improves the printout of several of the instructions, and adds the debugging- only commands "show procedure code <name>" and "show function code <name>". (In non-debug builds they are not available.) sql/lex.h: New symbol for debug-only command (e.g. show procedure code). sql/sp_head.cc: Fixed some minor debug-mode bugs in show_create_*(). New method for debugging: sp_head::show_routine_code() - returns the "assembly code" for a stored routine as a result set. Improved the print() methods for many sp_instr* classes, particularly for sp_instr_stmt where the query string is printed as well (up to a max length, just to give a hint of which statement it is). Also print the names of variables and cursors in some instruction. sql/sp_head.h: New debugging-only method in sp_head: show_routine_code(). Added offset member to sp_instr_cpush for improved debug printing. sql/sp_pcontext.cc: Moved find_pvar(uint i) method from sp_pcontext.h, and made it work for all frames, not just the first one. (For debugging purposes) Added a similar find_cursor(uint i, ...) method, for debugging. sql/sp_pcontext.h: Moved find_pvar(uint i) method to sp_pcontext.cc. Added a similar find_cursor(uint i, ...) method, for debugging. sql/sql_lex.h: Added new sql_command codes for debugging. sql/sql_parse.cc: Added new commands for debugging, e.g. "show procedure code". sql/sql_yacc.yy: Added new commands for debugging purposes: "show procedure code ..." and "show function code ...". These are only enabled in debug builds, otherwise they result in a syntax error. (I.e. they don't exist)
This commit is contained in:
@@ -4560,6 +4560,30 @@ end_with_restore_list:
|
||||
lex->wild->ptr() : NullS));
|
||||
break;
|
||||
}
|
||||
#ifndef DBUG_OFF
|
||||
case SQLCOM_SHOW_PROC_CODE:
|
||||
case SQLCOM_SHOW_FUNC_CODE:
|
||||
{
|
||||
sp_head *sp;
|
||||
|
||||
if (lex->spname->m_name.length > NAME_LEN)
|
||||
{
|
||||
my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str);
|
||||
goto error;
|
||||
}
|
||||
if (lex->sql_command == SQLCOM_SHOW_PROC_CODE)
|
||||
sp= sp_find_procedure(thd, lex->spname);
|
||||
else
|
||||
sp= sp_find_function(thd, lex->spname);
|
||||
if (!sp || !sp->show_routine_code(thd))
|
||||
{ /* We don't distinguish between errors for now */
|
||||
my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
|
||||
SP_COM_STRING(lex), lex->spname->m_name.str);
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif // ifndef DBUG_OFF
|
||||
case SQLCOM_CREATE_VIEW:
|
||||
{
|
||||
if (end_active_trans(thd))
|
||||
|
Reference in New Issue
Block a user