-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-37939 Add function context to division by zero warnings #4569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alexaustin007
wants to merge
7
commits into
MariaDB:main
Choose a base branch
from
alexaustin007:MDEV-37939
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6e9e851
MDEV-37939 Add function context to division by zero warnings
alexaustin007 50eb21a
MDEV-37939 Add function context to division by zero warnings
alexaustin007 0410b1a
MDEV-37939 Use correct warning for invalid logarithm arguments
alexaustin007 c01efe2
MDEV-37939: use proper log domain warnings
alexaustin007 8d3bafa
MDEV-37939: make log-domain warning helper static
alexaustin007 79d6395
MDEV-37939: Update test results for LOG domain warnings
alexaustin007 c993978
MDEV-37939: Update test results for rebased error codes
alexaustin007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,238 @@ | ||
| # | ||
| # MDEV-37939: Use correct error for invalid logarithm arguments | ||
| # | ||
| # LOG/LN/LOG2/LOG10 now emit function-specific domain warnings | ||
| # instead of ER_DIVISION_BY_ZERO, since these functions do not | ||
| # perform division. | ||
| # | ||
| # | ||
| # Test valid inputs first (before any warning-producing statements) | ||
| # This ensures SHOW WARNINGS is truly empty | ||
| # | ||
| SET SESSION sql_mode='ERROR_FOR_DIVISION_BY_ZERO'; | ||
| SELECT LOG(10); | ||
| LOG(10) | ||
| 2.302585092994046 | ||
| SELECT LN(2.718); | ||
| LN(2.718) | ||
| 0.999896315728952 | ||
| SELECT LOG2(8); | ||
| LOG2(8) | ||
| 3 | ||
| SELECT LOG10(100); | ||
| LOG10(100) | ||
| 2 | ||
| SELECT LOG(2, 8); | ||
| LOG(2, 8) | ||
| 3 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| # Should be empty - valid inputs produce no warnings | ||
| # | ||
| # Test sql_mode='' behavior (before any warnings are produced) | ||
| # | ||
| SET SESSION sql_mode=''; | ||
| SELECT LOG(-1); | ||
| LOG(-1) | ||
| NULL | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| # Should be empty - no warning when sql_mode doesn't include ERROR_FOR_DIVISION_BY_ZERO | ||
| SELECT LN(-1); | ||
| LN(-1) | ||
| NULL | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| # | ||
| # Now test warning-producing cases | ||
| # | ||
| SET SESSION sql_mode='ERROR_FOR_DIVISION_BY_ZERO'; | ||
| # | ||
| # LOG family should report function-specific domain warnings | ||
| # | ||
| SELECT LOG(-1); | ||
| LOG(-1) | ||
| NULL | ||
| Warnings: | ||
| Warning 4256 Passing non-positive argument to log() makes the function's result undefined | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 4256 Passing non-positive argument to log() makes the function's result undefined | ||
| SELECT LOG(0); | ||
| LOG(0) | ||
| NULL | ||
| Warnings: | ||
| Warning 4256 Passing non-positive argument to log() makes the function's result undefined | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 4256 Passing non-positive argument to log() makes the function's result undefined | ||
| SELECT LN(0); | ||
| LN(0) | ||
| NULL | ||
| Warnings: | ||
| Warning 4255 Passing non-positive argument to ln() makes the function's result undefined | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 4255 Passing non-positive argument to ln() makes the function's result undefined | ||
| SELECT LN(-5); | ||
| LN(-5) | ||
| NULL | ||
| Warnings: | ||
| Warning 4255 Passing non-positive argument to ln() makes the function's result undefined | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 4255 Passing non-positive argument to ln() makes the function's result undefined | ||
| SELECT LOG2(-1); | ||
| LOG2(-1) | ||
| NULL | ||
| Warnings: | ||
| Warning 4258 Passing non-positive argument to log2() makes the function's result undefined | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 4258 Passing non-positive argument to log2() makes the function's result undefined | ||
| SELECT LOG10(-1); | ||
| LOG10(-1) | ||
| NULL | ||
| Warnings: | ||
| Warning 4259 Passing non-positive argument to log10() makes the function's result undefined | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 4259 Passing non-positive argument to log10() makes the function's result undefined | ||
| # Two-argument LOG: invalid second argument | ||
| SELECT LOG(2, -1); | ||
| LOG(2, -1) | ||
| NULL | ||
| Warnings: | ||
| Warning 4256 Passing non-positive argument to log() makes the function's result undefined | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 4256 Passing non-positive argument to log() makes the function's result undefined | ||
| # Two-argument LOG: invalid base (negative) | ||
| SELECT LOG(-2, 10); | ||
| LOG(-2, 10) | ||
| NULL | ||
| Warnings: | ||
| Warning 4257 Passing non-positive or equal-to-1 base to log() makes the function's result undefined | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 4257 Passing non-positive or equal-to-1 base to log() makes the function's result undefined | ||
| # Two-argument LOG: base = 1 (invalid - would cause log(1)=0 in denominator) | ||
| SELECT LOG(1, 10); | ||
| LOG(1, 10) | ||
| NULL | ||
| Warnings: | ||
| Warning 4257 Passing non-positive or equal-to-1 base to log() makes the function's result undefined | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 4257 Passing non-positive or equal-to-1 base to log() makes the function's result undefined | ||
| # | ||
| # Division operations should report ER_DIVISION_BY_ZERO (1365) | ||
| # | ||
| # Division - integer | ||
| SELECT 1/0; | ||
| 1/0 | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # Division - real/float | ||
| SELECT 1.0/0.0; | ||
| 1.0/0.0 | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # Division - decimal | ||
| SELECT CAST(1 AS DECIMAL(10,2)) / CAST(0 AS DECIMAL(10,2)); | ||
| CAST(1 AS DECIMAL(10,2)) / CAST(0 AS DECIMAL(10,2)) | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # Division - with string arguments | ||
| SELECT '1'/'0'; | ||
| '1'/'0' | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # Integer DIV | ||
| SELECT 5 DIV 0; | ||
| 5 DIV 0 | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # Integer DIV - with string arguments | ||
| SELECT '5' DIV '0'; | ||
| '5' DIV '0' | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # MOD - integer | ||
| SELECT 5 MOD 0; | ||
| 5 MOD 0 | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # MOD - real/float | ||
| SELECT 5.5e0 MOD 0.0e0; | ||
| 5.5e0 MOD 0.0e0 | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # MOD - decimal | ||
| SELECT CAST(5 AS DECIMAL(10,2)) MOD CAST(0 AS DECIMAL(10,2)); | ||
| CAST(5 AS DECIMAL(10,2)) MOD CAST(0 AS DECIMAL(10,2)) | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # MOD - with string arguments | ||
| SELECT '5' MOD '0'; | ||
| '5' MOD '0' | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # MOD function syntax | ||
| SELECT MOD(5, 0); | ||
| MOD(5, 0) | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
| # MOD function - decimal | ||
| SELECT MOD(5.5, 0.0); | ||
| MOD(5.5, 0.0) | ||
| NULL | ||
| Warnings: | ||
| Warning 1365 Division by 0 | ||
| SHOW WARNINGS; | ||
| Level Code Message | ||
| Warning 1365 Division by 0 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.