Merge 10.2 into 10.3

This commit is contained in:
Marko Mäkelä 2019-09-23 10:25:34 +03:00
commit c016ea660e
90 changed files with 1022 additions and 555 deletions

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2000, 2013, Oracle and/or its affiliates. Copyright (c) 2000, 2013, Oracle and/or its affiliates.
Copyright (c) 2010, 2017, MariaDB Corporation. Copyright (c) 2010, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -1081,7 +1081,7 @@ static int get_options(int *argc, char ***argv)
my_progname_short); my_progname_short);
return(EX_USAGE); return(EX_USAGE);
} }
if (strcmp(default_charset, charset_info->csname) && if (strcmp(default_charset, MYSQL_AUTODETECT_CHARSET_NAME) &&
!(charset_info= get_charset_by_csname(default_charset, !(charset_info= get_charset_by_csname(default_charset,
MY_CS_PRIMARY, MYF(MY_WME)))) MY_CS_PRIMARY, MYF(MY_WME))))
exit(1); exit(1);
@ -1546,6 +1546,9 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name)
char query_buffer[QUERY_LENGTH]; char query_buffer[QUERY_LENGTH];
size_t query_length; size_t query_length;
if (!strcmp(cs_name, MYSQL_AUTODETECT_CHARSET_NAME))
cs_name= (char *)my_default_csname();
/* Server lacks facility. This is not an error, by arbitrary decision . */ /* Server lacks facility. This is not an error, by arbitrary decision . */
if (!server_supports_switching_charsets) if (!server_supports_switching_charsets)
return FALSE; return FALSE;

View File

@ -1,13 +1,31 @@
# If timestamping is used, it can (rarely) fail, when public timestamping service has issues.
#
# To handle the error gracefully and tranparently, we'll retry the signtool command,
# second time without "/t URL" parameter
SET(SIGNTOOL_PARAMETERS_NO_TIMESTAMP "@SIGNTOOL_PARAMETERS@")
LIST(FIND SIGNTOOL_PARAMETERS_NO_TIMESTAMP /t idx)
IF(NOT(idx EQUAL -1))
LIST(REMOVE_AT SIGNTOOL_PARAMETERS_NO_TIMESTAMP ${idx})
#remove the URL following /t , as well
LIST(REMOVE_AT SIGNTOOL_PARAMETERS_NO_TIMESTAMP ${idx})
ENDIF()
GET_FILENAME_COMPONENT(SIGNTOOL_DIR "@SIGNTOOL_EXECUTABLE@" DIRECTORY)
GET_FILENAME_COMPONENT(SIGNTOOL_NAME "@SIGNTOOL_EXECUTABLE@" NAME)
FILE(GLOB_RECURSE files "@CMAKE_BINARY_DIR@/*.signme") FILE(GLOB_RECURSE files "@CMAKE_BINARY_DIR@/*.signme")
MESSAGE(STATUS "signing files") MESSAGE(STATUS "signing files")
FOREACH(f ${files}) FOREACH(f ${files})
STRING(REPLACE ".signme" "" exe_location "${f}") STRING(REPLACE ".signme" "" exe_location "${f}")
string (REPLACE ";" " " params "@SIGNTOOL_PARAMETERS@") string (REPLACE ";" " " params "@SIGNTOOL_PARAMETERS@")
#MESSAGE("@SIGNTOOL_EXECUTABLE@" sign ${params} "${exe_location}")
EXECUTE_PROCESS(COMMAND EXECUTE_PROCESS(COMMAND
"@SIGNTOOL_EXECUTABLE@" sign @SIGNTOOL_PARAMETERS@ "${exe_location}" cmd /c "${SIGNTOOL_NAME}" sign @SIGNTOOL_PARAMETERS@ "${exe_location}" 2>NUL
|| "${SIGNTOOL_NAME}" sign ${SIGNTOOL_PARAMETERS_NO_TIMESTAMP} "${exe_location}"
WORKING_DIRECTORY ${SIGNTOOL_DIR}
RESULT_VARIABLE ERR) RESULT_VARIABLE ERR)
IF(NOT ${ERR} EQUAL 0) IF(NOT ${ERR} EQUAL 0)
MESSAGE( "Error ${ERR} signing ${exe_location}") MESSAGE( "Error ${ERR} signing ${exe_location}")

View File

@ -2,8 +2,8 @@
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
# assume the filename is /path/to/mariadb-server-##.#.postinst # Automatically set version to ease maintenance of this file
VER=${0: -13:4} MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}"
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
@ -11,7 +11,7 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
# This command can be used as pipe to syslog. With "-s" it also logs to stderr. # This command can be used as pipe to syslog. With "-s" it also logs to stderr.
ERR_LOGGER="logger -p daemon.err -t mariadb-server-$VER.postinst -i" ERR_LOGGER="logger -p daemon.err -t mariadb-server-$MAJOR_VER.postinst -i"
# This will make an error in a logged command immediately apparent by aborting # This will make an error in a logged command immediately apparent by aborting
# the install, rather than failing silently and leaving a broken install. # the install, rather than failing silently and leaving a broken install.
set -o pipefail set -o pipefail
@ -151,7 +151,7 @@ EOF
# To avoid downgrades. # To avoid downgrades.
touch $mysql_statedir/debian-$VER.flag touch $mysql_statedir/debian-$MAJOR_VER.flag
## On every reconfiguration the maintenance user is recreated. ## On every reconfiguration the maintenance user is recreated.
# #

View File

@ -1607,7 +1607,8 @@ bool backup_finish()
return(false); return(false);
} }
if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO, opt_history != 0)) { if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO,
opt_history != 0, true)) {
return(false); return(false);
} }

View File

@ -1473,9 +1473,12 @@ PERCONA_SCHEMA.xtrabackup_history and writes a new history record to the
table containing all the history info particular to the just completed table containing all the history info particular to the just completed
backup. */ backup. */
bool bool
write_xtrabackup_info(MYSQL *connection, const char * filename, bool history) write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
bool stream)
{ {
bool result = true;
FILE *fp = NULL;
char *uuid = NULL; char *uuid = NULL;
char *server_version = NULL; char *server_version = NULL;
char buf_start_time[100]; char buf_start_time[100];
@ -1501,7 +1504,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
|| xtrabackup_databases_exclude || xtrabackup_databases_exclude
); );
backup_file_printf(filename, char *buf = NULL;
int buf_len = asprintf(&buf,
"uuid = %s\n" "uuid = %s\n"
"name = %s\n" "name = %s\n"
"tool_name = %s\n" "tool_name = %s\n"
@ -1513,8 +1517,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
"end_time = %s\n" "end_time = %s\n"
"lock_time = %d\n" "lock_time = %d\n"
"binlog_pos = %s\n" "binlog_pos = %s\n"
"innodb_from_lsn = %llu\n" "innodb_from_lsn = " LSN_PF "\n"
"innodb_to_lsn = %llu\n" "innodb_to_lsn = " LSN_PF "\n"
"partial = %s\n" "partial = %s\n"
"incremental = %s\n" "incremental = %s\n"
"format = %s\n" "format = %s\n"
@ -1531,12 +1535,34 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
(int)history_lock_time, /* lock_time */ (int)history_lock_time, /* lock_time */
mysql_binlog_position ? mysql_binlog_position ?
mysql_binlog_position : "", /* binlog_pos */ mysql_binlog_position : "", /* binlog_pos */
incremental_lsn, /* innodb_from_lsn */ incremental_lsn,
metadata_to_lsn, /* innodb_to_lsn */ /* innodb_from_lsn */
metadata_to_lsn,
/* innodb_to_lsn */
is_partial? "Y" : "N", is_partial? "Y" : "N",
xtrabackup_incremental ? "Y" : "N", /* incremental */ xtrabackup_incremental ? "Y" : "N", /* incremental */
xb_stream_name[xtrabackup_stream_fmt], /* format */ xb_stream_name[xtrabackup_stream_fmt], /* format */
xtrabackup_compress ? "compressed" : "N"); /* compressed */ xtrabackup_compress ? "compressed" : "N"); /* compressed */
if (buf_len < 0) {
msg("Error: cannot generate xtrabackup_info");
result = false;
goto cleanup;
}
if (stream) {
backup_file_printf(filename, "%s", buf);
} else {
fp = fopen(filename, "w");
if (!fp) {
msg("Error: cannot open %s", filename);
result = false;
goto cleanup;
}
if (fwrite(buf, buf_len, 1, fp) < 1) {
result = false;
goto cleanup;
}
}
if (!history) { if (!history) {
goto cleanup; goto cleanup;
@ -1598,8 +1624,11 @@ cleanup:
free(uuid); free(uuid);
free(server_version); free(server_version);
free(buf);
if (fp)
fclose(fp);
return(true); return(result);
} }
extern const char *innodb_checksum_algorithm_names[]; extern const char *innodb_checksum_algorithm_names[];

View File

@ -68,7 +68,8 @@ bool
write_binlog_info(MYSQL *connection); write_binlog_info(MYSQL *connection);
bool bool
write_xtrabackup_info(MYSQL *connection, const char * filename, bool history); write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
bool stream);
bool bool
write_backup_config_file(); write_backup_config_file();

View File

@ -3966,7 +3966,7 @@ static bool xtrabackup_backup_low()
} }
sprintf(filename, "%s/%s", xtrabackup_extra_lsndir, sprintf(filename, "%s/%s", xtrabackup_extra_lsndir,
XTRABACKUP_INFO); XTRABACKUP_INFO);
if (!write_xtrabackup_info(mysql_connection, filename, false)) { if (!write_xtrabackup_info(mysql_connection, filename, false, false)) {
msg("Error: failed to write info " msg("Error: failed to write info "
"to '%s'.", filename); "to '%s'.", filename);
return false; return false;

View File

@ -38,9 +38,9 @@ DROP SERVER server_1;
CREATE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'Remote', HOST 'Server.Example.Com', DATABASE 'test'); CREATE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'Remote', HOST 'Server.Example.Com', DATABASE 'test');
SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1'; SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1';
Host Host
server.example.com Server.Example.Com
ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org'); ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org');
SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1'; SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1';
Host Host
server.example.org Server.Example.Org
DROP SERVER server_1; DROP SERVER server_1;

View File

@ -2119,12 +2119,12 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index
explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 102 94.12 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 102 94.12 Using where; Using index
Warnings: Warnings:
Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
create table t4 as select distinct a1, a2, b, c from t1; create table t4 as select distinct a1, a2, b, c from t1;

View File

@ -679,7 +679,7 @@ EXPLAIN
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c; HAVING t1.c != 5 ORDER BY t1.c;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using filesort 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort
1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where 1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c; HAVING t1.c != 5 ORDER BY t1.c;
@ -690,7 +690,7 @@ EXPLAIN
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c; HAVING t1.c != 5 ORDER BY t1.c;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using filesort 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort
1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where 1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c; HAVING t1.c != 5 ORDER BY t1.c;

View File

@ -49,6 +49,32 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using sort_union(key1,key2); Using where 1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using sort_union(key1,key2); Using where
drop table t0, t1; drop table t0, t1;
# #
# MDEV-18094: Query with order by limit picking index scan over filesort
#
create table t0 (a int);
INSERT INTO t0 VALUES (0),(0),(0),(0),(2),(0),(0),(1),(1),(0);
CREATE TABLE t1 (
a int(11),
b int(11),
c int(11),
KEY a_c (a,c),
KEY a_b (a,b)
) ENGINE=InnoDB;
insert into t1 select A.a , B.a, C.a from t0 A, t0 B, t0 C;
# should use ref access
explain select a,b,c from t1 where a=1 and c=2 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a_c,a_b a_c 10 const,const 20 Using where; Using filesort
# both should use range access
explain select a,b,c from t1 where a=1 and c=2 order by b limit 1000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a_c,a_b a_b 5 NULL 200 Using where
explain select a,b,c from t1 where a=1 and c=2 order by b limit 2000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a_c,a_b a_b 5 NULL 200 Using where
drop table t1,t0;
# Start of 10.2 tests
#
# MDEV-14071: wrong results with orderby_uses_equalities=on # MDEV-14071: wrong results with orderby_uses_equalities=on
# (duplicate of MDEV-13994) # (duplicate of MDEV-13994)
# #
@ -121,3 +147,4 @@ i n
656 eight 656 eight
set optimizer_switch= @save_optimizer_switch; set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
# End of 10.2 tests

View File

@ -62,6 +62,32 @@ where key1<3 or key2<3;
drop table t0, t1; drop table t0, t1;
--echo #
--echo # MDEV-18094: Query with order by limit picking index scan over filesort
--echo #
create table t0 (a int);
INSERT INTO t0 VALUES (0),(0),(0),(0),(2),(0),(0),(1),(1),(0);
CREATE TABLE t1 (
a int(11),
b int(11),
c int(11),
KEY a_c (a,c),
KEY a_b (a,b)
) ENGINE=InnoDB;
insert into t1 select A.a , B.a, C.a from t0 A, t0 B, t0 C;
--echo # should use ref access
explain select a,b,c from t1 where a=1 and c=2 order by b;
--echo # both should use range access
explain select a,b,c from t1 where a=1 and c=2 order by b limit 1000;
explain select a,b,c from t1 where a=1 and c=2 order by b limit 2000;
drop table t1,t0;
--echo # Start of 10.2 tests
--echo # --echo #
--echo # MDEV-14071: wrong results with orderby_uses_equalities=on --echo # MDEV-14071: wrong results with orderby_uses_equalities=on
--echo # (duplicate of MDEV-13994) --echo # (duplicate of MDEV-13994)
@ -108,3 +134,5 @@ eval $q2;
set optimizer_switch= @save_optimizer_switch; set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
--echo # End of 10.2 tests

View File

@ -1795,7 +1795,7 @@ SELECT * FROM t1 FORCE KEY (state,capital)
WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9 WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas'; OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range state,capital state 71 NULL 12 Using index condition; Using where 1 SIMPLE t1 range state,capital state 71 NULL 8 Using index condition; Using where
SELECT * FROM t1 FORCE KEY (state,capital) SELECT * FROM t1 FORCE KEY (state,capital)
WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9 WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas'; OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';

View File

@ -1796,7 +1796,7 @@ SELECT * FROM t1 FORCE KEY (state,capital)
WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9 WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas'; OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range state,capital state 71 NULL 12 Using index condition; Using where 1 SIMPLE t1 range state,capital state 71 NULL 8 Using index condition; Using where
SELECT * FROM t1 FORCE KEY (state,capital) SELECT * FROM t1 FORCE KEY (state,capital)
WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9 WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas'; OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';

View File

@ -1673,5 +1673,90 @@ drop table t1;
set use_stat_tables= @save_use_stat_tables; set use_stat_tables= @save_use_stat_tables;
set @@histogram_size=@save_histogram_size; set @@histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
#
# MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1)
#
set @@optimizer_use_condition_selectivity=2;
set names utf8;
CREATE DATABASE world;
use world;
CREATE TABLE Country (
Code char(3) NOT NULL default '',
Name char(52) NOT NULL default '',
SurfaceArea float(10,2) NOT NULL default '0.00',
Population int(11) NOT NULL default '0',
Capital int(11) default NULL,
PRIMARY KEY (Code),
UNIQUE INDEX (Name)
);
CREATE TABLE City (
ID int(11) NOT NULL auto_increment,
Name char(35) NOT NULL default '',
Country char(3) NOT NULL default '',
Population int(11) NOT NULL default '0',
PRIMARY KEY (ID),
INDEX (Population),
INDEX (Country)
);
CREATE TABLE CountryLanguage (
Country char(3) NOT NULL default '',
Language char(30) NOT NULL default '',
Percentage float(3,1) NOT NULL default '0.0',
PRIMARY KEY (Country, Language),
INDEX (Percentage)
);
CREATE INDEX Name ON City(Name);
CREATE INDEX CountryPopulation ON City(Country,Population);
CREATE INDEX CountryName ON City(Country,Name);
set @@optimizer_use_condition_selectivity=2;
EXPLAIN
SELECT * FROM City WHERE Country='FIN';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City ref Country,CountryPopulation,CountryName CountryName 3 const 5 Using index condition
DROP DATABASE world;
use test;
CREATE TABLE t1 (
a INT,
b INT NOT NULL,
c char(100),
KEY (b, c),
KEY (b, a, c)
) ENGINE=MyISAM
DEFAULT CHARSET = utf8;
INSERT INTO t1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9);
INSERT INTO t1 SELECT a + 10, b, c FROM t1;
INSERT INTO t1 SELECT a + 20, b, c FROM t1;
INSERT INTO t1 SELECT a + 40, b, c FROM t1;
INSERT INTO t1 SELECT a + 80, b, c FROM t1;
INSERT INTO t1 SELECT a + 160, b, c FROM t1;
INSERT INTO t1 SELECT a + 320, b, c FROM t1;
INSERT INTO t1 SELECT a + 640, b, c FROM t1;
INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80;
EXPLAIN
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
a
2071
2061
2051
2041
2031
2021
2011
2001
1991
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1;
# End of 10.1 tests # End of 10.1 tests
set @@global.histogram_size=@save_histogram_size; set @@global.histogram_size=@save_histogram_size;

