diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2020-10-29 15:16:53 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2020-10-29 15:16:53 +0100 |
commit | 2e5450af052040848042c6eae4f03efa23c5f8fc (patch) | |
tree | 0f2d695372c7aae8fc5ea63cf78f57475c297de2 | |
parent | 17cf27f5b61aace463c3ae52df54c2363d2d4ca8 (diff) | |
parent | d6302c9a47615019a3bca5304d3f61c587d826b8 (diff) | |
download | mariadb-git-2e5450af052040848042c6eae4f03efa23c5f8fc.tar.gz |
Merge branch '10.1' into 10.2
-rw-r--r-- | mysql-test/r/aria_icp_debug.result (renamed from mysql-test/t/aria_icp_debug.result) | 0 | ||||
-rw-r--r-- | mysql-test/r/func_group.result | 4 | ||||
-rw-r--r-- | mysql-test/r/innodb_icp_debug.result (renamed from mysql-test/t/innodb_icp_debug.result) | 0 | ||||
-rw-r--r-- | mysql-test/r/myisam_icp_debug.result (renamed from mysql-test/t/myisam_icp_debug.result) | 0 | ||||
-rw-r--r-- | mysql-test/r/precedence.result | 4 | ||||
-rw-r--r-- | mysql-test/r/subselect4.result | 2 | ||||
-rw-r--r-- | mysql-test/r/type_newdecimal.result | 5 | ||||
-rw-r--r-- | mysql-test/r/type_ranges.result | 6 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/r/div_precision_increment_func.result | 16 | ||||
-rw-r--r-- | mysql-test/suite/vcol/r/not_supported.result | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 6 | ||||
-rw-r--r-- | sql/item_func.cc | 2 | ||||
-rw-r--r-- | sql/my_decimal.h | 11 | ||||
-rw-r--r-- | sql/mysqld.cc | 75 | ||||
-rw-r--r-- | storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result | 5 | ||||
-rw-r--r-- | storage/tokudb/mysql-test/tokudb/r/type_ranges.result | 6 |
16 files changed, 110 insertions, 34 deletions
diff --git a/mysql-test/t/aria_icp_debug.result b/mysql-test/r/aria_icp_debug.result index fc01ee4fb3b..fc01ee4fb3b 100644 --- a/mysql-test/t/aria_icp_debug.result +++ b/mysql-test/r/aria_icp_debug.result diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 1ead006e08a..0f9fdefb81a 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1186,13 +1186,13 @@ i count(*) std(e1/e2) 3 4 0.00000000 select std(s1/s2) from bug22555; std(s1/s2) -0.21328517 +0.21325764 select std(o1/o2) from bug22555; std(o1/o2) 0.2132576358664934 select std(e1/e2) from bug22555; std(e1/e2) -0.21328517 +0.21325764 set @saved_div_precision_increment=@@div_precision_increment; set div_precision_increment=19; select i, count(*), std(s1/s2) from bug22555 group by i order by i; diff --git a/mysql-test/t/innodb_icp_debug.result b/mysql-test/r/innodb_icp_debug.result index 5a169650c8e..5a169650c8e 100644 --- a/mysql-test/t/innodb_icp_debug.result +++ b/mysql-test/r/innodb_icp_debug.result diff --git a/mysql-test/t/myisam_icp_debug.result b/mysql-test/r/myisam_icp_debug.result index cb45a0e2274..cb45a0e2274 100644 --- a/mysql-test/t/myisam_icp_debug.result +++ b/mysql-test/r/myisam_icp_debug.result diff --git a/mysql-test/r/precedence.result b/mysql-test/r/precedence.result index 34304d980c0..986af631346 100644 --- a/mysql-test/r/precedence.result +++ b/mysql-test/r/precedence.result @@ -5920,14 +5920,14 @@ view_definition select 2 / 3 * 3 AS `2 / 3 * 3`,2 / (3 * 3) AS `2 / (3 * 3)`,2 / 3 * 3 AS `(2 / 3) * 3` select 2 / 3 * 3, 2 / (3 * 3), (2 / 3) * 3 union select * from v1; 2 / 3 * 3 2 / (3 * 3) (2 / 3) * 3 -2.0001 0.2222 2.0001 +2.0000 0.2222 2.0000 create or replace view v1 as select 2 / 3 / 3, 2 / (3 / 3), (2 / 3) / 3; Select view_definition from information_schema.views where table_schema='test' and table_name='v1'; view_definition select 2 / 3 / 3 AS `2 / 3 / 3`,2 / (3 / 3) AS `2 / (3 / 3)`,2 / 3 / 3 AS `(2 / 3) / 3` select 2 / 3 / 3, 2 / (3 / 3), (2 / 3) / 3 union select * from v1; 2 / 3 / 3 2 / (3 / 3) (2 / 3) / 3 -0.22223333 2.0000 0.22223333 +0.22222222 2.0000 0.22222222 create or replace view v1 as select 2 / 3 DIV 3, 2 / (3 DIV 3), (2 / 3) DIV 3; Select view_definition from information_schema.views where table_schema='test' and table_name='v1'; view_definition diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 573df11e4a6..c0df4f626b1 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -2596,7 +2596,7 @@ SELECT population, area, population/area, cast(population/area as DECIMAL(20,9)) FROM t1 LIMIT 1; population area population/area cast(population/area as DECIMAL(20,9)) -11797 91 129.6374 129.637400000 +11797 91 129.6374 129.637362637 SELECT * FROM t1 A WHERE population/area = (SELECT MAX(population/area) from t1 B where A.region = B.region); region area population diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index 5c2a41524c1..0fbf64a4b18 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -1532,8 +1532,11 @@ select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 * 1.01500000 * 1.01500000 * 0.99500000) 0.81298807395367312459230693948000000000 create table t1 as select 5.05 / 0.014; +Warnings: +Note 1265 Data truncated for column '5.05 / 0.014' at row 1 show warnings; Level Code Message +Note 1265 Data truncated for column '5.05 / 0.014' at row 1 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -1648,6 +1651,8 @@ my_col 0.12345678912345678912345678912345678912 DROP TABLE t1; CREATE TABLE t1 SELECT 1 / .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +Warnings: +Note 1265 Data truncated for column 'my_col' at row 1 DESCRIBE t1; Field Type Null Key Default Extra my_col decimal(65,4) YES NULL diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index 7a01ba2d074..fe7392c758f 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -91,6 +91,8 @@ DROP INDEX test ON t1; insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one'); insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one'); insert ignore into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3); +Warnings: +Warning 1265 Data truncated for column 'string' at row 1 insert ignore into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1); Warnings: Warning 1264 Out of range value for column 'utiny' at row 1 @@ -128,7 +130,7 @@ select auto,string,tiny,short,medium,long_int,longlong,real_float,real_double,ut auto string tiny short medium long_int longlong real_float real_double utiny ushort umedium ulong ulonglong mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000) date_field time_field date_time blob_col tinyblob_col mediumblob_col longblob_col 10 1 1 1 1 1 1 1.0 1.0000 1 00001 1 1 1 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 1 1 1 11 2 2 2 2 2 2 2.0 2.0000 2 00002 2 2 2 0 NULL NULL NULL NULL NULL 2 2 -12 0.3333 3 3 3 3 3 3.0 3.0000 3 00003 3 3 3 0 1997-03-03 10:10:10 1997-03-03 10:10:10 3 +12 0.33333333 3 3 3 3 3 3.0 3.0000 3 00003 3 3 3 0 1997-03-03 10:10:10 1997-03-03 10:10:10 3 13 -1 -1 -1 -1 -1 -1 -1.0 -1.0000 0 00000 0 0 0 0 1997-08-07 08:07:06 1997-04-03 09:08:07 -1 -1 -1 -1 14 -429496729 -128 -32768 -8388608 -2147483648 -4294967295 -4294967296.0 -4294967295.0000 0 00000 0 0 0 0 0000-00-00 00:00:00 0000-00-00 00:00:00 -4294967295 -4294967295 -4294967295 -4294967295 15 4294967295 127 32767 8388607 2147483647 4294967295 4294967296.0 4294967295.0000 255 65535 16777215 4294967295 4294967295 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4294967295 4294967295 4294967295 4294967295 @@ -180,7 +182,7 @@ Warning 1265 Data truncated for column 'new_field' at row 7 select * from t2; auto string mediumblob_col new_field 1 2 2 ne -2 0.3333 ne +2 0.33333333 ne 3 -1 -1 ne 4 -429496729 -4294967295 ne 5 4294967295 4294967295 ne diff --git a/mysql-test/suite/sys_vars/r/div_precision_increment_func.result b/mysql-test/suite/sys_vars/r/div_precision_increment_func.result index e16ce76fed9..c839dd6b289 100644 --- a/mysql-test/suite/sys_vars/r/div_precision_increment_func.result +++ b/mysql-test/suite/sys_vars/r/div_precision_increment_func.result @@ -51,9 +51,9 @@ INSERT into t1(name, salary, income_tax) values('Record_2', 501, 501*2.5/1000); INSERT into t1(name, salary, income_tax) values('Record_3', 210, 210*2.5/1000); SELECT * from t1; id name salary income_tax -1 Record_1 100011 250.03 -2 Record_2 501 1.25 -3 Record_3 210 0.53 +1 Record_1 100011 250.027 +2 Record_2 501 1.2525 +3 Record_3 210 0.525 connect test_con2, localhost, root,,; connection test_con2; ## Verifying session & global value of variable ## @@ -69,11 +69,11 @@ INSERT into t1(name, salary, income_tax) values('Record_5', 501, 501*2.5/1000); INSERT into t1(name, salary, income_tax) values('Record_6', 210, 210*2.5/1000); SELECT * from t1; id name salary income_tax -1 Record_1 100011 250.03 -2 Record_2 501 1.25 -3 Record_3 210 0.53 -4 Record_4 100011 250.028 -5 Record_5 501 1.253 +1 Record_1 100011 250.027 +2 Record_2 501 1.2525 +3 Record_3 210 0.525 +4 Record_4 100011 250.027 +5 Record_5 501 1.2525 6 Record_6 210 0.525 ## Dropping table t1 ## drop table t1; diff --git a/mysql-test/suite/vcol/r/not_supported.result b/mysql-test/suite/vcol/r/not_supported.result index c524234e7e5..c804cf220d2 100644 --- a/mysql-test/suite/vcol/r/not_supported.result +++ b/mysql-test/suite/vcol/r/not_supported.result @@ -29,7 +29,7 @@ set time_zone='+1:00'; flush tables; select * from t1; a b v -1 2 0.3333000000000000000 +1 2 0.3333333330000000000 select * from t8; a b v 1234567890 2 2009-02-14 00:31:30 diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index d3a59e5b4f0..2a0972216f8 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -891,6 +891,8 @@ int Arg_comparator::compare_decimal() { if (set_null) owner->null_value= 0; + my_decimal_round_if_needed(E_DEC_FATAL_ERROR, val1, (*a)->decimals, 0); + my_decimal_round_if_needed(E_DEC_FATAL_ERROR, val2, (*b)->decimals, 0); return my_decimal_cmp(val1, val2); } } @@ -915,7 +917,9 @@ int Arg_comparator::compare_e_decimal() my_decimal *val2= (*b)->val_decimal(&decimal2); if ((*a)->null_value || (*b)->null_value) return MY_TEST((*a)->null_value && (*b)->null_value); - return MY_TEST(my_decimal_cmp(val1, val2) == 0); + my_decimal_round_if_needed(E_DEC_FATAL_ERROR, val1, (*a)->decimals, 0); + my_decimal_round_if_needed(E_DEC_FATAL_ERROR, val2, (*b)->decimals, 0); + return my_decimal_cmp(val1, val2) == 0; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 9d3ff804406..4d03e209eab 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1700,8 +1700,6 @@ my_decimal *Item_func_div::decimal_op(my_decimal *decimal_value) null_value= 1; return 0; } - my_decimal_round(E_DEC_FATAL_ERROR, decimal_value, - decimals, FALSE, decimal_value); return decimal_value; } diff --git a/sql/my_decimal.h b/sql/my_decimal.h index f318bcd1cd3..6a73cd54d50 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -304,6 +304,17 @@ bool my_decimal_is_zero(const my_decimal *decimal_value) inline +int my_decimal_round_if_needed(uint mask, my_decimal *dec, int scale, + bool truncate) +{ + if (scale >= dec->frac) + return E_DEC_OK; + return check_result(mask, decimal_round(dec, dec, scale, + (truncate ? TRUNCATE : HALF_UP))); +} + + +inline int my_decimal_round(uint mask, const my_decimal *from, int scale, bool truncate, my_decimal *to) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ad0b1d9c000..d3e124e3405 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2687,6 +2687,67 @@ static MYSQL_SOCKET activate_tcp_port(uint port) DBUG_RETURN(ip_sock); } +#ifdef _WIN32 +/* + Create a security descriptor for pipe. + - Use low integrity level, so that it is possible to connect + from any process. + - Give current user read/write access to pipe. + - Give Everyone read/write access to pipe minus FILE_CREATE_PIPE_INSTANCE +*/ +static void init_pipe_security_descriptor() +{ +#define SDDL_FMT "S:(ML;; NW;;; LW) D:(A;; 0x%08x;;; WD)(A;; FRFW;;; %s)" +#define EVERYONE_PIPE_ACCESS_MASK \ + (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES | READ_CONTROL | \ + SYNCHRONIZE | FILE_WRITE_DATA | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) + +#ifndef SECURITY_MAX_SID_STRING_CHARACTERS +/* Old SDK does not have this constant */ +#define SECURITY_MAX_SID_STRING_CHARACTERS 187 +#endif + + /* + Figure out SID of the user that runs the server, then create SDDL string + for pipe permissions, and convert it to the security descriptor. + */ + char sddl_string[sizeof(SDDL_FMT) + 8 + SECURITY_MAX_SID_STRING_CHARACTERS]; + struct + { + TOKEN_USER token_user; + BYTE buffer[SECURITY_MAX_SID_SIZE]; + } token_buffer; + HANDLE token; + DWORD tmp; + + if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) + goto fail; + + if (!GetTokenInformation(token, TokenUser, &token_buffer, + (DWORD) sizeof(token_buffer), &tmp)) + goto fail; + + CloseHandle(token); + + char *current_user_string_sid; + if (!ConvertSidToStringSid(token_buffer.token_user.User.Sid, + ¤t_user_string_sid)) + goto fail; + + snprintf(sddl_string, sizeof(sddl_string), SDDL_FMT, + EVERYONE_PIPE_ACCESS_MASK, current_user_string_sid); + LocalFree(current_user_string_sid); + + if (ConvertStringSecurityDescriptorToSecurityDescriptor(sddl_string, + SDDL_REVISION_1, &saPipeSecurity.lpSecurityDescriptor, 0)) + return; + +fail: + sql_perror("Can't start server : Initialize security descriptor"); + unireg_abort(1); +} +#endif + static void network_init(void) { #ifdef HAVE_SYS_UN_H @@ -2724,19 +2785,7 @@ static void network_init(void) strxnmov(pipe_name, sizeof(pipe_name)-1, "\\\\.\\pipe\\", mysqld_unix_port, NullS); - /* - Create a security descriptor for pipe. - - Use low integrity level, so that it is possible to connect - from any process. - - Give Everyone read/write access to pipe. - */ - if (!ConvertStringSecurityDescriptorToSecurityDescriptor( - "S:(ML;; NW;;; LW) D:(A;; FRFW;;; WD)", - SDDL_REVISION_1, &saPipeSecurity.lpSecurityDescriptor, NULL)) - { - sql_perror("Can't start server : Initialize security descriptor"); - unireg_abort(1); - } + init_pipe_security_descriptor(); saPipeSecurity.nLength = sizeof(SECURITY_ATTRIBUTES); saPipeSecurity.bInheritHandle = FALSE; if ((hPipe= CreateNamedPipe(pipe_name, diff --git a/storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result b/storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result index 17229fa5956..ad920deeda4 100644 --- a/storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result +++ b/storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result @@ -1533,8 +1533,11 @@ select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 * 1.01500000 * 1.01500000 * 0.99500000) 0.81298807395367312459230693948000000000 create table t1 as select 5.05 / 0.014; +Warnings: +Note 1265 Data truncated for column '5.05 / 0.014' at row 1 show warnings; Level Code Message +Note 1265 Data truncated for column '5.05 / 0.014' at row 1 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -1649,6 +1652,8 @@ my_col 0.12345678912345678912345678912345678912 DROP TABLE t1; CREATE TABLE t1 SELECT 1 / .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +Warnings: +Note 1265 Data truncated for column 'my_col' at row 1 DESCRIBE t1; Field Type Null Key Default Extra my_col decimal(65,4) YES NULL diff --git a/storage/tokudb/mysql-test/tokudb/r/type_ranges.result b/storage/tokudb/mysql-test/tokudb/r/type_ranges.result index 0b1054263ac..1c9cd769a14 100644 --- a/storage/tokudb/mysql-test/tokudb/r/type_ranges.result +++ b/storage/tokudb/mysql-test/tokudb/r/type_ranges.result @@ -92,6 +92,8 @@ DROP INDEX test ON t1; insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one'); insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one'); insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3); +Warnings: +Warning 1265 Data truncated for column 'string' at row 1 insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1); Warnings: Warning 1264 Out of range value for column 'utiny' at row 1 @@ -129,7 +131,7 @@ select auto,string,tiny,short,medium,long_int,longlong,real_float,real_double,ut auto string tiny short medium long_int longlong real_float real_double utiny ushort umedium ulong ulonglong mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000) date_field time_field date_time blob_col tinyblob_col mediumblob_col longblob_col 10 1 1 1 1 1 1 1.0 1.0000 1 00001 1 1 1 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 1 1 1 11 2 2 2 2 2 2 2.0 2.0000 2 00002 2 2 2 0 NULL NULL NULL NULL NULL 2 2 -12 0.3333 3 3 3 3 3 3.0 3.0000 3 00003 3 3 3 0 1997-03-03 10:10:10 1997-03-03 10:10:10 3 +12 0.33333333 3 3 3 3 3 3.0 3.0000 3 00003 3 3 3 0 1997-03-03 10:10:10 1997-03-03 10:10:10 3 13 -1 -1 -1 -1 -1 -1 -1.0 -1.0000 0 00000 0 0 0 0 1997-08-07 08:07:06 1997-04-03 09:08:07 -1 -1 -1 -1 14 -429496729 -128 -32768 -8388608 -2147483648 -4294967295 -4294967296.0 -4294967295.0000 0 00000 0 0 0 0 0000-00-00 00:00:00 0000-00-00 00:00:00 -4294967295 -4294967295 -4294967295 -4294967295 15 4294967295 127 32767 8388607 2147483647 4294967295 4294967296.0 4294967295.0000 255 65535 16777215 4294967295 4294967295 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4294967295 4294967295 4294967295 4294967295 @@ -181,7 +183,7 @@ Warning 1265 Data truncated for column 'new_field' at row 7 select * from t2; auto string mediumblob_col new_field 1 2 2 ne -2 0.3333 ne +2 0.33333333 ne 3 -1 -1 ne 4 -429496729 -4294967295 ne 5 4294967295 4294967295 ne |