diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index c421aab451e..d03f657d487 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB Originally Created 3/3/2009 Yasufumi Kinoshita Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko, Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz. -(c) 2017, 2018, MariaDB Corporation. +(c) 2017, 2019, MariaDB Corporation. Portions written by Marko Mäkelä. This program is free software; you can redistribute it and/or modify @@ -5419,8 +5419,7 @@ static ibool prepare_handle_del_files(const char *datadir, const char *db, const /** Implement --prepare @return whether the operation succeeded */ -static bool -xtrabackup_prepare_func(char** argv) +static bool xtrabackup_prepare_func(char** argv) { char metadata_path[FN_REFLEN]; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 4122d51fa70..b45b3f58278 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -197,8 +197,6 @@ my @DEFAULT_SUITES= qw( sys_vars- unit- vcol- - wsrep- - galera- ); my $opt_suites; diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index ff2e929cffc..255a218ea52 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -826,6 +826,49 @@ SELECT STDDEV_POP(ROUND(0,@A:=2009)) FROM (SELECT 1 UNION SELECT 2) fake_table; STDDEV_POP(ROUND(0,@A:=2009)) 0.0000 # +# Start of 10.1 tests +# +# +# MDEV-17643 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() +# +CREATE TABLE t1 ( pk int NOT NULL, i1 int NOT NULL, d1 date NOT NULL, t1 time); +INSERT INTO t1 VALUES (7,9,'2007-08-15','03:55:02'),(8,7,'1993-06-05','04:17:51'),(9,7,'2034-07-01','17:31:12'),(10,0,'1998-08-24','08:09:27'); +SELECT DISTINCT STDDEV_SAMP(EXPORT_SET(t1, -1379790335835635712, (i1 + 'o'), (MD5(d1)))) FROM t1; +STDDEV_SAMP(EXPORT_SET(t1, -1379790335835635712, (i1 + 'o'), (MD5(d1)))) +NULL +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'o' +Warning 1292 Truncated incorrect DOUBLE value: '98e466c7ff40fe6b95cde24200f376303-13797903358356357128e466c7ff40fe6b95cde24200f376303-13797903358356357128e466c7ff40fe6b95cde242' +Warning 1292 Truncated incorrect DOUBLE value: 'o' +Warning 1292 Truncated incorrect DOUBLE value: '-1379790335835635712e315457d879863c6ccf2ddee5562fc24-1379790335835635712e315457d879863c6ccf2ddee5562fc24-1379790335835635712e315' +Warning 1292 Truncated incorrect DOUBLE value: 'o' +Warning 1292 Truncated incorrect DOUBLE value: '7b4dd517b633f1f6304b773523b5279747b4dd517b633f1f6304b773523b5279747b4dd517b633f1f6304b773523b527974-1379790335835635712b4dd517b6' +Warning 1292 Truncated incorrect DOUBLE value: 'o' +Warning 1292 Truncated incorrect DOUBLE value: '-1379790335835635712b0e107767ea830fd3318893e40412a43-1379790335835635712b0e107767ea830fd3318893e40412a43-1379790335835635712b0e1' +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(128)); +INSERT INTO t1 VALUES ('1e310'); +INSERT INTO t1 VALUES ('-1e310'); +INSERT INTO t1 VALUES ('0'); +SELECT STDDEV_SAMP(a) FROM t1; +STDDEV_SAMP(a) +NULL +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1e310' +Warning 1292 Truncated incorrect DOUBLE value: '-1e310' +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 (a DOUBLE); +INSERT INTO t1 VALUES (1.7e+308); +INSERT INTO t1 VALUES (-1.7e+308); +INSERT INTO t1 VALUES (0); +SELECT STDDEV_SAMP(a) FROM t1; +STDDEV_SAMP(a) +NULL +DROP TABLE t1; +# +# End of 10.1 tests +# +# # Start of 10.2 tests # # Test zero diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 5334cc055d1..9295b2099ef 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -2987,6 +2987,77 @@ select md5(_filename "a"), sha(_filename "a"); md5(_filename "a") sha(_filename "a") 0cc175b9c0f1b6a831c399e269772661 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 # +# MDEV-18881 Assertion `0' failed in make_sortkey upon SELECT with GROUP BY after LOAD DATA +# +CREATE TABLE t1 (a BIT(22), b CHAR(8) NOT NULL, c CHAR(8)); +INSERT INTO t1 VALUES (0xA4B,'foo','qux'); +INSERT INTO t1 VALUES (0x8F5,'bar','foobar'); +INSERT INTO t1 VALUES (0x0, '', NULL); +INSERT INTO t1 VALUES (0x4B, 'foo','qux'); +INSERT INTO t1 VALUES (0x8F5, 'bar', 'foobar'); +SET SESSION SQL_MODE= ''; +SELECT GROUP_CONCAT(c) AS f FROM t1 GROUP BY LPAD('foo', 20, b); +f +NULL +foobar,foobar +qux,qux +DROP TABLE t1; +SET SESSION SQL_MODE=DEFAULT; +CREATE TABLE t1 AS SELECT +LPAD('a',10,' '), +RPAD('a',10,' '), +LPAD('a',10,' '), +RPAD('a',10,' '), +LPAD('a',10,NULL), +RPAD('a',10,NULL), +LPAD('a',10,''), +RPAD('a',10,''), +LPAD('a',10,RAND()), +RPAD('a',10,RAND()); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `LPAD('a',10,' ')` varchar(10) DEFAULT NULL, + `RPAD('a',10,' ')` varchar(10) DEFAULT NULL, + `LPAD('a',10,' ')` varchar(10) DEFAULT NULL, + `RPAD('a',10,' ')` varchar(10) DEFAULT NULL, + `LPAD('a',10,NULL)` varchar(10) DEFAULT NULL, + `RPAD('a',10,NULL)` varchar(10) DEFAULT NULL, + `LPAD('a',10,'')` varchar(10) DEFAULT NULL, + `RPAD('a',10,'')` varchar(10) DEFAULT NULL, + `LPAD('a',10,RAND())` varchar(10) DEFAULT NULL, + `RPAD('a',10,RAND())` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +SET SESSION SQL_MODE= ''; +CREATE TABLE t1 AS SELECT +LPAD('a',10,' '), +RPAD('a',10,' '), +LPAD('a',10,' '), +RPAD('a',10,' '), +LPAD('a',10,NULL), +RPAD('a',10,NULL), +LPAD('a',10,''), +RPAD('a',10,''), +LPAD('a',10,RAND()), +RPAD('a',10,RAND()); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `LPAD('a',10,' ')` varchar(10) NOT NULL, + `RPAD('a',10,' ')` varchar(10) NOT NULL, + `LPAD('a',10,' ')` varchar(10) NOT NULL, + `RPAD('a',10,' ')` varchar(10) NOT NULL, + `LPAD('a',10,NULL)` varchar(10) DEFAULT NULL, + `RPAD('a',10,NULL)` varchar(10) DEFAULT NULL, + `LPAD('a',10,'')` varchar(10) DEFAULT NULL, + `RPAD('a',10,'')` varchar(10) DEFAULT NULL, + `LPAD('a',10,RAND())` varchar(10) DEFAULT NULL, + `RPAD('a',10,RAND())` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +SET SESSION SQL_MODE=DEFAULT; +# # End of 5.5 tests # # diff --git a/mysql-test/r/log_slow_debug.result b/mysql-test/r/log_slow_debug.result index a823f4c2b98..bf803ad0530 100644 --- a/mysql-test/r/log_slow_debug.result +++ b/mysql-test/r/log_slow_debug.result @@ -14,6 +14,14 @@ FROM mysql.slow_log WHERE sql_text NOT LIKE '%debug_dbug%'; END $$ +CREATE PROCEDURE show_slow_log_exclude_ps() +BEGIN +SELECT CONCAT('[slow] ', sql_text) AS sql_text +FROM mysql.slow_log +WHERE sql_text NOT LIKE '%debug_dbug%' + AND sql_text NOT IN ('Prepare','Close stmt'); +END +$$ # # Expect all admin statements in the slow log (ON,DEFAULT) # @@ -33,7 +41,7 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log(); +CALL show_slow_log_exclude_ps(); sql_text [slow] TRUNCATE TABLE mysql.slow_log [slow] CREATE TABLE t1 (a INT) @@ -115,7 +123,7 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log(); +CALL show_slow_log_exclude_ps(); sql_text [slow] TRUNCATE TABLE mysql.slow_log [slow] CREATE TABLE t1 (a INT) @@ -135,3 +143,4 @@ SET @@global.slow_query_log= @org_slow_query_log; SET @@global.log_output= @org_log_output; SET @@global.log_slow_admin_statements= @org_log_slow_admin_statements; DROP PROCEDURE show_slow_log; +DROP PROCEDURE show_slow_log_exclude_ps; diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index 1d86b2acf72..ee4f20ea753 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -3190,5 +3190,12 @@ EXECUTE stmt; a drop view v3; drop table t1,t2,t3; +# +# MDEV-18896: IN subquery in WHERE of a table-less query used for INSERT +# +create table t1 (a1 varchar(25)); +create table t2 (a2 varchar(25)) ; +insert into t1 select 'xxx' from dual where 'xxx' in (select a2 from t2); +drop table t1,t2; # End of 5.5 test set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index 234ea6884bd..04d81c44eed 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -3204,6 +3204,13 @@ EXECUTE stmt; a drop view v3; drop table t1,t2,t3; +# +# MDEV-18896: IN subquery in WHERE of a table-less query used for INSERT +# +create table t1 (a1 varchar(25)); +create table t2 (a2 varchar(25)) ; +insert into t1 select 'xxx' from dual where 'xxx' in (select a2 from t2); +drop table t1,t2; # End of 5.5 test set optimizer_switch=@subselect_sj_tmp; # diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 0b819278a44..4332f21443f 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -596,6 +596,37 @@ DROP TABLE t1; --echo # SELECT STDDEV_POP(ROUND(0,@A:=2009)) FROM (SELECT 1 UNION SELECT 2) fake_table; +--echo # +--echo # Start of 10.1 tests +--echo # + +--echo # +--echo # MDEV-17643 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() +--echo # + +CREATE TABLE t1 ( pk int NOT NULL, i1 int NOT NULL, d1 date NOT NULL, t1 time); +INSERT INTO t1 VALUES (7,9,'2007-08-15','03:55:02'),(8,7,'1993-06-05','04:17:51'),(9,7,'2034-07-01','17:31:12'),(10,0,'1998-08-24','08:09:27'); +SELECT DISTINCT STDDEV_SAMP(EXPORT_SET(t1, -1379790335835635712, (i1 + 'o'), (MD5(d1)))) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(128)); +INSERT INTO t1 VALUES ('1e310'); +INSERT INTO t1 VALUES ('-1e310'); +INSERT INTO t1 VALUES ('0'); +SELECT STDDEV_SAMP(a) FROM t1; +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 (a DOUBLE); +INSERT INTO t1 VALUES (1.7e+308); +INSERT INTO t1 VALUES (-1.7e+308); +INSERT INTO t1 VALUES (0); +SELECT STDDEV_SAMP(a) FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.1 tests +--echo # + --echo # --echo # Start of 10.2 tests --echo # diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 881f21f3b64..6a69c71ff0b 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1610,6 +1610,51 @@ drop table t1,t2; # select md5(_filename "a"), sha(_filename "a"); +--echo # +--echo # MDEV-18881 Assertion `0' failed in make_sortkey upon SELECT with GROUP BY after LOAD DATA +--echo # + +CREATE TABLE t1 (a BIT(22), b CHAR(8) NOT NULL, c CHAR(8)); +INSERT INTO t1 VALUES (0xA4B,'foo','qux'); +INSERT INTO t1 VALUES (0x8F5,'bar','foobar'); +INSERT INTO t1 VALUES (0x0, '', NULL); +INSERT INTO t1 VALUES (0x4B, 'foo','qux'); +INSERT INTO t1 VALUES (0x8F5, 'bar', 'foobar'); +SET SESSION SQL_MODE= ''; +SELECT GROUP_CONCAT(c) AS f FROM t1 GROUP BY LPAD('foo', 20, b); +DROP TABLE t1; +SET SESSION SQL_MODE=DEFAULT; + +CREATE TABLE t1 AS SELECT + LPAD('a',10,' '), + RPAD('a',10,' '), + LPAD('a',10,' '), + RPAD('a',10,' '), + LPAD('a',10,NULL), + RPAD('a',10,NULL), + LPAD('a',10,''), + RPAD('a',10,''), + LPAD('a',10,RAND()), + RPAD('a',10,RAND()); +SHOW CREATE TABLE t1; +DROP TABLE t1; +SET SESSION SQL_MODE= ''; +CREATE TABLE t1 AS SELECT + LPAD('a',10,' '), + RPAD('a',10,' '), + LPAD('a',10,' '), + RPAD('a',10,' '), + LPAD('a',10,NULL), + RPAD('a',10,NULL), + LPAD('a',10,''), + RPAD('a',10,''), + LPAD('a',10,RAND()), + RPAD('a',10,RAND()); +SHOW CREATE TABLE t1; +DROP TABLE t1; +SET SESSION SQL_MODE=DEFAULT; + + --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/log_slow_debug.test b/mysql-test/t/log_slow_debug.test index 35b5b93423d..7945328fee3 100644 --- a/mysql-test/t/log_slow_debug.test +++ b/mysql-test/t/log_slow_debug.test @@ -19,6 +19,14 @@ BEGIN WHERE sql_text NOT LIKE '%debug_dbug%'; END $$ +CREATE PROCEDURE show_slow_log_exclude_ps() +BEGIN + SELECT CONCAT('[slow] ', sql_text) AS sql_text + FROM mysql.slow_log + WHERE sql_text NOT LIKE '%debug_dbug%' + AND sql_text NOT IN ('Prepare','Close stmt'); +END +$$ DELIMITER ;$$ @@ -42,7 +50,7 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log(); +CALL show_slow_log_exclude_ps(); --echo # @@ -111,7 +119,7 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log(); +CALL show_slow_log_exclude_ps(); --echo # @@ -124,3 +132,4 @@ SET @@global.slow_query_log= @org_slow_query_log; SET @@global.log_output= @org_log_output; SET @@global.log_slow_admin_statements= @org_log_slow_admin_statements; DROP PROCEDURE show_slow_log; +DROP PROCEDURE show_slow_log_exclude_ps; diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test index 623e414310a..1a1b8757864 100644 --- a/mysql-test/t/subselect_sj.test +++ b/mysql-test/t/subselect_sj.test @@ -2873,6 +2873,16 @@ EXECUTE stmt; drop view v3; drop table t1,t2,t3; +--echo # +--echo # MDEV-18896: IN subquery in WHERE of a table-less query used for INSERT +--echo # + +create table t1 (a1 varchar(25)); +create table t2 (a2 varchar(25)) ; +insert into t1 select 'xxx' from dual where 'xxx' in (select a2 from t2); + +drop table t1,t2; + --echo # End of 5.5 test # The following command must be the last one the file diff --git a/plugin/auth_pam/auth_pam.c b/plugin/auth_pam/auth_pam.c index ffc3d6f5537..a6a981f9641 100644 --- a/plugin/auth_pam/auth_pam.c +++ b/plugin/auth_pam/auth_pam.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2011, 2012, Monty Program Ab + Copyright (c) 2011, 2019, MariaDB Corporation. 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 @@ -161,7 +161,7 @@ static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) if (new_username && strcmp(new_username, info->user_name)) strncpy(info->authenticated_as, new_username, - sizeof(info->authenticated_as)); + sizeof(info->authenticated_as)-1); info->authenticated_as[sizeof(info->authenticated_as)-1]= 0; end: diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 612e9e91515..0995327a86d 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -1053,7 +1053,7 @@ static int start_logging() } error_header(); fprintf(stderr, "logging started to the file %s.\n", alt_fname); - strncpy(current_log_buf, alt_fname, sizeof(current_log_buf)); + strncpy(current_log_buf, alt_fname, sizeof(current_log_buf)-1); current_log_buf[sizeof(current_log_buf)-1]= 0; } else if (output_type == OUTPUT_SYSLOG) @@ -1061,7 +1061,8 @@ static int start_logging() openlog(syslog_ident, LOG_NOWAIT, syslog_facility_codes[syslog_facility]); error_header(); fprintf(stderr, "logging started to the syslog.\n"); - strncpy(current_log_buf, "[SYSLOG]", sizeof(current_log_buf)); + strncpy(current_log_buf, "[SYSLOG]", sizeof(current_log_buf)-1); + compile_time_assert(sizeof current_log_buf > sizeof "[SYSLOG]"); } is_active= 1; return 0; @@ -2597,7 +2598,7 @@ static void update_file_path(MYSQL_THD thd, internal_stop_logging= 0; } - strncpy(path_buffer, new_name, sizeof(path_buffer)); + strncpy(path_buffer, new_name, sizeof(path_buffer)-1); path_buffer[sizeof(path_buffer)-1]= 0; file_path= path_buffer; exit_func: @@ -2650,7 +2651,7 @@ static void update_incl_users(MYSQL_THD thd, if (!maria_55_started || !debug_server_started) flogger_mutex_lock(&lock_operations); mark_always_logged(thd); - strncpy(incl_user_buffer, new_users, sizeof(incl_user_buffer)); + strncpy(incl_user_buffer, new_users, sizeof(incl_user_buffer)-1); incl_user_buffer[sizeof(incl_user_buffer)-1]= 0; incl_users= incl_user_buffer; user_coll_fill(&incl_user_coll, incl_users, &excl_user_coll, 1); @@ -2669,7 +2670,7 @@ static void update_excl_users(MYSQL_THD thd __attribute__((unused)), if (!maria_55_started || !debug_server_started) flogger_mutex_lock(&lock_operations); mark_always_logged(thd); - strncpy(excl_user_buffer, new_users, sizeof(excl_user_buffer)); + strncpy(excl_user_buffer, new_users, sizeof(excl_user_buffer)-1); excl_user_buffer[sizeof(excl_user_buffer)-1]= 0; excl_users= excl_user_buffer; user_coll_fill(&excl_user_coll, excl_users, &incl_user_coll, 0); @@ -2801,7 +2802,7 @@ static void update_syslog_ident(MYSQL_THD thd __attribute__((unused)), void *var_ptr __attribute__((unused)), const void *save) { char *new_ident= (*(char **) save) ? *(char **) save : empty_str; - strncpy(syslog_ident_buffer, new_ident, sizeof(syslog_ident_buffer)); + strncpy(syslog_ident_buffer, new_ident, sizeof(syslog_ident_buffer)-1); syslog_ident_buffer[sizeof(syslog_ident_buffer)-1]= 0; syslog_ident= syslog_ident_buffer; error_header(); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 76f3a98cd2d..b88f376e8dd 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2018, MariaDB Corporation + Copyright (c) 2009, 2019, MariaDB Corporation 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 @@ -3086,8 +3086,12 @@ err: } -bool Item_func_rpad::fix_length_and_dec() +bool Item_func_pad::fix_length_and_dec() { + String *str; + if (!args[2]->basic_const_item() || !(str= args[2]->val_str(&pad_str)) || !str->length()) + maybe_null= true; + // Handle character set for args[0] and args[2]. if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2)) return TRUE; @@ -3122,7 +3126,7 @@ String *Item_func_rpad::val_str(String *str) longlong count= args[1]->val_int(); longlong byte_count; String *res= args[0]->val_str(str); - String *rpad= args[2]->val_str(&rpad_str); + String *rpad= args[2]->val_str(&pad_str); if (!res || args[1]->null_value || !rpad || ((count < 0) && !args[1]->unsigned_flag)) @@ -3195,33 +3199,6 @@ String *Item_func_rpad::val_str(String *str) } -bool Item_func_lpad::fix_length_and_dec() -{ - // Handle character set for args[0] and args[2]. - if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2)) - return TRUE; - - if (args[1]->const_item()) - { - ulonglong char_length= (ulonglong) args[1]->val_int(); - DBUG_ASSERT(collation.collation->mbmaxlen > 0); - /* Assumes that the maximum length of a String is < INT_MAX32. */ - /* Set here so that rest of code sees out-of-bound value as such. */ - if (args[1]->null_value) - char_length= 0; - else if (char_length > INT_MAX32) - char_length= INT_MAX32; - fix_char_length_ulonglong(char_length); - } - else - { - max_length= MAX_BLOB_WIDTH; - maybe_null= 1; - } - return FALSE; -} - - String *Item_func_lpad::val_str(String *str) { DBUG_ASSERT(fixed == 1); @@ -3230,7 +3207,7 @@ String *Item_func_lpad::val_str(String *str) longlong count= args[1]->val_int(); longlong byte_count; String *res= args[0]->val_str(&tmp_value); - String *pad= args[2]->val_str(&lpad_str); + String *pad= args[2]->val_str(&pad_str); if (!res || args[1]->null_value || !pad || ((count < 0) && !args[1]->unsigned_flag)) diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index b3baae99c15..9a78a7f34f5 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -3,7 +3,7 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2009, 2015, MariaDB + Copyright (c) 2009, 2019, MariaDB 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 @@ -932,28 +932,35 @@ public: }; -class Item_func_rpad :public Item_str_func +class Item_func_pad: public Item_str_func +{ +protected: + String tmp_value, pad_str; +public: + Item_func_pad(THD *thd, Item *arg1, Item *arg2, Item *arg3): + Item_str_func(thd, arg1, arg2, arg3) {} + bool fix_length_and_dec(); +}; + + +class Item_func_rpad :public Item_func_pad { - String tmp_value, rpad_str; public: Item_func_rpad(THD *thd, Item *arg1, Item *arg2, Item *arg3): - Item_str_func(thd, arg1, arg2, arg3) {} + Item_func_pad(thd, arg1, arg2, arg3) {} String *val_str(String *); - bool fix_length_and_dec(); const char *func_name() const { return "rpad"; } Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return get_item_copy(thd, mem_root, this); } }; -class Item_func_lpad :public Item_str_func +class Item_func_lpad :public Item_func_pad { - String tmp_value, lpad_str; public: Item_func_lpad(THD *thd, Item *arg1, Item *arg2, Item *arg3): - Item_str_func(thd, arg1, arg2, arg3) {} + Item_func_pad(thd, arg1, arg2, arg3) {} String *val_str(String *); - bool fix_length_and_dec(); const char *func_name() const { return "lpad"; } Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return get_item_copy(thd, mem_root, this); } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 9e59ec4e373..4405477b6a1 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1808,6 +1808,18 @@ double Item_sum_std::val_real() { DBUG_ASSERT(fixed == 1); double nr= Item_sum_variance::val_real(); + if (isnan(nr)) + { + /* + variance_fp_recurrence_next() can overflow in some cases and return "nan": + + CREATE OR REPLACE TABLE t1 (a DOUBLE); + INSERT INTO t1 VALUES (1.7e+308), (-1.7e+308), (0); + SELECT STDDEV_SAMP(a) FROM t1; + */ + null_value= true; // Convert "nan" to NULL + return 0; + } if (my_isinf(nr)) return DBL_MAX; DBUG_ASSERT(nr >= 0.0); @@ -1855,8 +1867,9 @@ static void variance_fp_recurrence_next(double *m, double *s, ulonglong *count, else { double m_kminusone= *m; - *m= m_kminusone + (nr - m_kminusone) / (double) *count; - *s= *s + (nr - m_kminusone) * (nr - *m); + volatile double diff= nr - m_kminusone; + *m= m_kminusone + diff / (double) *count; + *s= *s + diff * (nr - *m); } } diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index d0be72b8d51..e7bd7e88af3 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -677,7 +677,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join) select_lex->outer_select()->join && // 6 parent_unit->first_select()->leaf_tables.elements && // 7 !in_subs->has_strategy() && // 8 - select_lex->outer_select()->leaf_tables.elements && // 9 + select_lex->outer_select()->table_list.first && // 9 !((join->select_options | // 10 select_lex->outer_select()->join->select_options) // 10 & SELECT_STRAIGHT_JOIN) && // 10 diff --git a/sql/wsrep_binlog.cc b/sql/wsrep_binlog.cc index 672e1d77f47..292cbe6ee25 100644 --- a/sql/wsrep_binlog.cc +++ b/sql/wsrep_binlog.cc @@ -505,7 +505,6 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf, if (init_io_cache(&cache, file, 0, WRITE_CACHE, 0, 0, MYF(MY_WME | MY_NABP))) { - mysql_file_close(file, MYF(MY_WME)); goto cleanup2; } diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index c9988997801..7fc8ab79395 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -448,7 +448,8 @@ dict_mem_table_col_rename_low( ut_ad(to_len <= NAME_LEN); char from[NAME_LEN + 1]; - strncpy(from, s, NAME_LEN + 1); + strncpy(from, s, sizeof from - 1); + from[sizeof from - 1] = '\0'; if (from_len == to_len) { /* The easy case: simply replace the column name in diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc index 4ef3d5df750..4ce0981d972 100644 --- a/storage/xtradb/dict/dict0mem.cc +++ b/storage/xtradb/dict/dict0mem.cc @@ -2,7 +2,7 @@ Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2018, MariaDB Corporation. +Copyright (c) 2013, 2019, MariaDB Corporation. 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 the Free Software @@ -321,7 +321,8 @@ dict_mem_table_col_rename_low( ut_ad(to_len <= NAME_LEN); char from[NAME_LEN + 1]; - strncpy(from, s, NAME_LEN + 1); + strncpy(from, s, sizeof from - 1); + from[sizeof from - 1] = '\0'; if (from_len == to_len) { /* The easy case: simply replace the column name in