mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
BUG#6034 - Error code 124: Wrong medium type.
Version for 4.1. Committed for merge. If the result table is one of the select tables in INSERT SELECT, we must not disable the result tables indexes before selecting. mysql_execute_command() detects the match for other reasons and adds the flag OPTION_BUFFER_RESULT to the 'select_options'. In this case the result is put into a temporary table first. Hence, we can defer the preparation of the insert table until the result is to be used.
This commit is contained in:
@ -398,7 +398,16 @@ JOIN::prepare(Item ***rref_pointer_array,
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
if (!procedure && result && result->prepare(fields_list, unit_arg))
|
||||
/*
|
||||
We must not yet prepare the result table if it is the same as one of the
|
||||
source tables (INSERT SELECT). This is checked in mysql_execute_command()
|
||||
and OPTION_BUFFER_RESULT is added to the select_options. A temporary
|
||||
table is then used to hold the result. The preparation may disable
|
||||
indexes on the result table, which may be used during the select, if it
|
||||
is the same table (Bug #6034). Do the preparation after the select phase.
|
||||
*/
|
||||
if (! procedure && ! test(select_options & OPTION_BUFFER_RESULT) &&
|
||||
result && result->prepare(fields_list, unit_arg))
|
||||
goto err; /* purecov: inspected */
|
||||
|
||||
if (select_lex->olap == ROLLUP_TYPE && rollup_init())
|
||||
@ -1043,6 +1052,13 @@ JOIN::exec()
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
}
|
||||
else if (test(select_options & OPTION_BUFFER_RESULT) &&
|
||||
result && result->prepare(fields_list, unit))
|
||||
{
|
||||
error= 1;
|
||||
thd->limit_found_rows= thd->examined_row_count= 0;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
if (!tables_list)
|
||||
{ // Only test of functions
|
||||
|
Reference in New Issue
Block a user