View File

@ -1130,6 +1130,87 @@ drop table t1;
set use_stat_tables= @save_use_stat_tables; set use_stat_tables= @save_use_stat_tables;
set @@histogram_size=@save_histogram_size; set @@histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
--echo #
--echo # MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1)
--echo #
set @@optimizer_use_condition_selectivity=2;
set names utf8;
CREATE DATABASE world;
use world;
--source include/world_schema.inc
--disable_query_log
--disable_result_log
--disable_warnings
--source include/world.inc
--enable_warnings
--enable_result_log
--enable_query_log
CREATE INDEX Name ON City(Name);
CREATE INDEX CountryPopulation ON City(Country,Population);
CREATE INDEX CountryName ON City(Country,Name);
--disable_query_log
--disable_result_log
--disable_warnings
ANALYZE TABLE City;
--enable_warnings
--enable_result_log
--enable_query_log
set @@optimizer_use_condition_selectivity=2;
EXPLAIN
SELECT * FROM City WHERE Country='FIN';
DROP DATABASE world;
use test;
CREATE TABLE t1 (
a INT,
b INT NOT NULL,
c char(100),
KEY (b, c),
KEY (b, a, c)
) ENGINE=MyISAM
DEFAULT CHARSET = utf8;
INSERT INTO t1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9);
INSERT INTO t1 SELECT a + 10, b, c FROM t1;
INSERT INTO t1 SELECT a + 20, b, c FROM t1;
INSERT INTO t1 SELECT a + 40, b, c FROM t1;
INSERT INTO t1 SELECT a + 80, b, c FROM t1;
INSERT INTO t1 SELECT a + 160, b, c FROM t1;
INSERT INTO t1 SELECT a + 320, b, c FROM t1;
INSERT INTO t1 SELECT a + 640, b, c FROM t1;
INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80;
EXPLAIN
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1;
--echo # End of 10.1 tests --echo # End of 10.1 tests
# #

View File

@ -1683,6 +1683,91 @@ drop table t1;
set use_stat_tables= @save_use_stat_tables; set use_stat_tables= @save_use_stat_tables;
set @@histogram_size=@save_histogram_size; set @@histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
#
# MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1)
#
set @@optimizer_use_condition_selectivity=2;
set names utf8;
CREATE DATABASE world;
use world;
CREATE TABLE Country (
Code char(3) NOT NULL default '',
Name char(52) NOT NULL default '',
SurfaceArea float(10,2) NOT NULL default '0.00',
Population int(11) NOT NULL default '0',
Capital int(11) default NULL,
PRIMARY KEY (Code),
UNIQUE INDEX (Name)
);
CREATE TABLE City (
ID int(11) NOT NULL auto_increment,
Name char(35) NOT NULL default '',
Country char(3) NOT NULL default '',
Population int(11) NOT NULL default '0',
PRIMARY KEY (ID),
INDEX (Population),
INDEX (Country)
);
CREATE TABLE CountryLanguage (
Country char(3) NOT NULL default '',
Language char(30) NOT NULL default '',
Percentage float(3,1) NOT NULL default '0.0',
PRIMARY KEY (Country, Language),
INDEX (Percentage)
);
CREATE INDEX Name ON City(Name);
CREATE INDEX CountryPopulation ON City(Country,Population);
CREATE INDEX CountryName ON City(Country,Name);
set @@optimizer_use_condition_selectivity=2;
EXPLAIN
SELECT * FROM City WHERE Country='FIN';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City ref Country,CountryPopulation,CountryName Country 3 const 7 Using index condition
DROP DATABASE world;
use test;
CREATE TABLE t1 (
a INT,
b INT NOT NULL,
c char(100),
KEY (b, c),
KEY (b, a, c)
) ENGINE=MyISAM
DEFAULT CHARSET = utf8;
INSERT INTO t1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9);
INSERT INTO t1 SELECT a + 10, b, c FROM t1;
INSERT INTO t1 SELECT a + 20, b, c FROM t1;
INSERT INTO t1 SELECT a + 40, b, c FROM t1;
INSERT INTO t1 SELECT a + 80, b, c FROM t1;
INSERT INTO t1 SELECT a + 160, b, c FROM t1;
INSERT INTO t1 SELECT a + 320, b, c FROM t1;
INSERT INTO t1 SELECT a + 640, b, c FROM t1;
INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80;
EXPLAIN
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
a
2071
2061
2051
2041
2031
2021
2011
2001
1991
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1;
# End of 10.1 tests # End of 10.1 tests
set @@global.histogram_size=@save_histogram_size; set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test; set optimizer_switch=@save_optimizer_switch_for_selectivity_test;

View File

@ -797,9 +797,33 @@ col1
2004-01-01 2004-01-01
2004-02-29 2004-02-29
0000-10-31 0000-10-31
drop table t1;
set @@sql_mode= @save_sql_mode; set @@sql_mode= @save_sql_mode;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
set @@histogram_size= @save_histogram_size; set @@histogram_size= @save_histogram_size;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
#
# MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value
#
set names utf8;
create table t1 ( a varchar(255) character set utf8);
insert into t1 values (REPEAT('ӥ',255)), (REPEAT('ç',255));
set use_stat_tables='preferably';
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
set @save_sql_mode= @@sql_mode;
set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
update mysql.column_stats set min_value= REPEAT('ӥ',256) where db_name='test' and table_name='t1';
Warnings:
Warning 1265 Data truncated for column 'min_value' at row 1
set @@sql_mode= @save_sql_mode;
select length(a) from t1 where a=REPEAT('ӥ',255);
length(a)
510
set names latin1;
set @@use_stat_tables=@save_use_stat_tables;
drop table t1;
# please keep this at the last
set @@global.histogram_size=@save_histogram_size; set @@global.histogram_size=@save_histogram_size;

View File

@ -540,10 +540,33 @@ analyze table t1;
update mysql.column_stats set min_value='2004-0-31123' where db_name='test' and table_name='t1'; update mysql.column_stats set min_value='2004-0-31123' where db_name='test' and table_name='t1';
select min_value from mysql.column_stats where db_name='test' and table_name='t1'; select min_value from mysql.column_stats where db_name='test' and table_name='t1';
select * from t1; select * from t1;
drop table t1;
set @@sql_mode= @save_sql_mode; set @@sql_mode= @save_sql_mode;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
set @@histogram_size= @save_histogram_size; set @@histogram_size= @save_histogram_size;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
--echo #
--echo # MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value
--echo #
set names utf8;
create table t1 ( a varchar(255) character set utf8);
insert into t1 values (REPEAT('ӥ',255)), (REPEAT('ç',255));
set use_stat_tables='preferably';
analyze table t1 persistent for all;
set @save_sql_mode= @@sql_mode;
set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
update mysql.column_stats set min_value= REPEAT('ӥ',256) where db_name='test' and table_name='t1';
set @@sql_mode= @save_sql_mode;
select length(a) from t1 where a=REPEAT('ӥ',255);
set names latin1;
set @@use_stat_tables=@save_use_stat_tables;
drop table t1;
--echo # please keep this at the last
set @@global.histogram_size=@save_histogram_size; set @@global.histogram_size=@save_histogram_size;

View File

@ -824,11 +824,35 @@ col1
2004-01-01 2004-01-01
2004-02-29 2004-02-29
0000-10-31 0000-10-31
drop table t1;
set @@sql_mode= @save_sql_mode; set @@sql_mode= @save_sql_mode;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
set @@histogram_size= @save_histogram_size; set @@histogram_size= @save_histogram_size;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
#
# MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value
#
set names utf8;
create table t1 ( a varchar(255) character set utf8);
insert into t1 values (REPEAT('ӥ',255)), (REPEAT('ç',255));
set use_stat_tables='preferably';
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
set @save_sql_mode= @@sql_mode;
set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
update mysql.column_stats set min_value= REPEAT('ӥ',256) where db_name='test' and table_name='t1';
Warnings:
Warning 1265 Data truncated for column 'min_value' at row 1
set @@sql_mode= @save_sql_mode;
select length(a) from t1 where a=REPEAT('ӥ',255);
length(a)
510
set names latin1;
set @@use_stat_tables=@save_use_stat_tables;
drop table t1;
# please keep this at the last
set @@global.histogram_size=@save_histogram_size; set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_stat_tables_test; set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
SET SESSION STORAGE_ENGINE=DEFAULT; SET SESSION STORAGE_ENGINE=DEFAULT;

View File

@ -190,14 +190,14 @@ show create table servers;
Table Create Table Table Create Table
servers CREATE TABLE `servers` ( servers CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL DEFAULT '', `Server_name` char(64) NOT NULL DEFAULT '',
`Host` char(64) NOT NULL DEFAULT '', `Host` varchar(2048) NOT NULL DEFAULT '',
`Db` char(64) NOT NULL DEFAULT '', `Db` char(64) NOT NULL DEFAULT '',
`Username` char(80) NOT NULL DEFAULT '', `Username` char(80) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '', `Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0, `Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '', `Socket` char(64) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '', `Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` char(64) NOT NULL DEFAULT '', `Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`) PRIMARY KEY (`Server_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table'
show create table proc; show create table proc;

View File

@ -190,14 +190,14 @@ show create table servers;
Table Create Table Table Create Table
servers CREATE TABLE `servers` ( servers CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL DEFAULT '', `Server_name` char(64) NOT NULL DEFAULT '',
`Host` char(64) NOT NULL DEFAULT '', `Host` varchar(2048) NOT NULL DEFAULT '',
`Db` char(64) NOT NULL DEFAULT '', `Db` char(64) NOT NULL DEFAULT '',
`Username` char(80) NOT NULL DEFAULT '', `Username` char(80) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '', `Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0, `Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '', `Socket` char(64) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '', `Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` char(64) NOT NULL DEFAULT '', `Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`) PRIMARY KEY (`Server_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table'
show create table proc; show create table proc;

View File

@ -12,4 +12,3 @@
innodb_scrub : MDEV-8139 scrubbing does not work reliably innodb_scrub : MDEV-8139 scrubbing does not work reliably
innodb_scrub_background : MDEV-8139 scrubbing does not work reliably innodb_scrub_background : MDEV-8139 scrubbing does not work reliably
innodb-redo-badkey : MDEV-13893/MDEV-12699 fix recovery of corrupted pages

View File

@ -175,8 +175,8 @@ def mysql roles_mapping Host 1 '' NO char 60 180 NULL NULL NULL utf8 utf8_bin ch
def mysql roles_mapping Role 3 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI select,insert,update,references NEVER NULL def mysql roles_mapping Role 3 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI select,insert,update,references NEVER NULL
def mysql roles_mapping User 2 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI select,insert,update,references NEVER NULL def mysql roles_mapping User 2 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI select,insert,update,references NEVER NULL
def mysql servers Db 3 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL def mysql servers Db 3 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL
def mysql servers Host 2 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL def mysql servers Host 2 '' NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) select,insert,update,references NEVER NULL
def mysql servers Owner 9 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL def mysql servers Owner 9 '' NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select,insert,update,references NEVER NULL
def mysql servers Password 5 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL def mysql servers Password 5 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL
def mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) select,insert,update,references NEVER NULL def mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) select,insert,update,references NEVER NULL
def mysql servers Server_name 1 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NEVER NULL def mysql servers Server_name 1 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NEVER NULL
@ -518,14 +518,14 @@ NULL mysql proxies_priv Timestamp timestamp NULL NULL NULL NULL timestamp
3.0000 mysql roles_mapping Role char 80 240 utf8 utf8_bin char(80) 3.0000 mysql roles_mapping Role char 80 240 utf8 utf8_bin char(80)
3.0000 mysql roles_mapping Admin_option enum 1 3 utf8 utf8_general_ci enum('N','Y') 3.0000 mysql roles_mapping Admin_option enum 1 3 utf8 utf8_general_ci enum('N','Y')
3.0000 mysql servers Server_name char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Server_name char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Host char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Host varchar 2048 6144 utf8 utf8_general_ci varchar(2048)
3.0000 mysql servers Db char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Db char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Username char 80 240 utf8 utf8_general_ci char(80) 3.0000 mysql servers Username char 80 240 utf8 utf8_general_ci char(80)
3.0000 mysql servers Password char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Password char 64 192 utf8 utf8_general_ci char(64)
NULL mysql servers Port int NULL NULL NULL NULL int(4) NULL mysql servers Port int NULL NULL NULL NULL int(4)
3.0000 mysql servers Socket char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Socket char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Wrapper char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Wrapper char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Owner char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Owner varchar 512 1536 utf8 utf8_general_ci varchar(512)
NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6) NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6)
1.0000 mysql slow_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext 1.0000 mysql slow_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext
NULL mysql slow_log query_time time NULL NULL NULL NULL time(6) NULL mysql slow_log query_time time NULL NULL NULL NULL time(6)

View File

@ -161,8 +161,8 @@ def mysql roles_mapping Host 1 '' NO char 60 180 NULL NULL NULL utf8 utf8_bin ch
def mysql roles_mapping Role 3 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI NEVER NULL def mysql roles_mapping Role 3 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI NEVER NULL
def mysql roles_mapping User 2 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI NEVER NULL def mysql roles_mapping User 2 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI NEVER NULL
def mysql servers Db 3 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL def mysql servers Db 3 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL
def mysql servers Host 2 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL def mysql servers Host 2 '' NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) NEVER NULL
def mysql servers Owner 9 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL def mysql servers Owner 9 '' NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) NEVER NULL
def mysql servers Password 5 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL def mysql servers Password 5 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL
def mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) NEVER NULL def mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) NEVER NULL
def mysql servers Server_name 1 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI NEVER NULL def mysql servers Server_name 1 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI NEVER NULL
@ -501,14 +501,14 @@ NULL mysql proxies_priv Timestamp timestamp NULL NULL NULL NULL timestamp
3.0000 mysql roles_mapping Role char 80 240 utf8 utf8_bin char(80) 3.0000 mysql roles_mapping Role char 80 240 utf8 utf8_bin char(80)
3.0000 mysql roles_mapping Admin_option enum 1 3 utf8 utf8_general_ci enum('N','Y') 3.0000 mysql roles_mapping Admin_option enum 1 3 utf8 utf8_general_ci enum('N','Y')
3.0000 mysql servers Server_name char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Server_name char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Host char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Host varchar 2048 6144 utf8 utf8_general_ci varchar(2048)
3.0000 mysql servers Db char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Db char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Username char 80 240 utf8 utf8_general_ci char(80) 3.0000 mysql servers Username char 80 240 utf8 utf8_general_ci char(80)
3.0000 mysql servers Password char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Password char 64 192 utf8 utf8_general_ci char(64)
NULL mysql servers Port int NULL NULL NULL NULL int(4) NULL mysql servers Port int NULL NULL NULL NULL int(4)
3.0000 mysql servers Socket char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Socket char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Wrapper char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Wrapper char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Owner char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Owner varchar 512 1536 utf8 utf8_general_ci varchar(512)
NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6) NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6)
1.0000 mysql slow_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext 1.0000 mysql slow_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext
NULL mysql slow_log query_time time NULL NULL NULL NULL time(6) NULL mysql slow_log query_time time NULL NULL NULL NULL time(6)

