1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Bug#32890 Crash after repeated create and drop of tables and views

The problem is that CREATE VIEW statements inside prepared statements
weren't being expanded during the prepare phase, which leads to objects
not being allocated in the appropriate memory arenas.

The solution is to perform the validation of CREATE VIEW statements
during the prepare phase of a prepared statement. The validation
during the prepare phase assures that transformations of the parsed
tree will use the permanent arena of the prepared statement.
This commit is contained in:
davi@mysql.com/endora.local
2008-02-21 14:58:29 -03:00
parent f5cb5fdc4f
commit 0e91461842
6 changed files with 482 additions and 122 deletions

View File

@ -1512,6 +1512,45 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
}
/**
@brief Validate and prepare for execution CREATE VIEW statement
@param stmt prepared statement
@note This function handles create view commands.
@retval FALSE Operation was a success.
@retval TRUE An error occured.
*/
static bool mysql_test_create_view(Prepared_statement *stmt)
{
DBUG_ENTER("mysql_test_create_view");
THD *thd= stmt->thd;
LEX *lex= stmt->lex;
SELECT_LEX *select_lex= &lex->select_lex;
bool res= TRUE;
/* Skip first table, which is the view we are creating */
bool link_to_local;
TABLE_LIST *view= lex->unlink_first_table(&link_to_local);
TABLE_LIST *tables= lex->query_tables;
if (create_view_precheck(thd, tables, view, lex->create_view_mode))
goto err;
if (open_normal_and_derived_tables(thd, tables, 0))
goto err;
lex->view_prepare_mode= 1;
res= select_like_stmt_test(stmt, 0, 0);
err:
/* put view back for PS rexecuting */
lex->link_first_table_back(view, link_to_local);
DBUG_RETURN(res);
}
/*
Validate and prepare for execution a multi update statement.
@ -1730,6 +1769,7 @@ static bool check_prepared_statement(Prepared_statement *stmt,
my_message(ER_UNSUPPORTED_PS, ER(ER_UNSUPPORTED_PS), MYF(0));
goto error;
}
res= mysql_test_create_view(stmt);
break;
case SQLCOM_DO:
res= mysql_test_do_fields(stmt, tables, lex->insert_list);