| Bug #110502 | Incorrect output of FIELD function | ||
|---|---|---|---|
| Submitted: | 25 Mar 2023 22:03 | Modified: | 28 Mar 2023 6:11 |
| Reporter: | Zuming Jiang | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
| Version: | 8.0, 5.7 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[26 Mar 2023 7:39]
MySQL Verification Team
Hello Zuming Jiang, Thank you for the report and test case. regards, Umesh
[27 Mar 2023 13:06]
Tor Didriksen
Posted by developer:
select FIELD('o', null, ');
the function operates on strings, 'o' and ' are not equal
select FIELD('o', null + 1, ');
the function operates on doubles, and both 'o' and ' convert to 0.0
https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_field

Description: My fuzzer found a bug in the MySQL server. This bug made the FIELD() function return incorrect results. How to repeat: ** Test case** select FIELD('o', null, ''); select FIELD('o', null + 1, ''); ** Expected Behavior ** Two SELECT should output the same results {0}, because null + 1 is null. ** Actual Behavior ** select FIELD('o', null, ''); --- output {0} select FIELD('o', null + 1, ''); --- output {2} One outputs {0} and another one outputs {2}.