View File

@ -516,7 +516,7 @@ TABLE_NAME servers
TABLE_TYPE BASE TABLE TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA ENGINE MYISAM_OR_MARIA
VERSION 10 VERSION 10
ROW_FORMAT Fixed ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR# TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL# AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL# DATA_LENGTH #DL#

View File

@ -516,7 +516,7 @@ TABLE_NAME servers
TABLE_TYPE BASE TABLE TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA ENGINE MYISAM_OR_MARIA
VERSION 10 VERSION 10
ROW_FORMAT Fixed ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR# TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL# AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL# DATA_LENGTH #DL#
@ -1305,7 +1305,7 @@ TABLE_NAME servers
TABLE_TYPE BASE TABLE TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA ENGINE MYISAM_OR_MARIA
VERSION 10 VERSION 10
ROW_FORMAT Fixed ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR# TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL# AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL# DATA_LENGTH #DL#

View File

@ -10,7 +10,6 @@
# #
############################################################################## ##############################################################################
MW-286 : MDEV-19992 Galera test failure on MW-286
MW-329 : MDEV-19962 Galera test failure on MW-329 MW-329 : MDEV-19962 Galera test failure on MW-329
MW-388: MDEV-19803 Long semaphore wait error on galera.MW-388 MW-388: MDEV-19803 Long semaphore wait error on galera.MW-388
galera_account_management : MariaDB 10.0 does not support ALTER USER galera_account_management : MariaDB 10.0 does not support ALTER USER
@ -26,7 +25,7 @@ galera_ist_mariabackup : MDEV-18829 test leaves port open
galera_ist_progress : MDEV-15236 fails when trying to read transfer status galera_ist_progress : MDEV-15236 fails when trying to read transfer status
galera_migrate : MariaDB does not support START SLAVE USER galera_migrate : MariaDB does not support START SLAVE USER
galera_ssl_upgrade : MDEV-19950 Galera test failure on galera_ssl_upgrade galera_ssl_upgrade : MDEV-19950 Galera test failure on galera_ssl_upgrade
galera_var_node_address : MDEV-20485 Galera test failure on galera.galera_var_node_address galera_var_node_address : MDEV-20485 Galera test failure
galera_wan : MDEV-17259 Test failure on galera.galera_wan galera_wan : MDEV-17259 Test failure on galera.galera_wan
partition : MDEV-19958 Galera test failure on galera.partition partition : MDEV-19958 Galera test failure on galera.partition
query_cache: MDEV-15805 Test failure on galera.query_cache query_cache: MDEV-15805 Test failure on galera.query_cache

View File

@ -6,10 +6,6 @@ SET GLOBAL wsrep_slave_threads = 1;
connection node_2; connection node_2;
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
connection node_1; connection node_1;
SET SESSION wsrep_sync_wait=15;
SELECT COUNT(*) FROM t1;
COUNT(*)
1
SET GLOBAL wsrep_slave_threads = 10; SET GLOBAL wsrep_slave_threads = 10;
# Set slave threads to 10 step 2 # Set slave threads to 10 step 2
SET GLOBAL wsrep_slave_threads = 20; SET GLOBAL wsrep_slave_threads = 20;
@ -43,9 +39,11 @@ INSERT INTO t1 VALUES (17);
INSERT INTO t1 VALUES (18); INSERT INTO t1 VALUES (18);
INSERT INTO t1 VALUES (19); INSERT INTO t1 VALUES (19);
INSERT INTO t1 VALUES (20); INSERT INTO t1 VALUES (20);
INSERT INTO t1 VALUES (21);
INSERT INTO t1 VALUES (22);
connection node_1; connection node_1;
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)
21 23
SET GLOBAL wsrep_slave_threads = 1; SET GLOBAL wsrep_slave_threads = 1;
DROP TABLE t1; DROP TABLE t1;

View File

@ -0,0 +1,9 @@
connection node_1;
connection node_2;
connection node_1;
SET GLOBAL wsrep_provider_options = 'pc.weight=2';
connection node_2;
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1';
SET SESSION wsrep_sync_wait = 0;
connection node_1;
SET GLOBAL wsrep_provider_options = 'pc.weight = 1';

View File

@ -13,7 +13,7 @@ SET GLOBAL wsrep_slave_threads = 10;
# ensure that the threads have actually started running # ensure that the threads have actually started running
--echo # Set slave threads to 10 step 1 --echo # Set slave threads to 10 step 1
--let $wait_condition = SELECT COUNT(*) = 10 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; --let $wait_condition = SELECT VARIABLE_VALUE = 10 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
--let $wait_condition_on_error_output = SELECT COUNT(*), 10 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist --let $wait_condition_on_error_output = SELECT COUNT(*), 10 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist
--source include/wait_condition_with_debug.inc --source include/wait_condition_with_debug.inc
@ -23,20 +23,18 @@ SET GLOBAL wsrep_slave_threads = 1;
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
--connection node_1 --connection node_1
SET SESSION wsrep_sync_wait=15;
SELECT COUNT(*) FROM t1;
SET GLOBAL wsrep_slave_threads = 10; SET GLOBAL wsrep_slave_threads = 10;
# Note that above insert could be handled by one of the slave threads
--echo # Set slave threads to 10 step 2 --echo # Set slave threads to 10 step 2
--let $wait_condition = SELECT COUNT(*) = 10 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; --let $wait_condition = SELECT VARIABLE_VALUE >= 9 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
--let $wait_condition_on_error_output = SELECT COUNT(*), 10 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist --let $wait_condition_on_error_output = SELECT COUNT(*), 9 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist
--source include/wait_condition_with_debug.inc --source include/wait_condition_with_debug.inc
SET GLOBAL wsrep_slave_threads = 20; SET GLOBAL wsrep_slave_threads = 20;
--echo # Set slave threads to 20 --echo # Set slave threads to 20
--let $wait_condition = SELECT COUNT(*) = 20 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; --let $wait_condition = SELECT VARIABLE_VALUE = 20 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
--let $wait_condition_on_error_output = SELECT COUNT(*), 20 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist --let $wait_condition_on_error_output = SELECT COUNT(*), 20 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist
--source include/wait_condition_with_debug.inc --source include/wait_condition_with_debug.inc
@ -58,7 +56,7 @@ INSERT INTO t1 VALUES (10);
SET GLOBAL wsrep_slave_threads = 10; SET GLOBAL wsrep_slave_threads = 10;
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
--echo # Set slave threads to 10 step 3 --echo # Set slave threads to 10 step 3
--let $wait_condition = SELECT COUNT(*) = 10 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; --let $wait_condition = SELECT VARIABLE_VALUE = 10 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
--let $wait_condition_on_error_output = SELECT COUNT(*), 10 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist --let $wait_condition_on_error_output = SELECT COUNT(*), 10 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist
--source include/wait_condition_with_debug.inc --source include/wait_condition_with_debug.inc
@ -73,6 +71,8 @@ INSERT INTO t1 VALUES (17);
INSERT INTO t1 VALUES (18); INSERT INTO t1 VALUES (18);
INSERT INTO t1 VALUES (19); INSERT INTO t1 VALUES (19);
INSERT INTO t1 VALUES (20); INSERT INTO t1 VALUES (20);
INSERT INTO t1 VALUES (21);
INSERT INTO t1 VALUES (22);
--connection node_1 --connection node_1
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;

View File

@ -0,0 +1,36 @@
#
# Check that server can be shut down in non-primary configuration.
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let $node_1 = node_1
--let $node_2 = node_2
--source include/auto_increment_offset_save.inc
--connection node_1
# Set higher weight for node_1 to keep it in primary
# while node_2 is isolated.
SET GLOBAL wsrep_provider_options = 'pc.weight=2';
--connection node_2
# Isolate node_2 from the group and wait until wsrep_ready becomes OFF.
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1';
SET SESSION wsrep_sync_wait = 0;
--let $wait_condition = SELECT VARIABLE_VALUE = 'OFF' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'
--source include/wait_condition.inc
# Verify that graceful shutdown succeeds.
--source include/shutdown_mysqld.inc
--source include/start_mysqld.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
--connection node_1
--source include/wait_condition.inc
# Restore original settings.
SET GLOBAL wsrep_provider_options = 'pc.weight = 1';
--source include/auto_increment_offset_restore.inc

View File

@ -204,5 +204,32 @@ connection truncate;
disconnect truncate; disconnect truncate;
connection default; connection default;
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf
# on table with virtual columns and indexes
#
set @saved_dbug= @@global.debug_dbug;
set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2";
create table t1 (
pk serial, vb tinyblob as (b) virtual, b tinyblob,
primary key(pk), index (vb(64)))
engine innodb;
insert ignore into t1 (b) values ('foo');
select * into outfile 'load.data' from t1;
load data infile 'load.data' replace into table t1;
set debug_sync= "now WAIT_FOR latch_released";
set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1";
drop table t1;
set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table";
create table t1 (
pk serial, vb tinyblob as (b) virtual, b tinyblob,
primary key(pk), index (vb(64)))
engine innodb;
insert ignore into t1 (b) values ('foo');
select * into outfile 'load.data' from t1;
load data infile 'load.data' replace into table t1;
set debug_sync= "now WAIT_FOR got_no_such_table";
set global debug_dbug= @saved_dbug;
drop table t1;
set debug_sync=reset; set debug_sync=reset;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;

View File

@ -259,6 +259,54 @@ disconnect truncate;
connection default; connection default;
DROP TABLE t1, t2; DROP TABLE t1, t2;
--echo #
--echo # MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf
--echo # on table with virtual columns and indexes
--echo #
--let $datadir= `select @@datadir`
set @saved_dbug= @@global.debug_dbug;
set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2";
create table t1 (
pk serial, vb tinyblob as (b) virtual, b tinyblob,
primary key(pk), index (vb(64)))
engine innodb;
insert ignore into t1 (b) values ('foo');
select * into outfile 'load.data' from t1;
load data infile 'load.data' replace into table t1;
set debug_sync= "now WAIT_FOR latch_released";
set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1";
drop table t1;
--remove_file $datadir/test/load.data
set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table";
create table t1 (
pk serial, vb tinyblob as (b) virtual, b tinyblob,
primary key(pk), index (vb(64)))
engine innodb;
insert ignore into t1 (b) values ('foo');
select * into outfile 'load.data' from t1;
load data infile 'load.data' replace into table t1;
set debug_sync= "now WAIT_FOR got_no_such_table";
# FIXME: Race condition here:
# 1. purge thread goes into sending got_no_such_table
# 2. test thread finishes debug_sync= "RESET" below
# 3. purge thread sends got_no_such_table
set global debug_dbug= @saved_dbug;
# cleanup
drop table t1;
--remove_file $datadir/test/load.data
--source include/wait_until_count_sessions.inc --source include/wait_until_count_sessions.inc
set debug_sync=reset; set debug_sync=reset;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;

View File

@ -29,7 +29,7 @@ connection default;
# DELETE must not affect statistics before COMMIT. # DELETE must not affect statistics before COMMIT.
EXPLAIN SELECT * FROM t1 WHERE val=4; EXPLAIN SELECT * FROM t1 WHERE val=4;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref val val 4 const 16 Using index 1 SIMPLE t1 ref val val 4 const 1 Using index
connection con1; connection con1;
COUNT(*) COUNT(*)
0 0

View File

@ -1,30 +0,0 @@
#
# MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf on table with virtual columns and indexes
#
set @saved_frequency= @@global.innodb_purge_rseg_truncate_frequency;
set global innodb_purge_rseg_truncate_frequency= 1;
set @saved_dbug= @@global.debug_dbug;
set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2";
create table t1 (
pk serial, vb tinyblob as (b) virtual, b tinyblob,
primary key(pk), index (vb(64)))
engine innodb;
insert ignore into t1 (b) values ('foo');
select * into outfile 'load.data' from t1;
load data infile 'load.data' replace into table t1;
set debug_sync= "now WAIT_FOR latch_released";
set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1";
drop table t1;
set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table";
create table t1 (
pk serial, vb tinyblob as (b) virtual, b tinyblob,
primary key(pk), index (vb(64)))
engine innodb;
insert ignore into t1 (b) values ('foo');
select * into outfile 'load.data' from t1;
load data infile 'load.data' replace into table t1;
set debug_sync= "now WAIT_FOR got_no_such_table";
set global debug_dbug= @saved_dbug;
drop table t1;
set global innodb_purge_rseg_truncate_frequency= @saved_frequency;
set debug_sync= "RESET";

View File

@ -1,53 +0,0 @@
--source include/have_debug.inc
--source include/have_innodb.inc
--echo #
--echo # MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf on table with virtual columns and indexes
--echo #
--let $datadir= `select @@datadir`
set @saved_frequency= @@global.innodb_purge_rseg_truncate_frequency;
set global innodb_purge_rseg_truncate_frequency= 1;
set @saved_dbug= @@global.debug_dbug;
set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2";
create table t1 (
pk serial, vb tinyblob as (b) virtual, b tinyblob,
primary key(pk), index (vb(64)))
engine innodb;
insert ignore into t1 (b) values ('foo');
select * into outfile 'load.data' from t1;
load data infile 'load.data' replace into table t1;
set debug_sync= "now WAIT_FOR latch_released";
set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1";
drop table t1;
--remove_file $datadir/test/load.data
set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table";
create table t1 (
pk serial, vb tinyblob as (b) virtual, b tinyblob,
primary key(pk), index (vb(64)))
engine innodb;
insert ignore into t1 (b) values ('foo');
select * into outfile 'load.data' from t1;
load data infile 'load.data' replace into table t1;
set debug_sync= "now WAIT_FOR got_no_such_table";
# FIXME: Racing condition here:
# 1. purge thread goes into sending got_no_such_table
# 2. test thread finishes debug_sync= "RESET" below
# 3. purge thread sends got_no_such_table
set global debug_dbug= @saved_dbug;
# cleanup
drop table t1;
--remove_file $datadir/test/load.data
set global innodb_purge_rseg_truncate_frequency= @saved_frequency;
set debug_sync= "RESET";

View File

@ -9,3 +9,26 @@ disconnect dml;
connection default; connection default;
SET DEBUG_SYNC = 'RESET'; SET DEBUG_SYNC = 'RESET';
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-19529 InnoDB hang on DROP FULLTEXT INDEX
#
CREATE TABLE t1(f1 CHAR(100), FULLTEXT(f1))ENGINE=InnoDB;
INSERT INTO t1 VALUES('test');
CREATE TABLE t2 (f1 char(100), FULLTEXT idx1(f1))ENGINE=InnoDB;
INSERT INTO t2 VALUES('mariadb');
connection default;
SET GLOBAL debug_dbug ='+d,fts_instrument_sync_request,ib_optimize_wq_hang';
SET DEBUG_SYNC= 'fts_instrument_sync_request
SIGNAL drop_index_start WAIT_FOR sync_op';
INSERT INTO t1 VALUES('Keyword');
connect con1,localhost,root,,,;
SET DEBUG_SYNC='now WAIT_FOR drop_index_start';
SET DEBUG_SYNC= 'norebuild_fts_drop SIGNAL sync_op WAIT_FOR fts_drop_index';
ALTER TABLE t2 drop index idx1;
connection default;
set DEBUG_SYNC= 'now SIGNAL fts_drop_index';
connection con1;
SET global DEBUG_DBUG=RESET;
drop table t1, t2;
connection default;
set DEBUG_SYNC=RESET;

