List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:December 3 2005 2:02pm
Subject:bk commit into 5.0 tree (serg:1.2050) BUG#13012
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of serg. When serg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2050 05/12/03 15:02:09 serg@stripped +9 -0
  this has nothing to do with the bug#13012.
  it's about mysql_admin_commands not being reexecution-safe
  (and CHECK still isn't)

  sql/sql_yacc.yy
    1.442 05/12/03 15:01:54 serg@stripped +0 -5
    optimize is now allowed in SP

  sql/sql_table.cc
    1.290 05/12/03 15:01:53 serg@stripped +5 -2
    optimization - don't execute views when no view is expected/allowed

  sql/sql_parse.cc
    1.522 05/12/03 15:01:52 serg@stripped +12 -1
    all mysql_admin commands modify table list and we should restore it for SP

  sql/sp_head.cc
    1.198 05/12/03 15:01:52 serg@stripped +4 -0
    all mysql_admin commands return result set

  mysql-test/t/sp.test
    1.166 05/12/03 15:01:51 serg@stripped +12 -1
    test repair/optimize/analyze in SP

  mysql-test/t/sp-error.test
    1.99 05/12/03 15:01:51 serg@stripped +1 -1
    optimize is now allowed in SP

  mysql-test/t/backup.test
    1.16 05/12/03 15:01:51 serg@stripped +1 -0
    clean up after itself

  mysql-test/r/sp.result
    1.173 05/12/03 15:01:51 serg@stripped +63 -0
    test repair/optimize/analyze in SP

  mysql-test/r/sp-error.result
    1.95 05/12/03 15:01:51 serg@stripped +1 -1
    optimize is now allowed in SP

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	serg
# Host:	serg.mylan
# Root:	/usr/home/serg/Abk/mysql-5.0

--- 1.521/sql/sql_parse.cc	Mon Nov 28 19:51:26 2005
+++ 1.522/sql/sql_parse.cc	Sat Dec  3 15:01:52 2005
@@ -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:

--- 1.289/sql/sql_table.cc	Tue Nov 29 10:33:48 2005
+++ 1.290/sql/sql_table.cc	Sat Dec  3 15:01:53 2005
@@ -2222,9 +2222,12 @@ static bool mysql_admin_table(THD* thd, 
     */
     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;

--- 1.441/sql/sql_yacc.yy	Fri Dec  2 14:58:50 2005
+++ 1.442/sql/sql_yacc.yy	Sat Dec  3 15:01:54 2005
@@ -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();

--- 1.94/mysql-test/r/sp-error.result	Fri Dec  2 22:59:28 2005
+++ 1.95/mysql-test/r/sp-error.result	Sat Dec  3 15:01:51 2005
@@ -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

--- 1.172/mysql-test/r/sp.result	Fri Dec  2 22:59:28 2005
+++ 1.173/mysql-test/r/sp.result	Sat Dec  3 15:01:51 2005
@@ -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

--- 1.98/mysql-test/t/sp-error.test	Fri Dec  2 22:59:28 2005
+++ 1.99/mysql-test/t/sp-error.test	Sat Dec  3 15:01:51 2005
@@ -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;

--- 1.165/mysql-test/t/sp.test	Fri Dec  2 22:59:29 2005
+++ 1.166/mysql-test/t/sp.test	Sat Dec  3 15:01:51 2005
@@ -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|
 
 #

--- 1.197/sql/sp_head.cc	Fri Dec  2 22:59:29 2005
+++ 1.198/sql/sp_head.cc	Sat Dec  3 15:01:52 2005
@@ -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:

--- 1.15/mysql-test/t/backup.test	Thu Jul 28 15:12:32 2005
+++ 1.16/mysql-test/t/backup.test	Sat Dec  3 15:01:51 2005
@@ -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
Thread
bk commit into 5.0 tree (serg:1.2050) BUG#13012Sergei Golubchik3 Dec