summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/sp-error.result2
-rw-r--r--mysql-test/r/sp.result63
-rw-r--r--mysql-test/t/backup.test1
-rw-r--r--mysql-test/t/sp-error.test2
-rw-r--r--mysql-test/t/sp.test13
-rw-r--r--sql/sp_head.cc4
-rw-r--r--sql/sql_parse.cc13
-rw-r--r--sql/sql_table.cc7
-rw-r--r--sql/sql_yacc.yy5
9 files changed, 99 insertions, 11 deletions
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index f1d65ada4bf..4ba097e3d9f 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -768,7 +768,7 @@ BEGIN
OPTIMIZE TABLE t1;
RETURN 1;
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|
CREATE FUNCTION bug12995() RETURNS INT
BEGIN
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 41279534007..bfc16c826a5 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -4168,6 +4168,69 @@ test.t1 backup status OK
Table Op Msg_type Msg_text
test.t1 restore status OK
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|
a
a - table column
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
index 3034129ad4b..40a9fa73b60 100644
--- a/mysql-test/t/backup.test
+++ b/mysql-test/t/backup.test
@@ -52,5 +52,6 @@ unlock tables;
connection con1;
reap;
drop table t5;
+--system rm $MYSQL_TEST_DIR/var/tmp/t?.*
# End of 4.1 tests
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index ae13758a10e..b6c7d5476e7 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -1095,7 +1095,7 @@ delimiter |;
--disable_warnings
DROP FUNCTION IF EXISTS bug12953|
--enable_warnings
---error ER_SP_BADSTATEMENT
+--error ER_SP_NO_RETSET
CREATE FUNCTION bug12953() RETURNS INT
BEGIN
OPTIMIZE TABLE t1;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index fcd0fddb147..22dd1285b75 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -4961,9 +4961,20 @@ BEGIN
DROP TABLE t1;
RESTORE TABLE t1 FROM '../tmp';
END|
---replace_result ": 7" ": X" ": 17" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR
call 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|
#
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 13d503dfa28..a0a4e0a462f 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -72,7 +72,11 @@ sp_get_flags_for_command(LEX *lex)
}
/* fallthrough */
case SQLCOM_ANALYZE:
+ case SQLCOM_OPTIMIZE:
+ case SQLCOM_PRELOAD_KEYS:
+ case SQLCOM_ASSIGN_TO_KEYCACHE:
case SQLCOM_CHECKSUM:
+ case SQLCOM_CHECK:
case SQLCOM_HA_READ:
case SQLCOM_SHOW_BINLOGS:
case SQLCOM_SHOW_BINLOG_EVENTS:
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index c05529da745..0cc45a09015 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2614,7 +2614,8 @@ mysql_execute_command(THD *thd)
goto error; /* purecov: inspected */
thd->enable_slow_log= opt_log_slow_admin_statements;
res = mysql_backup_table(thd, first_table);
-
+ (TABLE_LIST*) select_lex->table_list.first=first_table;
+ lex->query_tables=all_tables;
break;
}
case SQLCOM_RESTORE_TABLE:
@@ -2626,6 +2627,8 @@ mysql_execute_command(THD *thd)
goto error; /* purecov: inspected */
thd->enable_slow_log= opt_log_slow_admin_statements;
res = mysql_restore_table(thd, first_table);
+ (TABLE_LIST*) select_lex->table_list.first=first_table;
+ lex->query_tables=all_tables;
break;
}
case SQLCOM_ASSIGN_TO_KEYCACHE:
@@ -3128,6 +3131,8 @@ end_with_restore_list:
mysql_bin_log.write(&qinfo);
}
}
+ (TABLE_LIST*) select_lex->table_list.first=first_table;
+ lex->query_tables=all_tables;
break;
}
case SQLCOM_CHECK:
@@ -3138,6 +3143,8 @@ end_with_restore_list:
goto error; /* purecov: inspected */
thd->enable_slow_log= opt_log_slow_admin_statements;
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;
}
case SQLCOM_ANALYZE:
@@ -3158,6 +3165,8 @@ end_with_restore_list:
mysql_bin_log.write(&qinfo);
}
}
+ (TABLE_LIST*) select_lex->table_list.first=first_table;
+ lex->query_tables=all_tables;
break;
}
@@ -3181,6 +3190,8 @@ end_with_restore_list:
mysql_bin_log.write(&qinfo);
}
}
+ (TABLE_LIST*) select_lex->table_list.first=first_table;
+ lex->query_tables=all_tables;
break;
}
case SQLCOM_UPDATE:
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index ae7e618f5df..20186d781f9 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2222,9 +2222,12 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
*/
lex->query_tables= table;
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;
- open_and_lock_tables(thd, table);
+ if (view_operator_func == NULL)
+ simple_open_n_lock_tables(thd, table);
+ else
+ open_and_lock_tables(thd, table);
thd->no_warnings_for_error= 0;
table->next_global= save_next_global;
table->next_local= save_next_local;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 3c478e6d52f..35449fc8398 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3779,11 +3779,6 @@ optimize:
OPTIMIZE opt_no_write_to_binlog table_or_tables
{
LEX *lex=Lex;
- if (lex->sphead)
- {
- my_error(ER_SP_BADSTATEMENT, MYF(0), "OPTIMIZE TABLE");
- YYABORT;
- }
lex->sql_command = SQLCOM_OPTIMIZE;
lex->no_write_to_binlog= $2;
lex->check_opt.init();