Bug #27573 | MIN() on an indexed column which is always NULL sets _other_ results to NULL | ||
---|---|---|---|
Submitted: | 1 Apr 2007 17:27 | Modified: | 9 Jun 2007 18:19 |
Reporter: | Ralf Neubauer | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 5.0.32 and 5.0.36, 5.0.37 | OS: | Linux (Debian and Win64) |
Assigned to: | Martin Hansson | CPU Architecture: | Any |
[1 Apr 2007 17:27]
Ralf Neubauer
[1 Apr 2007 18:09]
Valeriy Kravchuk
Thank you for a bug report. Verified just as described.
[11 Apr 2007 11:39]
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/24269 ChangeSet@1.2432, 2007-04-11 14:33:09+03:00, mhansson@linux-st28.site +3 -0 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL We have the following case: SELECT MIN(keypart2),... FROM t1 WHERE keypart1 = constant; There is an optimization which will substitute a constant for MIN(keypart2), inserting the 1) minimum non-null value where the WHERE clause still matches, or 2) null if there are only NULL values for keypart2. If no row matches, the result will be 3) a row of NULLs. The previous implementation skipped step 2, and went straight to a row of NULLs.
[20 Apr 2007 8:32]
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/24975 ChangeSet@1.2432, 2007-04-20 10:31:35+03:00, mhansson@linux-st28.site +3 -0 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL We have the following case: SELECT MIN(keypart2),... FROM t1 WHERE keypart1 = constant; There is an optimization which will substitute a constant for MIN(keypart2), inserting the 1) minimum non-null value where the WHERE clause still matches, or 2) null if there are only NULL values for keypart2. If no row matches, the result will be 3) a row of NULLs. The previous implementation skipped step 2, and went straight to a row of NULLs.
[20 Apr 2007 9:56]
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/24985 ChangeSet@1.2432, 2007-04-20 11:56:28+03:00, mhansson@linux-st28.site +3 -0 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL We have the following case: SELECT MIN(keypart2),... FROM t1 WHERE keypart1 = constant; There is an optimization which will substitute a constant for MIN(keypart2), inserting the 1) minimum non-null value where the WHERE clause still matches, or 2) null if there are only NULL values for keypart2. If no row matches, the result will be 3) a row of NULLs. The previous implementation skipped step 2, and went straight to a row of NULLs.
[23 Apr 2007 11:53]
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/25108 ChangeSet@1.2432, 2007-04-23 13:53:30+03:00, mhansson@linux-st28.site +3 -0 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL We have the following case: SELECT MIN(keypart2),... FROM t1 WHERE keypart1 = constant; There is an optimization which will substitute a constant for MIN(keypart2), inserting the 1) minimum non-null value where the WHERE clause still matches, or 2) null if there are only NULL values for keypart2. If no row matches, the result will be 3) a row of NULLs. The previous implementation skipped step 2, and went straight to a row of NULLs.
[23 Apr 2007 11:59]
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/25109 ChangeSet@1.2432, 2007-04-23 13:59:34+03:00, mhansson@linux-st28.site +3 -0 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL We have the following case: SELECT MIN(keypart2),... FROM t1 WHERE keypart1 = constant; There is an optimization which will substitute a constant for MIN(keypart2), inserting the 1) minimum non-null value where the WHERE clause still matches, or 2) null if there are only NULL values for keypart2. If no row matches, the result will be 3) a row of NULLs. The previous implementation skipped step 2, and went straight to a row of NULLs.
[23 Apr 2007 16:00]
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/25139 ChangeSet@1.2432, 2007-04-23 18:00:43+03:00, mhansson@linux-st28.site +3 -0 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL We have the following case: SELECT MIN(keypart2),... FROM t1 WHERE keypart1 = constant; There is an optimization which will substitute a constant for MIN(keypart2), inserting the 1) minimum non-null value where the WHERE clause still matches, or 2) null if there are only NULL values for keypart2. If no row matches, the result will be 3) a row of NULLs. The previous implementation skipped step 2, and went straight to a row of NULLs.
[10 May 2007 8:55]
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/26423 ChangeSet@1.2432, 2007-05-10 10:55:28+03:00, mhansson@linux-st28.site +3 -0 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL We have the following case: SELECT MIN(key_part_k) FROM t1 WHERE key_part_1 = const and ... and key_part_k-1 = const There is an optimization which will substitute a constant for MIN(key_part_k), inserting the 1) minimum non-null value where the WHERE clause still matches, or 2) null if there are only NULL values for keypart2. If no row matches, the result will be 3) a row of NULLs. The previous implementation skipped step 2, and went straight to a row of NULLs.
[14 May 2007 15:13]
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/26618 ChangeSet@1.2432, 2007-05-14 17:13:34+03:00, mhansson@linux-st28.site +3 -0 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL For queries of the form SELECT MIN(key_part_k) FROM t1 WHERE key_part_1 = const and ... and key_part_k-1 = const, the opt_sum_query optimization tries to use an index to substitute MIN/MAX functions with their values according to the following rules: 1) Insert the minimum non-null values where the WHERE clause still matches, or 3) A row of nulls However, the correct semantics requires that there is a third case 2) such that a NULL value is substituted if there are only NULL values for key_part_k. The patch modifies opt_sum_query() to handle this missing case.
[15 May 2007 13:29]
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/26694 ChangeSet@1.2432, 2007-05-15 15:29:12+03:00, mhansson@linux-st28.site +3 -0 Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL For queries of the form SELECT MIN(key_part_k) FROM t1 WHERE key_part_1 = const and ... and key_part_k-1 = const, the opt_sum_query optimization tries to use an index to substitute MIN/MAX functions with their values according to the following rules: 1) Insert the minimum non-null values where the WHERE clause still matches, or 3) A row of nulls However, the correct semantics requires that there is a third case 2) such that a NULL value is substituted if there are only NULL values for key_part_k. The patch modifies opt_sum_query() to handle this missing case.
[20 May 2007 17:11]
Bugs System
Pushed into 5.0.44
[20 May 2007 17:13]
Bugs System
Pushed into 5.1.19-beta
[9 Jun 2007 18:19]
Paul DuBois
Noted 5.0.44, 5.1.19 changelogs. Selecting MIN() on an indexed column that contained only NULL values caused NULL to be returned for other result columns.