From 6e9e8511f1491614c2c864c3749558753a0cc001 Mon Sep 17 00:00:00 2001 From: alexaustin007 Date: Tue, 20 Jan 2026 21:34:06 -0500 Subject: [PATCH 1/7] MDEV-37939 Add function context to division by zero warnings --- mysql-test/main/func_math_div_zero.result | 135 ++++++++++++++++++++++ mysql-test/main/func_math_div_zero.test | 65 +++++++++++ sql/item_func.cc | 24 +++- sql/item_func.h | 1 + 4 files changed, 220 insertions(+), 5 deletions(-) create mode 100644 mysql-test/main/func_math_div_zero.result create mode 100644 mysql-test/main/func_math_div_zero.test diff --git a/mysql-test/main/func_math_div_zero.result b/mysql-test/main/func_math_div_zero.result new file mode 100644 index 0000000000000..3e4c4118743fd --- /dev/null +++ b/mysql-test/main/func_math_div_zero.result @@ -0,0 +1,135 @@ +# +# MDEV-37939: Include function name in division by zero warnings +# +# +# Test with ERROR_FOR_DIVISION_BY_ZERO enabled +# +SET SESSION sql_mode='ERROR_FOR_DIVISION_BY_ZERO'; +# LOG family should show function context +SELECT LOG(-1); +LOG(-1) +NULL +Warnings: +Warning 1365 Division by 0 in function log +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 in function log +SELECT LOG(0); +LOG(0) +NULL +Warnings: +Warning 1365 Division by 0 in function log +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 in function log +SELECT LN(0); +LN(0) +NULL +Warnings: +Warning 1365 Division by 0 in function ln +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 in function ln +SELECT LN(-5); +LN(-5) +NULL +Warnings: +Warning 1365 Division by 0 in function ln +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 in function ln +SELECT LOG2(-1); +LOG2(-1) +NULL +Warnings: +Warning 1365 Division by 0 in function log2 +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 in function log2 +SELECT LOG10(-1); +LOG10(-1) +NULL +Warnings: +Warning 1365 Division by 0 in function log10 +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 in function log10 +# Two-argument LOG: invalid second argument +SELECT LOG(2, -1); +LOG(2, -1) +NULL +Warnings: +Warning 1365 Division by 0 in function log +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 in function log +# Two-argument LOG: invalid base (negative) +SELECT LOG(-2, 10); +LOG(-2, 10) +NULL +Warnings: +Warning 1365 Division by 0 in function log +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 in function log +# Two-argument LOG: base = 1 (log(1) = 0, causes division) +SELECT LOG(1, 10); +LOG(1, 10) +NULL +Warnings: +Warning 1365 Division by 0 in function log +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 in function log +# Non-LOG operations should stay generic +SELECT 1/0; +1/0 +NULL +Warnings: +Warning 1365 Division by 0 +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 +SELECT 5 DIV 0; +5 DIV 0 +NULL +Warnings: +Warning 1365 Division by 0 +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 +SELECT 5 MOD 0; +5 MOD 0 +NULL +Warnings: +Warning 1365 Division by 0 +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 +# Valid inputs should produce no warnings +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 +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 +# +# Test with ERROR_FOR_DIVISION_BY_ZERO disabled +# +SET SESSION sql_mode=''; +SELECT LOG(-1); +LOG(-1) +NULL +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 +# Should be empty - no warning when sql_mode doesn't include the flag diff --git a/mysql-test/main/func_math_div_zero.test b/mysql-test/main/func_math_div_zero.test new file mode 100644 index 0000000000000..39a2181e6d7e3 --- /dev/null +++ b/mysql-test/main/func_math_div_zero.test @@ -0,0 +1,65 @@ +--echo # +--echo # MDEV-37939: Include function name in division by zero warnings +--echo # + +--echo # +--echo # Test with ERROR_FOR_DIVISION_BY_ZERO enabled +--echo # +SET SESSION sql_mode='ERROR_FOR_DIVISION_BY_ZERO'; + +--echo # LOG family should show function context +SELECT LOG(-1); +SHOW WARNINGS; + +SELECT LOG(0); +SHOW WARNINGS; + +SELECT LN(0); +SHOW WARNINGS; + +SELECT LN(-5); +SHOW WARNINGS; + +SELECT LOG2(-1); +SHOW WARNINGS; + +SELECT LOG10(-1); +SHOW WARNINGS; + +--echo # Two-argument LOG: invalid second argument +SELECT LOG(2, -1); +SHOW WARNINGS; + +--echo # Two-argument LOG: invalid base (negative) +SELECT LOG(-2, 10); +SHOW WARNINGS; + +--echo # Two-argument LOG: base = 1 (log(1) = 0, causes division) +SELECT LOG(1, 10); +SHOW WARNINGS; + +--echo # Non-LOG operations should stay generic +SELECT 1/0; +SHOW WARNINGS; + +SELECT 5 DIV 0; +SHOW WARNINGS; + +SELECT 5 MOD 0; +SHOW WARNINGS; + +--echo # Valid inputs should produce no warnings +SELECT LOG(10); +SELECT LN(2.718); +SELECT LOG2(8); +SELECT LOG10(100); +SHOW WARNINGS; + +--echo # +--echo # Test with ERROR_FOR_DIVISION_BY_ZERO disabled +--echo # +SET SESSION sql_mode=''; + +SELECT LOG(-1); +SHOW WARNINGS; +--echo # Should be empty - no warning when sql_mode doesn't include the flag diff --git a/sql/item_func.cc b/sql/item_func.cc index 89ee8cfc1863f..53b26060bba2a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -793,6 +793,20 @@ void Item_func::signal_divide_by_null() } +void Item_func::signal_divide_by_null(const char *context) +{ + THD *thd= current_thd; + if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO) + { + char buf[MYSQL_ERRMSG_SIZE]; + my_snprintf(buf, sizeof(buf), ER_THD(thd, ER_DIVISION_BY_ZERO_IN_FUNC), + context); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, buf); + } + null_value= 1; +} + + Item *Item_func::get_tmp_table_item(THD *thd) { if (!with_sum_func() && !const_item()) @@ -2021,7 +2035,7 @@ double Item_func_ln::val_real() return 0.0; if (value <= 0.0) { - signal_divide_by_null(); + signal_divide_by_null(func_name()); return 0.0; } return log(value); @@ -2041,7 +2055,7 @@ double Item_func_log::val_real() return 0.0; if (value <= 0.0) { - signal_divide_by_null(); + signal_divide_by_null(func_name()); return 0.0; } if (arg_count == 2) @@ -2051,7 +2065,7 @@ double Item_func_log::val_real() return 0.0; if (value2 <= 0.0 || value == 1.0) { - signal_divide_by_null(); + signal_divide_by_null(func_name()); return 0.0; } return log(value2) / log(value); @@ -2068,7 +2082,7 @@ double Item_func_log2::val_real() return 0.0; if (value <= 0.0) { - signal_divide_by_null(); + signal_divide_by_null(func_name()); return 0.0; } return log(value) / M_LN2; @@ -2082,7 +2096,7 @@ double Item_func_log10::val_real() return 0.0; if (value <= 0.0) { - signal_divide_by_null(); + signal_divide_by_null(func_name()); return 0.0; } return log10(value); diff --git a/sql/item_func.h b/sql/item_func.h index 0be8cf61591b1..56e1bac25dab4 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -251,6 +251,7 @@ class Item_func :public Item_func_or_sum String *val_str_from_val_str_ascii(String *str, String *str2); void signal_divide_by_null(); + void signal_divide_by_null(const char *context); friend class udf_handler; Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) override { return tmp_table_field_from_field_type(root, table); } From 50eb21abcdad502a20f2604f8bc2e25cfdbb1018 Mon Sep 17 00:00:00 2001 From: alexaustin007 Date: Thu, 22 Jan 2026 00:11:42 -0500 Subject: [PATCH 2/7] MDEV-37939 Add function context to division by zero warnings 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. --- mysql-test/main/func_math_div_zero.result | 86 ++++++++++++++++++++++- mysql-test/main/func_math_div_zero.test | 42 ++++++++++- sql/item_func.cc | 37 +++++----- sql/item_func.h | 4 +- 4 files changed, 148 insertions(+), 21 deletions(-) diff --git a/mysql-test/main/func_math_div_zero.result b/mysql-test/main/func_math_div_zero.result index 3e4c4118743fd..704cc3a991b38 100644 --- a/mysql-test/main/func_math_div_zero.result +++ b/mysql-test/main/func_math_div_zero.result @@ -81,7 +81,8 @@ Warning 1365 Division by 0 in function log SHOW WARNINGS; Level Code Message Warning 1365 Division by 0 in function log -# Non-LOG operations should stay generic +# Non-LOG operations should stay generic (all show "Division by 0") +# Division - integer SELECT 1/0; 1/0 NULL @@ -90,6 +91,34 @@ 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 @@ -98,6 +127,16 @@ 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 @@ -106,6 +145,51 @@ 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 # Valid inputs should produce no warnings SELECT LOG(10); LOG(10) diff --git a/mysql-test/main/func_math_div_zero.test b/mysql-test/main/func_math_div_zero.test index 39a2181e6d7e3..321d2ef422ad8 100644 --- a/mysql-test/main/func_math_div_zero.test +++ b/mysql-test/main/func_math_div_zero.test @@ -38,16 +38,56 @@ SHOW WARNINGS; SELECT LOG(1, 10); SHOW WARNINGS; ---echo # Non-LOG operations should stay generic +--echo # Non-LOG operations should stay generic (all show "Division by 0") + +--echo # Division - integer SELECT 1/0; SHOW WARNINGS; +--echo # Division - real/float +SELECT 1.0/0.0; +SHOW WARNINGS; + +--echo # Division - decimal +SELECT CAST(1 AS DECIMAL(10,2)) / CAST(0 AS DECIMAL(10,2)); +SHOW WARNINGS; + +--echo # Division - with string arguments +SELECT '1'/'0'; +SHOW WARNINGS; + +--echo # Integer DIV SELECT 5 DIV 0; SHOW WARNINGS; +--echo # Integer DIV - with string arguments +SELECT '5' DIV '0'; +SHOW WARNINGS; + +--echo # MOD - integer SELECT 5 MOD 0; SHOW WARNINGS; +--echo # MOD - real/float +SELECT 5.5e0 MOD 0.0e0; +SHOW WARNINGS; + +--echo # MOD - decimal +SELECT CAST(5 AS DECIMAL(10,2)) MOD CAST(0 AS DECIMAL(10,2)); +SHOW WARNINGS; + +--echo # MOD - with string arguments +SELECT '5' MOD '0'; +SHOW WARNINGS; + +--echo # MOD function syntax +SELECT MOD(5, 0); +SHOW WARNINGS; + +--echo # MOD function - decimal +SELECT MOD(5.5, 0.0); +SHOW WARNINGS; + --echo # Valid inputs should produce no warnings SELECT LOG(10); SELECT LN(2.718); diff --git a/sql/item_func.cc b/sql/item_func.cc index 53b26060bba2a..053e1d6db5b42 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -783,26 +783,29 @@ void Item_udf_func::fix_num_length_and_dec() #endif -void Item_func::signal_divide_by_null() +namespace { + +void push_divide_by_zero_warning(THD *thd, const char *context) { - THD *thd= current_thd; - if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO) + if (context && context[0] != '\0') + { + char buf[MYSQL_ERRMSG_SIZE]; + my_snprintf(buf, sizeof(buf), ER_THD(thd, ER_DIVISION_BY_ZERO_IN_FUNC), + context); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, buf); + } + else push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, ER_THD(thd, ER_DIVISION_BY_ZERO)); - null_value= 1; } +} // namespace void Item_func::signal_divide_by_null(const char *context) { THD *thd= current_thd; if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO) - { - char buf[MYSQL_ERRMSG_SIZE]; - my_snprintf(buf, sizeof(buf), ER_THD(thd, ER_DIVISION_BY_ZERO_IN_FUNC), - context); - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, buf); - } + push_divide_by_zero_warning(thd, context); null_value= 1; } @@ -1533,7 +1536,7 @@ double Item_func_div::real_op() return 0.0; if (val2 == 0.0) { - signal_divide_by_null(); + signal_divide_by_null(nullptr); return 0.0; } return check_float_overflow(value/val2); @@ -1554,7 +1557,7 @@ my_decimal *Item_func_div::decimal_op(my_decimal *decimal_value) prec_increment))) > 3) { if (err == E_DEC_DIV_ZERO) - signal_divide_by_null(); + signal_divide_by_null(nullptr); null_value= 1; return 0; } @@ -1650,7 +1653,7 @@ longlong Item_func_int_div::val_int() val.m_a.ptr(), val.m_b.ptr(), 0)) > 3) { if (err == E_DEC_DIV_ZERO) - signal_divide_by_null(); + signal_divide_by_null(nullptr); return 0; } @@ -1671,7 +1674,7 @@ longlong Item_func_int_div::val_int() return 0; if (val1 == 0) { - signal_divide_by_null(); + signal_divide_by_null(nullptr); return 0; } @@ -1701,7 +1704,7 @@ longlong Item_func_mod::int_op() return 0; /* purecov: inspected */ if (val1 == 0) { - signal_divide_by_null(); + signal_divide_by_null(nullptr); return 0; } @@ -1723,7 +1726,7 @@ double Item_func_mod::real_op() return 0.0; /* purecov: inspected */ if (val2 == 0.0) { - signal_divide_by_null(); + signal_divide_by_null(nullptr); return 0.0; } return fmod(value,val2); @@ -1741,7 +1744,7 @@ my_decimal *Item_func_mod::decimal_op(my_decimal *decimal_value) case E_DEC_OK: return decimal_value; case E_DEC_DIV_ZERO: - signal_divide_by_null(); + signal_divide_by_null(nullptr); /* fall through */ default: null_value= 1; diff --git a/sql/item_func.h b/sql/item_func.h index 56e1bac25dab4..3cc9997e762b1 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -249,9 +249,9 @@ class Item_func :public Item_func_or_sum return null_value; } String *val_str_from_val_str_ascii(String *str, String *str2); - - void signal_divide_by_null(); +protected: void signal_divide_by_null(const char *context); +public: friend class udf_handler; Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) override { return tmp_table_field_from_field_type(root, table); } From 0410b1af07fb33826eba076109cda1f33105b30b Mon Sep 17 00:00:00 2001 From: alexaustin007 Date: Thu, 22 Jan 2026 07:09:31 -0500 Subject: [PATCH 3/7] MDEV-37939 Use correct warning for invalid logarithm 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. --- mysql-test/main/func_math_div_zero.result | 119 +++++++++++++--------- mysql-test/main/func_math_div_zero.test | 60 +++++++---- sql/item_func.cc | 57 ++++++----- sql/item_func.h | 3 +- 4 files changed, 142 insertions(+), 97 deletions(-) diff --git a/mysql-test/main/func_math_div_zero.result b/mysql-test/main/func_math_div_zero.result index 704cc3a991b38..e62e5d1834292 100644 --- a/mysql-test/main/func_math_div_zero.result +++ b/mysql-test/main/func_math_div_zero.result @@ -1,87 +1,133 @@ # -# MDEV-37939: Include function name in division by zero warnings +# MDEV-37939: Use correct error for invalid logarithm arguments # +# LOG/LN/LOG2/LOG10 now emit ER_INVALID_ARGUMENT_FOR_LOGARITHM (3020) +# instead of ER_DIVISION_BY_ZERO (1365), since these functions do not +# perform division. # -# Test with ERROR_FOR_DIVISION_BY_ZERO enabled +# +# 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 show function context +# +# LOG family should report ER_INVALID_ARGUMENT_FOR_LOGARITHM (3020) +# SELECT LOG(-1); LOG(-1) NULL Warnings: -Warning 1365 Division by 0 in function log +Warning 3020 Invalid argument for logarithm SHOW WARNINGS; Level Code Message -Warning 1365 Division by 0 in function log +Warning 3020 Invalid argument for logarithm SELECT LOG(0); LOG(0) NULL Warnings: -Warning 1365 Division by 0 in function log +Warning 3020 Invalid argument for logarithm SHOW WARNINGS; Level Code Message -Warning 1365 Division by 0 in function log +Warning 3020 Invalid argument for logarithm SELECT LN(0); LN(0) NULL Warnings: -Warning 1365 Division by 0 in function ln +Warning 3020 Invalid argument for logarithm SHOW WARNINGS; Level Code Message -Warning 1365 Division by 0 in function ln +Warning 3020 Invalid argument for logarithm SELECT LN(-5); LN(-5) NULL Warnings: -Warning 1365 Division by 0 in function ln +Warning 3020 Invalid argument for logarithm SHOW WARNINGS; Level Code Message -Warning 1365 Division by 0 in function ln +Warning 3020 Invalid argument for logarithm SELECT LOG2(-1); LOG2(-1) NULL Warnings: -Warning 1365 Division by 0 in function log2 +Warning 3020 Invalid argument for logarithm SHOW WARNINGS; Level Code Message -Warning 1365 Division by 0 in function log2 +Warning 3020 Invalid argument for logarithm SELECT LOG10(-1); LOG10(-1) NULL Warnings: -Warning 1365 Division by 0 in function log10 +Warning 3020 Invalid argument for logarithm SHOW WARNINGS; Level Code Message -Warning 1365 Division by 0 in function log10 +Warning 3020 Invalid argument for logarithm # Two-argument LOG: invalid second argument SELECT LOG(2, -1); LOG(2, -1) NULL Warnings: -Warning 1365 Division by 0 in function log +Warning 3020 Invalid argument for logarithm SHOW WARNINGS; Level Code Message -Warning 1365 Division by 0 in function log +Warning 3020 Invalid argument for logarithm # Two-argument LOG: invalid base (negative) SELECT LOG(-2, 10); LOG(-2, 10) NULL Warnings: -Warning 1365 Division by 0 in function log +Warning 3020 Invalid argument for logarithm SHOW WARNINGS; Level Code Message -Warning 1365 Division by 0 in function log -# Two-argument LOG: base = 1 (log(1) = 0, causes division) +Warning 3020 Invalid argument for logarithm +# Two-argument LOG: base = 1 (invalid - would cause log(1)=0 in denominator) SELECT LOG(1, 10); LOG(1, 10) NULL Warnings: -Warning 1365 Division by 0 in function log +Warning 3020 Invalid argument for logarithm SHOW WARNINGS; Level Code Message -Warning 1365 Division by 0 in function log -# Non-LOG operations should stay generic (all show "Division by 0") +Warning 3020 Invalid argument for logarithm +# +# Division operations should report ER_DIVISION_BY_ZERO (1365) +# # Division - integer SELECT 1/0; 1/0 @@ -190,30 +236,3 @@ Warning 1365 Division by 0 SHOW WARNINGS; Level Code Message Warning 1365 Division by 0 -# Valid inputs should produce no warnings -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 -SHOW WARNINGS; -Level Code Message -Warning 1365 Division by 0 -# -# Test with ERROR_FOR_DIVISION_BY_ZERO disabled -# -SET SESSION sql_mode=''; -SELECT LOG(-1); -LOG(-1) -NULL -SHOW WARNINGS; -Level Code Message -Warning 1365 Division by 0 -# Should be empty - no warning when sql_mode doesn't include the flag diff --git a/mysql-test/main/func_math_div_zero.test b/mysql-test/main/func_math_div_zero.test index 321d2ef422ad8..01c3620196808 100644 --- a/mysql-test/main/func_math_div_zero.test +++ b/mysql-test/main/func_math_div_zero.test @@ -1,13 +1,45 @@ --echo # ---echo # MDEV-37939: Include function name in division by zero warnings +--echo # MDEV-37939: Use correct error for invalid logarithm arguments +--echo # +--echo # LOG/LN/LOG2/LOG10 now emit ER_INVALID_ARGUMENT_FOR_LOGARITHM (3020) +--echo # instead of ER_DIVISION_BY_ZERO (1365), since these functions do not +--echo # perform division. --echo # --echo # ---echo # Test with ERROR_FOR_DIVISION_BY_ZERO enabled +--echo # Test valid inputs first (before any warning-producing statements) +--echo # This ensures SHOW WARNINGS is truly empty --echo # SET SESSION sql_mode='ERROR_FOR_DIVISION_BY_ZERO'; ---echo # LOG family should show function context +SELECT LOG(10); +SELECT LN(2.718); +SELECT LOG2(8); +SELECT LOG10(100); +SELECT LOG(2, 8); +SHOW WARNINGS; +--echo # Should be empty - valid inputs produce no warnings + +--echo # +--echo # Test sql_mode='' behavior (before any warnings are produced) +--echo # +SET SESSION sql_mode=''; + +SELECT LOG(-1); +SHOW WARNINGS; +--echo # Should be empty - no warning when sql_mode doesn't include ERROR_FOR_DIVISION_BY_ZERO + +SELECT LN(-1); +SHOW WARNINGS; + +--echo # +--echo # Now test warning-producing cases +--echo # +SET SESSION sql_mode='ERROR_FOR_DIVISION_BY_ZERO'; + +--echo # +--echo # LOG family should report ER_INVALID_ARGUMENT_FOR_LOGARITHM (3020) +--echo # SELECT LOG(-1); SHOW WARNINGS; @@ -34,11 +66,13 @@ SHOW WARNINGS; SELECT LOG(-2, 10); SHOW WARNINGS; ---echo # Two-argument LOG: base = 1 (log(1) = 0, causes division) +--echo # Two-argument LOG: base = 1 (invalid - would cause log(1)=0 in denominator) SELECT LOG(1, 10); SHOW WARNINGS; ---echo # Non-LOG operations should stay generic (all show "Division by 0") +--echo # +--echo # Division operations should report ER_DIVISION_BY_ZERO (1365) +--echo # --echo # Division - integer SELECT 1/0; @@ -87,19 +121,3 @@ SHOW WARNINGS; --echo # MOD function - decimal SELECT MOD(5.5, 0.0); SHOW WARNINGS; - ---echo # Valid inputs should produce no warnings -SELECT LOG(10); -SELECT LN(2.718); -SELECT LOG2(8); -SELECT LOG10(100); -SHOW WARNINGS; - ---echo # ---echo # Test with ERROR_FOR_DIVISION_BY_ZERO disabled ---echo # -SET SESSION sql_mode=''; - -SELECT LOG(-1); -SHOW WARNINGS; ---echo # Should be empty - no warning when sql_mode doesn't include the flag diff --git a/sql/item_func.cc b/sql/item_func.cc index 053e1d6db5b42..e5f4c901d095d 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -785,27 +785,34 @@ void Item_udf_func::fix_num_length_and_dec() namespace { -void push_divide_by_zero_warning(THD *thd, const char *context) +void push_divide_by_zero_warning(THD *thd) { - if (context && context[0] != '\0') - { - char buf[MYSQL_ERRMSG_SIZE]; - my_snprintf(buf, sizeof(buf), ER_THD(thd, ER_DIVISION_BY_ZERO_IN_FUNC), - context); - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, buf); - } - else - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, - ER_THD(thd, ER_DIVISION_BY_ZERO)); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, + ER_THD(thd, ER_DIVISION_BY_ZERO)); +} + +void push_invalid_log_argument_warning(THD *thd) +{ + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, + ER_INVALID_ARGUMENT_FOR_LOGARITHM, + ER_THD(thd, ER_INVALID_ARGUMENT_FOR_LOGARITHM)); } } // namespace -void Item_func::signal_divide_by_null(const char *context) +void Item_func::signal_divide_by_null() +{ + THD *thd= current_thd; + if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO) + push_divide_by_zero_warning(thd); + null_value= 1; +} + +void Item_func::signal_invalid_log_argument() { THD *thd= current_thd; if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO) - push_divide_by_zero_warning(thd, context); + push_invalid_log_argument_warning(thd); null_value= 1; } @@ -1536,7 +1543,7 @@ double Item_func_div::real_op() return 0.0; if (val2 == 0.0) { - signal_divide_by_null(nullptr); + signal_divide_by_null(); return 0.0; } return check_float_overflow(value/val2); @@ -1557,7 +1564,7 @@ my_decimal *Item_func_div::decimal_op(my_decimal *decimal_value) prec_increment))) > 3) { if (err == E_DEC_DIV_ZERO) - signal_divide_by_null(nullptr); + signal_divide_by_null(); null_value= 1; return 0; } @@ -1653,7 +1660,7 @@ longlong Item_func_int_div::val_int() val.m_a.ptr(), val.m_b.ptr(), 0)) > 3) { if (err == E_DEC_DIV_ZERO) - signal_divide_by_null(nullptr); + signal_divide_by_null(); return 0; } @@ -1674,7 +1681,7 @@ longlong Item_func_int_div::val_int() return 0; if (val1 == 0) { - signal_divide_by_null(nullptr); + signal_divide_by_null(); return 0; } @@ -1704,7 +1711,7 @@ longlong Item_func_mod::int_op() return 0; /* purecov: inspected */ if (val1 == 0) { - signal_divide_by_null(nullptr); + signal_divide_by_null(); return 0; } @@ -1726,7 +1733,7 @@ double Item_func_mod::real_op() return 0.0; /* purecov: inspected */ if (val2 == 0.0) { - signal_divide_by_null(nullptr); + signal_divide_by_null(); return 0.0; } return fmod(value,val2); @@ -1744,7 +1751,7 @@ my_decimal *Item_func_mod::decimal_op(my_decimal *decimal_value) case E_DEC_OK: return decimal_value; case E_DEC_DIV_ZERO: - signal_divide_by_null(nullptr); + signal_divide_by_null(); /* fall through */ default: null_value= 1; @@ -2038,7 +2045,7 @@ double Item_func_ln::val_real() return 0.0; if (value <= 0.0) { - signal_divide_by_null(func_name()); + signal_invalid_log_argument(); return 0.0; } return log(value); @@ -2058,7 +2065,7 @@ double Item_func_log::val_real() return 0.0; if (value <= 0.0) { - signal_divide_by_null(func_name()); + signal_invalid_log_argument(); return 0.0; } if (arg_count == 2) @@ -2068,7 +2075,7 @@ double Item_func_log::val_real() return 0.0; if (value2 <= 0.0 || value == 1.0) { - signal_divide_by_null(func_name()); + signal_invalid_log_argument(); return 0.0; } return log(value2) / log(value); @@ -2085,7 +2092,7 @@ double Item_func_log2::val_real() return 0.0; if (value <= 0.0) { - signal_divide_by_null(func_name()); + signal_invalid_log_argument(); return 0.0; } return log(value) / M_LN2; @@ -2099,7 +2106,7 @@ double Item_func_log10::val_real() return 0.0; if (value <= 0.0) { - signal_divide_by_null(func_name()); + signal_invalid_log_argument(); return 0.0; } return log10(value); diff --git a/sql/item_func.h b/sql/item_func.h index 3cc9997e762b1..ac8758355f59c 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -250,7 +250,8 @@ class Item_func :public Item_func_or_sum } String *val_str_from_val_str_ascii(String *str, String *str2); protected: - void signal_divide_by_null(const char *context); + void signal_divide_by_null(); + void signal_invalid_log_argument(); public: friend class udf_handler; Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) override From c01efe2777a7532c08a4c19de6404f9885de4b25 Mon Sep 17 00:00:00 2001 From: alexaustin007 Date: Fri, 23 Jan 2026 05:36:53 -0500 Subject: [PATCH 4/7] MDEV-37939: use proper log domain warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- mysql-test/main/func_math_div_zero.result | 42 ++++++++-------- mysql-test/main/func_math_div_zero.test | 6 +-- sql/item_func.cc | 58 ++++++++++------------- sql/item_func.h | 2 +- sql/share/errmsg-utf8.txt | 10 ++++ 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/mysql-test/main/func_math_div_zero.result b/mysql-test/main/func_math_div_zero.result index e62e5d1834292..056372f104330 100644 --- a/mysql-test/main/func_math_div_zero.result +++ b/mysql-test/main/func_math_div_zero.result @@ -1,8 +1,8 @@ # # MDEV-37939: Use correct error for invalid logarithm arguments # -# LOG/LN/LOG2/LOG10 now emit ER_INVALID_ARGUMENT_FOR_LOGARITHM (3020) -# instead of ER_DIVISION_BY_ZERO (1365), since these functions do not +# LOG/LN/LOG2/LOG10 now emit function-specific domain warnings +# instead of ER_DIVISION_BY_ZERO, since these functions do not # perform division. # # @@ -48,83 +48,83 @@ Level Code Message # SET SESSION sql_mode='ERROR_FOR_DIVISION_BY_ZERO'; # -# LOG family should report ER_INVALID_ARGUMENT_FOR_LOGARITHM (3020) +# LOG family should report function-specific domain warnings # SELECT LOG(-1); LOG(-1) NULL Warnings: -Warning 3020 Invalid argument for logarithm +Warning 4244 Passing non-positive argument to log() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 3020 Invalid argument for logarithm +Warning 4244 Passing non-positive argument to log() makes the function's result undefined SELECT LOG(0); LOG(0) NULL Warnings: -Warning 3020 Invalid argument for logarithm +Warning 4244 Passing non-positive argument to log() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 3020 Invalid argument for logarithm +Warning 4244 Passing non-positive argument to log() makes the function's result undefined SELECT LN(0); LN(0) NULL Warnings: -Warning 3020 Invalid argument for logarithm +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 3020 Invalid argument for logarithm +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined SELECT LN(-5); LN(-5) NULL Warnings: -Warning 3020 Invalid argument for logarithm +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 3020 Invalid argument for logarithm +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined SELECT LOG2(-1); LOG2(-1) NULL Warnings: -Warning 3020 Invalid argument for logarithm +Warning 4246 Passing non-positive argument to log2() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 3020 Invalid argument for logarithm +Warning 4246 Passing non-positive argument to log2() makes the function's result undefined SELECT LOG10(-1); LOG10(-1) NULL Warnings: -Warning 3020 Invalid argument for logarithm +Warning 4247 Passing non-positive argument to log10() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 3020 Invalid argument for logarithm +Warning 4247 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 3020 Invalid argument for logarithm +Warning 4244 Passing non-positive argument to log() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 3020 Invalid argument for logarithm +Warning 4244 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 3020 Invalid argument for logarithm +Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 3020 Invalid argument for logarithm +Warning 4245 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 3020 Invalid argument for logarithm +Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 3020 Invalid argument for logarithm +Warning 4245 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) # diff --git a/mysql-test/main/func_math_div_zero.test b/mysql-test/main/func_math_div_zero.test index 01c3620196808..15fd264779a84 100644 --- a/mysql-test/main/func_math_div_zero.test +++ b/mysql-test/main/func_math_div_zero.test @@ -1,8 +1,8 @@ --echo # --echo # MDEV-37939: Use correct error for invalid logarithm arguments --echo # ---echo # LOG/LN/LOG2/LOG10 now emit ER_INVALID_ARGUMENT_FOR_LOGARITHM (3020) ---echo # instead of ER_DIVISION_BY_ZERO (1365), since these functions do not +--echo # LOG/LN/LOG2/LOG10 now emit function-specific domain warnings +--echo # instead of ER_DIVISION_BY_ZERO, since these functions do not --echo # perform division. --echo # @@ -38,7 +38,7 @@ SHOW WARNINGS; SET SESSION sql_mode='ERROR_FOR_DIVISION_BY_ZERO'; --echo # ---echo # LOG family should report ER_INVALID_ARGUMENT_FOR_LOGARITHM (3020) +--echo # LOG family should report function-specific domain warnings --echo # SELECT LOG(-1); SHOW WARNINGS; diff --git a/sql/item_func.cc b/sql/item_func.cc index e5f4c901d095d..7d27846a01138 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -783,36 +783,21 @@ void Item_udf_func::fix_num_length_and_dec() #endif -namespace { - -void push_divide_by_zero_warning(THD *thd) -{ - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, - ER_THD(thd, ER_DIVISION_BY_ZERO)); -} - -void push_invalid_log_argument_warning(THD *thd) -{ - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, - ER_INVALID_ARGUMENT_FOR_LOGARITHM, - ER_THD(thd, ER_INVALID_ARGUMENT_FOR_LOGARITHM)); -} - -} // namespace - void Item_func::signal_divide_by_null() { THD *thd= current_thd; if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO) - push_divide_by_zero_warning(thd); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, + ER_THD(thd, ER_DIVISION_BY_ZERO)); null_value= 1; } -void Item_func::signal_invalid_log_argument() +void Item_func::signal_log_domain_error(uint sql_errno) { THD *thd= current_thd; if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO) - push_invalid_log_argument_warning(thd); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, sql_errno, + ER_THD(thd, sql_errno)); null_value= 1; } @@ -2045,7 +2030,7 @@ double Item_func_ln::val_real() return 0.0; if (value <= 0.0) { - signal_invalid_log_argument(); + signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LN); return 0.0; } return log(value); @@ -2060,27 +2045,32 @@ double Item_func_ln::val_real() double Item_func_log::val_real() { DBUG_ASSERT(fixed()); - double value= args[0]->val_real(); + double base= args[0]->val_real(); if ((null_value= args[0]->null_value)) return 0.0; - if (value <= 0.0) - { - signal_invalid_log_argument(); - return 0.0; - } if (arg_count == 2) { - double value2= args[1]->val_real(); + double value= args[1]->val_real(); if ((null_value= args[1]->null_value)) return 0.0; - if (value2 <= 0.0 || value == 1.0) + if (base <= 0.0 || base == 1.0) + { + signal_log_domain_error(ER_INVALID_BASE_FOR_LOG); + return 0.0; + } + if (value <= 0.0) { - signal_invalid_log_argument(); + signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LOG); return 0.0; } - return log(value2) / log(value); + return log(value) / log(base); } - return log(value); + if (base <= 0.0) + { + signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LOG); + return 0.0; + } + return log(base); } double Item_func_log2::val_real() @@ -2092,7 +2082,7 @@ double Item_func_log2::val_real() return 0.0; if (value <= 0.0) { - signal_invalid_log_argument(); + signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LOG2); return 0.0; } return log(value) / M_LN2; @@ -2106,7 +2096,7 @@ double Item_func_log10::val_real() return 0.0; if (value <= 0.0) { - signal_invalid_log_argument(); + signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LOG10); return 0.0; } return log10(value); diff --git a/sql/item_func.h b/sql/item_func.h index ac8758355f59c..69755d1979aeb 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -251,7 +251,7 @@ class Item_func :public Item_func_or_sum String *val_str_from_val_str_ascii(String *str, String *str2); protected: void signal_divide_by_null(); - void signal_invalid_log_argument(); + void signal_log_domain_error(uint sql_errno); public: friend class udf_handler; Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) override diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 56b1c7e07088b..7a52f75e27611 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -12386,3 +12386,13 @@ ER_PARTIAL_ROWS_LOG_EVENT_BAD_STREAM eng "Broken Partial_rows_log_event stream. Found %s, expected Partial_rows_log_event %u / %u" ER_SLAVE_INCOMPATIBLE_TABLE_DEF eng "Table structure for binlog event is not compatible with the table definition on this slave: %s" +ER_INVALID_ARGUMENT_FOR_LN 2201E + eng "Passing non-positive argument to ln() makes the function's result undefined" +ER_INVALID_ARGUMENT_FOR_LOG 2201E + eng "Passing non-positive argument to log() makes the function's result undefined" +ER_INVALID_BASE_FOR_LOG 2201E + eng "Passing non-positive or equal-to-1 base to log() makes the function's result undefined" +ER_INVALID_ARGUMENT_FOR_LOG2 2201E + eng "Passing non-positive argument to log2() makes the function's result undefined" +ER_INVALID_ARGUMENT_FOR_LOG10 2201E + eng "Passing non-positive argument to log10() makes the function's result undefined" From 8d3bafa583e24c6ea04050ba26621d82772693df Mon Sep 17 00:00:00 2001 From: alexaustin007 Date: Mon, 26 Jan 2026 09:17:29 -0500 Subject: [PATCH 5/7] MDEV-37939: make log-domain warning helper static --- sql/item_func.cc | 20 +++++++++++++------- sql/item_func.h | 1 - 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sql/item_func.cc b/sql/item_func.cc index 7d27846a01138..d443f48f88373 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -783,21 +783,21 @@ void Item_udf_func::fix_num_length_and_dec() #endif -void Item_func::signal_divide_by_null() +static void signal_log_domain_error(uint sql_errno) { THD *thd= current_thd; if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO) - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, - ER_THD(thd, ER_DIVISION_BY_ZERO)); - null_value= 1; + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, sql_errno, + ER_THD(thd, sql_errno)); } -void Item_func::signal_log_domain_error(uint sql_errno) + +void Item_func::signal_divide_by_null() { THD *thd= current_thd; if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO) - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, sql_errno, - ER_THD(thd, sql_errno)); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_DIVISION_BY_ZERO, + ER_THD(thd, ER_DIVISION_BY_ZERO)); null_value= 1; } @@ -2031,6 +2031,7 @@ double Item_func_ln::val_real() if (value <= 0.0) { signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LN); + null_value= 1; return 0.0; } return log(value); @@ -2056,11 +2057,13 @@ double Item_func_log::val_real() if (base <= 0.0 || base == 1.0) { signal_log_domain_error(ER_INVALID_BASE_FOR_LOG); + null_value= 1; return 0.0; } if (value <= 0.0) { signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LOG); + null_value= 1; return 0.0; } return log(value) / log(base); @@ -2068,6 +2071,7 @@ double Item_func_log::val_real() if (base <= 0.0) { signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LOG); + null_value= 1; return 0.0; } return log(base); @@ -2083,6 +2087,7 @@ double Item_func_log2::val_real() if (value <= 0.0) { signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LOG2); + null_value= 1; return 0.0; } return log(value) / M_LN2; @@ -2097,6 +2102,7 @@ double Item_func_log10::val_real() if (value <= 0.0) { signal_log_domain_error(ER_INVALID_ARGUMENT_FOR_LOG10); + null_value= 1; return 0.0; } return log10(value); diff --git a/sql/item_func.h b/sql/item_func.h index 69755d1979aeb..285da27a0062f 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -251,7 +251,6 @@ class Item_func :public Item_func_or_sum String *val_str_from_val_str_ascii(String *str, String *str2); protected: void signal_divide_by_null(); - void signal_log_domain_error(uint sql_errno); public: friend class udf_handler; Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) override From 79d6395e98d9aa374054db0f3f0d8a4bc08240c5 Mon Sep 17 00:00:00 2001 From: alexaustin007 Date: Tue, 27 Jan 2026 07:00:35 -0500 Subject: [PATCH 6/7] MDEV-37939: Update test results for LOG domain warnings --- mysql-test/main/func_math.result | 28 +++++++++---------- .../r/gcol_supported_sql_funcs_innodb.result | 20 ++++++------- .../r/gcol_supported_sql_funcs_myisam.result | 20 ++++++------- .../vcol/r/vcol_supported_sql_funcs.result | 20 ++++++------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result index 475485cbcae59..3066c982ba880 100644 --- a/mysql-test/main/func_math.result +++ b/mysql-test/main/func_math.result @@ -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 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined +Warning 4245 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 @@ -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 4243 Passing non-positive argument to ln() makes the function's result undefined +Warning 4243 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 @@ -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 4246 Passing non-positive argument to log2() makes the function's result undefined +Warning 4246 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 @@ -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 4247 Passing non-positive argument to log10() makes the function's result undefined +Warning 4247 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 @@ -239,27 +239,27 @@ select ln(-1); ln(-1) NULL Warnings: -Warning 1365 Division by 0 +Warning 4243 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 4247 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 4246 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 4244 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 4245 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) diff --git a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result index 1b901e6b87e8e..e06197a15104c 100644 --- a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result @@ -274,13 +274,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert into t1 values (-2,default); Warnings: -Warning 1365 Division by 0 +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined select * from t1; a b -2 NULL 2 0.693147 Warnings: -Warning 1365 Division by 0 +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG() @@ -297,14 +297,14 @@ insert into t1 values (2,65536,default); insert into t1 values (10,100,default); insert into t1 values (1,100,default); Warnings: -Warning 1365 Division by 0 +Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined select * from t1; a b c 1 100 NULL 10 100 2 2 65536 16 Warnings: -Warning 1365 Division by 0 +Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined drop table t1; set sql_warnings = 0; set sql_warnings = 1; @@ -318,13 +318,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert into t1 values (-2,default); Warnings: -Warning 1365 Division by 0 +Warning 4244 Passing non-positive argument to log() makes the function's result undefined select * from t1; a b -2 NULL 2 0.693147 Warnings: -Warning 1365 Division by 0 +Warning 4244 Passing non-positive argument to log() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG2() @@ -339,13 +339,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (65536,default); insert into t1 values (-100,default); Warnings: -Warning 1365 Division by 0 +Warning 4246 Passing non-positive argument to log2() makes the function's result undefined select * from t1; a b -100 NULL 65536 16 Warnings: -Warning 1365 Division by 0 +Warning 4246 Passing non-positive argument to log2() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG10() @@ -361,14 +361,14 @@ insert into t1 values (2,default); insert into t1 values (100,default); insert into t1 values (-100,default); Warnings: -Warning 1365 Division by 0 +Warning 4247 Passing non-positive argument to log10() makes the function's result undefined select * from t1; a b -100 NULL 100 2 2 0.30103 Warnings: -Warning 1365 Division by 0 +Warning 4247 Passing non-positive argument to log10() makes the function's result undefined drop table t1; set sql_warnings = 0; # - diff --git a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result index dab3d50b00eb3..0dbd0bb626bab 100644 --- a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result +++ b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result @@ -274,13 +274,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert into t1 values (-2,default); Warnings: -Warning 1365 Division by 0 +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined select * from t1; a b -2 NULL 2 0.693147 Warnings: -Warning 1365 Division by 0 +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG() @@ -297,14 +297,14 @@ insert into t1 values (2,65536,default); insert into t1 values (10,100,default); insert into t1 values (1,100,default); Warnings: -Warning 1365 Division by 0 +Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined select * from t1; a b c 1 100 NULL 10 100 2 2 65536 16 Warnings: -Warning 1365 Division by 0 +Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined drop table t1; set sql_warnings = 0; set sql_warnings = 1; @@ -318,13 +318,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert into t1 values (-2,default); Warnings: -Warning 1365 Division by 0 +Warning 4244 Passing non-positive argument to log() makes the function's result undefined select * from t1; a b -2 NULL 2 0.693147 Warnings: -Warning 1365 Division by 0 +Warning 4244 Passing non-positive argument to log() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG2() @@ -339,13 +339,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (65536,default); insert into t1 values (-100,default); Warnings: -Warning 1365 Division by 0 +Warning 4246 Passing non-positive argument to log2() makes the function's result undefined select * from t1; a b -100 NULL 65536 16 Warnings: -Warning 1365 Division by 0 +Warning 4246 Passing non-positive argument to log2() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG10() @@ -361,14 +361,14 @@ insert into t1 values (2,default); insert into t1 values (100,default); insert into t1 values (-100,default); Warnings: -Warning 1365 Division by 0 +Warning 4247 Passing non-positive argument to log10() makes the function's result undefined select * from t1; a b -100 NULL 100 2 2 0.30103 Warnings: -Warning 1365 Division by 0 +Warning 4247 Passing non-positive argument to log10() makes the function's result undefined drop table t1; set sql_warnings = 0; # - diff --git a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs.result b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs.result index 3c062b5f27af2..b5d616ba1d220 100644 --- a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs.result +++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs.result @@ -274,13 +274,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert ignore into t1 values (-2,default); Warnings: -Warning 1365 Division by 0 +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined select * from t1; a b 2 0.693147 -2 NULL Warnings: -Warning 1365 Division by 0 +Warning 4243 Passing non-positive argument to ln() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG() @@ -297,14 +297,14 @@ insert into t1 values (2,65536,default); insert ignore into t1 values (10,100,default); insert into t1 values (1,100,default); Warnings: -Warning 1365 Division by 0 +Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined select * from t1; a b c 2 65536 16 10 100 2 1 100 NULL Warnings: -Warning 1365 Division by 0 +Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined drop table t1; set sql_warnings = 0; set sql_warnings = 1; @@ -318,13 +318,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert ignore into t1 values (-2,default); Warnings: -Warning 1365 Division by 0 +Warning 4244 Passing non-positive argument to log() makes the function's result undefined select * from t1; a b 2 0.693147 -2 NULL Warnings: -Warning 1365 Division by 0 +Warning 4244 Passing non-positive argument to log() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG2() @@ -339,13 +339,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (65536,default); insert ignore into t1 values (-100,default); Warnings: -Warning 1365 Division by 0 +Warning 4246 Passing non-positive argument to log2() makes the function's result undefined select * from t1; a b 65536 16 -100 NULL Warnings: -Warning 1365 Division by 0 +Warning 4246 Passing non-positive argument to log2() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG10() @@ -361,14 +361,14 @@ insert into t1 values (2,default); insert ignore into t1 values (100,default); insert into t1 values (-100,default); Warnings: -Warning 1365 Division by 0 +Warning 4247 Passing non-positive argument to log10() makes the function's result undefined select * from t1; a b 2 0.30103 100 2 -100 NULL Warnings: -Warning 1365 Division by 0 +Warning 4247 Passing non-positive argument to log10() makes the function's result undefined drop table t1; set sql_warnings = 0; # - From c9939785fd5ff75c46b8790dfa745b7e5f2b0b5d Mon Sep 17 00:00:00 2001 From: alexaustin007 Date: Wed, 28 Jan 2026 15:35:49 -0500 Subject: [PATCH 7/7] MDEV-37939: Update test results for rebased error codes --- mysql-test/main/func_math.result | 28 +++++++-------- mysql-test/main/func_math_div_zero.result | 36 +++++++++---------- .../r/gcol_supported_sql_funcs_innodb.result | 20 +++++------ .../r/gcol_supported_sql_funcs_myisam.result | 20 +++++------ .../vcol/r/vcol_supported_sql_funcs.result | 20 +++++------ 5 files changed, 62 insertions(+), 62 deletions(-) diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result index 3066c982ba880..6364662b19b75 100644 --- a/mysql-test/main/func_math.result +++ b/mysql-test/main/func_math.result @@ -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 4244 Passing non-positive argument to log() makes the function's result undefined -Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined -Warning 4245 Passing non-positive or equal-to-1 base to log() makes the function's result undefined +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 @@ -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 4243 Passing non-positive argument to ln() makes the function's result undefined -Warning 4243 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 +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 @@ -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 4246 Passing non-positive argument to log2() makes the function's result undefined -Warning 4246 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 +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 @@ -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 4247 Passing non-positive argument to log10() makes the function's result undefined -Warning 4247 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 +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 @@ -239,27 +239,27 @@ select ln(-1); ln(-1) NULL Warnings: -Warning 4243 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 select log10(-1); log10(-1) NULL Warnings: -Warning 4247 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 select log2(-1); log2(-1) NULL Warnings: -Warning 4246 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 select log(2,-1); log(2,-1) NULL Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined select log(-2,1); log(-2,1) NULL Warnings: -Warning 4245 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 set sql_mode=''; select round(111,-10); round(111,-10) diff --git a/mysql-test/main/func_math_div_zero.result b/mysql-test/main/func_math_div_zero.result index 056372f104330..12588dea85218 100644 --- a/mysql-test/main/func_math_div_zero.result +++ b/mysql-test/main/func_math_div_zero.result @@ -54,77 +54,77 @@ SELECT LOG(-1); LOG(-1) NULL Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined SELECT LOG(0); LOG(0) NULL Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined SELECT LN(0); LN(0) NULL Warnings: -Warning 4243 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 SHOW WARNINGS; Level Code Message -Warning 4243 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 SELECT LN(-5); LN(-5) NULL Warnings: -Warning 4243 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 SHOW WARNINGS; Level Code Message -Warning 4243 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 SELECT LOG2(-1); LOG2(-1) NULL Warnings: -Warning 4246 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 SHOW WARNINGS; Level Code Message -Warning 4246 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 SELECT LOG10(-1); LOG10(-1) NULL Warnings: -Warning 4247 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 SHOW WARNINGS; Level Code Message -Warning 4247 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 # Two-argument LOG: invalid second argument SELECT LOG(2, -1); LOG(2, -1) NULL Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined SHOW WARNINGS; Level Code Message -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +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 4245 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 SHOW WARNINGS; Level Code Message -Warning 4245 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 # Two-argument LOG: base = 1 (invalid - would cause log(1)=0 in denominator) SELECT LOG(1, 10); LOG(1, 10) NULL Warnings: -Warning 4245 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 SHOW WARNINGS; Level Code Message -Warning 4245 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 # # Division operations should report ER_DIVISION_BY_ZERO (1365) # diff --git a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result index e06197a15104c..5dbd34a828e21 100644 --- a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result @@ -274,13 +274,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert into t1 values (-2,default); Warnings: -Warning 4243 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 select * from t1; a b -2 NULL 2 0.693147 Warnings: -Warning 4243 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 drop table t1; set sql_warnings = 0; # LOG() @@ -297,14 +297,14 @@ insert into t1 values (2,65536,default); insert into t1 values (10,100,default); insert into t1 values (1,100,default); Warnings: -Warning 4245 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 select * from t1; a b c 1 100 NULL 10 100 2 2 65536 16 Warnings: -Warning 4245 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 drop table t1; set sql_warnings = 0; set sql_warnings = 1; @@ -318,13 +318,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert into t1 values (-2,default); Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined select * from t1; a b -2 NULL 2 0.693147 Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG2() @@ -339,13 +339,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (65536,default); insert into t1 values (-100,default); Warnings: -Warning 4246 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 select * from t1; a b -100 NULL 65536 16 Warnings: -Warning 4246 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 drop table t1; set sql_warnings = 0; # LOG10() @@ -361,14 +361,14 @@ insert into t1 values (2,default); insert into t1 values (100,default); insert into t1 values (-100,default); Warnings: -Warning 4247 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 select * from t1; a b -100 NULL 100 2 2 0.30103 Warnings: -Warning 4247 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 drop table t1; set sql_warnings = 0; # - diff --git a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result index 0dbd0bb626bab..ec5894543241d 100644 --- a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result +++ b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result @@ -274,13 +274,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert into t1 values (-2,default); Warnings: -Warning 4243 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 select * from t1; a b -2 NULL 2 0.693147 Warnings: -Warning 4243 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 drop table t1; set sql_warnings = 0; # LOG() @@ -297,14 +297,14 @@ insert into t1 values (2,65536,default); insert into t1 values (10,100,default); insert into t1 values (1,100,default); Warnings: -Warning 4245 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 select * from t1; a b c 1 100 NULL 10 100 2 2 65536 16 Warnings: -Warning 4245 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 drop table t1; set sql_warnings = 0; set sql_warnings = 1; @@ -318,13 +318,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert into t1 values (-2,default); Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined select * from t1; a b -2 NULL 2 0.693147 Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG2() @@ -339,13 +339,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (65536,default); insert into t1 values (-100,default); Warnings: -Warning 4246 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 select * from t1; a b -100 NULL 65536 16 Warnings: -Warning 4246 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 drop table t1; set sql_warnings = 0; # LOG10() @@ -361,14 +361,14 @@ insert into t1 values (2,default); insert into t1 values (100,default); insert into t1 values (-100,default); Warnings: -Warning 4247 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 select * from t1; a b -100 NULL 100 2 2 0.30103 Warnings: -Warning 4247 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 drop table t1; set sql_warnings = 0; # - diff --git a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs.result b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs.result index b5d616ba1d220..3b9adc3182b2f 100644 --- a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs.result +++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs.result @@ -274,13 +274,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert ignore into t1 values (-2,default); Warnings: -Warning 4243 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 select * from t1; a b 2 0.693147 -2 NULL Warnings: -Warning 4243 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 drop table t1; set sql_warnings = 0; # LOG() @@ -297,14 +297,14 @@ insert into t1 values (2,65536,default); insert ignore into t1 values (10,100,default); insert into t1 values (1,100,default); Warnings: -Warning 4245 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 select * from t1; a b c 2 65536 16 10 100 2 1 100 NULL Warnings: -Warning 4245 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 drop table t1; set sql_warnings = 0; set sql_warnings = 1; @@ -318,13 +318,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (2,default); insert ignore into t1 values (-2,default); Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined select * from t1; a b 2 0.693147 -2 NULL Warnings: -Warning 4244 Passing non-positive argument to log() makes the function's result undefined +Warning 4256 Passing non-positive argument to log() makes the function's result undefined drop table t1; set sql_warnings = 0; # LOG2() @@ -339,13 +339,13 @@ t1 CREATE TABLE `t1` ( insert into t1 values (65536,default); insert ignore into t1 values (-100,default); Warnings: -Warning 4246 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 select * from t1; a b 65536 16 -100 NULL Warnings: -Warning 4246 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 drop table t1; set sql_warnings = 0; # LOG10() @@ -361,14 +361,14 @@ insert into t1 values (2,default); insert ignore into t1 values (100,default); insert into t1 values (-100,default); Warnings: -Warning 4247 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 select * from t1; a b 2 0.30103 100 2 -100 NULL Warnings: -Warning 4247 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 drop table t1; set sql_warnings = 0; # -