mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix bug in INSERT DELAYED with prepared statements
The bug was that if you have two TL_WRITE_DELAYED at the same time, mi_lock_databases() could be done in the wrong order and we could write the wrong header to the MyISAM index file.
This commit is contained in:
@ -725,6 +725,7 @@ void wait_for_refresh(THD *thd);
|
|||||||
int open_tables(THD *thd, TABLE_LIST *tables, uint *counter);
|
int open_tables(THD *thd, TABLE_LIST *tables, uint *counter);
|
||||||
int simple_open_n_lock_tables(THD *thd,TABLE_LIST *tables);
|
int simple_open_n_lock_tables(THD *thd,TABLE_LIST *tables);
|
||||||
int open_and_lock_tables(THD *thd,TABLE_LIST *tables);
|
int open_and_lock_tables(THD *thd,TABLE_LIST *tables);
|
||||||
|
int open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables);
|
||||||
void relink_tables_for_derived(THD *thd);
|
void relink_tables_for_derived(THD *thd);
|
||||||
int lock_tables(THD *thd, TABLE_LIST *tables, uint counter);
|
int lock_tables(THD *thd, TABLE_LIST *tables, uint counter);
|
||||||
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
|
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
|
||||||
|
@ -1702,6 +1702,34 @@ int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Open all tables in list and process derived tables
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
open_normal_and_derived_tables
|
||||||
|
thd - thread handler
|
||||||
|
tables - list of tables for open&locking
|
||||||
|
|
||||||
|
RETURN
|
||||||
|
FALSE - ok
|
||||||
|
TRUE - error
|
||||||
|
|
||||||
|
NOTE
|
||||||
|
This is to be used on prepare stage when you don't read any
|
||||||
|
data from the tables.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables)
|
||||||
|
{
|
||||||
|
uint counter;
|
||||||
|
DBUG_ENTER("open_normal_and_derived_tables");
|
||||||
|
if (open_tables(thd, tables, &counter))
|
||||||
|
DBUG_RETURN(-1); /* purecov: inspected */
|
||||||
|
relink_tables_for_derived(thd);
|
||||||
|
DBUG_RETURN(mysql_handle_derived(thd->lex));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Let us propagate pointers to open tables from global table list
|
Let us propagate pointers to open tables from global table list
|
||||||
to table lists in particular selects if needed.
|
to table lists in particular selects if needed.
|
||||||
|
@ -897,8 +897,12 @@ static int mysql_test_insert(Prepared_statement *stmt,
|
|||||||
/*
|
/*
|
||||||
open temporary memory pool for temporary data allocated by derived
|
open temporary memory pool for temporary data allocated by derived
|
||||||
tables & preparation procedure
|
tables & preparation procedure
|
||||||
|
Note that this is done without locks (should not be needed as we will not
|
||||||
|
access any data here)
|
||||||
|
If we would use locks, then we have to ensure we are not using
|
||||||
|
TL_WRITE_DELAYED as having two such locks can cause table corruption.
|
||||||
*/
|
*/
|
||||||
if (open_and_lock_tables(thd, table_list))
|
if (open_normal_and_derived_tables(thd, table_list))
|
||||||
{
|
{
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user