Skip to content
/ server Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions mysql-test/main/func_math.result
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
10 10.000000000000002 NULL NULL NULL 2 NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 4256 Passing non-positive argument to log() makes the function's result undefined
Warning 4257 Passing non-positive or equal-to-1 base to log() makes the function's result undefined
Warning 4257 Passing non-positive or equal-to-1 base to log() makes the function's result undefined
explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Expand All @@ -57,8 +57,8 @@ select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
10 10.000000000000002 NULL NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 4255 Passing non-positive argument to ln() makes the function's result undefined
Warning 4255 Passing non-positive argument to ln() makes the function's result undefined
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Expand All @@ -68,8 +68,8 @@ select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
3 3.9068905956085187 NULL NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 4258 Passing non-positive argument to log2() makes the function's result undefined
Warning 4258 Passing non-positive argument to log2() makes the function's result undefined
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Expand All @@ -79,8 +79,8 @@ select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
2 1.255272505103306 NULL NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 4259 Passing non-positive argument to log10() makes the function's result undefined
Warning 4259 Passing non-positive argument to log10() makes the function's result undefined
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Expand Down Expand Up @@ -239,27 +239,27 @@ select ln(-1);
ln(-1)
NULL
Warnings:
Warning 1365 Division by 0
Warning 4255 Passing non-positive argument to ln() makes the function's result undefined
select log10(-1);
log10(-1)
NULL
Warnings:
Warning 1365 Division by 0
Warning 4259 Passing non-positive argument to log10() makes the function's result undefined
select log2(-1);
log2(-1)
NULL
Warnings:
Warning 1365 Division by 0
Warning 4258 Passing non-positive argument to log2() makes the function's result undefined
select log(2,-1);
log(2,-1)
NULL
Warnings:
Warning 1365 Division by 0
Warning 4256 Passing non-positive argument to log() makes the function's result undefined
select log(-2,1);
log(-2,1)
NULL
Warnings:
Warning 1365 Division by 0
Warning 4257 Passing non-positive or equal-to-1 base to log() makes the function's result undefined
set sql_mode='';
select round(111,-10);
round(111,-10)
Expand Down
238 changes: 238 additions & 0 deletions mysql-test/main/func_math_div_zero.result
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
Loading