Merge branch '10.3' into 10.4

This commit is contained in:
Oleksandr Byelkin 2022-08-03 19:51:44 +02:00
commit e509065247
22 changed files with 622 additions and 180 deletions

View file

@ -146,6 +146,7 @@ static ulonglong opt_system= 0ULL;
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0,
select_field_names_inited= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static double opt_max_statement_time= 0.0;
static MYSQL mysql_connection,*mysql=0;
static DYNAMIC_STRING insert_pat, select_field_names;
static char *opt_password=0,*current_user=0,
@ -162,6 +163,7 @@ static my_bool server_supports_switching_charsets= TRUE;
static ulong opt_compatible_mode= 0;
#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2
#define MYSQL_OPT_MAX_STATEMENT_TIME 0
#define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL 1
#define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL 2
static uint opt_mysql_port= 0, opt_master_data;
@ -461,6 +463,10 @@ static struct my_option my_long_options[] =
&opt_max_allowed_packet, &opt_max_allowed_packet, 0,
GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096,
(longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
{"max-statement-time", MYSQL_OPT_MAX_STATEMENT_TIME,
"Max statement execution time. If unset, overrides server default with 0.",
&opt_max_statement_time, &opt_max_statement_time, 0, GET_DOUBLE,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
"The buffer size for TCP/IP and socket communication.",
&opt_net_buffer_length, &opt_net_buffer_length, 0,
@ -3056,9 +3062,8 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
if (strcmp(field->name, "View") == 0)
{
char *scv_buff= NULL;
my_ulonglong n_cols;
verbose_msg("-- It's a view, create dummy table for view\n");
verbose_msg("-- It's a view, create dummy view for view\n");
/* save "show create" statement for later */
if ((row= mysql_fetch_row(result)) && (scv_buff=row[1]))
@ -3067,9 +3072,9 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
mysql_free_result(result);
/*
Create a table with the same name as the view and with columns of
Create a view with the same name as the view and with columns of
the same name in order to satisfy views that depend on this view.
The table will be removed when the actual view is created.
The view will be removed when the actual view is created.
The properties of each column, are not preserved in this temporary
table, because they are not necessary.
@ -3101,23 +3106,9 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
else
my_free(scv_buff);
n_cols= mysql_num_rows(result);
if (0 != n_cols)
if (mysql_num_rows(result) != 0)
{
/*
The actual formula is based on the column names and how the .FRM
files are stored and is too volatile to be repeated here.
Thus we simply warn the user if the columns exceed a limit we
know works most of the time.
*/
if (n_cols >= 1000)
fprintf(stderr,
"-- Warning: Creating a stand-in table for view %s may"
" fail when replaying the dump file produced because "
"of the number of columns exceeding 1000. Exercise "
"caution when replaying the produced dump file.\n",
table);
if (opt_drop)
{
/*
@ -3133,7 +3124,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
fprintf(sql_file,
"SET @saved_cs_client = @@character_set_client;\n"
"SET character_set_client = utf8;\n"
"/*!50001 CREATE TABLE %s (\n",
"/*!50001 CREATE VIEW %s AS SELECT\n",
result_table);
/*
@ -3145,28 +3136,21 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
row= mysql_fetch_row(result);
/*
The actual column type doesn't matter anyway, since the table will
The actual column value doesn't matter anyway, since the view will
be dropped at run time.
We do tinyint to avoid hitting the row size limit.
*/
fprintf(sql_file, " %s tinyint NOT NULL",
fprintf(sql_file, " 1 AS %s",
quote_name(row[0], name_buff, 0));
while((row= mysql_fetch_row(result)))
{
/* col name, col type */
fprintf(sql_file, ",\n %s tinyint NOT NULL",
fprintf(sql_file, ",\n 1 AS %s",
quote_name(row[0], name_buff, 0));
}
/*
Stand-in tables are always MyISAM tables as the default
engine might have a column-limit that's lower than the
number of columns in the view, and MyISAM support is
guaranteed to be in the server anyway.
*/
fprintf(sql_file,
"\n) ENGINE=MyISAM */;\n"
" */;\n"
"SET character_set_client = @saved_cs_client;\n");
check_io(sql_file);
@ -6626,15 +6610,8 @@ static my_bool get_view_structure(char *table, char* db)
"\n--\n-- Final view structure for view %s\n--\n\n",
fix_for_comment(result_table));
/* Table might not exist if this view was dumped with --tab. */
fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table);
if (opt_drop)
{
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
opt_quoted_table);
check_io(sql_file);
}
/* View might not exist if this view was dumped with --tab. */
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n", opt_quoted_table);
my_snprintf(query, sizeof(query),
"SELECT CHECK_OPTION, DEFINER, SECURITY_TYPE, "
@ -6806,6 +6783,7 @@ static void dynstr_realloc_checked(DYNAMIC_STRING *str, ulong additional_size)
int main(int argc, char **argv)
{
char query[48];
char bin_log_name[FN_REFLEN];
int exit_code;
int consistent_binlog_pos= 0;
@ -6847,6 +6825,13 @@ int main(int argc, char **argv)
if (!path)
write_header(md_result_file, *argv);
/* Set MAX_STATEMENT_TIME to 0 unless set in client */
my_snprintf(query, sizeof(query), "/*!100100 SET @@MAX_STATEMENT_TIME=%f */", opt_max_statement_time);
mysql_query(mysql, query);
/* Set server side timeout between client commands to server compiled-in default */
mysql_query(mysql, "/*!100100 SET WAIT_TIMEOUT=DEFAULT */");
/* Check if the server support multi source */
if (mysql_get_server_version(mysql) >= 100000)
{

View file

@ -514,13 +514,15 @@ static void safe_exit(int error, MYSQL *mysql)
if (mysql)
mysql_close(mysql);
mysql_library_end();
free_defaults(argv_to_free);
my_free(opt_password);
if (error)
sf_leaking_memory= 1; /* dirty exit, some threads are still running */
else
{
mysql_library_end();
free_defaults(argv_to_free);
my_free(opt_password);
my_end(my_end_arg); /* clean exit */
}
exit(error);
}

View file

@ -1361,6 +1361,21 @@ Sets the maximum packet length to send to or receive from server\&.
.sp -1
.IP \(bu 2.3
.\}
.\" mysqldump: max-statement-time option
.\" max-statement-time option: mysqldump
\fB\-\-max\-statement\-time=\fR\fB\fIseconds\fR\fR
.sp
Sets the maximum time any statement can run before being timed out by the server. (Default value is 0 (no limit))\&
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
.\" mysqldump: net-buffer-length option
.\" net-buffer-length option: mysqldump
\fB\-\-net\-buffer\-length=\fR\fB\fIlength\fR\fR
@ -2619,6 +2634,21 @@ The maximum size of the buffer for client/server communication\&. The maximum is
.sp -1
.IP \(bu 2.3
.\}
max_statement_time
.sp
A query that has taken more than max_statement_time seconds will be aborted and the backup will
fail\&. The argument will be treated as a decimal value with microsecond precision\&. A value
of 0 (default) means no timeout\&. The maximum timeout is 31536000 seconds\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
net_buffer_length
.sp
The initial size of the buffer for client/server communication\&. When creating multiple\-row

View file

@ -2524,5 +2524,30 @@ DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
#
# MDEV-23809: Server crash in JOIN_CACHE::free or ...
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
SELECT DISTINCT CASE CONVERT(EXPORT_SET(0, COLLATION(BENCHMARK(1, BIT_OR(0))),0),TIME) WHEN a THEN 1 END AS f FROM t1;
f
NULL
Warnings:
Warning 1292 Truncated incorrect time value: '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0'
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(8) NULL, b BIGINT);
INSERT INTO t1 (a,b) VALUES (NULL,NULL),('foo',NULL);
SELECT DISTINCT STRCMP((b > COLLATION(STDDEV_SAMP(15750))), a) AS f FROM t1;
f
NULL
DROP TABLE t1;
CREATE TABLE t1 (a BIGINT) AS SELECT 1 AS v3 UNION SELECT FALSE ;
SELECT DISTINCT a IN ( COLLATION (AVG ('x'))) FROM t1 ;
a IN ( COLLATION (AVG ('x')))
NULL
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'x'
DROP TABLE t1;
#
# End of 10.3 tests
#

View file

@ -1757,6 +1757,25 @@ DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
--echo #
--echo # MDEV-23809: Server crash in JOIN_CACHE::free or ...
--echo #
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
SELECT DISTINCT CASE CONVERT(EXPORT_SET(0, COLLATION(BENCHMARK(1, BIT_OR(0))),0),TIME) WHEN a THEN 1 END AS f FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(8) NULL, b BIGINT);
INSERT INTO t1 (a,b) VALUES (NULL,NULL),('foo',NULL);
SELECT DISTINCT STRCMP((b > COLLATION(STDDEV_SAMP(15750))), a) AS f FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a BIGINT) AS SELECT 1 AS v3 UNION SELECT FALSE ;
SELECT DISTINCT a IN ( COLLATION (AVG ('x'))) FROM t1 ;
DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo #

View file

@ -954,3 +954,92 @@ ERROR 23000: Duplicate entry '-128' for key 'a'
DROP TABLE t1, t2;
DROP PROCEDURE p1;
# End of 10.2 test
#
# MDEV-28617: INSERT ... SELECT with redundant IN subquery in GROUP BY
# list that uses mergeable derived table containing
# reference to target table
#
create table t1 (a int);
create table t2 (b int);
create table t3 (c int);
insert into t1 values (3), (1);
insert into t2 values (3), (2);
insert into t3 values (4), (2);
insert into t1
select b from t2
where b in (select c from t3
group by (select * from (select a from t1) dt where a = 1));
select * from t1;
a
3
1
2
delete from t1;
insert into t1 values (3), (1);
insert into t1
select b from t2
where b >= any (select c from t3
group by (select * from (select a from t1) dt where a = 1));
select * from t1;
a
3
1
3
2
delete from t1;
insert into t1 values (3), (1);
insert into t1
select b from t2
where b <= all (select c from t3
group by (select * from (select a from t1) dt where a = 1));
select * from t1;
a
3
1
2
delete from t1;
insert into t1 values (3), (1);
insert into t1
select b from t2
where exists (select c from t3
group by (select * from (select a from t1) dt where a = 1));
select * from t1;
a
3
1
3
2
delete from t1;
insert into t1 values (3), (1);
prepare stmt from "
insert into t1
select b from t2
where b in (select c from t3
group by (select * from (select a from t1) dt where a = 1));
";
execute stmt;
select * from t1;
a
3
1
2
delete from t1;
insert into t1 values (3), (1);
execute stmt;
select * from t1;
a
3
1
2
delete from t1;
insert into t1 values (3), (1);
delete from t1
where exists (select b from t2
where b in (select c from t3
group by (select * from (select a from t1) dt
where a = 1)));
select * from t1;
a
deallocate prepare stmt;
drop table t1,t2,t3;
# End of 10.3 test

View file

@ -514,3 +514,85 @@ DROP TABLE t1, t2;
DROP PROCEDURE p1;
--echo # End of 10.2 test
--echo #
--echo # MDEV-28617: INSERT ... SELECT with redundant IN subquery in GROUP BY
--echo # list that uses mergeable derived table containing
--echo # reference to target table
--echo #
create table t1 (a int);
create table t2 (b int);
create table t3 (c int);
insert into t1 values (3), (1);
insert into t2 values (3), (2);
insert into t3 values (4), (2);
insert into t1
select b from t2
where b in (select c from t3
group by (select * from (select a from t1) dt where a = 1));
select * from t1;
delete from t1;
insert into t1 values (3), (1);
insert into t1
select b from t2
where b >= any (select c from t3
group by (select * from (select a from t1) dt where a = 1));
select * from t1;
delete from t1;
insert into t1 values (3), (1);
insert into t1
select b from t2
where b <= all (select c from t3
group by (select * from (select a from t1) dt where a = 1));
select * from t1;
delete from t1;
insert into t1 values (3), (1);
insert into t1
select b from t2
where exists (select c from t3
group by (select * from (select a from t1) dt where a = 1));
select * from t1;
delete from t1;
insert into t1 values (3), (1);
prepare stmt from "
insert into t1
select b from t2
where b in (select c from t3
group by (select * from (select a from t1) dt where a = 1));
";
execute stmt;
select * from t1;
delete from t1;
insert into t1 values (3), (1);
execute stmt;
select * from t1;
delete from t1;
insert into t1 values (3), (1);
delete from t1
where exists (select b from t2
where b in (select c from t3
group by (select * from (select a from t1) dt
where a = 1)));
select * from t1;
deallocate prepare stmt;
drop table t1,t2,t3;
--echo # End of 10.3 test

View file

@ -32,9 +32,8 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER
USE `mysqltest2`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
`a` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v2` AS SELECT
1 AS `a` */;
SET character_set_client = @saved_cs_client;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest3` /*!40100 DEFAULT CHARACTER SET latin1 */;
@ -42,39 +41,34 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest3` /*!40100 DEFAULT CHARACTER
USE `mysqltest3`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v3` (
`a` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v3` AS SELECT
1 AS `a` */;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v3i` (
`a` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v3i` AS SELECT
1 AS `a` */;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v3is` (
`schema_name` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v3is` AS SELECT
1 AS `schema_name` */;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v3nt` (
`1` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v3nt` AS SELECT
1 AS `1` */;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v3ps` (
`user` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v3ps` AS SELECT
1 AS `user` */;
SET character_set_client = @saved_cs_client;
USE `mysqltest1`;
USE `mysqltest2`;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -89,7 +83,7 @@ USE `mysqltest2`;
/*!50001 SET collation_connection = @saved_col_connection */;
USE `mysqltest3`;
/*!50001 DROP TABLE IF EXISTS `v3`*/;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -102,7 +96,7 @@ USE `mysqltest3`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v3i`*/;
/*!50001 DROP VIEW IF EXISTS `v3i`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -115,7 +109,7 @@ USE `mysqltest3`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v3is`*/;
/*!50001 DROP VIEW IF EXISTS `v3is`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -128,7 +122,7 @@ USE `mysqltest3`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v3nt`*/;
/*!50001 DROP VIEW IF EXISTS `v3nt`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -141,7 +135,7 @@ USE `mysqltest3`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v3ps`*/;
/*!50001 DROP VIEW IF EXISTS `v3ps`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -243,11 +237,10 @@ disconnect con1;
connection default;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
`id` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v1` AS SELECT
1 AS `id` */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;

View file

@ -53,11 +53,10 @@ raboof` int(11) DEFAULT NULL
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1
1v` (
`foobar
raboof` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v1
1v` AS SELECT
1 AS `foobar
raboof` */;
SET character_set_client = @saved_cs_client;
--
@ -95,7 +94,7 @@ USE `mysqltest1
-- 1v`
--
/*!50001 DROP TABLE IF EXISTS `v1
/*!50001 DROP VIEW IF EXISTS `v1
1v`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;

View file

@ -0,0 +1,71 @@
#
# MDEV-18702 mysqldump should use max_statement_time=0 and/or allow setting one
#
CREATE DATABASE test1;
USE test1;
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (0);
LOCK TABLE t1 WRITE;
timeout without t1 contents expected
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
SET @save_max_statement_time=@@max_statement_time;
SET GLOBAL max_statement_time=0.1;
UNLOCK TABLES;;
This would be a race condition otherwise, but default max_statement_time=0 makes it succeed
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (0);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
SET GLOBAL max_statement_time=@save_max_statement_time;
DROP DATABASE test1;
#
# End of 10.3 test
#

View file

@ -0,0 +1,26 @@
--echo #
--echo # MDEV-18702 mysqldump should use max_statement_time=0 and/or allow setting one
--echo #
CREATE DATABASE test1;
USE test1;
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (0);
LOCK TABLE t1 WRITE;
--echo timeout without t1 contents expected
--error 2
--exec $MYSQL_DUMP --max-statement-time=1 --skip-lock-tables --skip-comments test1 t1
SET @save_max_statement_time=@@max_statement_time;
SET GLOBAL max_statement_time=0.1;
--send UNLOCK TABLES;
--echo This would be a race condition otherwise, but default max_statement_time=0 makes it succeed
--exec $MYSQL_DUMP --skip-lock-tables --skip-comments test1 t1
--reap
SET GLOBAL max_statement_time=@save_max_statement_time;
DROP DATABASE test1;
--echo #
--echo # End of 10.3 test
--echo #

View file

@ -2068,11 +2068,9 @@ DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
`a` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v2` AS SELECT
1 AS `a` */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -2162,11 +2160,9 @@ DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
`a` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v1` AS SELECT
1 AS `a` */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -2236,11 +2232,9 @@ DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
`a` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v2` AS SELECT
1 AS `a` */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -2350,31 +2344,27 @@ DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
`a` tinyint NOT NULL,
`b` tinyint NOT NULL,
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v1` AS SELECT
1 AS `a`,
1 AS `b`,
1 AS `c` */;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
`a` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v2` AS SELECT
1 AS `a` */;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `v3`;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v3` (
`a` tinyint NOT NULL,
`b` tinyint NOT NULL,
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v3` AS SELECT
1 AS `a`,
1 AS `b`,
1 AS `c` */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -2388,7 +2378,6 @@ SET character_set_client = @saved_cs_client;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -2402,7 +2391,6 @@ SET character_set_client = @saved_cs_client;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v3`*/;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -3109,35 +3097,31 @@ DROP TABLE IF EXISTS `v0`;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v0` (
`a` tinyint NOT NULL,
`b` tinyint NOT NULL,
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v0` AS SELECT
1 AS `a`,
1 AS `b`,
1 AS `c` */;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
`a` tinyint NOT NULL,
`b` tinyint NOT NULL,
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v1` AS SELECT
1 AS `a`,
1 AS `b`,
1 AS `c` */;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
`a` tinyint NOT NULL,
`b` tinyint NOT NULL,
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v2` AS SELECT
1 AS `a`,
1 AS `b`,
1 AS `c` */;
SET character_set_client = @saved_cs_client;
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -3151,7 +3135,6 @@ USE `test`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -3165,7 +3148,6 @@ USE `test`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -3403,7 +3385,7 @@ insert into t values(5, 51);
create view v1 as select qty, price, qty*price as value from t;
create view v2 as select qty from v1;
mysqldump {
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -3418,7 +3400,7 @@ mysqldump {
/*!50001 SET collation_connection = @saved_col_connection */;
} mysqldump {
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -3511,13 +3493,11 @@ DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
`id` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v1` AS SELECT
1 AS `id` */;
SET character_set_client = @saved_cs_client;
USE `mysqldump_test_db`;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -3571,15 +3551,14 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_views` /*!40100 DEFAULT CHAR
USE `mysqldump_views`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `nasishnasifu` (
`id` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `nasishnasifu` AS SELECT
1 AS `id` */;
SET character_set_client = @saved_cs_client;
USE `mysqldump_tables`;
USE `mysqldump_views`;
/*!50001 DROP TABLE IF EXISTS `nasishnasifu`*/;
/*!50001 DROP VIEW IF EXISTS `nasishnasifu`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -3980,11 +3959,9 @@ DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v2` AS SELECT
1 AS `c` */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -4402,13 +4379,11 @@ DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
`id` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v1` AS SELECT
1 AS `id` */;
SET character_set_client = @saved_cs_client;
USE `mysqldump_test_db`;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@ -5496,9 +5471,8 @@ CREATE TABLE `nonunique_table_name` (
/*!40101 SET character_set_client = @saved_cs_client */;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `nonunique_table_view_name` (
`1` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `nonunique_table_view_name` AS SELECT
1 AS `1` */;
SET character_set_client = @saved_cs_client;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `db2` /*!40100 DEFAULT CHARACTER SET utf8 */;
@ -5521,7 +5495,7 @@ CREATE TABLE `nonunique_table_view_name` (
INSERT INTO `nonunique_table_view_name` VALUES (3),(4);
USE `db1`;
/*!50001 DROP TABLE IF EXISTS `nonunique_table_view_name`*/;
/*!50001 DROP VIEW IF EXISTS `nonunique_table_view_name`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -5597,15 +5571,14 @@ CREATE TABLE `nonunique_table_name` (
INSERT INTO `nonunique_table_name` VALUES (5),(6);
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `nonunique_table_view_name` (
`1` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `nonunique_table_view_name` AS SELECT
1 AS `1` */;
SET character_set_client = @saved_cs_client;
USE `db2`;
USE `db1`;
/*!50001 DROP TABLE IF EXISTS `nonunique_table_view_name`*/;
/*!50001 DROP VIEW IF EXISTS `nonunique_table_view_name`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;

View file

@ -0,0 +1,39 @@
#
# Bug 1634932: Assertion failure in thread x in
# file fts0que.cc
#
SET @saved_innodb_ft_result_cache_limit= @@global.innodb_ft_result_cache_limit;
CREATE TABLE `t1` (
`FTS_DOC_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`text_content` MEDIUMTEXT, PRIMARY KEY (`FTS_DOC_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE UNIQUE INDEX FTS_DOC_ID_INDEX ON t1(FTS_DOC_ID);
SET autocommit=0;
CREATE PROCEDURE populate_t1()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE (i <= 250) DO
INSERT INTO t1 (text_content) VALUES ("some_text_1234 aaa");
SET i = i + 1;
END WHILE;
END//
CALL populate_t1;
SET autocommit=1;
SET SESSION debug="+d,fts_instrument_result_cache_limit";
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
ALTER TABLE t1 ADD FULLTEXT INDEX `text_content_idx` (`text_content`);
SELECT FTS_DOC_ID, text_content
FROM t1
WHERE MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE);
ERROR HY000: Table handler out of memory
UPDATE t1
SET text_content='some_text_12345'
where MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE);
ERROR HY000: Table handler out of memory
DELETE FROM t1
WHERE MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE);
ERROR HY000: Table handler out of memory
SET GLOBAL innodb_ft_result_cache_limit = @saved_innodb_ft_result_cache_limit;
DROP TABLE t1;
DROP PROCEDURE populate_t1;

View file

@ -0,0 +1,57 @@
--echo #
--echo # Bug 1634932: Assertion failure in thread x in
--echo # file fts0que.cc
--echo #
--source include/have_innodb.inc
--source include/have_debug.inc
SET @saved_innodb_ft_result_cache_limit= @@global.innodb_ft_result_cache_limit;
CREATE TABLE `t1` (
`FTS_DOC_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`text_content` MEDIUMTEXT, PRIMARY KEY (`FTS_DOC_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE UNIQUE INDEX FTS_DOC_ID_INDEX ON t1(FTS_DOC_ID);
SET autocommit=0;
DELIMITER //;
CREATE PROCEDURE populate_t1()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE (i <= 250) DO
INSERT INTO t1 (text_content) VALUES ("some_text_1234 aaa");
SET i = i + 1;
END WHILE;
END//
DELIMITER ;//
CALL populate_t1;
SET autocommit=1;
SET SESSION debug="+d,fts_instrument_result_cache_limit";
ALTER TABLE t1 ADD FULLTEXT INDEX `text_content_idx` (`text_content`);
# HA_ERR_FTS_EXCEED_RESULT_CACHE_LIMIT = 188
--error 128
SELECT FTS_DOC_ID, text_content
FROM t1
WHERE MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE);
--error 128
UPDATE t1
SET text_content='some_text_12345'
where MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE);
--error 128
DELETE FROM t1
WHERE MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE);
SET GLOBAL innodb_ft_result_cache_limit = @saved_innodb_ft_result_cache_limit;
DROP TABLE t1;
DROP PROCEDURE populate_t1;

View file

@ -280,39 +280,34 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
`a+b` tinyint NOT NULL,
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v1` AS SELECT
1 AS `a+b`,
1 AS `c` */;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
`a+b` tinyint NOT NULL,
`c` tinyint NOT NULL,
`current_role()` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v2` AS SELECT
1 AS `a+b`,
1 AS `c`,
1 AS `current_role()` */;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v3` (
`a+b` tinyint NOT NULL,
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v3` AS SELECT
1 AS `a+b`,
1 AS `c` */;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v4` (
`a+b` tinyint NOT NULL,
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v4` AS SELECT
1 AS `a+b`,
1 AS `c` */;
SET character_set_client = @saved_cs_client;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v5` (
`a+b` tinyint NOT NULL,
`c` tinyint NOT NULL
) ENGINE=MyISAM */;
/*!50001 CREATE VIEW `v5` AS SELECT
1 AS `a+b`,
1 AS `c` */;
SET character_set_client = @saved_cs_client;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET latin1 */;
@ -536,7 +531,7 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -547,7 +542,7 @@ USE `test`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -558,7 +553,7 @@ USE `test`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v3`*/;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -571,7 +566,7 @@ USE `test`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v4`*/;
/*!50001 DROP VIEW IF EXISTS `v4`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@ -584,7 +579,7 @@ USE `test`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!50001 DROP TABLE IF EXISTS `v5`*/;
/*!50001 DROP VIEW IF EXISTS `v5`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;

View file

@ -316,7 +316,18 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item,
field_item->field_type() != MYSQL_TYPE_YEAR)
return 1;
if ((*item)->const_item() && !(*item)->is_expensive())
/*
Replace (*item) with its value if the item can be computed.
Do not replace items that contain aggregate functions:
There can be such items that are constants, e.g. COLLATION(AVG(123)),
but this function is called at Name Resolution phase.
Removing aggregate functions may confuse query plan generation code, e.g.
the optimizer might conclude that the query doesn't need to do grouping
at all.
*/
if ((*item)->const_item() && !(*item)->is_expensive() &&
!(*item)->with_sum_func())
{
TABLE *table= field->table;
Sql_mode_save sql_mode(thd);

View file

@ -6081,6 +6081,8 @@ bool Item_func_match::init_search(THD *thd, bool no_order)
ft_handler= table->file->ft_init_ext(flags, key, ft_tmp);
if (!ft_handler)
DBUG_RETURN(1);
if (join_key)
table->file->ft_handler=ft_handler;

View file

@ -1303,7 +1303,9 @@ multi_delete::initialize_tables(JOIN *join)
table->file->ref_length,
MEM_STRIP_BUF_SIZE);
}
init_ftfuncs(thd, thd->lex->current_select, 1);
if (init_ftfuncs(thd, thd->lex->current_select, 1))
DBUG_RETURN(true);
DBUG_RETURN(thd->is_fatal_error);
}

View file

@ -2616,6 +2616,7 @@ void st_select_lex_node::fast_exclude()
for (; slave; slave= slave->next)
slave->fast_exclude();
prev= NULL; // to ensure correct behavior of st_select_lex_unit::is_excluded()
}
@ -2690,9 +2691,7 @@ void st_select_lex_node::exclude_from_tree()
*/
void st_select_lex_node::exclude()
{
/* exclude from global list */
fast_exclude();
/* exclude from other structures */
/* exclude the node from the tree */
exclude_from_tree();
/*
We do not need following statements, because prev pointer of first
@ -2700,6 +2699,8 @@ void st_select_lex_node::exclude()
if (master->slave == this)
master->slave= next;
*/
/* exclude all nodes under this excluded node */
fast_exclude();
}

View file

@ -1871,6 +1871,9 @@ JOIN::optimize_inner()
DEBUG_SYNC(thd, "before_join_optimize");
THD_STAGE_INFO(thd, stage_optimizing);
#ifndef DBUG_OFF
dbug_join_tab_array_size= 0;
#endif
set_allowed_join_cache_types();
need_distinct= TRUE;
@ -3104,6 +3107,9 @@ setup_subq_exit:
{
if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB))))
DBUG_RETURN(1);
#ifndef DBUG_OFF
dbug_join_tab_array_size= 1;
#endif
need_tmp= 1;
}
if (make_aggr_tables_info())
@ -3416,6 +3422,7 @@ bool JOIN::make_aggr_tables_info()
{
aggr_tables++;
curr_tab= join_tab + exec_join_tab_cnt();
DBUG_ASSERT(curr_tab - join_tab < dbug_join_tab_array_size);
bzero((void*)curr_tab, sizeof(JOIN_TAB));
curr_tab->ref.key= -1;
if (only_const_tables())
@ -3544,6 +3551,7 @@ bool JOIN::make_aggr_tables_info()
curr_tab++;
aggr_tables++;
DBUG_ASSERT(curr_tab - join_tab < dbug_join_tab_array_size);
bzero((void*)curr_tab, sizeof(JOIN_TAB));
curr_tab->ref.key= -1;
@ -10426,6 +10434,23 @@ bool JOIN::get_best_combination()
if (aggr_tables > 2)
aggr_tables= 2;
#ifndef DBUG_OFF
dbug_join_tab_array_size= top_join_tab_count + aggr_tables;
#endif
/*
NOTE: The above computation of aggr_tables can produce wrong result because some
of the variables it uses may change their values after we leave this function.
Known examples:
- Dangerous: using_outer_summary_function=false at this point. Added
DBUG_ASSERT below to demonstrate. Can this cause us to allocate less
space than we would need?
- Not dangerous: select_distinct can be true here but be assigned false
afterwards.
*/
aggr_tables= 2;
DBUG_ASSERT(!tmp_table_param.using_outer_summary_function);
if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*
(top_join_tab_count + aggr_tables))))
DBUG_RETURN(TRUE);

View file

@ -1289,6 +1289,7 @@ public:
#ifndef DBUG_OFF
void dbug_verify_sj_inner_tables(uint n_positions) const;
uint dbug_join_tab_array_size;
#endif
/* We also maintain a stack of join optimization states in * join->positions[] */

View file

@ -1202,6 +1202,14 @@ fts_query_difference(
return(query->error);
}
/* Free the query intersection
@param query query instance */
static void fts_query_free_intersection(fts_query_t* query)
{
fts_query_free_doc_ids(query, query->intersection);
query->intersection = NULL;
}
/*****************************************************************//**
Intersect the token doc ids with the current set.
@return DB_SUCCESS if all go well */
@ -1300,6 +1308,7 @@ fts_query_intersect(
/* error is passed by 'query->error' */
if (query->error != DB_SUCCESS) {
ut_ad(query->error == DB_FTS_EXCEED_RESULT_CACHE_LIMIT);
fts_query_free_intersection(query);
return(query->error);
}
@ -1328,6 +1337,8 @@ fts_query_intersect(
ut_a(!query->multi_exist || (query->multi_exist
&& rbt_size(query->doc_ids) <= n_doc_ids));
} else if (query->intersection) {
fts_query_free_intersection(query);
}
}
@ -1546,6 +1557,10 @@ fts_merge_doc_ids(
query, ranking->doc_id, ranking->rank);
if (query->error != DB_SUCCESS) {
if (query->intersection) {
ut_a(query->oper == FTS_EXIST);
fts_query_free_intersection(query);
}
DBUG_RETURN(query->error);
}