mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Improved error handling regarding SPs (with info like names etc in the output).
Disabled queries in FUNCTIONs. include/mysqld_error.h: New error message for queries in FUNCTIONs. mysql-test/t/sp.test: Moved error tests to sp-error.test. sql/share/czech/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/danish/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/dutch/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/english/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/estonian/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/french/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/german/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/greek/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/hungarian/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/italian/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/japanese/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/korean/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/norwegian-ny/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/norwegian/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/polish/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/portuguese/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/romanian/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/russian/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/serbian/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/slovak/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/spanish/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/swedish/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/share/ukrainian/errmsg.txt: New error message for queries in FUNCTIONs. Improved most of the SP error messages with added info. sql/sp_head.cc: Added debug output to sp_instr_jump::execute(). (Moved from sp_head.h) sql/sp_head.h: Moved sp_instr_jump::execute() to sp_head.cc. sql/sql_lex.h: Added SQLCOM_CREATE_SPFUNCTION (for improved error handling). sql/sql_parse.cc: Improved error handling regarding SPs (adding info like names etc in output). sql/sql_yacc.yy: Improved error handling regarding SPs (adding info like names etc in output). Disabled queries in FUNCTIONS (since it can't work anyway).
This commit is contained in:
@ -52,6 +52,15 @@
|
||||
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
|
||||
#define TRANS_MEM_ROOT_PREALLOC 4096
|
||||
|
||||
/* Used in error handling only */
|
||||
#define SP_TYPE_STRING(LP) \
|
||||
((LP)->sphead->m_type == TYPE_ENUM_FUNCTION ? "FUNCTION" : "PROCEDURE")
|
||||
#define SP_COM_STRING(LP) \
|
||||
((LP)->sql_command == SQLCOM_CREATE_SPFUNCTION || \
|
||||
(LP)->sql_command == SQLCOM_ALTER_FUNCTION || \
|
||||
(LP)->sql_command == SQLCOM_DROP_FUNCTION ? \
|
||||
"FUNCTION" : "PROCEDURE")
|
||||
|
||||
extern int yyparse(void *thd);
|
||||
extern "C" pthread_mutex_t THR_LOCK_keycache;
|
||||
#ifdef SOLARIS
|
||||
@ -1589,7 +1598,7 @@ mysql_execute_command(THD *thd)
|
||||
*/
|
||||
sp_clear_function_cache(thd);
|
||||
if (lex->sql_command != SQLCOM_CREATE_PROCEDURE &&
|
||||
lex->sql_command != SQLCOM_CREATE_FUNCTION)
|
||||
lex->sql_command != SQLCOM_CREATE_SPFUNCTION)
|
||||
{
|
||||
if (sp_cache_functions(thd, lex))
|
||||
DBUG_RETURN(-1);
|
||||
@ -2961,23 +2970,27 @@ mysql_execute_command(THD *thd)
|
||||
res= -1;
|
||||
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE);
|
||||
break;
|
||||
case SQLCOM_CREATE_PROCEDURE: // FUNCTION too (but not UDF!)
|
||||
case SQLCOM_CREATE_PROCEDURE:
|
||||
case SQLCOM_CREATE_SPFUNCTION:
|
||||
if (!lex->sphead)
|
||||
{
|
||||
send_error(thd, ER_SP_NO_RECURSIVE_CREATE);
|
||||
goto error;
|
||||
res= -1; // Shouldn't happen
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint namelen;
|
||||
char *name= lex->sphead->name(&namelen);
|
||||
#ifdef HAVE_DLOPEN
|
||||
udf_func *udf = find_udf(name, namelen);
|
||||
|
||||
if (udf)
|
||||
if (lex->sphead->m_type == TYPE_ENUM_FUNCTION)
|
||||
{
|
||||
net_printf(thd, ER_UDF_EXISTS, name);
|
||||
goto error;
|
||||
udf_func *udf = find_udf(name, namelen);
|
||||
|
||||
if (udf)
|
||||
{
|
||||
net_printf(thd, ER_UDF_EXISTS, name);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
res= lex->sphead->create(thd);
|
||||
@ -2987,10 +3000,10 @@ mysql_execute_command(THD *thd)
|
||||
send_ok(thd);
|
||||
break;
|
||||
case SP_WRITE_ROW_FAILED:
|
||||
send_error(thd, ER_SP_ALREADY_EXISTS);
|
||||
net_printf(thd, ER_SP_ALREADY_EXISTS, SP_TYPE_STRING(lex), name);
|
||||
goto error;
|
||||
default:
|
||||
send_error(thd, ER_SP_STORE_FAILED);
|
||||
net_printf(thd, ER_SP_STORE_FAILED, SP_TYPE_STRING(lex), name);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -3002,7 +3015,7 @@ mysql_execute_command(THD *thd)
|
||||
sp= sp_find_procedure(thd, &lex->udf.name);
|
||||
if (! sp)
|
||||
{
|
||||
send_error(thd, ER_SP_DOES_NOT_EXIST);
|
||||
net_printf(thd, ER_SP_DOES_NOT_EXIST, "PROCEDURE", lex->udf.name);
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
@ -3037,7 +3050,7 @@ mysql_execute_command(THD *thd)
|
||||
sp= sp_find_function(thd, &lex->udf.name);
|
||||
if (! sp)
|
||||
{
|
||||
send_error(thd, ER_SP_DOES_NOT_EXIST);
|
||||
net_printf(thd, ER_SP_DOES_NOT_EXIST, SP_COM_STRING(lex),lex->udf.name);
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
@ -3079,10 +3092,12 @@ mysql_execute_command(THD *thd)
|
||||
send_ok(thd);
|
||||
break;
|
||||
case SP_KEY_NOT_FOUND:
|
||||
send_error(thd, ER_SP_DOES_NOT_EXIST);
|
||||
net_printf(thd, ER_SP_DOES_NOT_EXIST, SP_COM_STRING(lex),
|
||||
lex->udf.name.str);
|
||||
goto error;
|
||||
default:
|
||||
send_error(thd, ER_SP_DROP_FAILED);
|
||||
net_printf(thd, ER_SP_DROP_FAILED, SP_COM_STRING(lex),
|
||||
lex->udf.name.str);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user