View File

@ -700,15 +700,21 @@ count(*)
DROP TABLE t1; DROP TABLE t1;
"----------Test27---------" "----------Test27---------"
CREATE TABLE t1 (id INT,char_column VARCHAR(60)); CREATE TABLE t1 (id INT,char_column VARCHAR(60));
CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB;
ALTER TABLE t2 DROP a;
SET @@autocommit=0; SET @@autocommit=0;
CREATE FULLTEXT INDEX i ON t1 (char_column); CREATE FULLTEXT INDEX i ON t1 (char_column);
INSERT INTO t1 values (1,'aaa'); INSERT INTO t1 values (1,'aaa');
"restart server..." "restart server..."
# Restart the server SHOW CREATE TABLE t2;
--source include/restart_mysqld.inc Table Create Table
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb') t2 CREATE TABLE `t2` (
`FTS_DOC_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`FTS_DOC_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
SET @@autocommit=1; SET @@autocommit=1;
DROP TABLE t1; DROP TABLE t1, t2;
"----------Test28---------" "----------Test28---------"
drop table if exists `fts_test`; drop table if exists `fts_test`;
Warnings: Warnings:

View File

@ -18,3 +18,34 @@ reap;
SET DEBUG_SYNC = 'RESET'; SET DEBUG_SYNC = 'RESET';
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-19529 InnoDB hang on DROP FULLTEXT INDEX
--echo #
CREATE TABLE t1(f1 CHAR(100), FULLTEXT(f1))ENGINE=InnoDB;
INSERT INTO t1 VALUES('test');
CREATE TABLE t2 (f1 char(100), FULLTEXT idx1(f1))ENGINE=InnoDB;
INSERT INTO t2 VALUES('mariadb');
connection default;
SET GLOBAL debug_dbug ='+d,fts_instrument_sync_request,ib_optimize_wq_hang';
SET DEBUG_SYNC= 'fts_instrument_sync_request
SIGNAL drop_index_start WAIT_FOR sync_op';
send INSERT INTO t1 VALUES('Keyword');
connect(con1,localhost,root,,,);
SET DEBUG_SYNC='now WAIT_FOR drop_index_start';
SET DEBUG_SYNC= 'norebuild_fts_drop SIGNAL sync_op WAIT_FOR fts_drop_index';
send ALTER TABLE t2 drop index idx1;
connection default;
reap;
set DEBUG_SYNC= 'now SIGNAL fts_drop_index';
connection con1;
reap;
SET global DEBUG_DBUG=RESET;
drop table t1, t2;
connection default;
set DEBUG_SYNC=RESET;

View File

@ -670,15 +670,18 @@ DROP TABLE t1;
--echo "----------Test27---------" --echo "----------Test27---------"
#27 Crash after server restart #27 Crash after server restart
CREATE TABLE t1 (id INT,char_column VARCHAR(60)); CREATE TABLE t1 (id INT,char_column VARCHAR(60));
CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB;
ALTER TABLE t2 DROP a;
SET @@autocommit=0; SET @@autocommit=0;
CREATE FULLTEXT INDEX i ON t1 (char_column); CREATE FULLTEXT INDEX i ON t1 (char_column);
INSERT INTO t1 values (1,'aaa'); INSERT INTO t1 values (1,'aaa');
echo "restart server..." echo "restart server...";
# Restart the server # Restart the server
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
SHOW CREATE TABLE t2;
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb'); DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
SET @@autocommit=1; SET @@autocommit=1;
DROP TABLE t1; DROP TABLE t1, t2;
--echo "----------Test28---------" --echo "----------Test28---------"
drop table if exists `fts_test`; drop table if exists `fts_test`;

View File

@ -167,7 +167,7 @@ WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC ORDER BY ts DESC
LIMIT 2; LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using where 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where
DROP TABLE t1; DROP TABLE t1;
# #

View File

@ -0,0 +1,2 @@
xtrabackup_checkpoints
xtrabackup_info

View File

@ -0,0 +1,7 @@
let $extra_lsndir=$MYSQLTEST_VARDIR/tmp/extra_lsndir;
mkdir $extra_lsndir;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --stream=xbstream --extra-lsndir=$extra_lsndir > /dev/null;
--enable_result_log
list_files $extra_lsndir;
rmdir $extra_lsndir;

View File

@ -0,0 +1 @@
stream.xb

View File

@ -0,0 +1,11 @@
let $basedir=$MYSQLTEST_VARDIR/tmp/mdev-18438;
mkdir $basedir;
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extra-lsndir=$basedir/extra_lsndir --stream=xbstream > $basedir/stream.xb;
mkdir $basedir/backup;
rmdir $basedir/extra_lsndir;
--disable_result_log
exec $XBSTREAM -x -C $basedir/backup < $basedir/stream.xb;
--enable_result_log
rmdir $basedir/backup;
list_files $basedir;
rmdir $basedir;

View File

@ -48,7 +48,7 @@ CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret
CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl varchar(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci comment='MySQL plugins'; CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl varchar(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci comment='MySQL plugins';
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(80) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table'; CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host varchar(2048) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(80) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(80) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(141) DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger','Delete versioning rows') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges'; CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(80) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(141) DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger','Delete versioning rows') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';

View File

@ -929,7 +929,13 @@ do
cmd="$cmd "`shell_quote_string "$i"` cmd="$cmd "`shell_quote_string "$i"`
done done
cmd="$cmd $args" cmd="$cmd $args"
[ $dry_run -eq 1 ] && return
if [ $dry_run -eq 1 ]
then
# RETURN or EXIT depending if the script is being sourced or not.
(return 2> /dev/null) && return || exit
fi
# Avoid 'nohup: ignoring input' warning # Avoid 'nohup: ignoring input' warning
test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null" test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null"

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2000, 2017, Oracle and/or its affiliates. Copyright (c) 2000, 2017, Oracle and/or its affiliates.
Copyright (c) 2008, 2017, MariaDB Copyright (c) 2008, 2019, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -2405,12 +2405,12 @@ Field *Field::clone(MEM_ROOT *root, TABLE *new_table)
} }
Field *Field::clone(MEM_ROOT *root, TABLE *new_table, my_ptrdiff_t diff) Field *Field::clone(MEM_ROOT *root, TABLE *new_table, my_ptrdiff_t diff)
{ {
Field *tmp; Field *tmp;
if ((tmp= (Field*) memdup_root(root,(char*) this,size_of()))) if ((tmp= (Field*) memdup_root(root,(char*) this,size_of())))
{ {
if (new_table)
tmp->init(new_table); tmp->init(new_table);
tmp->move_field_offset(diff); tmp->move_field_offset(diff);
} }
@ -2418,16 +2418,6 @@ Field *Field::clone(MEM_ROOT *root, TABLE *new_table, my_ptrdiff_t diff)
} }
Field *Field::clone(MEM_ROOT *root, my_ptrdiff_t diff)
{
Field *tmp;
if ((tmp= (Field*) memdup_root(root,(char*) this,size_of())))
{
tmp->move_field_offset(diff);
}
return tmp;
}
int Field::set_default() int Field::set_default()
{ {
if (default_value) if (default_value)

View File

@ -1254,7 +1254,6 @@ public:
uchar *new_null_ptr, uint new_null_bit); uchar *new_null_ptr, uint new_null_bit);
Field *clone(MEM_ROOT *mem_root, TABLE *new_table); Field *clone(MEM_ROOT *mem_root, TABLE *new_table);
Field *clone(MEM_ROOT *mem_root, TABLE *new_table, my_ptrdiff_t diff); Field *clone(MEM_ROOT *mem_root, TABLE *new_table, my_ptrdiff_t diff);
Field *clone(MEM_ROOT *mem_root, my_ptrdiff_t diff);
inline void move_field(uchar *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg) inline void move_field(uchar *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg)
{ {
ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg; ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;

View File

@ -2414,12 +2414,16 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
records= head->stat_records(); records= head->stat_records();
if (!records) if (!records)
records++; /* purecov: inspected */ records++; /* purecov: inspected */
if (head->force_index || force_quick_range)
scan_time= read_time= DBL_MAX;
else
{
scan_time= (double) records / TIME_FOR_COMPARE + 1; scan_time= (double) records / TIME_FOR_COMPARE + 1;
read_time= (double) head->file->scan_time() + scan_time + 1.1; read_time= (double) head->file->scan_time() + scan_time + 1.1;
if (head->force_index)
scan_time= read_time= DBL_MAX;
if (limit < records) if (limit < records)
read_time= (double) records + scan_time + 1; // Force to use index read_time= (double) records + scan_time + 1; // Force to use index
}
possible_keys.clear_all(); possible_keys.clear_all();
@ -10413,6 +10417,16 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only,
bufsize, mrr_flags, cost); bufsize, mrr_flags, cost);
if (rows != HA_POS_ERROR) if (rows != HA_POS_ERROR)
{ {
ha_rows table_records= param->table->stat_records();
if (rows > table_records)
{
/*
For any index the total number of records within all ranges
cannot be be bigger than the number of records in the table
*/
rows= table_records;
set_if_bigger(rows, 1);
}
param->quick_rows[keynr]= rows; param->quick_rows[keynr]= rows;
param->possible_keys.set_bit(keynr); param->possible_keys.set_bit(keynr);
if (update_tbl_stats) if (update_tbl_stats)

View File

@ -452,11 +452,6 @@ bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables);
static SJ_MATERIALIZATION_INFO * static SJ_MATERIALIZATION_INFO *
at_sjmat_pos(const JOIN *join, table_map remaining_tables, const JOIN_TAB *tab, at_sjmat_pos(const JOIN *join, table_map remaining_tables, const JOIN_TAB *tab,
uint idx, bool *loose_scan); uint idx, bool *loose_scan);
void best_access_path(JOIN *join, JOIN_TAB *s,
table_map remaining_tables, uint idx,
bool disable_jbuf, double record_count,
POSITION *pos, POSITION *loose_scan_pos);
static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm, static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm,
Item_in_subselect *subq_pred); Item_in_subselect *subq_pred);
static bool remove_sj_conds(THD *thd, Item **tree); static bool remove_sj_conds(THD *thd, Item **tree);
@ -2718,6 +2713,13 @@ void advance_sj_state(JOIN *join, table_map remaining_tables, uint idx,
NULL, NULL,
}; };
#ifdef HAVE_valgrind
new (&pos->firstmatch_picker) Firstmatch_picker;
new (&pos->loosescan_picker) LooseScan_picker;
new (&pos->sjmat_picker) Sj_materialization_picker;
new (&pos->dups_weedout_picker) Duplicate_weedout_picker;
#endif
if (join->emb_sjm_nest) if (join->emb_sjm_nest)
{ {
/* /*
@ -3007,7 +3009,8 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
bool disable_jbuf= (join->thd->variables.join_cache_level == 0); bool disable_jbuf= (join->thd->variables.join_cache_level == 0);
for (i= first_tab + mat_info->tables; i <= idx; i++) for (i= first_tab + mat_info->tables; i <= idx; i++)
{ {
best_access_path(join, join->positions[i].table, rem_tables, i, best_access_path(join, join->positions[i].table, rem_tables,
join->positions, i,
disable_jbuf, prefix_rec_count, &curpos, &dummy); disable_jbuf, prefix_rec_count, &curpos, &dummy);
prefix_rec_count= COST_MULT(prefix_rec_count, curpos.records_read); prefix_rec_count= COST_MULT(prefix_rec_count, curpos.records_read);
prefix_cost= COST_ADD(prefix_cost, curpos.read_time); prefix_cost= COST_ADD(prefix_cost, curpos.read_time);
@ -3626,7 +3629,8 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
join->cur_sj_inner_tables= 0; join->cur_sj_inner_tables= 0;
for (i= first + sjm->tables; i <= tablenr; i++) for (i= first + sjm->tables; i <= tablenr; i++)
{ {
best_access_path(join, join->best_positions[i].table, rem_tables, i, best_access_path(join, join->best_positions[i].table, rem_tables,
join->best_positions, i,
FALSE, prefix_rec_count, FALSE, prefix_rec_count,
join->best_positions + i, &dummy); join->best_positions + i, &dummy);
prefix_rec_count *= join->best_positions[i].records_read; prefix_rec_count *= join->best_positions[i].records_read;
@ -3659,7 +3663,8 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
if (join->best_positions[idx].use_join_buffer) if (join->best_positions[idx].use_join_buffer)
{ {
best_access_path(join, join->best_positions[idx].table, best_access_path(join, join->best_positions[idx].table,
rem_tables, idx, TRUE /* no jbuf */, rem_tables, join->best_positions, idx,
TRUE /* no jbuf */,
record_count, join->best_positions + idx, &dummy); record_count, join->best_positions + idx, &dummy);
} }
record_count *= join->best_positions[idx].records_read; record_count *= join->best_positions[idx].records_read;
@ -3689,7 +3694,8 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
if (join->best_positions[idx].use_join_buffer || (idx == first)) if (join->best_positions[idx].use_join_buffer || (idx == first))
{ {
best_access_path(join, join->best_positions[idx].table, best_access_path(join, join->best_positions[idx].table,
rem_tables, idx, TRUE /* no jbuf */, rem_tables, join->best_positions, idx,
TRUE /* no jbuf */,
record_count, join->best_positions + idx, record_count, join->best_positions + idx,
&loose_scan_pos); &loose_scan_pos);
if (idx==first) if (idx==first)

View File

@ -88,6 +88,7 @@ class Loose_scan_opt
KEYUSE *best_loose_scan_start_key; KEYUSE *best_loose_scan_start_key;
uint best_max_loose_keypart; uint best_max_loose_keypart;
table_map best_ref_depend_map;
public: public:
Loose_scan_opt(): Loose_scan_opt():
@ -249,13 +250,14 @@ public:
best_loose_scan_records= records; best_loose_scan_records= records;
best_max_loose_keypart= max_loose_keypart; best_max_loose_keypart= max_loose_keypart;
best_loose_scan_start_key= start_key; best_loose_scan_start_key= start_key;
best_ref_depend_map= 0;
} }
} }
} }
} }
void check_ref_access_part2(uint key, KEYUSE *start_key, double records, void check_ref_access_part2(uint key, KEYUSE *start_key, double records,
double read_time) double read_time, table_map ref_depend_map_arg)
{ {
if (part1_conds_met && read_time < best_loose_scan_cost) if (part1_conds_met && read_time < best_loose_scan_cost)
{ {
@ -265,6 +267,7 @@ public:
best_loose_scan_records= records; best_loose_scan_records= records;
best_max_loose_keypart= max_loose_keypart; best_max_loose_keypart= max_loose_keypart;
best_loose_scan_start_key= start_key; best_loose_scan_start_key= start_key;
best_ref_depend_map= ref_depend_map_arg;
} }
} }
@ -280,6 +283,7 @@ public:
best_loose_scan_records= rows2double(quick->records); best_loose_scan_records= rows2double(quick->records);
best_max_loose_keypart= quick_max_loose_keypart; best_max_loose_keypart= quick_max_loose_keypart;
best_loose_scan_start_key= NULL; best_loose_scan_start_key= NULL;
best_ref_depend_map= 0;
} }
} }
@ -295,7 +299,7 @@ public:
pos->loosescan_picker.loosescan_parts= best_max_loose_keypart + 1; pos->loosescan_picker.loosescan_parts= best_max_loose_keypart + 1;
pos->use_join_buffer= FALSE; pos->use_join_buffer= FALSE;
pos->table= tab; pos->table= tab;
// todo need ref_depend_map ? pos->ref_depend_map= best_ref_depend_map;
DBUG_PRINT("info", ("Produced a LooseScan plan, key %s, %s", DBUG_PRINT("info", ("Produced a LooseScan plan, key %s, %s",
tab->table->key_info[best_loose_scan_key].name.str, tab->table->key_info[best_loose_scan_key].name.str,
best_loose_scan_start_key? "(ref access)": best_loose_scan_start_key? "(ref access)":

View File

@ -522,7 +522,6 @@ void init_update_queries(void)
server_command_flags[COM_STMT_SEND_LONG_DATA]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_STMT_SEND_LONG_DATA]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_REGISTER_SLAVE]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_REGISTER_SLAVE]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_MULTI]= CF_SKIP_WSREP_CHECK | CF_NO_COM_MULTI; server_command_flags[COM_MULTI]= CF_SKIP_WSREP_CHECK | CF_NO_COM_MULTI;
server_command_flags[CF_NO_COM_MULTI]= CF_NO_COM_MULTI;
/* Initialize the sql command flags array. */ /* Initialize the sql command flags array. */
memset(sql_command_flags, 0, sizeof(sql_command_flags)); memset(sql_command_flags, 0, sizeof(sql_command_flags));

