mirror of
https://github.com/MariaDB/server.git
synced 2025-04-18 21:44:20 +03:00
MDEV-32086 Server crash for INSERT..SELECT: followup, add comments
TODO: Squash this with the main patch
This commit is contained in:
parent
831fcfed1e
commit
397ca50066
@ -1184,13 +1184,20 @@ retry:
|
||||
DBUG_PRINT("info",
|
||||
("found same copy of table or table which we should skip"));
|
||||
}
|
||||
// INSERT SELECT has better dealing with duplicates
|
||||
/*
|
||||
If we've found a duplicate in a derived table, try to work around that.
|
||||
|
||||
For INSERT...SELECT, do not do any workarounds, return the duplicate. The
|
||||
caller will enable buffering to handle this.
|
||||
*/
|
||||
if (res && res->belong_to_derived &&
|
||||
!(check_flag & CHECK_DUP_FOR_INSERT_SELECT))
|
||||
{
|
||||
/*
|
||||
We come here for queries of type:
|
||||
INSERT INTO t1 (SELECT tmp.a FROM (select * FROM t1) as tmp);
|
||||
We come here for queries like this:
|
||||
|
||||
INSERT INTO t1 VALUES ((SELECT tmp.a FROM (select * FROM t1)));
|
||||
DELETE FROM t1 WHERE ( ... (SELECT ... FROM t1) ) ;
|
||||
|
||||
Try to fix by materializing the derived table
|
||||
*/
|
||||
|
@ -1710,7 +1710,14 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
// SELECT INSERT has good workaround of the problem - buffering results
|
||||
/*
|
||||
Check if we read from the same table we're inserting into.
|
||||
Queries like INSERT INTO t1 VALUES ((SELECT ... FROM t1...)) are not
|
||||
allowed.
|
||||
|
||||
INSERT...SELECT is an exception: it will detect this case and use
|
||||
buffering to handle it correctly.
|
||||
*/
|
||||
if (!select_insert)
|
||||
{
|
||||
Item *fake_conds= 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user