Commit 66b71ca3 authored by unknown's avatar unknown

Fixed BUG#6600: Stored procedure crash after repeated calls with check table.

  Sedond attempt: Simply disallow CHECK in SPs, since it can't work.


mysql-test/r/sp-error.result:
  New test cast for BUG#6600
mysql-test/r/sp.result:
  Removed old test case for BUG#6600
mysql-test/t/sp-error.test:
  New test cast for BUG#6600
mysql-test/t/sp.test:
  Removed old test case for BUG#6600
sql/share/errmsg.txt:
  Made the SP bad statement error message more general.
sql/sp_head.cc:
  CHECK is not possible in stored procedures.
sql/sql_parse.cc:
  Undid attempt to fix CHECK in stored procedures, it didn't work.
sql/sql_yacc.yy:
  CHECK is not possible in stored procedures.
  (And updated error messages for LOCK/UNLOCK.)
parent 3a44dcd1
...@@ -494,4 +494,13 @@ declare continue handler for sqlstate '42x00' begin end; ...@@ -494,4 +494,13 @@ declare continue handler for sqlstate '42x00' begin end;
begin end; begin end;
end| end|
ERROR 42000: Bad SQLSTATE: '42x00' ERROR 42000: Bad SQLSTATE: '42x00'
create procedure bug6600()
check table t1|
ERROR 0A000: CHECK is not allowed in stored procedures
create procedure bug6600()
lock table t1 read|
ERROR 0A000: LOCK is not allowed in stored procedures
create procedure bug6600()
unlock table t1|
ERROR 0A000: UNLOCK is not allowed in stored procedures
drop table t1| drop table t1|
...@@ -2779,23 +2779,4 @@ a ...@@ -2779,23 +2779,4 @@ a
3.2000 3.2000
drop procedure bug8937| drop procedure bug8937|
delete from t1| delete from t1|
drop procedure if exists bug6600|
drop table if exists t3|
drop view if exists v1|
create table t3 (s1 decimal(31,30))|
create view v1 as select * from t3|
create procedure bug6600()
check table v1|
call bug6600()|
Table Op Msg_type Msg_text
test.v1 check status OK
call bug6600()|
Table Op Msg_type Msg_text
test.v1 check status OK
call bug6600()|
Table Op Msg_type Msg_text
test.v1 check status OK
drop procedure bug6600|
drop view v1|
drop table t3|
drop table t1,t2; drop table t1,t2;
...@@ -680,6 +680,23 @@ begin ...@@ -680,6 +680,23 @@ begin
end| end|
#
# BUG#6600: Stored procedure crash after repeated calls with check table
#
--error ER_SP_BADSTATEMENT
create procedure bug6600()
check table t1|
# Check these two as well, while we're at it. (Although it isn't really
# related to the bug report, but to the fix.)
--error ER_SP_BADSTATEMENT
create procedure bug6600()
lock table t1 read|
--error ER_SP_BADSTATEMENT
create procedure bug6600()
unlock table t1|
# #
# BUG#NNNN: New bug synopsis # BUG#NNNN: New bug synopsis
# #
......
...@@ -3398,28 +3398,6 @@ drop procedure bug8937| ...@@ -3398,28 +3398,6 @@ drop procedure bug8937|
delete from t1| delete from t1|
#
# BUG#6600: Stored procedure crash after repeated calls with check table
#
--disable_warnings
drop procedure if exists bug6600|
drop table if exists t3|
drop view if exists v1|
--enable_warnings
create table t3 (s1 decimal(31,30))|
create view v1 as select * from t3|
create procedure bug6600()
check table v1|
call bug6600()|
call bug6600()|
call bug6600()|
drop procedure bug6600|
drop view v1|
drop table t3|
# #
# BUG#NNNN: New bug synopsis # BUG#NNNN: New bug synopsis
# #
......
...@@ -5094,7 +5094,7 @@ ER_SP_BADSELECT 0A000 ...@@ -5094,7 +5094,7 @@ ER_SP_BADSELECT 0A000
ER_SP_BADRETURN 42000 ER_SP_BADRETURN 42000
eng "RETURN is only allowed in a FUNCTION" eng "RETURN is only allowed in a FUNCTION"
ER_SP_BADSTATEMENT 0A000 ER_SP_BADSTATEMENT 0A000
eng "LOCK and UNLOCK tables are not allowed in stored procedures" eng "%s is not allowed in stored procedures"
ER_UPDATE_LOG_DEPRECATED_IGNORED 42000 ER_UPDATE_LOG_DEPRECATED_IGNORED 42000
eng "The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been ignored" eng "The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been ignored"
ER_UPDATE_LOG_DEPRECATED_TRANSLATED 42000 ER_UPDATE_LOG_DEPRECATED_TRANSLATED 42000
......
...@@ -58,7 +58,6 @@ sp_multi_results_command(enum enum_sql_command cmd) ...@@ -58,7 +58,6 @@ sp_multi_results_command(enum enum_sql_command cmd)
{ {
switch (cmd) { switch (cmd) {
case SQLCOM_ANALYZE: case SQLCOM_ANALYZE:
case SQLCOM_CHECK:
case SQLCOM_CHECKSUM: case SQLCOM_CHECKSUM:
case SQLCOM_HA_READ: case SQLCOM_HA_READ:
case SQLCOM_SHOW_BINLOGS: case SQLCOM_SHOW_BINLOGS:
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "sp_head.h" #include "sp_head.h"
#include "sp.h" #include "sp.h"
#include "sp_cache.h"
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
/* /*
...@@ -3046,7 +3045,6 @@ unsent_create_error: ...@@ -3046,7 +3045,6 @@ unsent_create_error:
goto error; /* purecov: inspected */ goto error; /* purecov: inspected */
thd->slow_command=TRUE; thd->slow_command=TRUE;
res = mysql_check_table(thd, first_table, &lex->check_opt); res = mysql_check_table(thd, first_table, &lex->check_opt);
sp_cache_invalidate();
break; break;
} }
case SQLCOM_ANALYZE: case SQLCOM_ANALYZE:
......
...@@ -3670,9 +3670,15 @@ analyze: ...@@ -3670,9 +3670,15 @@ analyze:
check: check:
CHECK_SYM table_or_tables CHECK_SYM table_or_tables
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->sql_command = SQLCOM_CHECK;
lex->check_opt.init(); if (lex->sphead)
{
my_error(ER_SP_BADSTATEMENT, MYF(0), "CHECK");
YYABORT;
}
lex->sql_command = SQLCOM_CHECK;
lex->check_opt.init();
} }
table_list opt_mi_check_type table_list opt_mi_check_type
{} {}
...@@ -7719,7 +7725,7 @@ lock: ...@@ -7719,7 +7725,7 @@ lock:
if (lex->sphead) if (lex->sphead)
{ {
my_message(ER_SP_BADSTATEMENT, ER(ER_SP_BADSTATEMENT), MYF(0)); my_error(ER_SP_BADSTATEMENT, MYF(0), "LOCK");
YYABORT; YYABORT;
} }
lex->sql_command= SQLCOM_LOCK_TABLES; lex->sql_command= SQLCOM_LOCK_TABLES;
...@@ -7758,7 +7764,7 @@ unlock: ...@@ -7758,7 +7764,7 @@ unlock:
if (lex->sphead) if (lex->sphead)
{ {
my_message(ER_SP_BADSTATEMENT, ER(ER_SP_BADSTATEMENT), MYF(0)); my_error(ER_SP_BADSTATEMENT, MYF(0), "UNLOCK");
YYABORT; YYABORT;
} }
lex->sql_command= SQLCOM_UNLOCK_TABLES; lex->sql_command= SQLCOM_UNLOCK_TABLES;
......
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