View File

@ -100,10 +100,6 @@ static int sort_keyuse(KEYUSE *a,KEYUSE *b);
static bool are_tables_local(JOIN_TAB *jtab, table_map used_tables); static bool are_tables_local(JOIN_TAB *jtab, table_map used_tables);
static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
bool allow_full_scan, table_map used_tables); bool allow_full_scan, table_map used_tables);
void best_access_path(JOIN *join, JOIN_TAB *s,
table_map remaining_tables, uint idx,
bool disable_jbuf, double record_count,
POSITION *pos, POSITION *loose_scan_pos);
static void optimize_straight_join(JOIN *join, table_map join_tables); static void optimize_straight_join(JOIN *join, table_map join_tables);
static bool greedy_search(JOIN *join, table_map remaining_tables, static bool greedy_search(JOIN *join, table_map remaining_tables,
uint depth, uint prune_level, uint depth, uint prune_level,
@ -5088,6 +5084,13 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
{ {
if (choose_plan(join, all_table_map & ~join->const_table_map)) if (choose_plan(join, all_table_map & ~join->const_table_map))
goto error; goto error;
#ifdef HAVE_valgrind
// JOIN::positions holds the current query plan. We've already
// made the plan choice, so we should only use JOIN::best_positions
for (uint k=join->const_tables; k < join->table_count; k++)
MEM_UNDEFINED(&join->positions[k], sizeof(join->positions[k]));
#endif
} }
else else
{ {
@ -6785,6 +6788,7 @@ void
best_access_path(JOIN *join, best_access_path(JOIN *join,
JOIN_TAB *s, JOIN_TAB *s,
table_map remaining_tables, table_map remaining_tables,
const POSITION *join_positions,
uint idx, uint idx,
bool disable_jbuf, bool disable_jbuf,
double record_count, double record_count,
@ -6897,7 +6901,7 @@ best_access_path(JOIN *join,
if (!keyuse->val->maybe_null || keyuse->null_rejecting) if (!keyuse->val->maybe_null || keyuse->null_rejecting)
notnull_part|=keyuse->keypart_map; notnull_part|=keyuse->keypart_map;
double tmp2= prev_record_reads(join->positions, idx, double tmp2= prev_record_reads(join_positions, idx,
(found_ref | keyuse->used_tables)); (found_ref | keyuse->used_tables));
if (tmp2 < best_prev_record_reads) if (tmp2 < best_prev_record_reads)
{ {
@ -6938,7 +6942,7 @@ best_access_path(JOIN *join,
Really, there should be records=0.0 (yes!) Really, there should be records=0.0 (yes!)
but 1.0 would be probably safer but 1.0 would be probably safer
*/ */
tmp= prev_record_reads(join->positions, idx, found_ref); tmp= prev_record_reads(join_positions, idx, found_ref);
records= 1.0; records= 1.0;
} }
else else
@ -6961,7 +6965,7 @@ best_access_path(JOIN *join,
(!(key_flags & HA_NULL_PART_KEY) || // (2) (!(key_flags & HA_NULL_PART_KEY) || // (2)
all_key_parts == notnull_part)) // (3) all_key_parts == notnull_part)) // (3)
{ {
tmp = prev_record_reads(join->positions, idx, found_ref); tmp = prev_record_reads(join_positions, idx, found_ref);
records=1.0; records=1.0;
} }
else else
@ -7205,7 +7209,8 @@ best_access_path(JOIN *join,
} }
tmp= COST_ADD(tmp, s->startup_cost); tmp= COST_ADD(tmp, s->startup_cost);
loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp); loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp,
found_ref);
} /* not ft_key */ } /* not ft_key */
if (tmp + 0.0001 < best_time - records/(double) TIME_FOR_COMPARE) if (tmp + 0.0001 < best_time - records/(double) TIME_FOR_COMPARE)
@ -7890,7 +7895,8 @@ optimize_straight_join(JOIN *join, table_map join_tables)
for (JOIN_TAB **pos= join->best_ref + idx ; (s= *pos) ; pos++) for (JOIN_TAB **pos= join->best_ref + idx ; (s= *pos) ; pos++)
{ {
/* Find the best access method from 's' to the current partial plan */ /* Find the best access method from 's' to the current partial plan */
best_access_path(join, s, join_tables, idx, disable_jbuf, record_count, best_access_path(join, s, join_tables, join->positions, idx,
disable_jbuf, record_count,
join->positions + idx, &loose_scan_pos); join->positions + idx, &loose_scan_pos);
/* compute the cost of the new plan extended with 's' */ /* compute the cost of the new plan extended with 's' */
@ -8510,7 +8516,19 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
} }
keyparts++; keyparts++;
} }
/*
Here we discount selectivity of the constant range CR. To calculate
this selectivity we use elements from the quick_rows[] array.
If we have indexes i1,...,ik with the same prefix compatible
with CR any of the estimate quick_rows[i1], ... quick_rows[ik] could
be used for this calculation but here we don't know which one was
actually used. So sel could be greater than 1 and we have to cap it.
However if sel becomes greater than 2 then with high probability
something went wrong.
*/
sel /= (double)table->quick_rows[key] / (double) table->stat_records(); sel /= (double)table->quick_rows[key] / (double) table->stat_records();
DBUG_ASSERT(0 < sel && sel <= 2.0);
set_if_smaller(sel, 1.0);
used_range_selectivity= true; used_range_selectivity= true;
} }
} }
@ -8558,6 +8576,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
if (table->field[fldno]->cond_selectivity > 0) if (table->field[fldno]->cond_selectivity > 0)
{ {
sel /= table->field[fldno]->cond_selectivity; sel /= table->field[fldno]->cond_selectivity;
DBUG_ASSERT(0 < sel && sel <= 2.0);
set_if_smaller(sel, 1.0); set_if_smaller(sel, 1.0);
} }
/* /*
@ -8615,6 +8634,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
if (field->cond_selectivity > 0) if (field->cond_selectivity > 0)
{ {
sel/= field->cond_selectivity; sel/= field->cond_selectivity;
DBUG_ASSERT(0 < sel && sel <= 2.0);
set_if_smaller(sel, 1.0); set_if_smaller(sel, 1.0);
} }
break; break;
@ -8626,6 +8646,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
sel*= table_multi_eq_cond_selectivity(join, idx, s, rem_tables, sel*= table_multi_eq_cond_selectivity(join, idx, s, rem_tables,
keyparts, ref_keyuse_steps); keyparts, ref_keyuse_steps);
DBUG_ASSERT(0.0 < sel && sel <= 1.0);
return sel; return sel;
} }
@ -8809,8 +8830,8 @@ best_extension_by_limited_search(JOIN *join,
/* Find the best access method from 's' to the current partial plan */ /* Find the best access method from 's' to the current partial plan */
POSITION loose_scan_pos; POSITION loose_scan_pos;
best_access_path(join, s, remaining_tables, idx, disable_jbuf, best_access_path(join, s, remaining_tables, join->positions, idx,
record_count, position, &loose_scan_pos); disable_jbuf, record_count, position, &loose_scan_pos);
/* Compute the cost of extending the plan with 's' */ /* Compute the cost of extending the plan with 's' */
current_record_count= COST_MULT(record_count, position->records_read); current_record_count= COST_MULT(record_count, position->records_read);
@ -9196,11 +9217,11 @@ cache_record_length(JOIN *join,uint idx)
*/ */
double double
prev_record_reads(POSITION *positions, uint idx, table_map found_ref) prev_record_reads(const POSITION *positions, uint idx, table_map found_ref)
{ {
double found=1.0; double found=1.0;
POSITION *pos_end= positions - 1; const POSITION *pos_end= positions - 1;
for (POSITION *pos= positions + idx - 1; pos != pos_end; pos--) for (const POSITION *pos= positions + idx - 1; pos != pos_end; pos--)
{ {
if (pos->table->table->map & found_ref) if (pos->table->table->map & found_ref)
{ {
@ -15963,7 +15984,8 @@ void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
if ((i == first_tab && first_alt) || join->positions[i].use_join_buffer) if ((i == first_tab && first_alt) || join->positions[i].use_join_buffer)
{ {
/* Find the best access method that would not use join buffering */ /* Find the best access method that would not use join buffering */
best_access_path(join, rs, reopt_remaining_tables, i, best_access_path(join, rs, reopt_remaining_tables,
join->positions, i,
TRUE, rec_count, TRUE, rec_count,
&pos, &loose_scan_pos); &pos, &loose_scan_pos);
} }

View File

@ -838,6 +838,7 @@ public:
friend void best_access_path(JOIN *join, friend void best_access_path(JOIN *join,
JOIN_TAB *s, JOIN_TAB *s,
table_map remaining_tables, table_map remaining_tables,
const struct st_position *join_positions,
uint idx, uint idx,
bool disable_jbuf, bool disable_jbuf,
double record_count, double record_count,
@ -2043,6 +2044,11 @@ protected:
} }
}; };
void best_access_path(JOIN *join, JOIN_TAB *s,
table_map remaining_tables,
const POSITION *join_positions, uint idx,
bool disable_jbuf, double record_count,
POSITION *pos, POSITION *loose_scan_pos);
bool cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref); bool cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref);
bool error_if_full_join(JOIN *join); bool error_if_full_join(JOIN *join);
int report_error(TABLE *table, int error); int report_error(TABLE *table, int error);
@ -2413,7 +2419,7 @@ bool instantiate_tmp_table(TABLE *table, KEY *keyinfo,
ulonglong options); ulonglong options);
bool open_tmp_table(TABLE *table); bool open_tmp_table(TABLE *table);
void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps); void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps);
double prev_record_reads(POSITION *positions, uint idx, table_map found_ref); double prev_record_reads(const POSITION *positions, uint idx, table_map found_ref);
void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist); void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist);
double get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size); double get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size);
double get_tmp_table_write_cost(THD *thd, double row_count, uint row_size); double get_tmp_table_write_cost(THD *thd, double row_count, uint row_size);

View File

