Bug #112149 Inconsistent results caused by SPACE() function and ''||'' operations
Submitted: 23 Aug 2023 4:09 Modified: 23 Aug 2023 8:14
Reporter: Zuming Jiang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S2 (Serious)
Version:8.0.34, 5.7.43, 5.6, 5.5 OS:Any
Assigned to: CPU Architecture:Any

[23 Aug 2023 4:09] Zuming Jiang
Description:
Dear MySQL developers,

I used my new fuzzer to fuzz MySQL and found a logic bug that make MySQL server output inconsistent results:

How to repeat:
*** Test Case 1 ***

select nullif(SPACE(5), case when false then ('P') else ('i' || '~') end) as c_4;

I simplified "case when false then ('P') else ('i' || '~') end" to "('i' || '~')", and get Test Case 2:

*** Test Case 2 ***

select nullif(SPACE(5), ('i' || '~')) as c_4;

*** Expected results ***

Test Case 1 and Test Case 2 return the same results.

*** Actual results ***

Test Case 1 and Test Case 2 return inconsistent results.

Test Case 1 return:

+-------+
| c_4   |
+-------+
|       |
+-------+

Test Case 2 return:

+------+
| c_4  |
+------+
| NULL |
+------+
[23 Aug 2023 8:14] MySQL Verification Team
Hello Zuming Jiang,

Thank you for the report and test case.

regards,
Umesh