Commit 4a254173 authored by ingo@mysql.com's avatar ingo@mysql.com

Bug#10224 - ANALYZE TABLE crashing with simultaneous CREATE ... SELECT statement.

After merge fixes.
parent 0a1e38b7
...@@ -1384,7 +1384,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh) ...@@ -1384,7 +1384,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh)
MYSQL_LOCK *lock; MYSQL_LOCK *lock;
/* We should always get these locks */ /* We should always get these locks */
thd->some_tables_deleted=0; thd->some_tables_deleted=0;
if ((lock= mysql_lock_tables(thd, tables, (uint) (tables_ptr-tables), 0))) if ((lock= mysql_lock_tables(thd, tables, (uint) (tables_ptr - tables), 0)))
{ {
thd->locked_tables=mysql_lock_merge(thd->locked_tables,lock); thd->locked_tables=mysql_lock_merge(thd->locked_tables,lock);
} }
......
...@@ -2808,7 +2808,7 @@ mysql_execute_command(THD *thd) ...@@ -2808,7 +2808,7 @@ mysql_execute_command(THD *thd)
unique_table(create_table, select_tables)) unique_table(create_table, select_tables))
{ {
my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->table_name); my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->table_name);
goto unsent_create_error; goto unsent_create_error1;
} }
/* If we create merge table, we have to test tables in merge, too */ /* If we create merge table, we have to test tables in merge, too */
if (lex->create_info.used_fields & HA_CREATE_USED_UNION) if (lex->create_info.used_fields & HA_CREATE_USED_UNION)
...@@ -2821,7 +2821,7 @@ mysql_execute_command(THD *thd) ...@@ -2821,7 +2821,7 @@ mysql_execute_command(THD *thd)
if (unique_table(tab, select_tables)) if (unique_table(tab, select_tables))
{ {
my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->table_name); my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->table_name);
goto unsent_create_error; goto unsent_create_error1;
} }
} }
} }
...@@ -2872,6 +2872,13 @@ mysql_execute_command(THD *thd) ...@@ -2872,6 +2872,13 @@ mysql_execute_command(THD *thd)
lex->link_first_table_back(create_table, link_to_local); lex->link_first_table_back(create_table, link_to_local);
break; break;
unsent_create_error1:
/*
Release the protection against the global read lock and wake
everyone, who might want to set a global read lock.
*/
start_waiting_global_read_lock(thd);
/* put tables back for PS rexecuting */ /* put tables back for PS rexecuting */
unsent_create_error: unsent_create_error:
lex->link_first_table_back(create_table, link_to_local); lex->link_first_table_back(create_table, link_to_local);
...@@ -6959,6 +6966,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, ...@@ -6959,6 +6966,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
{ {
/* Check permissions for used tables in CREATE TABLE ... SELECT */ /* Check permissions for used tables in CREATE TABLE ... SELECT */
#ifdef NOT_NECESSARY_TO_CHECK_CREATE_TABLE_EXIST_WHEN_PREPARING_STATEMENT
/* This code throws an ill error for CREATE TABLE t1 SELECT * FROM t1 */
/* /*
Only do the check for PS, becasue we on execute we have to check that Only do the check for PS, becasue we on execute we have to check that
against the opened tables to ensure we don't use a table that is part against the opened tables to ensure we don't use a table that is part
...@@ -6977,6 +6986,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, ...@@ -6977,6 +6986,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
goto err; goto err;
} }
} }
#endif
if (tables && check_table_access(thd, SELECT_ACL, tables,0)) if (tables && check_table_access(thd, SELECT_ACL, tables,0))
goto err; goto err;
} }
......
...@@ -7083,12 +7083,13 @@ field_ident: ...@@ -7083,12 +7083,13 @@ field_ident:
TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first;
if (my_strcasecmp(table_alias_charset, $1.str, table->db)) if (my_strcasecmp(table_alias_charset, $1.str, table->db))
{ {
net_printf(YYTHD, ER_WRONG_DB_NAME, $1.str); my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
YYABORT; YYABORT;
} }
if (my_strcasecmp(table_alias_charset, $3.str, table->real_name)) if (my_strcasecmp(table_alias_charset, $3.str,
table->table_name))
{ {
net_printf(YYTHD, ER_WRONG_TABLE_NAME, $3.str); my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
YYABORT; YYABORT;
} }
$$=$5; $$=$5;
...@@ -7098,7 +7099,7 @@ field_ident: ...@@ -7098,7 +7099,7 @@ field_ident:
TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first;
if (my_strcasecmp(table_alias_charset, $1.str, table->alias)) if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
{ {
net_printf(YYTHD, ER_WRONG_TABLE_NAME, $1.str); my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
YYABORT; YYABORT;
} }
$$=$3; $$=$3;
......
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