Commit c9ec1cc7 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.1 into 10.2

parents a66eebf5 328edf85
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# -*- cperl -*- # -*- cperl -*-
# Copyright (c) 2004, 2014, Oracle and/or its affiliates. # Copyright (c) 2004, 2014, Oracle and/or its affiliates.
# Copyright (c) 2009, 2018, MariaDB Corporation # Copyright (c) 2009, 2020, MariaDB Corporation
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -614,7 +614,8 @@ sub main { ...@@ -614,7 +614,8 @@ sub main {
else else
{ {
my $sys_info= My::SysInfo->new(); my $sys_info= My::SysInfo->new();
$opt_parallel= $sys_info->num_cpus(); $opt_parallel= $sys_info->num_cpus() +
int($sys_info->min_bogomips()/500) - 4;
for my $limit (2000, 1500, 1000, 500){ for my $limit (2000, 1500, 1000, 500){
$opt_parallel-- if ($sys_info->min_bogomips() < $limit); $opt_parallel-- if ($sys_info->min_bogomips() < $limit);
} }
......
...@@ -967,6 +967,54 @@ STDDEV_SAMP(a) ...@@ -967,6 +967,54 @@ STDDEV_SAMP(a)
NULL NULL
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-21977 main.func_math fails due to undefined behaviour
#
SELECT 9223372036854775808 DIV 1;
9223372036854775808 DIV 1
9223372036854775808
SELECT 9223372036854775808 DIV -1;
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 DIV -1'
SELECT -9223372036854775808 DIV 1;
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 DIV 1'
SELECT -9223372036854775808 DIV -1;
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 DIV -1'
SELECT 9223372036854775808 MOD 1;
9223372036854775808 MOD 1
0
SELECT 9223372036854775808 MOD -1;
9223372036854775808 MOD -1
0
SELECT -9223372036854775808 MOD 1;
-9223372036854775808 MOD 1
0
SELECT -9223372036854775808 MOD -1;
-9223372036854775808 MOD -1
0
SELECT 1 MOD 9223372036854775808;
1 MOD 9223372036854775808
1
SELECT -1 MOD 9223372036854775808;
-1 MOD 9223372036854775808
-1
SELECT 1 MOD -9223372036854775808;
1 MOD -9223372036854775808
1
SELECT -1 MOD -9223372036854775808;
-1 MOD -9223372036854775808
-1
SELECT 9223372036854775808 MOD 9223372036854775808;
9223372036854775808 MOD 9223372036854775808
0
SELECT 9223372036854775808 MOD -9223372036854775808;
9223372036854775808 MOD -9223372036854775808
0
SELECT -9223372036854775808 MOD 9223372036854775808;
-9223372036854775808 MOD 9223372036854775808
0
SELECT -9223372036854775808 MOD -9223372036854775808;
-9223372036854775808 MOD -9223372036854775808
0
#
# End of 10.1 tests # End of 10.1 tests
# #
# #
......
...@@ -688,6 +688,35 @@ INSERT INTO t1 VALUES (0); ...@@ -688,6 +688,35 @@ INSERT INTO t1 VALUES (0);
SELECT STDDEV_SAMP(a) FROM t1; SELECT STDDEV_SAMP(a) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-21977 main.func_math fails due to undefined behaviour
--echo #
SELECT 9223372036854775808 DIV 1;
--error ER_DATA_OUT_OF_RANGE
SELECT 9223372036854775808 DIV -1;
--error ER_DATA_OUT_OF_RANGE
SELECT -9223372036854775808 DIV 1;
--error ER_DATA_OUT_OF_RANGE
SELECT -9223372036854775808 DIV -1;
SELECT 9223372036854775808 MOD 1;
SELECT 9223372036854775808 MOD -1;
SELECT -9223372036854775808 MOD 1;
SELECT -9223372036854775808 MOD -1;
SELECT 1 MOD 9223372036854775808;
SELECT -1 MOD 9223372036854775808;
SELECT 1 MOD -9223372036854775808;
SELECT -1 MOD -9223372036854775808;
SELECT 9223372036854775808 MOD 9223372036854775808;
SELECT 9223372036854775808 MOD -9223372036854775808;
SELECT -9223372036854775808 MOD 9223372036854775808;
SELECT -9223372036854775808 MOD -9223372036854775808;
--echo # --echo #
--echo # End of 10.1 tests --echo # End of 10.1 tests
--echo # --echo #
......
...@@ -1817,11 +1817,9 @@ longlong Item_func_int_div::val_int() ...@@ -1817,11 +1817,9 @@ longlong Item_func_int_div::val_int()
raise_integer_overflow(); raise_integer_overflow();
return res; return res;
} }
longlong val0=args[0]->val_int(); Longlong_hybrid val0= args[0]->to_longlong_hybrid();
longlong val1=args[1]->val_int(); Longlong_hybrid val1= args[1]->to_longlong_hybrid();
bool val0_negative, val1_negative, res_negative;
ulonglong uval0, uval1, res;
if ((null_value= (args[0]->null_value || args[1]->null_value))) if ((null_value= (args[0]->null_value || args[1]->null_value)))
return 0; return 0;
if (val1 == 0) if (val1 == 0)
...@@ -1830,12 +1828,8 @@ longlong Item_func_int_div::val_int() ...@@ -1830,12 +1828,8 @@ longlong Item_func_int_div::val_int()
return 0; return 0;
} }
val0_negative= !args[0]->unsigned_flag && val0 < 0; bool res_negative= val0.neg() != val1.neg();
val1_negative= !args[1]->unsigned_flag && val1 < 0; ulonglong res= val0.abs() / val1.abs();
res_negative= val0_negative != val1_negative;
uval0= (ulonglong) (val0_negative ? -val0 : val0);
uval1= (ulonglong) (val1_negative ? -val1 : val1);
res= uval0 / uval1;
if (res_negative) if (res_negative)
{ {
if (res > (ulonglong) LONGLONG_MAX) if (res > (ulonglong) LONGLONG_MAX)
...@@ -1864,11 +1858,8 @@ bool Item_func_int_div::fix_length_and_dec() ...@@ -1864,11 +1858,8 @@ bool Item_func_int_div::fix_length_and_dec()
longlong Item_func_mod::int_op() longlong Item_func_mod::int_op()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
longlong val0= args[0]->val_int(); Longlong_hybrid val0= args[0]->to_longlong_hybrid();
longlong val1= args[1]->val_int(); Longlong_hybrid val1= args[1]->to_longlong_hybrid();
bool val0_negative, val1_negative;
ulonglong uval0, uval1;
ulonglong res;
if ((null_value= args[0]->null_value || args[1]->null_value)) if ((null_value= args[0]->null_value || args[1]->null_value))
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
...@@ -1883,13 +1874,9 @@ longlong Item_func_mod::int_op() ...@@ -1883,13 +1874,9 @@ longlong Item_func_mod::int_op()
LONGLONG_MIN by -1 generates SIGFPE, we calculate using unsigned values and LONGLONG_MIN by -1 generates SIGFPE, we calculate using unsigned values and
then adjust the sign appropriately. then adjust the sign appropriately.
*/ */
val0_negative= !args[0]->unsigned_flag && val0 < 0; ulonglong res= val0.abs() % val1.abs();
val1_negative= !args[1]->unsigned_flag && val1 < 0; return check_integer_overflow(val0.neg() ? -(longlong) res : res,
uval0= (ulonglong) (val0_negative ? -val0 : val0); !val0.neg());
uval1= (ulonglong) (val1_negative ? -val1 : val1);
res= uval0 % uval1;
return check_integer_overflow(val0_negative ? -(longlong) res : res,
!val0_negative);
} }
double Item_func_mod::real_op() double Item_func_mod::real_op()
......
...@@ -8525,9 +8525,9 @@ SHOW_VAR status_vars[]= { ...@@ -8525,9 +8525,9 @@ SHOW_VAR status_vars[]= {
{"Key", (char*) &show_default_keycache, SHOW_FUNC}, {"Key", (char*) &show_default_keycache, SHOW_FUNC},
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS}, {"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
{"Max_statement_time_exceeded", (char*) offsetof(STATUS_VAR, max_statement_time_exceeded), SHOW_LONG_STATUS}, {"Max_statement_time_exceeded", (char*) offsetof(STATUS_VAR, max_statement_time_exceeded), SHOW_LONG_STATUS},
{"Master_gtid_wait_count", (char*) offsetof(STATUS_VAR, master_gtid_wait_count), SHOW_LONGLONG_STATUS}, {"Master_gtid_wait_count", (char*) offsetof(STATUS_VAR, master_gtid_wait_count), SHOW_LONG_STATUS},
{"Master_gtid_wait_timeouts", (char*) offsetof(STATUS_VAR, master_gtid_wait_timeouts), SHOW_LONGLONG_STATUS}, {"Master_gtid_wait_timeouts", (char*) offsetof(STATUS_VAR, master_gtid_wait_timeouts), SHOW_LONG_STATUS},
{"Master_gtid_wait_time", (char*) offsetof(STATUS_VAR, master_gtid_wait_time), SHOW_LONGLONG_STATUS}, {"Master_gtid_wait_time", (char*) offsetof(STATUS_VAR, master_gtid_wait_time), SHOW_LONG_STATUS},
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
{"Memory_used", (char*) &show_memory_used, SHOW_SIMPLE_FUNC}, {"Memory_used", (char*) &show_memory_used, SHOW_SIMPLE_FUNC},
{"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH}, {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH},
......
...@@ -811,9 +811,9 @@ typedef struct system_status_var ...@@ -811,9 +811,9 @@ typedef struct system_status_var
ulong feature_window_functions; /* +1 when window functions are used */ ulong feature_window_functions; /* +1 when window functions are used */
/* From MASTER_GTID_WAIT usage */ /* From MASTER_GTID_WAIT usage */
ulonglong master_gtid_wait_timeouts; /* Number of timeouts */ ulong master_gtid_wait_timeouts; /* Number of timeouts */
ulonglong master_gtid_wait_time; /* Time in microseconds */ ulong master_gtid_wait_time; /* Time in microseconds */
ulonglong master_gtid_wait_count; ulong master_gtid_wait_count;
ulong empty_queries; ulong empty_queries;
ulong access_denied_errors; ulong access_denied_errors;
......
...@@ -67,6 +67,26 @@ class Longlong_hybrid ...@@ -67,6 +67,26 @@ class Longlong_hybrid
*/ */
return cmp_signed(other); return cmp_signed(other);
} }
bool operator==(const Longlong_hybrid &nr) const
{
return cmp(nr) == 0;
}
bool operator==(ulonglong nr) const
{
return cmp(Longlong_hybrid((longlong) nr, true)) == 0;
}
bool operator==(uint nr) const
{
return cmp(Longlong_hybrid((longlong) nr, true)) == 0;
}
bool operator==(longlong nr) const
{
return cmp(Longlong_hybrid(nr, false)) == 0;
}
bool operator==(int nr) const
{
return cmp(Longlong_hybrid(nr, false)) == 0;
}
}; };
#endif // SQL_TYPE_INT_INCLUDED #endif // SQL_TYPE_INT_INCLUDED
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment