merge 10-base->10.0

This commit is contained in:
unknown 2013-11-11 23:40:53 +02:00
commit 55de9b0468
50 changed files with 617 additions and 108 deletions

View File

@ -3041,6 +3041,10 @@ void open_file(const char *name)
5.try in basedir
*/
#ifdef __WIN__
fix_win_paths(curname, sizeof(curname));
#endif
bool in_overlay= opt_overlay_dir &&
!strncmp(curname, opt_overlay_dir, overlay_dir_len);
bool in_suiteir= opt_overlay_dir && !in_overlay &&
@ -5180,11 +5184,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 +5212,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)
{
st_error *e= global_error_names;
uint get_errcode_from_name(const char *error_name, const char *error_end)
{
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 +5247,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 +5343,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 +5352,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
{

View File

@ -59,6 +59,7 @@ SET(HEADERS
my_attribute.h
my_compiler.h
handler_state.h
handler_ername.h
)
INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)

80
include/handler_ername.h Normal file
View File

@ -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, "" },

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -895,6 +895,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;

View File

@ -1058,6 +1058,25 @@ s 0
ß 1
DROP TABLE t1;
"END ctype_german.inc"
#
# 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;

View File

@ -42,3 +42,47 @@ select * from t1 where a in ('4828532208463511553');
a
4828532208463511553
drop table t1;
#End of 4.1 tests
#
# MDEV-5103: server crashed on singular Item_equal
#
CREATE TABLE `t1` (
`tipo` enum('p','r') NOT NULL DEFAULT 'r',
`arquivo_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`arquivo_md5` char(32) NOT NULL,
`conteudo` longblob NOT NULL,
`usuario` varchar(15) NOT NULL,
`datahora_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`tipo_arquivo` varchar(255) NOT NULL,
`nome_arquivo` varchar(255) NOT NULL,
`tamanho_arquivo` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`tipo`,`arquivo_id`),
UNIQUE KEY `tipo` (`tipo`,`arquivo_md5`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
INSERT INTO `t1` (`tipo`, `arquivo_id`, `arquivo_md5`, `conteudo`, `usuario`, `datahora_gmt`, `tipo_arquivo`, `nome_arquivo`, `tamanho_arquivo`) VALUES
('r', 1, 'ad18832202b199728921807033a8a515', '', 'rspadim', '2013-10-05 13:55:50', '001_cbr643', 'CBR6431677410201314132.ret', 21306);
CREATE TABLE `t2` (
`tipo` enum('p','r') NOT NULL DEFAULT 'p',
`arquivo_id` bigint(20) NOT NULL DEFAULT '0',
`usuario` varchar(25) NOT NULL,
`datahora` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`erros` longblob NOT NULL,
`importados` bigint(20) unsigned NOT NULL DEFAULT '0',
`n_importados` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`tipo`,`arquivo_id`,`datahora`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
INSERT INTO `t2` (`tipo`, `arquivo_id`, `usuario`, `datahora`, `erros`, `importados`, `n_importados`) VALUES
('r', 1, 'rspadim', '2013-10-05 14:25:30', '', 32, 0);
SELECT
arquivo_id,usuario,datahora_gmt,tipo_arquivo,nome_arquivo,tamanho_arquivo
FROM t1 AS a
WHERE datahora_gmt>='0000-00-00 00:00:00' AND
datahora_gmt<='2013-10-07 02:59:59' AND tipo='r' AND
(tipo_arquivo,arquivo_id) NOT IN
(SELECT tipo_arquivo,arquivo_id
FROM t2
WHERE (tipo_arquivo,arquivo_id)=(a.tipo_arquivo,a.arquivo_id))
ORDER BY arquivo_id DESC;
arquivo_id usuario datahora_gmt tipo_arquivo nome_arquivo tamanho_arquivo
drop table t2, t1;
#End of 5.3 tests

View File

@ -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

View File

@ -4919,6 +4919,37 @@ q 1 q
q 1 q
drop view v1;
drop table t1,t2;
#
# MDEV-5153: Server crashes in Item_ref::fix_fields on 2nd execution
# of PS with LEFT JOIN and MERGE view or SELECT SQ
#
CREATE TABLE t1 (i1 INT, c1 VARCHAR(6)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
CREATE TABLE t2 (c2 VARCHAR(6)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('foobar'),('qux');
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1 WHERE ( c1 ) IN ( SELECT c2 FROM t2 ) AND i1 <= 2 ;
PREPARE stmt FROM 'SELECT * FROM t1 LEFT JOIN v1 ON (v1.i1 = t1.i1)';
EXECUTE stmt;
i1 c1 i1 c1
1 foo NULL NULL
2 bar NULL NULL
EXECUTE stmt;
i1 c1 i1 c1
1 foo NULL NULL
2 bar NULL NULL
drop view v1;
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1 WHERE ( c1, c1 ) IN ( SELECT c2, c2 FROM t2 ) AND i1 <= 2 ;
EXECUTE stmt;
i1 c1 i1 c1
1 foo NULL NULL
2 bar NULL NULL
EXECUTE stmt;
i1 c1 i1 c1
1 foo NULL NULL
2 bar NULL NULL
deallocate prepare stmt;
drop view v1;
drop table t1,t2;
# -----------------------------------------------------------------
# -- End of 5.3 tests.
# -----------------------------------------------------------------

View File

@ -0,0 +1,2 @@
select 2;

View File

@ -1,3 +1,6 @@
select 1;
1
1
select 2;
2
2

View File

@ -5,4 +5,8 @@
# three times - once for the parent suite, and once for each overlay.
# even if the test files are not overlayed.
#
# overlay.inc is overridden in mtr2-myisam, and there is an rdiff file.
#
select 1;
source overlay.inc;

View File

@ -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

View File

@ -0,0 +1 @@
--loose-thread-handling=pool-of-threads

View File

@ -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;
#

View File

@ -0,0 +1 @@
--loose-thread-handling=pool-of-threads --loose-thread-pool-size=200

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -379,6 +379,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

View File

@ -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

View File

@ -43,4 +43,54 @@ select * from t1 where a = '4828532208463511553';
select * from t1 where a in ('4828532208463511553');
drop table t1;
# End of 4.1 tests
--echo #End of 4.1 tests
--echo #
--echo # MDEV-5103: server crashed on singular Item_equal
--echo #
CREATE TABLE `t1` (
`tipo` enum('p','r') NOT NULL DEFAULT 'r',
`arquivo_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`arquivo_md5` char(32) NOT NULL,
`conteudo` longblob NOT NULL,
`usuario` varchar(15) NOT NULL,
`datahora_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`tipo_arquivo` varchar(255) NOT NULL,
`nome_arquivo` varchar(255) NOT NULL,
`tamanho_arquivo` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`tipo`,`arquivo_id`),
UNIQUE KEY `tipo` (`tipo`,`arquivo_md5`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
INSERT INTO `t1` (`tipo`, `arquivo_id`, `arquivo_md5`, `conteudo`, `usuario`, `datahora_gmt`, `tipo_arquivo`, `nome_arquivo`, `tamanho_arquivo`) VALUES
('r', 1, 'ad18832202b199728921807033a8a515', '', 'rspadim', '2013-10-05 13:55:50', '001_cbr643', 'CBR6431677410201314132.ret', 21306);
CREATE TABLE `t2` (
`tipo` enum('p','r') NOT NULL DEFAULT 'p',
`arquivo_id` bigint(20) NOT NULL DEFAULT '0',
`usuario` varchar(25) NOT NULL,
`datahora` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`erros` longblob NOT NULL,
`importados` bigint(20) unsigned NOT NULL DEFAULT '0',
`n_importados` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`tipo`,`arquivo_id`,`datahora`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
INSERT INTO `t2` (`tipo`, `arquivo_id`, `usuario`, `datahora`, `erros`, `importados`, `n_importados`) VALUES
('r', 1, 'rspadim', '2013-10-05 14:25:30', '', 32, 0);
SELECT
arquivo_id,usuario,datahora_gmt,tipo_arquivo,nome_arquivo,tamanho_arquivo
FROM t1 AS a
WHERE datahora_gmt>='0000-00-00 00:00:00' AND
datahora_gmt<='2013-10-07 02:59:59' AND tipo='r' AND
(tipo_arquivo,arquivo_id) NOT IN
(SELECT tipo_arquivo,arquivo_id
FROM t2
WHERE (tipo_arquivo,arquivo_id)=(a.tipo_arquivo,a.arquivo_id))
ORDER BY arquivo_id DESC;
drop table t2, t1;
--echo #End of 5.3 tests

View File

@ -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);

View File

@ -4845,6 +4845,34 @@ SELECT * FROM t2 LEFT JOIN v1 ON ( c=b AND a IN ( 1,6 ) );
drop view v1;
drop table t1,t2;
--echo #
--echo # MDEV-5153: Server crashes in Item_ref::fix_fields on 2nd execution
--echo # of PS with LEFT JOIN and MERGE view or SELECT SQ
--echo #
CREATE TABLE t1 (i1 INT, c1 VARCHAR(6)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
CREATE TABLE t2 (c2 VARCHAR(6)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('foobar'),('qux');
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1 WHERE ( c1 ) IN ( SELECT c2 FROM t2 ) AND i1 <= 2 ;
PREPARE stmt FROM 'SELECT * FROM t1 LEFT JOIN v1 ON (v1.i1 = t1.i1)';
EXECUTE stmt;
EXECUTE stmt;
drop view v1;
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1 WHERE ( c1, c1 ) IN ( SELECT c2, c2 FROM t2 ) AND i1 <= 2 ;
EXECUTE stmt;
EXECUTE stmt;
deallocate prepare stmt;
drop view v1;
drop table t1,t2;
--echo # -----------------------------------------------------------------
--echo # -- End of 5.3 tests.
--echo # -----------------------------------------------------------------

View File

@ -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();

View File

@ -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.

View File

@ -1438,9 +1438,11 @@ bool Item_in_optimizer::eval_not_null_tables(uchar *opt_arg)
bool Item_in_optimizer::fix_left(THD *thd)
{
DBUG_ENTER("Item_in_optimizer::fix_left");
if ((!args[0]->fixed && args[0]->fix_fields(thd, args)) ||
(!cache && !(cache= Item_cache::get_cache(args[0]))))
return 1;
DBUG_RETURN(1);
DBUG_PRINT("info", ("actual fix fields"));
cache->setup(args[0]);
if (cache->cols() == 1)
@ -1466,11 +1468,15 @@ bool Item_in_optimizer::fix_left(THD *thd)
{
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
"SUBQUERY in ROW in left expression of IN/ALL/ANY");
return 1;
DBUG_RETURN(1);
}
Item *element=args[0]->element_index(i);
if (element->used_tables() || !element->const_item())
((Item_cache *)cache->element_index(i))->set_used_tables(OUTER_REF_TABLE_BIT);
{
((Item_cache *)cache->element_index(i))->
set_used_tables(OUTER_REF_TABLE_BIT);
cache->set_used_tables(OUTER_REF_TABLE_BIT);
}
else
((Item_cache *)cache->element_index(i))->set_used_tables(0);
}
@ -1491,7 +1497,7 @@ bool Item_in_optimizer::fix_left(THD *thd)
with_sum_func= with_sum_func || args[1]->with_sum_func;
const_item_cache= const_item_cache && args[1]->const_item();
}
return 0;
DBUG_RETURN(0);
}
@ -5794,6 +5800,12 @@ void Item_equal::add_const(Item *c, Item *f)
func->quick_fix_field();
cond_false= !func->val_int();
}
/*
TODO: also support the case where Item_equal becomes singular with
this->is_cond_true()=1. When I attempted to mark the item as constant,
the optimizer attempted to remove it, however it is still referenced from
COND_EQUAL and I got a crash.
*/
if (cond_false)
const_item_cache= 1;
}
@ -5998,7 +6010,8 @@ void Item_equal::merge_into_list(List<Item_equal> *list,
void Item_equal::sort(Item_field_cmpfunc compare, void *arg)
{
bubble_sort<Item>(&equal_items, compare, arg);
if (equal_items.elements > 1)
bubble_sort<Item>(&equal_items, compare, arg);
}
@ -6126,6 +6139,12 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
void Item_equal::update_used_tables()
{
not_null_tables_cache= used_tables_cache= 0;
/*
TODO: also support the case where Item_equal becomes singular with
this->is_cond_true()=1. When I attempted to mark the item as constant,
the optimizer attempted to remove it, however it is still referenced from
COND_EQUAL and I got a crash.
*/
if ((const_item_cache= cond_false))
return;
Item_equal_fields_iterator it(*this);
@ -6175,6 +6194,8 @@ longlong Item_equal::val_int()
{
if (cond_false)
return 0;
if (is_cond_true())
return 1;
Item *item= get_const();
Item_equal_fields_iterator it(*this);
if (!item)
@ -6199,6 +6220,11 @@ longlong Item_equal::val_int()
void Item_equal::fix_length_and_dec()
{
Item *item= get_first(NO_PARTICULAR_TAB, NULL);
if (!item)
{
DBUG_ASSERT(is_cond_true()); // it should be the only constant
item= equal_items.head();
}
eval_item= cmp_item::get_comparator(item->cmp_type(), item,
item->collation.collation);
}

View File

@ -1826,6 +1826,7 @@ public:
Item_equal(Item_equal *item_equal);
/* Currently the const item is always the first in the list of equal items */
inline Item* get_const() { return with_const ? equal_items.head() : NULL; }
inline bool is_cond_true() { return equal_items.elements == 1; }
void add_const(Item *c, Item *f = NULL);
/** Add a non-constant item to the multiple equality */
void add(Item *f) { equal_items.push_back(f); }

View File

@ -2277,11 +2277,11 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
DBUG_RETURN(true);
Item *item_eq=
new Item_func_eq(new
Item_ref(&select_lex->context,
(*optimizer->get_cache())->
addr(i),
(char *)"<no matter>",
(char *)in_left_expr_name),
Item_direct_ref(&select_lex->context,
(*optimizer->get_cache())->
addr(i),
(char *)"<no matter>",
(char *)in_left_expr_name),
new
Item_ref(&select_lex->context,
select_lex->ref_pointer_array + i,
@ -3000,7 +3000,7 @@ out:
bool
Item_in_subselect::select_in_like_transformer(JOIN *join)
{
Query_arena *arena, backup;
Query_arena *arena= 0, backup;
SELECT_LEX *current= thd->lex->current_select;
const char *save_where= thd->where;
bool trans_res= true;
@ -3022,9 +3022,6 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
}
}
if (changed)
DBUG_RETURN(false);
thd->where= "IN/ALL/ANY subquery";
/*
@ -3035,25 +3032,29 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
note: we won't need Item_in_optimizer when handling degenerate cases
like "... IN (SELECT 1)"
*/
arena= thd->activate_stmt_arena_if_needed(&backup);
if (!optimizer)
{
arena= thd->activate_stmt_arena_if_needed(&backup);
result= (!(optimizer= new Item_in_optimizer(left_expr, this)));
if (arena)
thd->restore_active_arena(arena, &backup);
if (result)
goto err;
goto out;
}
thd->lex->current_select= current->return_after_parsing();
result= (!left_expr->fixed &&
left_expr->fix_fields(thd, optimizer->arguments()));
result= optimizer->fix_left(thd);
/* fix_fields can change reference to left_expr, we need reassign it */
left_expr= optimizer->arguments()[0];
thd->lex->current_select= current;
if (changed)
{
trans_res= false;
goto out;
}
if (result)
goto err;
goto out;
/*
Both transformers call fix_fields() only for Items created inside them,
@ -3062,7 +3063,6 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
of Item, we have to call fix_fields() for it only with original arena to
avoid memory leack)
*/
arena= thd->activate_stmt_arena_if_needed(&backup);
if (left_expr->cols() == 1)
trans_res= single_value_transformer(join);
else
@ -3077,9 +3077,9 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
}
trans_res= row_value_transformer(join);
}
out:
if (arena)
thd->restore_active_arena(arena, &backup);
err:
thd->where= save_where;
DBUG_RETURN(trans_res);
}

View File

@ -3117,13 +3117,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)
{
@ -3161,8 +3173,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);

View File

@ -1062,9 +1062,13 @@ class Item_func_str_to_date :public Item_temporal_hybrid_func
{
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_hybrid_func(a, b), const_item(false)
:Item_temporal_hybrid_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"; }

View File

@ -1272,11 +1272,11 @@ void get_delayed_table_estimates(TABLE *table,
@brief Replaces an expression destructively inside the expression tree of
the WHERE clase.
@note Because of current requirements for semijoin flattening, we do not
need to recurse here, hence this function will only examine the top-level
AND conditions. (see JOIN::prepare, comment starting with "Check if the
subquery predicate can be executed via materialization".
@note We substitute AND/OR structure because it was copied by
copy_andor_structure and some changes could be done in the copy but
should be left permanent, also there could be several layers of AND over
AND and OR over OR because ::fix_field() possibly is not called.
@param join The top-level query.
@param old_cond The expression to be replaced.
@param new_cond The expression to be substituted.
@ -1304,13 +1304,20 @@ static bool replace_where_subcondition(JOIN *join, Item **expr,
Item *item;
while ((item= li++))
{
if (item == old_cond)
if (item == old_cond)
{
li.replace(new_cond);
if (do_fix_fields)
new_cond->fix_fields(join->thd, li.ref());
return FALSE;
}
else if (item->type() == Item::COND_ITEM)
{
DBUG_ASSERT(!(*expr)->fixed);
replace_where_subcondition(join, li.ref(),
old_cond, new_cond,
do_fix_fields);
}
}
}
/*

View File

@ -15,12 +15,6 @@
rpl_parallel_thread_pool::get_thread()) need to be killable. And on kill,
everything needs to be correctly rolled back and stopped in all threads,
to ensure a consistent slave replication state.
- Handle the case of a partial event group. This occurs when the master
crashes in the middle of writing the event group to the binlog. The
slave rolls back the transaction; parallel execution needs to be able
to deal with this wrt. commit_orderer and such.
See Format_description_log_event::do_apply_event().
*/
struct rpl_parallel_thread_pool global_rpl_thread_pool;

View File

@ -1490,6 +1490,7 @@ rpl_group_info::rpl_group_info(Relay_log_info *rli_)
rpl_group_info::~rpl_group_info()
{
free_annotate_event();
delete deferred_events;
mysql_mutex_destroy(&sleep_lock);
mysql_cond_destroy(&sleep_cond);
}

View File

@ -592,7 +592,10 @@ public:
void cleanup_after_session()
{
if (deferred_events)
{
delete deferred_events;
deferred_events= NULL;
}
};
/**

View File

@ -4582,8 +4582,9 @@ err_during_init:
serial_rgi->thd= rli->sql_driver_thd= 0;
mysql_mutex_lock(&LOCK_thread_count);
THD_CHECK_SENTRY(thd);
delete thd;
thd->rgi_fake= thd->rgi_slave= NULL;
delete serial_rgi;
delete thd;
mysql_mutex_unlock(&LOCK_thread_count);
/*
Note: the order of the broadcast and unlock calls below (first broadcast, then unlock)

View File

@ -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)

View File

@ -2868,19 +2868,20 @@ void remove_status_vars(SHOW_VAR *list)
for (; list->name; list++)
{
int res= 0, a= 0, b= all_status_vars.elements, c= (a+b)/2;
for (; b-a > 0; c= (a+b)/2)
int first= 0, last= ((int) all_status_vars.elements) - 1;
for ( ; first <= last; )
{
res= show_var_cmp(list, all+c);
if (res < 0)
b= c;
int res, middle= (first + last) / 2;
if ((res= show_var_cmp(list, all + middle)) < 0)
last= middle - 1;
else if (res > 0)
a= c;
first= middle + 1;
else
{
all[middle].type= SHOW_UNDEF;
break;
}
}
if (res == 0)
all[c].type= SHOW_UNDEF;
}
shrink_var_array(&all_status_vars);
mysql_mutex_unlock(&LOCK_status);

View File

@ -2900,6 +2900,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);
@ -2944,7 +2956,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(

View File

@ -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 */

View File

@ -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;

View File

@ -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= MY_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);
}

View File

@ -0,0 +1,2 @@
select 3;

View File

@ -0,0 +1,12 @@
--- suite/mtr2/single.result 2013-11-10 03:58:37.000000000 +0400
+++ suite/mtr2/single.reject 2013-11-10 03:59:08.000000000 +0400
@@ -1,6 +1,6 @@
select 1;
1
1
-select 2;
-2
-2
+select 3;
+3
+3

View File

@ -12794,7 +12794,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;
}