@ -1,4 +1,5 @@
/* Copyright (C) 2009 MySQL AB /* Copyright (C) 2009 MySQL AB
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -1154,12 +1155,18 @@ public:
case COLUMN_STAT_MIN_VALUE: case COLUMN_STAT_MIN_VALUE:
table_field->read_stats->min_value->set_notnull(); table_field->read_stats->min_value->set_notnull();
stat_field->val_str(&val); stat_field->val_str(&val);
#if 0 /* MDEV-20589 FIXME: This fails! */
DBUG_ASSERT(table_field->read_stats->min_value->is_stat_field);
#endif
table_field->read_stats->min_value->store(val.ptr(), val.length(), table_field->read_stats->min_value->store(val.ptr(), val.length(),
&my_charset_bin); &my_charset_bin);
break; break;
case COLUMN_STAT_MAX_VALUE: case COLUMN_STAT_MAX_VALUE:
table_field->read_stats->max_value->set_notnull(); table_field->read_stats->max_value->set_notnull();
stat_field->val_str(&val); stat_field->val_str(&val);
#if 0 /* MDEV-20589 FIXME: This fails! */
DBUG_ASSERT(table_field->read_stats->min_value->is_stat_field);
#endif
table_field->read_stats->max_value->store(val.ptr(), val.length(), table_field->read_stats->max_value->store(val.ptr(), val.length(),
&my_charset_bin); &my_charset_bin);
break; break;
@ -2043,7 +2050,7 @@ void create_min_max_statistical_fields_for_table_share(THD *thd,
Field *fld; Field *fld;
Field *table_field= *field_ptr; Field *table_field= *field_ptr;
my_ptrdiff_t diff= record - table_share->default_values; my_ptrdiff_t diff= record - table_share->default_values;
if (!(fld= table_field->clone(&stats_cb->mem_root, diff))) if (!(fld= table_field->clone(&stats_cb->mem_root, NULL, diff)))
continue; continue;
if (i == 0) if (i == 0)
table_field->read_stats->min_value= fld; table_field->read_stats->min_value= fld;

View File

@ -3082,8 +3082,6 @@ server_option:
{ {
MYSQL_YYABORT_UNLESS(Lex->server_options.host.str == 0); MYSQL_YYABORT_UNLESS(Lex->server_options.host.str == 0);
Lex->server_options.host= $2; Lex->server_options.host= $2;
my_casedn_str(system_charset_info,
(char*) Lex->server_options.host.str);
} }
| DATABASE TEXT_STRING_sys | DATABASE TEXT_STRING_sys
{ {

View File

@ -2715,8 +2715,6 @@ server_option:
{ {
MYSQL_YYABORT_UNLESS(Lex->server_options.host.str == 0); MYSQL_YYABORT_UNLESS(Lex->server_options.host.str == 0);
Lex->server_options.host= $2; Lex->server_options.host= $2;
my_casedn_str(system_charset_info,
(char*) Lex->server_options.host.str);
} }
| DATABASE TEXT_STRING_sys | DATABASE TEXT_STRING_sys
{ {

View File

@ -2803,30 +2803,6 @@ dict_table_copy_types(
dict_table_copy_v_types(tuple, table); dict_table_copy_v_types(tuple, table);
} }
/********************************************************************
Wait until all the background threads of the given table have exited, i.e.,
bg_threads == 0. Note: bg_threads_mutex must be reserved when
calling this. */
void
dict_table_wait_for_bg_threads_to_exit(
/*===================================*/
dict_table_t* table, /*< in: table */
ulint delay) /*< in: time in microseconds to wait between
checks of bg_threads. */
{
fts_t* fts = table->fts;
ut_ad(mutex_own(&fts->bg_threads_mutex));
while (fts->bg_threads > 0) {
mutex_exit(&fts->bg_threads_mutex);
os_thread_sleep(delay);
mutex_enter(&fts->bg_threads_mutex);
}
}
/*******************************************************************//** /*******************************************************************//**
Builds the internal dictionary cache representation for a clustered Builds the internal dictionary cache representation for a clustered
index, containing also system fields not defined by the user. index, containing also system fields not defined by the user.

View File

@ -215,8 +215,7 @@ fts_config_set_value(
pars_info_bind_varchar_literal(info, "value", pars_info_bind_varchar_literal(info, "value",
value->f_str, value->f_len); value->f_str, value->f_len);
const bool dict_locked = fts_table->table->fts->fts_status const bool dict_locked = fts_table->table->fts->dict_locked;
& TABLE_DICT_LOCKED;
fts_table->suffix = "CONFIG"; fts_table->suffix = "CONFIG";
fts_get_table_name(fts_table, table_name, dict_locked); fts_get_table_name(fts_table, table_name, dict_locked);

View File

@ -459,7 +459,7 @@ fts_load_user_stopword(
dberr_t error = DB_SUCCESS; dberr_t error = DB_SUCCESS;
ibool ret = TRUE; ibool ret = TRUE;
trx_t* trx; trx_t* trx;
ibool has_lock = fts->fts_status & TABLE_DICT_LOCKED; ibool has_lock = fts->dict_locked;
trx = trx_create(); trx = trx_create();
trx->op_info = "Load user stopword table into FTS cache"; trx->op_info = "Load user stopword table into FTS cache";
@ -917,18 +917,16 @@ fts_que_graph_free_check_lock(
const fts_index_cache_t*index_cache, /*!< in: FTS index cache */ const fts_index_cache_t*index_cache, /*!< in: FTS index cache */
que_t* graph) /*!< in: query graph */ que_t* graph) /*!< in: query graph */
{ {
ibool has_dict = FALSE; bool has_dict = FALSE;
if (fts_table && fts_table->table) { if (fts_table && fts_table->table) {
ut_ad(fts_table->table->fts); ut_ad(fts_table->table->fts);
has_dict = fts_table->table->fts->fts_status has_dict = fts_table->table->fts->dict_locked;
& TABLE_DICT_LOCKED;
} else if (index_cache) { } else if (index_cache) {
ut_ad(index_cache->index->table->fts); ut_ad(index_cache->index->table->fts);
has_dict = index_cache->index->table->fts->fts_status has_dict = index_cache->index->table->fts->dict_locked;
& TABLE_DICT_LOCKED;
} }
if (!has_dict) { if (!has_dict) {
@ -2780,7 +2778,7 @@ fts_update_sync_doc_id(
pars_info_bind_varchar_literal(info, "doc_id", id, id_len); pars_info_bind_varchar_literal(info, "doc_id", id, id_len);
fts_get_table_name(&fts_table, fts_name, fts_get_table_name(&fts_table, fts_name,
table->fts->fts_status & TABLE_DICT_LOCKED); table->fts->dict_locked);
pars_info_bind_id(info, true, "table_name", fts_name); pars_info_bind_id(info, true, "table_name", fts_name);
graph = fts_parse_sql( graph = fts_parse_sql(
@ -2894,7 +2892,7 @@ fts_delete(
into cache from last crash (delete Doc will not initialize the into cache from last crash (delete Doc will not initialize the
sync). Avoid any added counter accounting until the FTS cache sync). Avoid any added counter accounting until the FTS cache
is re-established and sync-ed */ is re-established and sync-ed */
if (table->fts->fts_status & ADDED_TABLE_SYNCED if (table->fts->added_synced
&& doc_id > cache->synced_doc_id) { && doc_id > cache->synced_doc_id) {
mutex_enter(&table->fts->cache->deleted_lock); mutex_enter(&table->fts->cache->deleted_lock);
@ -3357,7 +3355,7 @@ fts_add_doc_from_tuple(
ut_ad(cache->get_docs); ut_ad(cache->get_docs);
if (!(ftt->table->fts->fts_status & ADDED_TABLE_SYNCED)) { if (!ftt->table->fts->added_synced) {
fts_init_index(ftt->table, FALSE); fts_init_index(ftt->table, FALSE);
} }
@ -3442,7 +3440,7 @@ fts_add_doc_by_id(
/* If Doc ID has been supplied by the user, then the table /* If Doc ID has been supplied by the user, then the table
might not yet be sync-ed */ might not yet be sync-ed */
if (!(ftt->table->fts->fts_status & ADDED_TABLE_SYNCED)) { if (!ftt->table->fts->added_synced) {
fts_init_index(ftt->table, FALSE); fts_init_index(ftt->table, FALSE);
} }
@ -4877,7 +4875,7 @@ fts_init_doc_id(
fts_init_index((dict_table_t*) table, TRUE); fts_init_index((dict_table_t*) table, TRUE);
} }
table->fts->fts_status |= ADDED_TABLE_SYNCED; table->fts->added_synced = true;
table->fts->cache->first_doc_id = max_doc_id; table->fts->cache->first_doc_id = max_doc_id;
@ -5286,67 +5284,6 @@ fts_cache_append_deleted_doc_ids(
mutex_exit((ib_mutex_t*) &cache->deleted_lock); mutex_exit((ib_mutex_t*) &cache->deleted_lock);
} }
/*********************************************************************//**
Wait for the background thread to start. We poll to detect change
of state, which is acceptable, since the wait should happen only
once during startup.
@return true if the thread started else FALSE (i.e timed out) */
ibool
fts_wait_for_background_thread_to_start(
/*====================================*/
dict_table_t* table, /*!< in: table to which the thread
is attached */
ulint max_wait) /*!< in: time in microseconds, if
set to 0 then it disables
timeout checking */
{
ulint count = 0;
ibool done = FALSE;
ut_a(max_wait == 0 || max_wait >= FTS_MAX_BACKGROUND_THREAD_WAIT);
for (;;) {
fts_t* fts = table->fts;
mutex_enter(&fts->bg_threads_mutex);
if (fts->fts_status & BG_THREAD_READY) {
done = TRUE;
}
mutex_exit(&fts->bg_threads_mutex);
if (!done) {
os_thread_sleep(FTS_MAX_BACKGROUND_THREAD_WAIT);
if (max_wait > 0) {
max_wait -= FTS_MAX_BACKGROUND_THREAD_WAIT;
/* We ignore the residual value. */
if (max_wait < FTS_MAX_BACKGROUND_THREAD_WAIT) {
break;
}
}
++count;
} else {
break;
}
if (count >= FTS_BACKGROUND_THREAD_WAIT_COUNT) {
ib::error() << "The background thread for the FTS"
" table " << table->name
<< " refuses to start";
count = 0;
}
}
return(done);
}
/*********************************************************************//** /*********************************************************************//**
Add the FTS document id hidden column. */ Add the FTS document id hidden column. */
void void
@ -5429,8 +5366,8 @@ fts_t::fts_t(
const dict_table_t* table, const dict_table_t* table,
mem_heap_t* heap) mem_heap_t* heap)
: :
in_queue(0), added_synced(0), dict_locked(0),
bg_threads(0), bg_threads(0),
fts_status(0),
add_wq(NULL), add_wq(NULL),
cache(NULL), cache(NULL),
doc_col(ULINT_UNDEFINED), doc_col(ULINT_UNDEFINED),
@ -5500,42 +5437,6 @@ fts_free(
table->fts = NULL; table->fts = NULL;
} }
#if 0 // TODO: Enable this in WL#6608
/*********************************************************************//**
Signal FTS threads to initiate shutdown. */
void
fts_start_shutdown(
/*===============*/
dict_table_t* table, /*!< in: table with FTS indexes */
fts_t* fts) /*!< in: fts instance that needs
to be informed about shutdown */
{
mutex_enter(&fts->bg_threads_mutex);
fts->fts_status |= BG_THREAD_STOP;
mutex_exit(&fts->bg_threads_mutex);
}
/*********************************************************************//**
Wait for FTS threads to shutdown. */
void
fts_shutdown(
/*=========*/
dict_table_t* table, /*!< in: table with FTS indexes */
fts_t* fts) /*!< in: fts instance to shutdown */
{
mutex_enter(&fts->bg_threads_mutex);
ut_a(fts->fts_status & BG_THREAD_STOP);
dict_table_wait_for_bg_threads_to_exit(table, 20000);
mutex_exit(&fts->bg_threads_mutex);
}
#endif
/*********************************************************************//** /*********************************************************************//**
Take a FTS savepoint. */ Take a FTS savepoint. */
UNIV_INLINE UNIV_INLINE
@ -7517,7 +7418,7 @@ fts_init_index(
} }
rw_lock_x_unlock(&cache->init_lock); rw_lock_x_unlock(&cache->init_lock);
if (table->fts->fts_status & ADDED_TABLE_SYNCED) { if (table->fts->added_synced) {
goto func_exit; goto func_exit;
} }
@ -7559,7 +7460,7 @@ fts_init_index(
} }
} }
table->fts->fts_status |= ADDED_TABLE_SYNCED; table->fts->added_synced = true;
fts_get_docs_clear(cache->get_docs); fts_get_docs_clear(cache->get_docs);

View File

@ -2553,12 +2553,22 @@ void fts_optimize_add_table(dict_table_t* table)
return; return;
} }
/* If there is no fts index present then don't add to
optimize queue. */
if (!ib_vector_size(table->fts->indexes)) {
return;
}
/* Make sure table with FTS index cannot be evicted */ /* Make sure table with FTS index cannot be evicted */
dict_table_prevent_eviction(table); dict_table_prevent_eviction(table);
msg = fts_optimize_create_msg(FTS_MSG_ADD_TABLE, table); msg = fts_optimize_create_msg(FTS_MSG_ADD_TABLE, table);
ib_wqueue_add(fts_optimize_wq, msg, msg->heap); ib_wqueue_add(fts_optimize_wq, msg, msg->heap);
mutex_enter(&table->fts->bg_threads_mutex);
table->fts->in_queue = true;
mutex_exit(&table->fts->bg_threads_mutex);
} }
/**********************************************************************//** /**********************************************************************//**
@ -2585,6 +2595,15 @@ fts_optimize_remove_table(
return; return;
} }
fts_t* fts = table->fts;
mutex_enter(&fts->bg_threads_mutex);
bool is_in_optimize_queue = fts->in_queue;
mutex_exit(&fts->bg_threads_mutex);
if (!is_in_optimize_queue) {
return;
}
msg = fts_optimize_create_msg(FTS_MSG_DEL_TABLE, NULL); msg = fts_optimize_create_msg(FTS_MSG_DEL_TABLE, NULL);
/* We will wait on this event until signalled by the consumer. */ /* We will wait on this event until signalled by the consumer. */
@ -2602,6 +2621,10 @@ fts_optimize_remove_table(
os_event_wait(event); os_event_wait(event);
os_event_destroy(event); os_event_destroy(event);
mutex_enter(&fts->bg_threads_mutex);
fts->in_queue = false;
mutex_exit(&fts->bg_threads_mutex);
} }
/** Send sync fts cache for the table. /** Send sync fts cache for the table.
@ -2633,6 +2656,10 @@ fts_optimize_request_sync_table(
msg->ptr = table_id; msg->ptr = table_id;
ib_wqueue_add(fts_optimize_wq, msg, msg->heap); ib_wqueue_add(fts_optimize_wq, msg, msg->heap);
mutex_enter(&table->fts->bg_threads_mutex);
table->fts->in_queue = true;
mutex_exit(&table->fts->bg_threads_mutex);
} }
/** Add a table to fts_slots if it doesn't already exist. */ /** Add a table to fts_slots if it doesn't already exist. */
@ -2776,6 +2803,10 @@ static void fts_optimize_sync_table(table_id_t table_id)
fts_sync_table(table, false); fts_sync_table(table, false);
} }
DBUG_EXECUTE_IF(
"ib_optimize_wq_hang",
os_thread_sleep(6000000););
dict_table_close(table, FALSE, FALSE); dict_table_close(table, FALSE, FALSE);
} }
} }

View File

@ -154,8 +154,7 @@ fts_parse_sql(
str = ut_str3cat(fts_sql_begin, sql, fts_sql_end); str = ut_str3cat(fts_sql_begin, sql, fts_sql_end);
dict_locked = (fts_table && fts_table->table->fts dict_locked = (fts_table && fts_table->table->fts
&& (fts_table->table->fts->fts_status && fts_table->table->fts->dict_locked);
& TABLE_DICT_LOCKED));
if (!dict_locked) { if (!dict_locked) {
ut_ad(!mutex_own(&dict_sys->mutex)); ut_ad(!mutex_own(&dict_sys->mutex));

View File

@ -9938,10 +9938,10 @@ ha_innobase::ft_init_ext(
return(NULL); return(NULL);
} }
if (!(ft_table->fts->fts_status & ADDED_TABLE_SYNCED)) { if (!(ft_table->fts->added_synced)) {
fts_init_index(ft_table, FALSE); fts_init_index(ft_table, FALSE);
ft_table->fts->fts_status |= ADDED_TABLE_SYNCED; ft_table->fts->added_synced = true;
} }
const byte* q = reinterpret_cast<const byte*>( const byte* q = reinterpret_cast<const byte*>(

View File

@ -4450,7 +4450,7 @@ empty_table:
index->set_modified(mtr); index->set_modified(mtr);
err = row_ins_clust_index_entry_low( err = row_ins_clust_index_entry_low(
BTR_NO_LOCKING_FLAG, BTR_MODIFY_TREE, index, BTR_NO_LOCKING_FLAG, BTR_MODIFY_TREE, index,
index->n_uniq, entry, 0, thr, false); index->n_uniq, entry, 0, thr);
} else { } else {
err_exit: err_exit:
err = DB_CORRUPTION; err = DB_CORRUPTION;
@ -5751,15 +5751,13 @@ op_ok:
goto error_handling; goto error_handling;
} }
ctx->new_table->fts->fts_status ctx->new_table->fts->dict_locked = true;
|= TABLE_DICT_LOCKED;
error = innobase_fts_load_stopword( error = innobase_fts_load_stopword(
ctx->new_table, ctx->trx, ctx->new_table, ctx->trx,
ctx->prebuilt->trx->mysql_thd) ctx->prebuilt->trx->mysql_thd)
? DB_SUCCESS : DB_ERROR; ? DB_SUCCESS : DB_ERROR;
ctx->new_table->fts->fts_status ctx->new_table->fts->dict_locked = false;
&= ulint(~TABLE_DICT_LOCKED);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
goto error_handling; goto error_handling;
@ -8924,6 +8922,7 @@ commit_cache_norebuild(
|| (index->type || (index->type
& DICT_CORRUPT)); & DICT_CORRUPT));
DBUG_ASSERT(index->table->fts); DBUG_ASSERT(index->table->fts);
DEBUG_SYNC_C("norebuild_fts_drop");
fts_drop_index(index->table, index, trx); fts_drop_index(index->table, index, trx);
} }

View File

