Bug #1308 | after upgrading from 4.0.12 to 4.0.15(-max), a sql query doesn't work anymore | ||
---|---|---|---|
Submitted: | 16 Sep 2003 13:39 | Modified: | 21 Oct 2003 3:02 |
Reporter: | Gael Martinez | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 4.0.15 4.0.15-max | OS: | Linux (linux debian) |
Assigned to: | Ramil Kalimullin | CPU Architecture: | Any |
[16 Sep 2003 13:39]
Gael Martinez
[16 Sep 2003 14:30]
Alexander Keremidarski
Please send us your dump. You can use either Files URL above or upload it at ftp://support.mysql.com/pub/mysql/secret with some easy recognizable name like bug-1308.gz
[16 Sep 2003 16:13]
Gael Martinez
I uploaded the file as requested
[4 Oct 2003 17:19]
Gael Martinez
What is the status on that issue ?
[20 Oct 2003 5:41]
Ramil Kalimullin
What server charset did you use?
[20 Oct 2003 7:24]
Ramil Kalimullin
Using the data you submitted, I see that the first LEFT OUTER JOIN condition is impracticable: ... LEFT OUTER JOIN lfgpl_champs_bonus on ((lfgpl_champs_resultats.M_CHAMPS_ID = lfgpl_champs_bonus.M_CHAMPS_ID) and ... where (lfgpl_champs_resultats.M_CHAMPS_ID = '5') and ... because there are no records where lfgpl_champs_bonus.M_CHAMPS_ID = 5 in the lfgpl_champs_bonus table. So I got NULLs for V_BONUS_PILOTES_PTS field. Try: select * from lfgpl_champs_bonus where M_CHAMPS_ID = '5'; and you'll get an empty result.
[20 Oct 2003 12:23]
Gael Martinez
That doesn't explain the fact that the query runs fine on other version of the database ...
[20 Oct 2003 12:59]
Sergei Golubchik
Ramil - I repeated the behaviour, 4.0.12 and 4.0.16 produce different results.
[21 Oct 2003 3:02]
Sergei Golubchik
Ok, here it is. As Ramil correctly noticed, you use a condition that excludes all not NULL rows from lfgpl_champs_bonus table. Try your select with only SELECT sum(V_BONUS_PILOTES_PTS) FROM ... <everything else as in your select above> (and without ORDER BY, of course). You will find that 4.0.15 returns NULLs while 4.0.12 returns 0. Try also MIN or MAX instead of SUM - both versions will return NULL. Thus, you can see that 4.0.15 behaves correctly, while 4.0.12 calculates SUM(NULL) as 0, instead of NULL. Checking changelog in the manual, indeed, you can see that: Changes in release 4.0.13 (16 May 2003) --------------------------------------- ... Bugs fixed: ... * `SUM()' didn't return `NULL' when there was no rows in result or when all values was `NULL'. ... hopefully, this closes the issue.