1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fix for bug #1564: CREATE TABLE + UNION + same table name = crash

This commit is contained in:
unknown
2003-11-11 18:14:49 +04:00
parent 25f9971aaa
commit 1c45978512
3 changed files with 14 additions and 2 deletions

View File

@ -3496,6 +3496,9 @@ static bool create_total_list(THD *thd, LEX *lex, TABLE_LIST **result)
return 0;
}
/* We should skip first table if SQL command is SQLCOM_CREATE_TABLE */
bool skip_first= (lex->sql_command == SQLCOM_CREATE_TABLE);
bool first_added= 0;
SELECT_LEX *sl;
TABLE_LIST **new_table_list= result, *aux;
@ -3512,9 +3515,11 @@ static bool create_total_list(THD *thd, LEX *lex, TABLE_LIST **result)
TABLE_LIST *next;
for (; aux; aux=next)
{
TABLE_LIST *cursor;
TABLE_LIST *cursor= *result;
if (first_added && skip_first)
cursor= cursor->next;
next= aux->next;
for (cursor= *result; cursor; cursor=cursor->next)
for ( ; cursor; cursor=cursor->next)
if (!strcmp(cursor->db,aux->db) &&
!strcmp(cursor->real_name,aux->real_name) &&
!strcmp(cursor->alias, aux->alias))
@ -3531,6 +3536,7 @@ static bool create_total_list(THD *thd, LEX *lex, TABLE_LIST **result)
*new_table_list= cursor;
new_table_list= &cursor->next;
*new_table_list=0; // end result list
first_added= 1;
}
else
aux->shared=1; // Mark that it's used twice