1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Bug #48315 Metadata lock is not taken for merged views that use

an INFORMATION_SCHEMA table

When a prepared statement using a merged view containing an information
schema table was executed, a metadata lock of the view was not taken.
This meant that it was possible for concurrent view DDL to execute,
thereby breaking the binary log. For example, it was possible
for DROP VIEW to appear in the binary log before a query using the view.
This also happened when a statement in a stored routine was executed a
second time.

For such views, the information schema table is merged into the view
during the prepare phase (or first execution of a statement in a routine).
The problem was that we took a short cut and were not executing full-blown
view opening during subsequent executions of the statement. As a result,
a metadata lock on the view was not taken to protect the view definition.

This patch resolves the problem by making sure a metadata lock is taken
for views even after information schema tables are merged into them.

Test cased added to view.test.
This commit is contained in:
Jon Olav Hauglid
2010-02-18 14:54:38 +01:00
parent 2529fa94ed
commit 813ad38ef4
3 changed files with 124 additions and 3 deletions

View File

@ -4168,9 +4168,18 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
TABLE_LIST is processed. This code works only during re-execution.
*/
if (tables->view)
goto process_view_routines;
if (!mysql_schema_table(thd, lex, tables) &&
!check_and_update_table_version(thd, tables, tables->table->s))
{
/*
We still need to take a MDL lock on the merged view to protect
it from concurrent changes.
*/
if (!open_table_get_mdl_lock(thd, tables, &tables->mdl_request,
ot_ctx, flags))
goto process_view_routines;
/* Fall-through to return error. */
}
else if (!mysql_schema_table(thd, lex, tables) &&
!check_and_update_table_version(thd, tables, tables->table->s))
{
goto end;
}