Commit 9c0a8bbd authored by serg@serg.mylan's avatar serg@serg.mylan

this has nothing to do with the bug#13012.

it's about mysql_admin_commands not being reexecution-safe
(and CHECK still isn't)
parent e5182639
...@@ -768,7 +768,7 @@ BEGIN ...@@ -768,7 +768,7 @@ BEGIN
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
RETURN 1; RETURN 1;
END| END|
ERROR 0A000: OPTIMIZE TABLE is not allowed in stored procedures ERROR 0A000: Not allowed to return a result set from a function
DROP FUNCTION IF EXISTS bug12995| DROP FUNCTION IF EXISTS bug12995|
CREATE FUNCTION bug12995() RETURNS INT CREATE FUNCTION bug12995() RETURNS INT
BEGIN BEGIN
......
...@@ -4168,6 +4168,69 @@ test.t1 backup status OK ...@@ -4168,6 +4168,69 @@ test.t1 backup status OK
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 restore status OK test.t1 restore status OK
drop procedure bug13012| drop procedure bug13012|
create view v1 as select * from t1|
create procedure bug13012()
BEGIN
REPAIR TABLE t1,t2,t3,v1;
OPTIMIZE TABLE t1,t2,t3,v1;
ANALYZE TABLE t1,t2,t3,v1;
END|
call bug13012()|
Table Op Msg_type Msg_text
test.t1 repair status OK
test.t2 repair status OK
test.t3 repair error Table 'test.t3' doesn't exist
test.v1 repair note Unknown table 'test.v1'
Table Op Msg_type Msg_text
test.t1 optimize status OK
test.t2 optimize status OK
test.t3 optimize error Table 'test.t3' doesn't exist
test.v1 optimize note Unknown table 'test.v1'
Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date
test.t2 analyze status Table is already up to date
test.t3 analyze error Table 'test.t3' doesn't exist
test.v1 analyze note Unknown table 'test.v1'
Warnings:
Error 1146 Table 'test.t3' doesn't exist
call bug13012()|
Table Op Msg_type Msg_text
test.t1 repair status OK
test.t2 repair status OK
test.t3 repair error Table 'test.t3' doesn't exist
test.v1 repair note Unknown table 'test.v1'
Table Op Msg_type Msg_text
test.t1 optimize status OK
test.t2 optimize status OK
test.t3 optimize error Table 'test.t3' doesn't exist
test.v1 optimize note Unknown table 'test.v1'
Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date
test.t2 analyze status Table is already up to date
test.t3 analyze error Table 'test.t3' doesn't exist
test.v1 analyze note Unknown table 'test.v1'
Warnings:
Error 1146 Table 'test.t3' doesn't exist
call bug13012()|
Table Op Msg_type Msg_text
test.t1 repair status OK
test.t2 repair status OK
test.t3 repair error Table 'test.t3' doesn't exist
test.v1 repair note Unknown table 'test.v1'
Table Op Msg_type Msg_text
test.t1 optimize status OK
test.t2 optimize status OK
test.t3 optimize error Table 'test.t3' doesn't exist
test.v1 optimize note Unknown table 'test.v1'
Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date
test.t2 analyze status Table is already up to date
test.t3 analyze error Table 'test.t3' doesn't exist
test.v1 analyze note Unknown table 'test.v1'
Warnings:
Error 1146 Table 'test.t3' doesn't exist
drop procedure bug13012|
drop view v1;
select * from t1| select * from t1|
a a
a - table column a - table column
......
...@@ -52,5 +52,6 @@ unlock tables; ...@@ -52,5 +52,6 @@ unlock tables;
connection con1; connection con1;
reap; reap;
drop table t5; drop table t5;
--system rm $MYSQL_TEST_DIR/var/tmp/t?.*
# End of 4.1 tests # End of 4.1 tests
...@@ -1095,7 +1095,7 @@ delimiter |; ...@@ -1095,7 +1095,7 @@ delimiter |;
--disable_warnings --disable_warnings
DROP FUNCTION IF EXISTS bug12953| DROP FUNCTION IF EXISTS bug12953|
--enable_warnings --enable_warnings
--error ER_SP_BADSTATEMENT --error ER_SP_NO_RETSET
CREATE FUNCTION bug12953() RETURNS INT CREATE FUNCTION bug12953() RETURNS INT
BEGIN BEGIN
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
......
...@@ -4961,9 +4961,20 @@ BEGIN ...@@ -4961,9 +4961,20 @@ BEGIN
DROP TABLE t1; DROP TABLE t1;
RESTORE TABLE t1 FROM '../tmp'; RESTORE TABLE t1 FROM '../tmp';
END| END|
--replace_result ": 7" ": X" ": 17" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR
call bug13012()| call bug13012()|
drop procedure bug13012| drop procedure bug13012|
create view v1 as select * from t1|
create procedure bug13012()
BEGIN
REPAIR TABLE t1,t2,t3,v1;
OPTIMIZE TABLE t1,t2,t3,v1;
ANALYZE TABLE t1,t2,t3,v1;
END|
call bug13012()|
call bug13012()|
call bug13012()|
drop procedure bug13012|
drop view v1;
select * from t1| select * from t1|
# #
......
...@@ -72,7 +72,11 @@ sp_get_flags_for_command(LEX *lex) ...@@ -72,7 +72,11 @@ sp_get_flags_for_command(LEX *lex)
} }
/* fallthrough */ /* fallthrough */
case SQLCOM_ANALYZE: case SQLCOM_ANALYZE:
case SQLCOM_OPTIMIZE:
case SQLCOM_PRELOAD_KEYS:
case SQLCOM_ASSIGN_TO_KEYCACHE:
case SQLCOM_CHECKSUM: case SQLCOM_CHECKSUM:
case SQLCOM_CHECK:
case SQLCOM_HA_READ: case SQLCOM_HA_READ:
case SQLCOM_SHOW_BINLOGS: case SQLCOM_SHOW_BINLOGS:
case SQLCOM_SHOW_BINLOG_EVENTS: case SQLCOM_SHOW_BINLOG_EVENTS:
......
...@@ -2614,7 +2614,8 @@ mysql_execute_command(THD *thd) ...@@ -2614,7 +2614,8 @@ mysql_execute_command(THD *thd)
goto error; /* purecov: inspected */ goto error; /* purecov: inspected */
thd->enable_slow_log= opt_log_slow_admin_statements; thd->enable_slow_log= opt_log_slow_admin_statements;
res = mysql_backup_table(thd, first_table); res = mysql_backup_table(thd, first_table);
(TABLE_LIST*) select_lex->table_list.first=first_table;
lex->query_tables=all_tables;
break; break;
} }
case SQLCOM_RESTORE_TABLE: case SQLCOM_RESTORE_TABLE:
...@@ -2626,6 +2627,8 @@ mysql_execute_command(THD *thd) ...@@ -2626,6 +2627,8 @@ mysql_execute_command(THD *thd)
goto error; /* purecov: inspected */ goto error; /* purecov: inspected */
thd->enable_slow_log= opt_log_slow_admin_statements; thd->enable_slow_log= opt_log_slow_admin_statements;
res = mysql_restore_table(thd, first_table); res = mysql_restore_table(thd, first_table);
(TABLE_LIST*) select_lex->table_list.first=first_table;
lex->query_tables=all_tables;
break; break;
} }
case SQLCOM_ASSIGN_TO_KEYCACHE: case SQLCOM_ASSIGN_TO_KEYCACHE:
...@@ -3128,6 +3131,8 @@ end_with_restore_list: ...@@ -3128,6 +3131,8 @@ end_with_restore_list:
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
} }
(TABLE_LIST*) select_lex->table_list.first=first_table;
lex->query_tables=all_tables;
break; break;
} }
case SQLCOM_CHECK: case SQLCOM_CHECK:
...@@ -3138,6 +3143,8 @@ end_with_restore_list: ...@@ -3138,6 +3143,8 @@ end_with_restore_list:
goto error; /* purecov: inspected */ goto error; /* purecov: inspected */
thd->enable_slow_log= opt_log_slow_admin_statements; thd->enable_slow_log= opt_log_slow_admin_statements;
res = mysql_check_table(thd, first_table, &lex->check_opt); res = mysql_check_table(thd, first_table, &lex->check_opt);
(TABLE_LIST*) select_lex->table_list.first=first_table;
lex->query_tables=all_tables;
break; break;
} }
case SQLCOM_ANALYZE: case SQLCOM_ANALYZE:
...@@ -3158,6 +3165,8 @@ end_with_restore_list: ...@@ -3158,6 +3165,8 @@ end_with_restore_list:
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
} }
(TABLE_LIST*) select_lex->table_list.first=first_table;
lex->query_tables=all_tables;
break; break;
} }
...@@ -3181,6 +3190,8 @@ end_with_restore_list: ...@@ -3181,6 +3190,8 @@ end_with_restore_list:
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
} }
(TABLE_LIST*) select_lex->table_list.first=first_table;
lex->query_tables=all_tables;
break; break;
} }
case SQLCOM_UPDATE: case SQLCOM_UPDATE:
......
...@@ -2222,8 +2222,11 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -2222,8 +2222,11 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
*/ */
lex->query_tables= table; lex->query_tables= table;
lex->query_tables_last= &table->next_global; lex->query_tables_last= &table->next_global;
lex->query_tables_own_last= 0;; lex->query_tables_own_last= 0;
thd->no_warnings_for_error= no_warnings_for_error; thd->no_warnings_for_error= no_warnings_for_error;
if (view_operator_func == NULL)
simple_open_n_lock_tables(thd, table);
else
open_and_lock_tables(thd, table); open_and_lock_tables(thd, table);
thd->no_warnings_for_error= 0; thd->no_warnings_for_error= 0;
table->next_global= save_next_global; table->next_global= save_next_global;
......
...@@ -3779,11 +3779,6 @@ optimize: ...@@ -3779,11 +3779,6 @@ optimize:
OPTIMIZE opt_no_write_to_binlog table_or_tables OPTIMIZE opt_no_write_to_binlog table_or_tables
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (lex->sphead)
{
my_error(ER_SP_BADSTATEMENT, MYF(0), "OPTIMIZE TABLE");
YYABORT;
}
lex->sql_command = SQLCOM_OPTIMIZE; lex->sql_command = SQLCOM_OPTIMIZE;
lex->no_write_to_binlog= $2; lex->no_write_to_binlog= $2;
lex->check_opt.init(); lex->check_opt.init();
......
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