Bug #114546 function sometime returns a NULL value
Submitted: 4 Apr 2024 1:11 Modified: 4 Apr 2024 9:28
Reporter: Phong C Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0.36 OS:Debian
Assigned to: CPU Architecture:x86

[4 Apr 2024 1:11] Phong C
Description:
I have the following query with a custom function. The get_test() function simply return the input variable. There are no complex calculations in the function. 

Sometimes the query just return a NULL value while at other times it return the correct number. I can see this in the test results bellow. Not sure if anyone else is experiencing the same issue. It only happens when the server is under heavy load.

How to repeat:
-----
Query:
SELECT
            dl.account_id AS 'accountId',
            get_test(dl.account_id) AS 'test'
FROM document_line dl
JOIN document d
            USING (document_id)
WHERE d.document_id = _document_id AND dl.line_amount != 0

----
Function:
CREATE FUNCTION get_test(
    _account_id INT
)
RETURNS SMALLINT UNSIGNED
DETERMINISTIC
READS SQL DATA
BEGIN

RETURN _account_id;

----
Results:
      "checks": [
        {
          "accountId": 243,
          "test": null
        },]
[4 Apr 2024 9:28] MySQL Verification Team
Hi Mr. M.,

Thank you for your bug report.

However, let us inform you that this is a forum for the reports with fully repeatable test cases. Hence, in your report, we have missing dumps of the tables involved. Without those, we can not proceed.

Regarding function returning different results, it should depend on the data, so we need a set of data that returns correct results and set of data for wrong results.

We can not proceed with your report without a test case that will return different results for your stored function.

Can't repeat.
[4 Apr 2024 19:49] MySQL Verification Team
Take a look at this bug, perhaps it is related:

 https://bugs.mysql.com/bug.php?id=114235

-- 
Shane Bester, MySQL Senior Principal Technical Support Engineer
Oracle Corporation
http://dev.mysql.com/