@ -1040,17 +1040,6 @@ dict_table_copy_types(
dtuple_t* tuple, /*!< in/out: data tuple */ dtuple_t* tuple, /*!< in/out: data tuple */
const dict_table_t* table) /*!< in: table */ const dict_table_t* table) /*!< in: table */
MY_ATTRIBUTE((nonnull)); MY_ATTRIBUTE((nonnull));
/********************************************************************
Wait until all the background threads of the given table have exited, i.e.,
bg_threads == 0. Note: bg_threads_mutex must be reserved when
calling this. */
void
dict_table_wait_for_bg_threads_to_exit(
/*===================================*/
dict_table_t* table, /* in: table */
ulint delay) /* in: time in microseconds to wait between
checks of bg_threads. */
MY_ATTRIBUTE((nonnull));
/**********************************************************************//** /**********************************************************************//**
Looks for an index with the given id. NOTE that we do not reserve Looks for an index with the given id. NOTE that we do not reserve
the dictionary mutex: this function is for emergency purposes like the dictionary mutex: this function is for emergency purposes like

View File

@ -304,27 +304,6 @@ struct fts_table_t {
index auxiliary table */ index auxiliary table */
}; };
enum fts_status {
BG_THREAD_STOP = 1, /*!< TRUE if the FTS background thread
has finished reading the ADDED table,
meaning more items can be added to
the table. */
BG_THREAD_READY = 2, /*!< TRUE if the FTS background thread
is ready */
ADD_THREAD_STARTED = 4, /*!< TRUE if the FTS add thread
has started */
ADDED_TABLE_SYNCED = 8, /*!< TRUE if the ADDED table record is
sync-ed after crash recovery */
TABLE_DICT_LOCKED = 16 /*!< Set if the table has
dict_sys->mutex */
};
typedef enum fts_status fts_status_t;
/** The state of the FTS sub system. */ /** The state of the FTS sub system. */
class fts_t { class fts_t {
public: public:
@ -341,13 +320,19 @@ public:
/** Mutex protecting bg_threads* and fts_add_wq. */ /** Mutex protecting bg_threads* and fts_add_wq. */
ib_mutex_t bg_threads_mutex; ib_mutex_t bg_threads_mutex;
/** Whether the table was added to fts_optimize_wq();
protected by bg_threads_mutex */
unsigned in_queue:1;
/** Whether the ADDED table record sync-ed after
crash recovery; protected by bg_threads_mutex */
unsigned added_synced:1;
/** Whether the table holds dict_sys->mutex;
protected by bg_threads_mutex */
unsigned dict_locked:1;
/** Number of background threads accessing this table. */ /** Number of background threads accessing this table. */
ulint bg_threads; ulint bg_threads;
/** Status bit regarding fts running state. TRUE if background
threads running should stop themselves. */
ulint fts_status;
/** Work queue for scheduling jobs for the FTS 'Add' thread, or NULL /** Work queue for scheduling jobs for the FTS 'Add' thread, or NULL
if the thread has not yet been created. Each work item is a if the thread has not yet been created. Each work item is a
fts_trx_doc_ids_t*. */ fts_trx_doc_ids_t*. */
@ -634,28 +619,6 @@ void
fts_startup(void); fts_startup(void);
/*==============*/ /*==============*/
#if 0 // TODO: Enable this in WL#6608
/******************************************************************//**
Signal FTS threads to initiate shutdown. */
void
fts_start_shutdown(
/*===============*/
dict_table_t* table, /*!< in: table with FTS
indexes */
fts_t* fts); /*!< in: fts instance to
shutdown */
/******************************************************************//**
Wait for FTS threads to shutdown. */
void
fts_shutdown(
/*=========*/
dict_table_t* table, /*!< in: table with FTS
indexes */
fts_t* fts); /*!< in: fts instance to
shutdown */
#endif
/******************************************************************//** /******************************************************************//**
Create an instance of fts_t. Create an instance of fts_t.
@return instance of fts_t */ @return instance of fts_t */

View File

@ -442,19 +442,6 @@ fts_cache_append_deleted_doc_ids(
cache, /*!< in: cache to use */ cache, /*!< in: cache to use */
ib_vector_t* vector); /*!< in: append to this vector */ ib_vector_t* vector); /*!< in: append to this vector */
/******************************************************************//** /******************************************************************//**
Wait for the background thread to start. We poll to detect change
of state, which is acceptable, since the wait should happen only
once during startup.
@return true if the thread started else FALSE (i.e timed out) */
ibool
fts_wait_for_background_thread_to_start(
/*====================================*/
dict_table_t* table, /*!< in: table to which the thread
is attached */
ulint max_wait); /*!< in: time in microseconds, if set
to 0 then it disables timeout
checking */
/******************************************************************//**
Search the index specific cache for a particular FTS index. Search the index specific cache for a particular FTS index.
@return the index specific cache else NULL */ @return the index specific cache else NULL */
fts_index_cache_t* fts_index_cache_t*

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation. Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@ -92,10 +92,7 @@ row_ins_clust_index_entry_low(
ulint n_uniq, /*!< in: 0 or index->n_uniq */ ulint n_uniq, /*!< in: 0 or index->n_uniq */
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
ulint n_ext, /*!< in: number of externally stored columns */ ulint n_ext, /*!< in: number of externally stored columns */
que_thr_t* thr, /*!< in: query thread or NULL */ que_thr_t* thr) /*!< in: query thread or NULL */
bool dup_chk_only)
/*!< in: if true, just do duplicate check
and return. don't execute actual insert. */
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/***************************************************************//** /***************************************************************//**
@ -120,10 +117,7 @@ row_ins_sec_index_entry_low(
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
trx_id_t trx_id, /*!< in: PAGE_MAX_TRX_ID during trx_id_t trx_id, /*!< in: PAGE_MAX_TRX_ID during
row_log_table_apply(), or 0 */ row_log_table_apply(), or 0 */
que_thr_t* thr, /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
bool dup_chk_only)
/*!< in: if true, just do duplicate check
and return. don't execute actual insert. */
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/***************************************************************//** /***************************************************************//**
@ -138,10 +132,7 @@ row_ins_clust_index_entry(
dict_index_t* index, /*!< in: clustered index */ dict_index_t* index, /*!< in: clustered index */
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
que_thr_t* thr, /*!< in: query thread */ que_thr_t* thr, /*!< in: query thread */
ulint n_ext, /*!< in: number of externally stored columns */ ulint n_ext) /*!< in: number of externally stored columns */
bool dup_chk_only)
/*!< in: if true, just do duplicate check
and return. don't execute actual insert. */
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/***************************************************************//** /***************************************************************//**
Inserts an entry into a secondary index. Tries first optimistic, Inserts an entry into a secondary index. Tries first optimistic,
@ -154,10 +145,7 @@ row_ins_sec_index_entry(
/*====================*/ /*====================*/
dict_index_t* index, /*!< in: secondary index */ dict_index_t* index, /*!< in: secondary index */
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
que_thr_t* thr, /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
bool dup_chk_only)
/*!< in: if true, just do duplicate check
and return. don't execute actual insert. */
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/***********************************************************//** /***********************************************************//**
Inserts a row to a table. This is a high-level function used in Inserts a row to a table. This is a high-level function used in

View File

@ -6182,6 +6182,8 @@ lock_cancel_waiting_and_release(
} }
lock_table_dequeue(lock); lock_table_dequeue(lock);
/* Remove the lock from table lock vector too. */
lock_trx_table_locks_remove(lock);
} }
/* Reset the wait flag and the back pointer to lock in trx. */ /* Reset the wait flag and the back pointer to lock in trx. */

View File

