Commit e02ad98c authored by Alexander Barkov's avatar Alexander Barkov

Merge 5.5 -> 10.0-base

parents 7876d53b d79d0c40
......@@ -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
{
......
......@@ -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)
......
/* 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, "" },
......@@ -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
......
--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;
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
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
--loose-thread-handling=pool-of-threads
# 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;
#
......
--loose-thread-handling=pool-of-threads --loose-thread-pool-size=200
--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;
......@@ -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;
......
......@@ -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;
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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();
......
......@@ -906,6 +906,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.
......
......@@ -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);
......
......@@ -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"; }
......
......@@ -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)
......
......@@ -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(
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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;
}
......
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