Bug #16630 | error, when INSERT t1 SELECT ... FROM t1 ON DUPLICATE | ||
---|---|---|---|
Submitted: | 19 Jan 2006 12:47 | Modified: | 6 Mar 2007 19:42 |
Reporter: | Matthias Leich | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 4.1 | OS: | |
Assigned to: | Evgeny Potemkin | CPU Architecture: | Any |
[19 Jan 2006 12:47]
Matthias Leich
[19 Jan 2006 12:49]
Matthias Leich
testscript
Attachment: ml004.test (application/test, text), 5.00 KiB.
[19 Jan 2006 12:49]
Matthias Leich
reject file got on MySQL 4.1
Attachment: ml004.reject (application/octet-stream, text), 5.03 KiB.
[9 Feb 2007 21:20]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/19643 ChangeSet@1.2409, 2007-02-10 00:19:48+03:00, evgen@moonbone.local +6 -0 Bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE contains wrong data if the SELECT employs a temporary table. If the UPDATE values of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE statement contains fields from the SELECT part and the select employs a temporary table then those fields will contain wrong values because they aren't corrected to get data from the temporary table. The solution is to add these fields to the selects all_fields list, to store pointers to those fields in the selects ref_pointer_array and access them via Item_ref objects. The substitution for Item_ref objects is done in the new function called Item_field::update_value_transformer(). It is called through item->transform() mechanism at the end of the select_insert::prepare() function.
[20 Feb 2007 14:21]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/20181 ChangeSet@1.2409, 2007-02-16 19:39:28+03:00, evgen@moonbone.local +6 -0 Bug#16630: The update fields of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE contains wrong data if the SELECT employs a temporary table. If the UPDATE values of the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE statement contains fields from the SELECT part and the select employs a temporary table then those fields will contain wrong values because they aren't corrected to get data from the temporary table. The solution is to add these fields to the selects all_fields list, to store pointers to those fields in the selects ref_pointer_array and to access them via Item_ref objects. The substitution for Item_ref objects is done in the new function called Item_field::update_value_transformer(). It is called through the item->transform() mechanism at the end of the select_insert::prepare() function.
[28 Feb 2007 17:39]
Sergei Glukhov
Fixed in 5.0.38, 5.1.17-beta
[6 Mar 2007 19:42]
Paul DuBois
Noted in 5.0.38, 5.1.17 changelogs.