diff options
32 files changed, 356 insertions, 61 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 347a2e4f736..6e3c8d1eab3 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5180,11 +5180,17 @@ static st_error global_error_names[] = { 0, 0, 0 } }; -uint get_errcode_from_name(char *error_name, char *error_end) +#include <my_base.h> +static st_error handler_error_names[] = { - /* SQL error as string */ - st_error *e= global_error_names; + { "<No error>", -1U, "" }, +#include <handler_ername.h> + { 0, 0, 0 } +}; +uint get_errcode_from_name(const char *error_name, const char *error_end, + st_error *e) +{ DBUG_ENTER("get_errcode_from_name"); DBUG_PRINT("enter", ("error_name: %s", error_name)); @@ -5202,15 +5208,26 @@ uint get_errcode_from_name(char *error_name, char *error_end) DBUG_RETURN(e->code); } } - if (!e->name) - die("Unknown SQL error name '%s'", error_name); DBUG_RETURN(0); } -const char *get_errname_from_code (uint error_code) + +uint get_errcode_from_name(const char *error_name, const char *error_end) { - st_error *e= global_error_names; + uint tmp; + if ((tmp= get_errcode_from_name(error_name, error_end, + global_error_names))) + return tmp; + if ((tmp= get_errcode_from_name(error_name, error_end, + handler_error_names))) + return tmp; + die("Unknown SQL error name '%s'", error_name); +} + +const char *unknown_error= "<Unknown>"; +const char *get_errname_from_code (uint error_code, st_error *e) +{ DBUG_ENTER("get_errname_from_code"); DBUG_PRINT("enter", ("error_code: %d", error_code)); @@ -5226,9 +5243,18 @@ const char *get_errname_from_code (uint error_code) } } /* Apparently, errors without known names may occur */ - DBUG_RETURN("<Unknown>"); + DBUG_RETURN(unknown_error); } +const char *get_errname_from_code(uint error_code) +{ + const char *name; + if ((name= get_errname_from_code(error_code, global_error_names)) != + unknown_error) + return name; + return get_errname_from_code(error_code, handler_error_names); +} + void do_get_errcodes(struct st_command *command) { struct st_match_err *to= saved_expected_errors.err; @@ -5313,7 +5339,7 @@ void do_get_errcodes(struct st_command *command) { die("The sqlstate definition must start with an uppercase S"); } - else if (*p == 'E' || *p == 'W') + else if (*p == 'E' || *p == 'W' || *p == 'H') { /* Error name string */ @@ -5322,9 +5348,9 @@ void do_get_errcodes(struct st_command *command) to->type= ERR_ERRNO; DBUG_PRINT("info", ("ERR_ERRNO: %d", to->code.errnum)); } - else if (*p == 'e' || *p == 'w') + else if (*p == 'e' || *p == 'w' || *p == 'h') { - die("The error name definition must start with an uppercase E or W"); + die("The error name definition must start with an uppercase E or W or H"); } else { diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 95850da382b..33eaa28ae1e 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -52,6 +52,7 @@ SET(HEADERS my_attribute.h my_compiler.h handler_state.h + handler_ername.h ) INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development) diff --git a/include/handler_ername.h b/include/handler_ername.h new file mode 100644 index 00000000000..91780be553d --- /dev/null +++ b/include/handler_ername.h @@ -0,0 +1,80 @@ +/* Copyright (c) 2013 SkySQL Ab + + 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 Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + +/* Names of all handler error numbers. Used by mysqltest */ + +{ "HA_ERR_KEY_NOT_FOUND", HA_ERR_KEY_NOT_FOUND, "" }, +{ "HA_ERR_FOUND_DUPP_KEY", HA_ERR_FOUND_DUPP_KEY, "" }, +{ "HA_ERR_INTERNAL_ERROR", HA_ERR_INTERNAL_ERROR, "" }, +{ "HA_ERR_RECORD_CHANGED", HA_ERR_RECORD_CHANGED, "" }, +{ "HA_ERR_WRONG_INDEX", HA_ERR_WRONG_INDEX, "" }, +{ "HA_ERR_CRASHED", HA_ERR_CRASHED, "" }, +{ "HA_ERR_WRONG_IN_RECORD", HA_ERR_WRONG_IN_RECORD, "" }, +{ "HA_ERR_OUT_OF_MEM", HA_ERR_OUT_OF_MEM, "" }, +{ "HA_ERR_NOT_A_TABLE", HA_ERR_NOT_A_TABLE, "" }, +{ "HA_ERR_WRONG_COMMAND", HA_ERR_WRONG_COMMAND, "" }, +{ "HA_ERR_OLD_FILE", HA_ERR_OLD_FILE, "" }, +{ "HA_ERR_NO_ACTIVE_RECORD", HA_ERR_NO_ACTIVE_RECORD, "" }, +{ "HA_ERR_RECORD_DELETED", HA_ERR_RECORD_DELETED, "" }, +{ "HA_ERR_RECORD_FILE_FULL", HA_ERR_RECORD_FILE_FULL, "" }, +{ "HA_ERR_INDEX_FILE_FULL", HA_ERR_INDEX_FILE_FULL, "" }, +{ "HA_ERR_END_OF_FILE", HA_ERR_END_OF_FILE, "" }, +{ "HA_ERR_UNSUPPORTED", HA_ERR_UNSUPPORTED, "" }, +{ "HA_ERR_TO_BIG_ROW", HA_ERR_TO_BIG_ROW, "" }, +{ "HA_WRONG_CREATE_OPTION", HA_WRONG_CREATE_OPTION, "" }, +{ "HA_ERR_FOUND_DUPP_UNIQUE", HA_ERR_FOUND_DUPP_UNIQUE, "" }, +{ "HA_ERR_UNKNOWN_CHARSET", HA_ERR_UNKNOWN_CHARSET, "" }, +{ "HA_ERR_WRONG_MRG_TABLE_DEF", HA_ERR_WRONG_MRG_TABLE_DEF, "" }, +{ "HA_ERR_CRASHED_ON_REPAIR", HA_ERR_CRASHED_ON_REPAIR, "" }, +{ "HA_ERR_CRASHED_ON_USAGE", HA_ERR_CRASHED_ON_USAGE, "" }, +{ "HA_ERR_LOCK_WAIT_TIMEOUT", HA_ERR_LOCK_WAIT_TIMEOUT, "" }, +{ "HA_ERR_LOCK_TABLE_FULL", HA_ERR_LOCK_TABLE_FULL, "" }, +{ "HA_ERR_READ_ONLY_TRANSACTION", HA_ERR_READ_ONLY_TRANSACTION, "" }, +{ "HA_ERR_LOCK_DEADLOCK", HA_ERR_LOCK_DEADLOCK, "" }, +{ "HA_ERR_CANNOT_ADD_FOREIGN", HA_ERR_CANNOT_ADD_FOREIGN, "" }, +{ "HA_ERR_NO_REFERENCED_ROW", HA_ERR_NO_REFERENCED_ROW, "" }, +{ "HA_ERR_ROW_IS_REFERENCED", HA_ERR_ROW_IS_REFERENCED, "" }, +{ "HA_ERR_NO_SAVEPOINT", HA_ERR_NO_SAVEPOINT, "" }, +{ "HA_ERR_NON_UNIQUE_BLOCK_SIZE", HA_ERR_NON_UNIQUE_BLOCK_SIZE, "" }, +{ "HA_ERR_NO_SUCH_TABLE", HA_ERR_NO_SUCH_TABLE, "" }, +{ "HA_ERR_TABLE_EXIST", HA_ERR_TABLE_EXIST, "" }, +{ "HA_ERR_NO_CONNECTION", HA_ERR_NO_CONNECTION, "" }, +{ "HA_ERR_NULL_IN_SPATIAL", HA_ERR_NULL_IN_SPATIAL, "" }, +{ "HA_ERR_TABLE_DEF_CHANGED", HA_ERR_TABLE_DEF_CHANGED, "" }, +{ "HA_ERR_NO_PARTITION_FOUND", HA_ERR_NO_PARTITION_FOUND, "" }, +{ "HA_ERR_RBR_LOGGING_FAILED", HA_ERR_RBR_LOGGING_FAILED, "" }, +{ "HA_ERR_DROP_INDEX_FK", HA_ERR_DROP_INDEX_FK, "" }, +{ "HA_ERR_FOREIGN_DUPLICATE_KEY", HA_ERR_FOREIGN_DUPLICATE_KEY, "" }, +{ "HA_ERR_TABLE_NEEDS_UPGRADE", HA_ERR_TABLE_NEEDS_UPGRADE, "" }, +{ "HA_ERR_TABLE_READONLY", HA_ERR_TABLE_READONLY, "" }, +{ "HA_ERR_AUTOINC_READ_FAILED", HA_ERR_AUTOINC_READ_FAILED, "" }, +{ "HA_ERR_AUTOINC_ERANGE", HA_ERR_AUTOINC_ERANGE, "" }, +{ "HA_ERR_GENERIC", HA_ERR_GENERIC, "" }, +{ "HA_ERR_RECORD_IS_THE_SAME", HA_ERR_RECORD_IS_THE_SAME, "" }, +{ "HA_ERR_LOGGING_IMPOSSIBLE", HA_ERR_LOGGING_IMPOSSIBLE, "" }, +{ "HA_ERR_CORRUPT_EVENT", HA_ERR_CORRUPT_EVENT, "" }, +{ "HA_ERR_NEW_FILE", HA_ERR_NEW_FILE, "" }, +{ "HA_ERR_ROWS_EVENT_APPLY", HA_ERR_ROWS_EVENT_APPLY, "" }, +{ "HA_ERR_INITIALIZATION", HA_ERR_INITIALIZATION, "" }, +{ "HA_ERR_FILE_TOO_SHORT", HA_ERR_FILE_TOO_SHORT, "" }, +{ "HA_ERR_WRONG_CRC", HA_ERR_WRONG_CRC, "" }, +{ "HA_ERR_TOO_MANY_CONCURRENT_TRXS", HA_ERR_TOO_MANY_CONCURRENT_TRXS, "" }, +{ "HA_ERR_INDEX_COL_TOO_LONG", HA_ERR_INDEX_COL_TOO_LONG, "" }, +{ "HA_ERR_INDEX_CORRUPT", HA_ERR_INDEX_CORRUPT, "" }, +{ "HA_ERR_UNDO_REC_TOO_BIG", HA_ERR_UNDO_REC_TOO_BIG, "" }, +{ "HA_ERR_TABLE_IN_FK_CHECK", HA_ERR_TABLE_IN_FK_CHECK, "" }, +{ "HA_ERR_ROW_NOT_VISIBLE", HA_ERR_ROW_NOT_VISIBLE, "" }, +{ "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" }, +{ "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" }, diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test index a87f1f351cc..190aa9e04b9 100644 --- a/mysql-test/extra/binlog_tests/binlog.test +++ b/mysql-test/extra/binlog_tests/binlog.test @@ -216,7 +216,7 @@ reset master; create table t1 (id tinyint auto_increment primary key); insert into t1 values(5); set insert_id=128; ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(null) /* Not binlogged */; # The followin insert ignore will be put in binlog @@ -238,7 +238,7 @@ drop table t1; create table t1 (id tinyint auto_increment primary key) engine=myisam; set insert_id=128; ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(5),(null) /* Insert_id 128 */; # The followin insert ignore will be put in binlog diff --git a/mysql-test/include/ctype_str_to_date.inc b/mysql-test/include/ctype_str_to_date.inc new file mode 100644 index 00000000000..62adb05b094 --- /dev/null +++ b/mysql-test/include/ctype_str_to_date.inc @@ -0,0 +1,12 @@ +--echo # +--echo # MDEV-4842 STR_TO_DATE does not work with UCS2/UTF16/UTF32 +--echo # + +SELECT @@character_set_connection, HEX(CAST(_utf8'÷' AS CHAR)); +SELECT STR_TO_DATE(CAST(_utf8'2001÷01÷01' AS CHAR),CAST(_utf8'%Y÷%m÷%d' AS CHAR)); +CREATE TABLE t1 AS SELECT REPEAT(' ', 64) AS subject, REPEAT(' ',64) AS pattern LIMIT 0; +SHOW COLUMNS FROM t1; +INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d'); +SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1; +DROP TABLE t1; + diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index 5ed8159aae3..2debf288f44 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -336,6 +336,25 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; c2h ab_def drop table t1; +# +# MDEV-4842 STR_TO_DATE does not work with UCS2/UTF16/UTF32 +# +SELECT @@character_set_connection, HEX(CAST(_utf8'÷' AS CHAR)); +@@character_set_connection HEX(CAST(_utf8'÷' AS CHAR)) +latin1 F7 +SELECT STR_TO_DATE(CAST(_utf8'2001÷01÷01' AS CHAR),CAST(_utf8'%Y÷%m÷%d' AS CHAR)); +STR_TO_DATE(CAST(_utf8'2001÷01÷01' AS CHAR),CAST(_utf8'%Y÷%m÷%d' AS CHAR)) +2001-01-01 +CREATE TABLE t1 AS SELECT REPEAT(' ', 64) AS subject, REPEAT(' ',64) AS pattern LIMIT 0; +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +subject varchar(64) NO +pattern varchar(64) NO +INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d'); +SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1; +HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern) +32303031F73031F73031 2559F7256DF72564 2001-01-01 00:00:00 +DROP TABLE t1; SET collation_connection='latin1_bin'; create table t1 select repeat('a',4000) a; delete from t1; diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result index abeb19c0c8f..b776f1cf7d6 100644 --- a/mysql-test/r/ctype_sjis.result +++ b/mysql-test/r/ctype_sjis.result @@ -138,6 +138,25 @@ a hex(b) c 3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 DROP TABLE t1; +# +# MDEV-4842 STR_TO_DATE does not work with UCS2/UTF16/UTF32 +# +SELECT @@character_set_connection, HEX(CAST(_utf8'÷' AS CHAR)); +@@character_set_connection HEX(CAST(_utf8'÷' AS CHAR)) +sjis 8180 +SELECT STR_TO_DATE(CAST(_utf8'2001÷01÷01' AS CHAR),CAST(_utf8'%Y÷%m÷%d' AS CHAR)); +STR_TO_DATE(CAST(_utf8'2001÷01÷01' AS CHAR),CAST(_utf8'%Y÷%m÷%d' AS CHAR)) +2001-01-01 +CREATE TABLE t1 AS SELECT REPEAT(' ', 64) AS subject, REPEAT(' ',64) AS pattern LIMIT 0; +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +subject varchar(64) NO +pattern varchar(64) NO +INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d'); +SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1; +HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern) +323030318180303181803031 25598180256D81802564 2001-01-01 00:00:00 +DROP TABLE t1; SET collation_connection='sjis_bin'; create table t1 select repeat('a',4000) a; delete from t1; diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index f73ea4bdbee..20aabdb528b 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -804,6 +804,25 @@ a hex(b) c 3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 DROP TABLE t1; +# +# MDEV-4842 STR_TO_DATE does not work with UCS2/UTF16/UTF32 +# +SELECT @@character_set_connection, HEX(CAST(_utf8'÷' AS CHAR)); +@@character_set_connection HEX(CAST(_utf8'÷' AS CHAR)) +ucs2 00F7 +SELECT STR_TO_DATE(CAST(_utf8'2001÷01÷01' AS CHAR),CAST(_utf8'%Y÷%m÷%d' AS CHAR)); +STR_TO_DATE(CAST(_utf8'2001÷01÷01' AS CHAR),CAST(_utf8'%Y÷%m÷%d' AS CHAR)) +2001-01-01 +CREATE TABLE t1 AS SELECT REPEAT(' ', 64) AS subject, REPEAT(' ',64) AS pattern LIMIT 0; +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +subject varchar(64) NO +pattern varchar(64) NO +INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d'); +SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1; +HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern) +003200300030003100F70030003100F700300031 0025005900F70025006D00F700250064 2001-01-01 00:00:00 +DROP TABLE t1; SET NAMES latin1; SET collation_connection='ucs2_bin'; create table t1 select repeat('a',4000) a; diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index e7aaf68b271..a2324ff9dee 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -977,6 +977,25 @@ ss u,ü ue drop table t1; +# +# MDEV-4842 STR_TO_DATE does not work with UCS2/UTF16/UTF32 +# +SELECT @@character_set_connection, HEX(CAST(_utf8'÷' AS CHAR)); +@@character_set_connection HEX(CAST(_utf8'÷' AS CHAR)) +utf8 C3B7 +SELECT STR_TO_DATE(CAST(_utf8'2001÷01÷01' AS CHAR),CAST(_utf8'%Y÷%m÷%d' AS CHAR)); +STR_TO_DATE(CAST(_utf8'2001÷01÷01' AS CHAR),CAST(_utf8'%Y÷%m÷%d' AS CHAR)) +2001-01-01 +CREATE TABLE t1 AS SELECT REPEAT(' ', 64) AS subject, REPEAT(' ',64) AS pattern LIMIT 0; +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +subject varchar(64) NO +pattern varchar(64) NO +INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d'); +SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1; +HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern) +32303031C3B73031C3B73031 2559C3B7256DC3B72564 2001-01-01 00:00:00 +DROP TABLE t1; SET collation_connection='utf8_bin'; create table t1 select repeat('a',4000) a; delete from t1; diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 811861a6d93..7228daa2712 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -232,7 +232,7 @@ mysqltest: At line 2: Spurious text after `query` expression mysqltest: At line 1: Missing argument(s) to 'error' mysqltest: At line 1: Missing argument(s) to 'error' mysqltest: At line 1: The sqlstate definition must start with an uppercase S -mysqltest: At line 1: The error name definition must start with an uppercase E or W +mysqltest: At line 1: The error name definition must start with an uppercase E or W or H mysqltest: At line 1: Invalid argument to error: '9eeeee' - the errno may only consist of digits[0-9] mysqltest: At line 1: Invalid argument to error: '1sssss' - the errno may only consist of digits[0-9] mysqltest: At line 1: The sqlstate must be exactly 5 chars long diff --git a/mysql-test/suite/sys_vars/r/thread_pool_size_high.result b/mysql-test/suite/sys_vars/r/thread_pool_size_high.result new file mode 100644 index 00000000000..f581ae8e315 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/thread_pool_size_high.result @@ -0,0 +1,11 @@ +SELECT @@global.thread_pool_size; +@@global.thread_pool_size +200 +SET @@global.thread_pool_size=150; +SET @@global.thread_pool_size=200; +SET @@global.thread_pool_size=201; +Warnings: +Warning 1292 Truncated incorrect thread_pool_size value: '201' +SELECT @@global.thread_pool_size; +@@global.thread_pool_size +200 diff --git a/mysql-test/suite/sys_vars/t/thread_pool_size_basic.opt b/mysql-test/suite/sys_vars/t/thread_pool_size_basic.opt new file mode 100644 index 00000000000..7a2696875b8 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/thread_pool_size_basic.opt @@ -0,0 +1 @@ +--loose-thread-handling=pool-of-threads diff --git a/mysql-test/suite/sys_vars/t/thread_pool_size_basic.test b/mysql-test/suite/sys_vars/t/thread_pool_size_basic.test index eeed58956a4..5d432eb9940 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_size_basic.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_size_basic.test @@ -1,6 +1,7 @@ # uint global --source include/not_windows.inc --source include/not_embedded.inc +--source include/have_pool_of_threads.inc SET @start_global_value = @@global.thread_pool_size; # diff --git a/mysql-test/suite/sys_vars/t/thread_pool_size_high.opt b/mysql-test/suite/sys_vars/t/thread_pool_size_high.opt new file mode 100644 index 00000000000..fe54a37c4ce --- /dev/null +++ b/mysql-test/suite/sys_vars/t/thread_pool_size_high.opt @@ -0,0 +1 @@ +--loose-thread-handling=pool-of-threads --loose-thread-pool-size=200 diff --git a/mysql-test/suite/sys_vars/t/thread_pool_size_high.test b/mysql-test/suite/sys_vars/t/thread_pool_size_high.test new file mode 100644 index 00000000000..761aeee2b0a --- /dev/null +++ b/mysql-test/suite/sys_vars/t/thread_pool_size_high.test @@ -0,0 +1,14 @@ +--source include/not_windows.inc +--source include/not_embedded.inc +--source include/have_pool_of_threads.inc + +SELECT @@global.thread_pool_size; + +# Set lower value +SET @@global.thread_pool_size=150; +# Set original value +SET @@global.thread_pool_size=200; +# Try higher value +SET @@global.thread_pool_size=201; + +SELECT @@global.thread_pool_size; diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index 15156b89d8e..7f0ab5dc169 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -104,7 +104,7 @@ explain extended select last_insert_id(); --error ER_DUP_ENTRY insert into t1 set i = 254; select last_insert_id(); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 set i = null; select last_insert_id(); drop table t1; @@ -113,7 +113,7 @@ create table t1 (i tinyint unsigned not null auto_increment, key (i)); insert into t1 set i = 254; insert into t1 set i = null; select last_insert_id(); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 set i = null; select last_insert_id(); drop table t1; @@ -354,7 +354,7 @@ INSERT INTO t1 VALUES (18446744073709551601); SET @@SESSION.AUTO_INCREMENT_INCREMENT=10; SELECT @@SESSION.AUTO_INCREMENT_OFFSET; ---error 167 +--error HA_ERR_AUTOINC_ERANGE INSERT INTO t1 VALUES (NULL), (NULL), (NULL); SELECT * FROM t1; diff --git a/mysql-test/t/auto_increment_ranges.inc b/mysql-test/t/auto_increment_ranges.inc index a94aa46d38e..1540be0828e 100644 --- a/mysql-test/t/auto_increment_ranges.inc +++ b/mysql-test/t/auto_increment_ranges.inc @@ -13,25 +13,25 @@ let $range_max=32767; eval create table t1 (a $type primary key auto_increment); eval insert into t1 values($range_max); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); truncate table t1; eval insert into t1 values($range_max-1); insert into t1 values(NULL); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max),(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max-1),(NULL),(NULL); truncate table t1; eval insert into t1 values($range_max+1); select * from t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values(NULL); drop table t1; @@ -44,25 +44,25 @@ let $range_max=65535; eval create table t1 (a $type primary key auto_increment); eval insert into t1 values($range_max); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); truncate table t1; eval insert into t1 values($range_max-1); insert into t1 values(NULL); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max),(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max-1),(NULL),(NULL); truncate table t1; eval insert into t1 values($range_max+1); select * from t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values(NULL); drop table t1; @@ -75,25 +75,25 @@ let $range_max=2147483647; eval create table t1 (a $type primary key auto_increment); eval insert into t1 values($range_max); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); truncate table t1; eval insert into t1 values($range_max-1); insert into t1 values(NULL); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max),(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max-1),(NULL),(NULL); truncate table t1; eval insert into t1 values($range_max+1); select * from t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values(NULL); drop table t1; @@ -106,25 +106,25 @@ let $range_max=4294967295; eval create table t1 (a $type primary key auto_increment); eval insert into t1 values($range_max); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); truncate table t1; eval insert into t1 values($range_max-1); insert into t1 values(NULL); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max),(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max-1),(NULL),(NULL); truncate table t1; eval insert into t1 values($range_max+1); select * from t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values(NULL); drop table t1; @@ -137,25 +137,25 @@ let $range_max=cast(9223372036854775807 as unsigned); eval create table t1 (a $type primary key auto_increment); eval insert into t1 values($range_max); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); truncate table t1; eval insert into t1 values($range_max-1); insert into t1 values(NULL); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max),(NULL); select * from t1; truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values($range_max-1),(NULL),(NULL); truncate table t1; eval insert into t1 values($range_max+1); select * from t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE eval insert into t1 values(NULL); drop table t1; @@ -200,7 +200,7 @@ set @org_mode=@@sql_mode; set @@sql_mode='ansi,traditional'; insert ignore into t1 values(32766),(NULL),(NULL); truncate table t1; ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(32766),(NULL),(NULL); set @@sql_mode=@org_mode; drop table t1; @@ -223,7 +223,7 @@ DROP TABLE t1; CREATE TABLE t1 (a smallint AUTO_INCREMENT, PRIMARY KEY (a)); INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (32768); ---error 167 +--error HA_ERR_AUTOINC_ERANGE INSERT INTO t1 VALUES (NULL); SELECT * FROM t1; DROP TABLE t1; @@ -235,6 +235,6 @@ DROP TABLE t1; create table t1 (a smallint primary key auto_increment); insert into t1 values(32766),(NULL); delete from t1 where a=32767; ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values(NULL); drop table t1; diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test index 5d1acf107d7..ec9b836a78b 100644 --- a/mysql-test/t/ctype_latin1.test +++ b/mysql-test/t/ctype_latin1.test @@ -82,6 +82,7 @@ select 'a' regexp 'A' collate latin1_bin; SET collation_connection='latin1_swedish_ci'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc +-- source include/ctype_str_to_date.inc SET collation_connection='latin1_bin'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test index f45e6ab9b54..a988c07ebe0 100644 --- a/mysql-test/t/ctype_sjis.test +++ b/mysql-test/t/ctype_sjis.test @@ -69,6 +69,7 @@ SET collation_connection='sjis_japanese_ci'; -- source include/ctype_innodb_like.inc -- source include/ctype_like_escape.inc -- source include/ctype_like_range_f1f2.inc +-- source include/ctype_str_to_date.inc SET collation_connection='sjis_bin'; -- source include/ctype_filesort.inc -- source include/ctype_innodb_like.inc diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 9f5b4153bce..343adcd5712 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -421,6 +421,7 @@ SET collation_connection='ucs2_general_ci'; -- source include/ctype_like_escape.inc -- source include/ctype_german.inc -- source include/ctype_like_range_f1f2.inc +-- source include/ctype_str_to_date.inc SET NAMES latin1; SET collation_connection='ucs2_bin'; -- source include/ctype_filesort.inc diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 176d7e58c77..cb47391471e 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -714,6 +714,7 @@ SET collation_connection='utf8_general_ci'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc -- source include/ctype_german.inc +-- source include/ctype_str_to_date.inc SET collation_connection='utf8_bin'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test index 3d32a8c0da6..3f2569b0c62 100644 --- a/mysql-test/t/replace.test +++ b/mysql-test/t/replace.test @@ -25,9 +25,9 @@ drop table t1; create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value"); insert into t1 values (126,"first"),(63, "middle"),(0,"last"); ---error 167 +--error HA_ERR_AUTOINC_ERANGE insert into t1 values (0,"error"); ---error 167 +--error HA_ERR_AUTOINC_ERANGE replace into t1 values (0,"error"); replace into t1 values (126,"first updated"); replace into t1 values (63,default); diff --git a/sql/item.cc b/sql/item.cc index 26c75ccfd40..f1968e952be 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -263,6 +263,24 @@ String *Item::val_str_ascii(String *str) } +String *Item::val_str(String *str, String *converter, CHARSET_INFO *cs) +{ + String *res= val_str(str); + if (null_value) + return (String *) 0; + + if (!cs) + return res; + + uint errors; + if ((null_value= converter->copy(res->ptr(), res->length(), + collation.collation, cs, &errors))) + return (String *) 0; + + return converter; +} + + String *Item::val_string_from_real(String *str) { double nr= val_real(); diff --git a/sql/item.h b/sql/item.h index 2a4a7537a66..89d46e83e28 100644 --- a/sql/item.h +++ b/sql/item.h @@ -907,6 +907,10 @@ public: virtual String *val_str_ascii(String *str); /* + Returns the val_str() value converted to the given character set. + */ + String *val_str(String *str, String *converter, CHARSET_INFO *to); + /* Return decimal representation of item with fixed point. SYNOPSIS diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index f405aae4766..51d6d3fa6a6 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -3096,13 +3096,25 @@ get_date_time_result_type(const char *format, uint length) void Item_func_str_to_date::fix_length_and_dec() { + if (agg_arg_charsets(collation, args, 2, MY_COLL_ALLOW_CONV, 1)) + return; + if (collation.collation->mbminlen > 1) + { +#if MYSQL_VERSION_ID > 50500 + internal_charset= &my_charset_utf8mb4_general_ci; +#else + internal_charset= &my_charset_utf8_general_ci; +#endif + } + cached_field_type= MYSQL_TYPE_DATETIME; decimals= NOT_FIXED_DEC; if ((const_item= args[1]->const_item())) { char format_buff[64]; String format_str(format_buff, sizeof(format_buff), &my_charset_bin); - String *format= args[1]->val_str(&format_str); + String *format= args[1]->val_str(&format_str, &format_converter, + internal_charset); decimals= 0; if (!args[1]->null_value) { @@ -3140,8 +3152,8 @@ bool Item_func_str_to_date::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) String format_str(format_buff, sizeof(format_buff), &my_charset_bin), *format; - val= args[0]->val_str(&val_string); - format= args[1]->val_str(&format_str); + val= args[0]->val_str(&val_string, &subject_converter, internal_charset); + format= args[1]->val_str(&format_str, &format_converter, internal_charset); if (args[0]->null_value || args[1]->null_value) return (null_value=1); diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 1f686f34367..c54490f45af 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -1029,9 +1029,13 @@ class Item_func_str_to_date :public Item_temporal_func enum_field_types cached_field_type; timestamp_type cached_timestamp_type; bool const_item; + String subject_converter; + String format_converter; + CHARSET_INFO *internal_charset; public: Item_func_str_to_date(Item *a, Item *b) - :Item_temporal_func(a, b), const_item(false) + :Item_temporal_func(a, b), const_item(false), + internal_charset(NULL) {} bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); const char *func_name() const { return "str_to_date"; } diff --git a/sql/sql_plist.h b/sql/sql_plist.h index 2b6f1067321..e703b4c0f62 100644 --- a/sql/sql_plist.h +++ b/sql/sql_plist.h @@ -75,6 +75,11 @@ class I_P_List : public C, public I */ public: I_P_List() : I(&m_first), m_first(NULL) {}; + /* + empty() is used in many places in the code instead of a constructor, to + initialize a bzero-ed I_P_List instance. + */ + inline void empty() { m_first= NULL; C::reset(); I::set_last(&m_first); } inline bool is_empty() const { return (m_first == NULL); } inline void push_front(T* a) diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 7f24365b090..36f70875abf 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2720,6 +2720,18 @@ static bool fix_tp_min_threads(sys_var *, THD *, enum_var_type) #ifndef _WIN32 +static bool check_threadpool_size(sys_var *self, THD *thd, set_var *var) +{ + ulonglong v= var->save_result.ulonglong_value; + if (v > threadpool_max_size) + { + var->save_result.ulonglong_value= threadpool_max_size; + return throw_bounds_warning(thd, self->name.str, true, true, v); + } + return false; +} + + static bool fix_threadpool_size(sys_var*, THD*, enum_var_type) { tp_set_threadpool_size(threadpool_size); @@ -2764,7 +2776,7 @@ static Sys_var_uint Sys_threadpool_size( "executing threads (threads in a waiting state do not count as executing).", GLOBAL_VAR(threadpool_size), CMD_LINE(REQUIRED_ARG), VALID_RANGE(1, MAX_THREAD_GROUPS), DEFAULT(my_getncpus()), BLOCK_SIZE(1), - NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_threadpool_size), ON_UPDATE(fix_threadpool_size) ); static Sys_var_uint Sys_threadpool_stall_limit( diff --git a/sql/threadpool.h b/sql/threadpool.h index 919836e5a57..c080e5ba343 100644 --- a/sql/threadpool.h +++ b/sql/threadpool.h @@ -13,12 +13,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define MAX_THREAD_GROUPS 128 +#define MAX_THREAD_GROUPS 100000 /* Threadpool parameters */ extern uint threadpool_min_threads; /* Minimum threads in pool */ extern uint threadpool_idle_timeout; /* Shutdown idle worker threads after this timeout */ extern uint threadpool_size; /* Number of parallel executing threads */ +extern uint threadpool_max_size; extern uint threadpool_stall_limit; /* time interval in 10 ms units for stall checks*/ extern uint threadpool_max_threads; /* Maximum threads in pool */ extern uint threadpool_oversubscribe; /* Maximum active threads in group */ diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 5be06f0bdc8..9e0cb07b86c 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -30,6 +30,7 @@ uint threadpool_min_threads; uint threadpool_idle_timeout; uint threadpool_size; +uint threadpool_max_size; uint threadpool_stall_limit; uint threadpool_max_threads; uint threadpool_oversubscribe; diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc index dc2d8d999ef..df1a05b3ebf 100644 --- a/sql/threadpool_unix.cc +++ b/sql/threadpool_unix.cc @@ -147,8 +147,9 @@ struct thread_group_t } MY_ALIGNED(512); -static thread_group_t all_groups[MAX_THREAD_GROUPS]; +static thread_group_t *all_groups; static uint group_count; +static int32 shutdown_group_count; /** Used for printing "pool blocked" message, see @@ -517,7 +518,7 @@ static void* timer_thread(void *param) timer->current_microtime= microsecond_interval_timer(); /* Check stalls in thread groups */ - for(i=0; i< array_elements(all_groups);i++) + for (i= 0; i < threadpool_max_size; i++) { if(all_groups[i].connection_count) check_stall(&all_groups[i]); @@ -907,6 +908,7 @@ int thread_group_init(thread_group_t *thread_group, pthread_attr_t* thread_attr) thread_group->pollfd= -1; thread_group->shutdown_pipe[0]= -1; thread_group->shutdown_pipe[1]= -1; + thread_group->queue.empty(); DBUG_RETURN(0); } @@ -927,6 +929,8 @@ void thread_group_destroy(thread_group_t *thread_group) thread_group->shutdown_pipe[i]= -1; } } + if (my_atomic_add32(&shutdown_group_count, -1) == 1) + my_free(all_groups); } /** @@ -1510,10 +1514,18 @@ static void *worker_main(void *param) bool tp_init() { DBUG_ENTER("tp_init"); + threadpool_max_size= max(threadpool_size, 128); + all_groups= (thread_group_t *) + my_malloc(sizeof(thread_group_t) * threadpool_max_size, MYF(MY_WME|MY_ZEROFILL)); + if (!all_groups) + { + threadpool_max_size= 0; + DBUG_RETURN(1); + } threadpool_started= true; scheduler_init(); - for(uint i=0; i < array_elements(all_groups); i++) + for (uint i= 0; i < threadpool_max_size; i++) { thread_group_init(&all_groups[i], get_connection_attrib()); } @@ -1542,7 +1554,8 @@ void tp_end() DBUG_VOID_RETURN; stop_timer(&pool_timer); - for(uint i=0; i< array_elements(all_groups); i++) + shutdown_group_count= threadpool_max_size; + for (uint i= 0; i < threadpool_max_size; i++) { thread_group_close(&all_groups[i]); } @@ -1604,9 +1617,7 @@ void tp_set_threadpool_stall_limit(uint limit) int tp_get_idle_thread_count() { int sum=0; - for(uint i= 0; - i< array_elements(all_groups) && (all_groups[i].pollfd >= 0); - i++) + for (uint i= 0; i < threadpool_max_size && all_groups[i].pollfd >= 0; i++) { sum+= (all_groups[i].thread_count - all_groups[i].active_thread_count); } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 590dffd8749..ecc151d9fc1 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -12811,7 +12811,7 @@ innodb_buffer_pool_evict_update( mutex_enter(&block->mutex); buf_LRU_free_block(&block->page, - FALSE, FALSE); + FALSE, TRUE); mutex_exit(&block->mutex); block = prev_block; } |