Bug #113849 | Incorrect results when case ... when used in update statement | ||
---|---|---|---|
Submitted: | 1 Feb 2024 10:50 | Modified: | 9 Feb 2024 7:29 |
Reporter: | yi qian | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | case ... when, UPDATE |
[1 Feb 2024 10:50]
yi qian
[1 Feb 2024 12:08]
MySQL Verification Team
Hi Mr. gian, Thank you for your bug report. We were able to reproduce the results that you get with 8.0.36. This is what we get: +----------------------------------------+ | case when count(1)>1 then 1 else 0 end | +----------------------------------------+ | 1 | +----------------------------------------+ +--------+ | a_code | +--------+ | 1 | | NULL | | 1 | +--------+ We agree with you that this is not correct. Verified as reported.
[9 Feb 2024 7:29]
Roy Lyseng
This is not a bug. When the scalar subquery is evaluated for the row from t1_hash where id is 2, the result is NULL because there are no rows in t1_range that matches a.infom='bcd'; If the GROUP BY is omitted, thus making the subquery implicitly grouped, I think the desired result will be returned.