mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fix for Bug#12995: Inside function "Table 't4' was not locked with LOCK TABLES"
Any form of HANDLER statement is forbidden from usage in stored procedures/functions. mysql-test/r/sp-error.result: Results for the test case for Bug#12995 added. mysql-test/t/sp-error.test: Test case for Bug#12995 added. sql/sql_yacc.yy: Forbid any form of "HANDLER" statement from use in stored procedures/functions.
This commit is contained in:
@ -765,3 +765,24 @@ OPTIMIZE TABLE t1;
|
|||||||
RETURN 1;
|
RETURN 1;
|
||||||
END|
|
END|
|
||||||
ERROR 0A000: OPTIMIZE TABLE is not allowed in stored procedures
|
ERROR 0A000: OPTIMIZE TABLE is not allowed in stored procedures
|
||||||
|
DROP FUNCTION IF EXISTS bug12995|
|
||||||
|
CREATE FUNCTION bug12995() RETURNS INT
|
||||||
|
BEGIN
|
||||||
|
HANDLER t1 OPEN;
|
||||||
|
RETURN 1;
|
||||||
|
END|
|
||||||
|
ERROR 0A000: HANDLER is not allowed in stored procedures
|
||||||
|
CREATE FUNCTION bug12995() RETURNS INT
|
||||||
|
BEGIN
|
||||||
|
HANDLER t1 READ FIRST;
|
||||||
|
RETURN 1;
|
||||||
|
END|
|
||||||
|
ERROR 0A000: HANDLER is not allowed in stored procedures
|
||||||
|
CREATE FUNCTION bug12995() RETURNS INT
|
||||||
|
BEGIN
|
||||||
|
HANDLER t1 CLOSE;
|
||||||
|
RETURN 1;
|
||||||
|
END|
|
||||||
|
ERROR 0A000: HANDLER is not allowed in stored procedures
|
||||||
|
SELECT bug12995()|
|
||||||
|
ERROR 42000: FUNCTION test.bug12995 does not exist
|
||||||
|
@ -1099,6 +1099,36 @@ BEGIN
|
|||||||
OPTIMIZE TABLE t1;
|
OPTIMIZE TABLE t1;
|
||||||
RETURN 1;
|
RETURN 1;
|
||||||
END|
|
END|
|
||||||
|
delimiter ;|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug##12995 "Inside function "Table 't4' was not locked with LOCK TABLES"
|
||||||
|
#
|
||||||
|
delimiter |;
|
||||||
|
--disable_warnings
|
||||||
|
DROP FUNCTION IF EXISTS bug12995|
|
||||||
|
--enable_warnings
|
||||||
|
--error ER_SP_BADSTATEMENT
|
||||||
|
CREATE FUNCTION bug12995() RETURNS INT
|
||||||
|
BEGIN
|
||||||
|
HANDLER t1 OPEN;
|
||||||
|
RETURN 1;
|
||||||
|
END|
|
||||||
|
--error ER_SP_BADSTATEMENT
|
||||||
|
CREATE FUNCTION bug12995() RETURNS INT
|
||||||
|
BEGIN
|
||||||
|
HANDLER t1 READ FIRST;
|
||||||
|
RETURN 1;
|
||||||
|
END|
|
||||||
|
--error ER_SP_BADSTATEMENT
|
||||||
|
CREATE FUNCTION bug12995() RETURNS INT
|
||||||
|
BEGIN
|
||||||
|
HANDLER t1 CLOSE;
|
||||||
|
RETURN 1;
|
||||||
|
END|
|
||||||
|
--error 1305
|
||||||
|
SELECT bug12995()|
|
||||||
|
delimiter ;|
|
||||||
|
|
||||||
#
|
#
|
||||||
# BUG#NNNN: New bug synopsis
|
# BUG#NNNN: New bug synopsis
|
||||||
|
@ -8157,6 +8157,11 @@ handler:
|
|||||||
HANDLER_SYM table_ident OPEN_SYM opt_table_alias
|
HANDLER_SYM table_ident OPEN_SYM opt_table_alias
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
|
if (lex->sphead)
|
||||||
|
{
|
||||||
|
my_error(ER_SP_BADSTATEMENT, MYF(0), "HANDLER");
|
||||||
|
YYABORT;
|
||||||
|
}
|
||||||
lex->sql_command = SQLCOM_HA_OPEN;
|
lex->sql_command = SQLCOM_HA_OPEN;
|
||||||
if (!lex->current_select->add_table_to_list(lex->thd, $2, $4, 0))
|
if (!lex->current_select->add_table_to_list(lex->thd, $2, $4, 0))
|
||||||
YYABORT;
|
YYABORT;
|
||||||
@ -8164,6 +8169,11 @@ handler:
|
|||||||
| HANDLER_SYM table_ident_nodb CLOSE_SYM
|
| HANDLER_SYM table_ident_nodb CLOSE_SYM
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
|
if (lex->sphead)
|
||||||
|
{
|
||||||
|
my_error(ER_SP_BADSTATEMENT, MYF(0), "HANDLER");
|
||||||
|
YYABORT;
|
||||||
|
}
|
||||||
lex->sql_command = SQLCOM_HA_CLOSE;
|
lex->sql_command = SQLCOM_HA_CLOSE;
|
||||||
if (!lex->current_select->add_table_to_list(lex->thd, $2, 0, 0))
|
if (!lex->current_select->add_table_to_list(lex->thd, $2, 0, 0))
|
||||||
YYABORT;
|
YYABORT;
|
||||||
@ -8171,6 +8181,11 @@ handler:
|
|||||||
| HANDLER_SYM table_ident_nodb READ_SYM
|
| HANDLER_SYM table_ident_nodb READ_SYM
|
||||||
{
|
{
|
||||||
LEX *lex=Lex;
|
LEX *lex=Lex;
|
||||||
|
if (lex->sphead)
|
||||||
|
{
|
||||||
|
my_error(ER_SP_BADSTATEMENT, MYF(0), "HANDLER");
|
||||||
|
YYABORT;
|
||||||
|
}
|
||||||
lex->sql_command = SQLCOM_HA_READ;
|
lex->sql_command = SQLCOM_HA_READ;
|
||||||
lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */
|
lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */
|
||||||
lex->current_select->select_limit= new Item_int((int32) 1);
|
lex->current_select->select_limit= new Item_int((int32) 1);
|
||||||
|
Reference in New Issue
Block a user