@ -2593,10 +2593,7 @@ row_ins_clust_index_entry_low(
ulint n_uniq, /*!< in: 0 or index->n_uniq */ ulint n_uniq, /*!< in: 0 or index->n_uniq */
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
ulint n_ext, /*!< in: number of externally stored columns */ ulint n_ext, /*!< in: number of externally stored columns */
que_thr_t* thr, /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
bool dup_chk_only)
/*!< in: if true, just do duplicate check
and return. don't execute actual insert. */
{ {
btr_pcur_t pcur; btr_pcur_t pcur;
btr_cur_t* cursor; btr_cur_t* cursor;
@ -2685,7 +2682,6 @@ row_ins_clust_index_entry_low(
ut_ad(flags == BTR_NO_LOCKING_FLAG); ut_ad(flags == BTR_NO_LOCKING_FLAG);
ut_ad(index->is_instant()); ut_ad(index->is_instant());
ut_ad(!dict_index_is_online_ddl(index)); ut_ad(!dict_index_is_online_ddl(index));
ut_ad(!dup_chk_only);
const rec_t* rec = btr_cur_get_rec(cursor); const rec_t* rec = btr_cur_get_rec(cursor);
@ -2751,11 +2747,6 @@ err_exit:
} }
} }
if (dup_chk_only) {
mtr_commit(&mtr);
goto func_exit;
}
/* Note: Allowing duplicates would qualify for modification of /* Note: Allowing duplicates would qualify for modification of
an existing record as the new entry is exactly same as old entry. */ an existing record as the new entry is exactly same as old entry. */
if (row_ins_must_modify_rec(cursor)) { if (row_ins_must_modify_rec(cursor)) {
@ -2917,10 +2908,7 @@ row_ins_sec_index_entry_low(
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
trx_id_t trx_id, /*!< in: PAGE_MAX_TRX_ID during trx_id_t trx_id, /*!< in: PAGE_MAX_TRX_ID during
row_log_table_apply(), or 0 */ row_log_table_apply(), or 0 */
que_thr_t* thr, /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
bool dup_chk_only)
/*!< in: if true, just do duplicate check
and return. don't execute actual insert. */
{ {
DBUG_ENTER("row_ins_sec_index_entry_low"); DBUG_ENTER("row_ins_sec_index_entry_low");
@ -3117,10 +3105,6 @@ row_ins_sec_index_entry_low(
&cursor, 0, __FILE__, __LINE__, &mtr); &cursor, 0, __FILE__, __LINE__, &mtr);
} }
if (dup_chk_only) {
goto func_exit;
}
if (row_ins_must_modify_rec(&cursor)) { if (row_ins_must_modify_rec(&cursor)) {
/* There is already an index entry with a long enough common /* There is already an index entry with a long enough common
prefix, we must convert the insert into a modify of an prefix, we must convert the insert into a modify of an
@ -3209,10 +3193,7 @@ row_ins_clust_index_entry(
dict_index_t* index, /*!< in: clustered index */ dict_index_t* index, /*!< in: clustered index */
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
que_thr_t* thr, /*!< in: query thread */ que_thr_t* thr, /*!< in: query thread */
ulint n_ext, /*!< in: number of externally stored columns */ ulint n_ext) /*!< in: number of externally stored columns */
bool dup_chk_only)
/*!< in: if true, just do duplicate check
and return. don't execute actual insert. */
{ {
dberr_t err; dberr_t err;
ulint n_uniq; ulint n_uniq;
@ -3251,7 +3232,7 @@ row_ins_clust_index_entry(
err = row_ins_clust_index_entry_low( err = row_ins_clust_index_entry_low(
flags, BTR_MODIFY_LEAF, index, n_uniq, entry, flags, BTR_MODIFY_LEAF, index, n_uniq, entry,
n_ext, thr, dup_chk_only); n_ext, thr);
entry->n_fields = orig_n_fields; entry->n_fields = orig_n_fields;
@ -3268,7 +3249,7 @@ row_ins_clust_index_entry(
err = row_ins_clust_index_entry_low( err = row_ins_clust_index_entry_low(
flags, BTR_MODIFY_TREE, index, n_uniq, entry, flags, BTR_MODIFY_TREE, index, n_uniq, entry,
n_ext, thr, dup_chk_only); n_ext, thr);
entry->n_fields = orig_n_fields; entry->n_fields = orig_n_fields;
@ -3286,10 +3267,7 @@ row_ins_sec_index_entry(
/*====================*/ /*====================*/
dict_index_t* index, /*!< in: secondary index */ dict_index_t* index, /*!< in: secondary index */
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
que_thr_t* thr, /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
bool dup_chk_only)
/*!< in: if true, just do duplicate check
and return. don't execute actual insert. */
{ {
dberr_t err; dberr_t err;
mem_heap_t* offsets_heap; mem_heap_t* offsets_heap;
@ -3332,7 +3310,7 @@ row_ins_sec_index_entry(
err = row_ins_sec_index_entry_low( err = row_ins_sec_index_entry_low(
flags, BTR_MODIFY_LEAF, index, offsets_heap, heap, entry, flags, BTR_MODIFY_LEAF, index, offsets_heap, heap, entry,
trx_id, thr, dup_chk_only); trx_id, thr);
if (err == DB_FAIL) { if (err == DB_FAIL) {
mem_heap_empty(heap); mem_heap_empty(heap);
@ -3346,8 +3324,7 @@ row_ins_sec_index_entry(
err = row_ins_sec_index_entry_low( err = row_ins_sec_index_entry_low(
flags, BTR_MODIFY_TREE, index, flags, BTR_MODIFY_TREE, index,
offsets_heap, heap, entry, 0, thr, offsets_heap, heap, entry, 0, thr);
dup_chk_only);
} }
mem_heap_free(heap); mem_heap_free(heap);
@ -3376,9 +3353,9 @@ row_ins_index_entry(
return(DB_LOCK_WAIT);}); return(DB_LOCK_WAIT);});
if (index->is_primary()) { if (index->is_primary()) {
return(row_ins_clust_index_entry(index, entry, thr, 0, false)); return row_ins_clust_index_entry(index, entry, thr, 0);
} else { } else {
return(row_ins_sec_index_entry(index, entry, thr, false)); return row_ins_sec_index_entry(index, entry, thr);
} }
} }

View File

@ -1717,7 +1717,7 @@ row_log_table_apply_insert_low(
error = row_ins_clust_index_entry_low( error = row_ins_clust_index_entry_low(
flags, BTR_MODIFY_TREE, index, index->n_uniq, flags, BTR_MODIFY_TREE, index, index->n_uniq,
entry, 0, thr, false); entry, 0, thr);
switch (error) { switch (error) {
case DB_SUCCESS: case DB_SUCCESS:
@ -1741,7 +1741,7 @@ row_log_table_apply_insert_low(
error = row_ins_sec_index_entry_low( error = row_ins_sec_index_entry_low(
flags, BTR_MODIFY_TREE, flags, BTR_MODIFY_TREE,
index, offsets_heap, heap, entry, index, offsets_heap, heap, entry,
thr_get_trx(thr)->id, thr, false); thr_get_trx(thr)->id, thr);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
if (error == DB_DUPLICATE_KEY) { if (error == DB_DUPLICATE_KEY) {
@ -2373,7 +2373,7 @@ func_exit_committed:
BTR_CREATE_FLAG | BTR_NO_LOCKING_FLAG BTR_CREATE_FLAG | BTR_NO_LOCKING_FLAG
| BTR_NO_UNDO_LOG_FLAG | BTR_KEEP_SYS_FLAG, | BTR_NO_UNDO_LOG_FLAG | BTR_KEEP_SYS_FLAG,
BTR_MODIFY_TREE, index, offsets_heap, heap, BTR_MODIFY_TREE, index, offsets_heap, heap,
entry, thr_get_trx(thr)->id, thr, false); entry, thr_get_trx(thr)->id, thr);
/* Report correct index name for duplicate key error. */ /* Report correct index name for duplicate key error. */
if (error == DB_DUPLICATE_KEY) { if (error == DB_DUPLICATE_KEY) {

View File

@ -3246,10 +3246,9 @@ row_drop_ancillary_fts_tables(
DICT_TF2_FTS flag set. So keep this out of above DICT_TF2_FTS flag set. So keep this out of above
dict_table_has_fts_index condition */ dict_table_has_fts_index condition */
if (table->fts != NULL) { if (table->fts != NULL) {
/* Need to set TABLE_DICT_LOCKED bit, since /* fts_que_graph_free_check_lock would try to acquire
fts_que_graph_free_check_lock would try to acquire
dict mutex lock */ dict mutex lock */
table->fts->fts_status |= TABLE_DICT_LOCKED; table->fts->dict_locked = true;
fts_free(table); fts_free(table);
} }

View File

@ -2529,7 +2529,7 @@ row_upd_sec_index_entry(
ut_a(entry); ut_a(entry);
/* Insert new index entry */ /* Insert new index entry */
err = row_ins_sec_index_entry(index, entry, thr, false); err = row_ins_sec_index_entry(index, entry, thr);
func_exit: func_exit:
mem_heap_free(heap); mem_heap_free(heap);
@ -2801,7 +2801,7 @@ check_fk:
err = row_ins_clust_index_entry( err = row_ins_clust_index_entry(
index, entry, thr, index, entry, thr,
node->upd_ext ? node->upd_ext->n_ext : 0, false); node->upd_ext ? node->upd_ext->n_ext : 0);
node->state = UPD_NODE_INSERT_CLUSTERED; node->state = UPD_NODE_INSERT_CLUSTERED;
mem_heap_free(heap); mem_heap_free(heap);

View File

@ -499,7 +499,7 @@ inline void trx_t::release_locks()
mem_heap_empty(lock.lock_heap); mem_heap_empty(lock.lock_heap);
} }
lock.table_locks.clear(); /* outside "if" to work around MDEV-20483 */ lock.table_locks.clear();
} }
/** At shutdown, frees a transaction object. */ /** At shutdown, frees a transaction object. */
@ -1147,27 +1147,15 @@ trx_finalize_for_fts_table(
fts_t* fts = ftt->table->fts; fts_t* fts = ftt->table->fts;
fts_doc_ids_t* doc_ids = ftt->added_doc_ids; fts_doc_ids_t* doc_ids = ftt->added_doc_ids;
mutex_enter(&fts->bg_threads_mutex);
if (fts->fts_status & BG_THREAD_STOP) {
/* The table is about to be dropped, no use
adding anything to its work queue. */
mutex_exit(&fts->bg_threads_mutex);
} else {
mem_heap_t* heap;
mutex_exit(&fts->bg_threads_mutex);
ut_a(fts->add_wq); ut_a(fts->add_wq);
heap = static_cast<mem_heap_t*>(doc_ids->self_heap->arg); mem_heap_t* heap = static_cast<mem_heap_t*>(doc_ids->self_heap->arg);
ib_wqueue_add(fts->add_wq, doc_ids, heap); ib_wqueue_add(fts->add_wq, doc_ids, heap);
/* fts_trx_table_t no longer owns the list. */ /* fts_trx_table_t no longer owns the list. */
ftt->added_doc_ids = NULL; ftt->added_doc_ids = NULL;
} }
}
/******************************************************************//** /******************************************************************//**
Finalize a transaction containing updates to FTS tables. */ Finalize a transaction containing updates to FTS tables. */
@ -1363,6 +1351,16 @@ trx_commit_in_memory(
DBUG_LOG("trx", "Autocommit in memory: " << trx); DBUG_LOG("trx", "Autocommit in memory: " << trx);
trx->state = TRX_STATE_NOT_STARTED; trx->state = TRX_STATE_NOT_STARTED;
} else { } else {
#ifdef UNIV_DEBUG
if (!UT_LIST_GET_LEN(trx->lock.trx_locks)) {
for (lock_list::iterator it
= trx->lock.table_locks.begin();
it != trx->lock.table_locks.end();
it++) {
ut_ad(!*it);
}
}
#endif /* UNIV_DEBUG */
trx->commit_state(); trx->commit_state();
if (trx->id) { if (trx->id) {

View File

@ -295,31 +295,31 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 502 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 502 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 753 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 753 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 1004 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 1004 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b; explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 753 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b; explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
@ -1599,10 +1599,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 251 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 502 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 251 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 502 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 251 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 251 Using where; Using index for group-by
@ -1805,10 +1805,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 Using where; Using index
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b'; explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 63 Using where; Using index for group-by
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e'; explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 63 Using where; Using index for group-by
explain select distinct a1,a2,b from t2; explain select distinct a1,a2,b from t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by
@ -1828,10 +1828,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_2 146 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_2 146 NULL 1000 Using where; Using index
explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b'; explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 129 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 129 NULL 63 Using where; Using index for group-by
explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e'; explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 129 NULL 126 Using where; Using index for group-by 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 129 NULL 63 Using where; Using index for group-by
select distinct a1,a2,b from t1; select distinct a1,a2,b from t1;
a1 a2 b a1 a2 b
a a a a a a
@ -1975,10 +1975,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by; Using temporary; Using filesort 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 251 Using where; Using index for group-by; Using temporary; Using filesort
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1; explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 63 Using where; Using index for group-by
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1; explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 126 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 63 Using where; Using index for group-by
explain select distinct a1,a2,b from t2; explain select distinct a1,a2,b from t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by 1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by
@ -2204,19 +2204,19 @@ id select_type table type possible_keys key key_len ref rows Extra
explain extended select a1,a2,min(b),max(b) from t1 explain extended select a1,a2,min(b),max(b) from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2; where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 1000 100.00 Using where; Using index 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 1000 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`
explain extended select a1,a2,b,min(c),max(c) from t1 explain extended select a1,a2,b,min(c),max(c) from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b; where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 1000 100.00 Using where 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 1000 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain extended select a1,a2,b,c from t1 explain extended select a1,a2,b,c from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 1000 100.00 Using where 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 1000 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c`
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1; explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
@ -2233,7 +2233,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 1000 Using where; Using index
explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 1000 100.00 Using where; Using index 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 1000 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
@ -2257,12 +2257,12 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 Using index 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 1000 Using index
explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 1000 100.00 Using where; Using index 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 1000 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 1000 100.00 Using where; Using index 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 1000 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1; explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1;

View File

@ -101,6 +101,7 @@ a b
SELECT * FROM t1 FORCE INDEX (kb); SELECT * FROM t1 FORCE INDEX (kb);
a b a b
DROP TABLE t1; DROP TABLE t1;
set global rocksdb_compact_cf= 'default';
# Read filtering index scan tests (None of these queries should return any results) # Read filtering index scan tests (None of these queries should return any results)
CREATE TABLE t1 ( CREATE TABLE t1 (
a int, a int,

View File

@ -121,6 +121,9 @@ SELECT * FROM t1 FORCE INDEX (kb);
DROP TABLE t1; DROP TABLE t1;
# Compact away the dropped data
set global rocksdb_compact_cf= 'default';
--echo # Read filtering index scan tests (None of these queries should return any results) --echo # Read filtering index scan tests (None of these queries should return any results)
CREATE TABLE t1 ( CREATE TABLE t1 (
a int, a int,

View File

@ -2163,7 +2163,7 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort )
#if MYSQL_VERSION_ID>=50515 #if MYSQL_VERSION_ID>=50515
struct addrinfo *hp = NULL; struct addrinfo *hp = NULL;
tmp_errno = getaddrinfo ( sHost, NULL, NULL, &hp ); tmp_errno = getaddrinfo ( sHost, NULL, NULL, &hp );
if ( !tmp_errno || !hp || !hp->ai_addr ) if ( tmp_errno || !hp || !hp->ai_addr )
{ {
bError = true; bError = true;
if ( hp ) if ( hp )
@ -2190,7 +2190,8 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort )
} }
#if MYSQL_VERSION_ID>=50515 #if MYSQL_VERSION_ID>=50515
memcpy ( &sin.sin_addr, hp->ai_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->ai_addrlen ) ); struct sockaddr_in *in = (sockaddr_in *)hp->ai_addr;
memcpy ( &sin.sin_addr, &in->sin_addr, Min ( sizeof(sin.sin_addr), sizeof(in->sin_addr) ) );
freeaddrinfo ( hp ); freeaddrinfo ( hp );
#else #else
memcpy ( &sin.sin_addr, hp->h_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->h_length ) ); memcpy ( &sin.sin_addr, hp->h_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->h_length ) );

View File

@ -75,3 +75,23 @@ id w q
1 2 test;range=meta.foo_count,100,500 1 2 test;range=meta.foo_count,100,500
5 1 test;range=meta.foo_count,100,500 5 1 test;range=meta.foo_count,100,500
drop table ts; drop table ts;
#
# MDEV-19205: Sphinx unable to connect using a host name
#
create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://localhost:SPHINXSEARCH_PORT/*";
select * from ts where q=';filter=meta.foo_count,100';
id w q
1 1 ;filter=meta.foo_count,100
select * from ts where q='test;filter=meta.sub.int,7';
id w q
5 1 test;filter=meta.sub.int,7
select * from ts where q=';filter=meta.sub.list[0],4';
id w q
select * from ts where q=';filter=meta.sub.list[1],4';
id w q
5 1 ;filter=meta.sub.list[1],4
select * from ts where q='test;range=meta.foo_count,100,500';
id w q
1 2 test;range=meta.foo_count,100,500
5 1 test;range=meta.foo_count,100,500
drop table ts;

View File

@ -41,3 +41,16 @@ select * from ts where q=';filter=meta.sub.list[0],4';
select * from ts where q=';filter=meta.sub.list[1],4'; select * from ts where q=';filter=meta.sub.list[1],4';
select * from ts where q='test;range=meta.foo_count,100,500'; select * from ts where q='test;range=meta.foo_count,100,500';
drop table ts; drop table ts;
--echo #
--echo # MDEV-19205: Sphinx unable to connect using a host name
--echo #
--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT
eval create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://localhost:$SPHINXSEARCH_PORT/*";
select * from ts where q=';filter=meta.foo_count,100';
select * from ts where q='test;filter=meta.sub.int,7';
select * from ts where q=';filter=meta.sub.list[0],4';
select * from ts where q=';filter=meta.sub.list[1],4';
select * from ts where q='test;range=meta.foo_count,100,500';
drop table ts;

View File

@ -31,7 +31,7 @@ delete from foo where a > 5;
# number of rows should be 9 # number of rows should be 9
explain select * from foo where a > 1; explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values # should have just 4 values
select * from foo where a > 1; select * from foo where a > 1;
a b a b
@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9 # number of rows should be 9
explain select * from foo where a > 1; explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values # 9 values
select * From foo where a > 1; select * From foo where a > 1;
a b a b

View File

@ -31,7 +31,7 @@ delete from foo where a < 10;
# number of rows should be 9 # number of rows should be 9
explain select * from foo where a < 50; explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values # should have just 4 values
select * from foo where a < 50; select * from foo where a < 50;
a b a b
@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9 # number of rows should be 9
explain select * from foo where a < 50; explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values # 9 values
select * From foo where a < 50; select * From foo where a < 50;
a b a b

View File

@ -31,7 +31,7 @@ delete from foo where a = 2 or a = 4 or a = 10 or a = 30 or a = 50;
# number of rows should be 8 # number of rows should be 8
explain select * from foo where a > 1 and a < 50; explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values # should have just 4 values
select * from foo where a > 1 and a < 50; select * from foo where a > 1 and a < 50;
a b a b
@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 8 # number of rows should be 8
explain select * from foo where a > 1 and a < 50; explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 8 values # 8 values
select * from foo where a > 1 and a < 50; select * from foo where a > 1 and a < 50;
a b a b

View File

@ -6,5 +6,5 @@ create table t2970 (a int, b int, c int, d int, key(a), key(a,b));
insert into t2970 values (1,1,1,1),(1,2,3,4); insert into t2970 values (1,1,1,1),(1,2,3,4);
explain select a,count(b),max(b) from t2970 where a > 0 group by a order by a; explain select a,count(b),max(b) from t2970 where a > 0 group by a order by a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2970 index a,a_2 a_2 10 NULL 2 Using where; Using index 1 SIMPLE t2970 range a,a_2 a_2 5 NULL 2 Using where; Using index
drop table t2970; drop table t2970;

View File

@ -1,16 +1,22 @@
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. If you want to customize, the
# best way is to create a file "/etc/systemd/system/mariadb.service",
# containing
# .include /usr/lib/systemd/system/mariadb.service
# ...make your changes here...
# or create a file "/etc/systemd/system/mariadb.service.d/foo.conf",
# which doesn't need to include ".include" call and which will be parsed
# after the file mariadb.service itself is parsed.
# #
# /etc/systemd/system/mariadb.service # For more info about custom unit files, see systemd.unit(5) or
# https://mariadb.com/kb/en/mariadb/systemd/
#
# Copyright notice:
# #
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by # under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or # the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version. # (at your option) any later version.
#
# Thanks to:
# Daniel Black
# Erkan Yanar
# David Strauss
# and probably others
[Unit] [Unit]
Description=MariaDB @VERSION@ database server Description=MariaDB @VERSION@ database server
@ -80,12 +86,15 @@ ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
# Use the [Service] section and Environment="MYSQLD_OPTS=...". # Use the [Service] section and Environment="MYSQLD_OPTS=...".
# This isn't a replacement for my.cnf. # This isn't a replacement for my.cnf.
# _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster # _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster
ExecStart=@sbindir@/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION # Note: we set --basedir to prevent probes that might trigger SELinux alarms,
@SYSTEMD_EXECSTARTPOST@ # per bug https://bugzilla.redhat.com/show_bug.cgi?id=547485
ExecStart=@sbindir@/mysqld $MYSQLD_OPTS --basedir=@prefix@ $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION
# Unset _WSREP_START_POSITION environment variable. # Unset _WSREP_START_POSITION environment variable.
ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION"
@SYSTEMD_EXECSTARTPOST@
KillSignal=SIGTERM KillSignal=SIGTERM
# Don't want to see an automated SIGKILL ever # Don't want to see an automated SIGKILL ever

View File

@ -1,28 +1,35 @@
# Multi instance version of mariadb. For if you run multiple versions at once. # Multi instance version of mariadb. For if you run multiple versions at once.
# Also used for mariadb@bootstrap to bootstrap Galera.
# #
# create config file @sysconf2dir@/my{instancename}.cnf # create config file @sysconf2dir@/my{instancename}.cnf to be used as the
# configuration file for this service.
# #
# start as systemctl start mariadb@{instancename}.server # start as systemctl start mariadb@{instancename}.server
#
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. If you want to customize, the
# best way is to create a file "/etc/systemd/system/mariadb@.service",
# containing
# .include /usr/lib/systemd/system/mariadb@.service
# ...make your changes here...
# or create a file "/etc/systemd/system/mariadb@.service.d/foo.conf",
# which doesn't need to include ".include" call and which will be parsed
# after the file mariadb@.service itself is parsed.
#
# For more info about custom unit files, see systemd.unit(5) or
# https://mariadb.com/kb/en/mariadb/systemd/
#
# Copyright notice:
#
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by # under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or # the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version. # (at your option) any later version.
#
# Thanks to:
# Daniel Black
# Erkan Yanar
# David Strauss
# and probably others
# Inspired from https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mysql-init-scripts/files/mysqld_at.service
[Unit] [Unit]
Description=MariaDB @VERSION@ database server (multi-instance) Description=MariaDB @VERSION@ database server (multi-instance %I)
Documentation=man:mysqld(8) Documentation=man:mysqld(8)
Documentation=https://mariadb.com/kb/en/library/systemd/ Documentation=https://mariadb.com/kb/en/library/systemd/
After=network.target After=network.target
ConditionPathExists=@sysconf2dir@/my%I.cnf ConditionPathExists=@sysconf2dir@/my%I.cnf
[Install] [Install]
@ -67,6 +74,8 @@ ProtectHome=true
# Execute pre and post scripts as root, otherwise it does it as User= # Execute pre and post scripts as root, otherwise it does it as User=
PermissionsStartOnly=true PermissionsStartOnly=true
@SYSTEMD_EXECSTARTPRE@
# Perform automatic wsrep recovery. When server is started without wsrep, # Perform automatic wsrep recovery. When server is started without wsrep,
# galera_recovery simply returns an empty string. In any case, however, # galera_recovery simply returns an empty string. In any case, however,
# the script is not expected to return with a non-zero status. # the script is not expected to return with a non-zero status.
@ -94,9 +103,12 @@ ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
# This isn't a replacement for my.cnf. # This isn't a replacement for my.cnf.
# _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster # _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# per bug https://bugzilla.redhat.com/show_bug.cgi?id=547485
#
# Note: Place $MYSQLD_OPTS at the very end for its options to take precedence. # Note: Place $MYSQLD_OPTS at the very end for its options to take precedence.
ExecStart=@sbindir@/mysqld --defaults-file=@sysconf2dir@/my%I.cnf \ ExecStart=@sbindir@/mysqld --defaults-file=@sysconf2dir@/my%I.cnf --basedir=@prefix@ \
$_WSREP_NEW_CLUSTER $_WSREP_START_POSITION%I $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION%I $MYSQLD_OPTS
# Alternate: (remove ConditionPathExists above) # Alternate: (remove ConditionPathExists above)
# use [mysqld.INSTANCENAME] as sections in my.cnf # use [mysqld.INSTANCENAME] as sections in my.cnf
@ -107,6 +119,8 @@ ExecStart=@sbindir@/mysqld --defaults-file=@sysconf2dir@/my%I.cnf \
# Unset _WSREP_START_POSITION environment variable. # Unset _WSREP_START_POSITION environment variable.
ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I" ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I"
@SYSTEMD_EXECSTARTPOST@
KillSignal=SIGTERM KillSignal=SIGTERM
# Don't want to see an automated SIGKILL ever # Don't want to see an automated SIGKILL ever

View File

@ -15,8 +15,11 @@ ConditionPathExists=
Type=oneshot Type=oneshot
Restart=no Restart=no
ExecStartPre=
# Override the multi instance service for a bootstrap start instance # Override the multi instance service for a bootstrap start instance
ExecStart= ExecStart=
ExecStart=/usr/bin/echo "Please use galera_new_cluster to start the mariadb service with --wsrep-new-cluster" ExecStart=/usr/bin/echo "Please use galera_new_cluster to start the mariadb service with --wsrep-new-cluster"
ExecStart=/usr/bin/false ExecStart=/usr/bin/false
ExecStartPost=