Skip to content
/ server Public

Conversation

@alexaustin007
Copy link

JIRA: https://jira.mariadb.org/browse/MDEV-37939

Summary

  • Add contextual “Division by 0 in function” warnings for LOG/LN/LOG2/LOG10
  • Keep warning code ER_DIVISION_BY_ZERO (1365) unchanged
  • Add a regression test for LOG-family warnings vs generic division warnings

Testing

  • MTR_BINDIR=../build ./mariadb-test-run.pl --suite=main --record func_math_div_zero
  • MTR_BINDIR=../build ./mariadb-test-run.pl --suite=main func_math_div_zero

@CLAassistant
Copy link

CLAassistant commented Jan 21, 2026

CLA assistant check
All committers have signed the CLA.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Jan 21, 2026
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a preliminary review. The approach is sound IMHO, but there's some things missing (see the comments below).

Also, please make sure you re-record the rest of the failing test cases too.

@alexaustin007
Copy link
Author

Thank you for the suggestion @gkodinov . I removed the no arg signal_divide_by_null() and made the remaining method protected
All call sites now pass explicit context and also expanded func_math_div_zero` to cover DIV/MOD with decimal/string args and re‑recorded the result file.
I still haven't added the specific cause for the error, once this looks good, I can cover up in my next steps.

@alexaustin007
Copy link
Author

Updated it so LOG/LN/LOG2/LOG10 now emit the correct warning (Invalid argument for logarithm) instead of Division by 0. Division/DIV/MOD remain unchanged also reordered the expanded test of func_math_div_zero to verify empty warnings and all cases. Build and test pass. @gkodinov @vuvova Requesting to review. Thank you

Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something interesting from https://dev.mysql.com/doc/refman/8.4/en/mathematical-functions.html#function_log2:

If X is less than or equal to 0.0E0, the function returns NULL and a warning “Invalid argument for logarithm” is reported. Returns NULL if X is NULL.

I think this is a good idea. But I will leave this to the final reviewer.

@alexaustin007
Copy link
Author

@gkodinov Updated the log warnings to use specific messages instead of "division by 0", removed the dead code, and refreshed the tests/results. Requesting to review

Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please wait for the final review.

@vuvova vuvova self-requested a review January 26, 2026 14:32
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are failing tests because of the new warnings. Please fix.

@alexaustin007
Copy link
Author

alexaustin007 commented Jan 27, 2026

There are failing tests because of the new warnings. Please fix.

Re-recorded test results for the updated LOG domain warnings. All related tests now pass. The main.tmp_space_usage failure in the MSAN build seems unrelated issue

@gkodinov
Copy link
Member

Thanks, there's also some conflicts in the error message file. Please resolve.

Add contextual warnings for LOG/LN/LOG2/LOG10 while preserving error code 1365 for compatibility.

Make divide by zero reporting explicit at call sites and expand tests to cover div/mod with real, decimal, and string arguments.
Replace division by zero warnings for LOG/LN/LOG2/LOG10 with ER_INVALID_ARGUMENT_FOR_LOGARITHM while keeping division warnings unchanged.

Reorder and expand the test to verify empty warnings, log warnings, and division warnings.
  Replace “division by 0” warnings for LOG/LN/LOG2/LOG10 with specific
  logarithm domain warnings and keep division/mod paths on ER_DIVISION_BY_ZERO.
  Update func_math_div_zero test and expected results accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

3 participants