summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2022-08-03 19:51:44 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2022-08-03 19:51:44 +0200
commite509065247b1a0cda0bc7863ac1d43d0fab9acc8 (patch)
tree0a89b1350bbf06177b63c92111e769a71a4b84c0
parent8fd8a81a9933e6a5b8afe2e7a2655652bd7c7190 (diff)
parent37a3d4467e3115f4d4dfcad0a6ee3c23e785f524 (diff)
downloadmariadb-git-e509065247b1a0cda0bc7863ac1d43d0fab9acc8.tar.gz
Merge branch '10.3' into 10.4
-rw-r--r--client/mysqldump.c65
-rw-r--r--client/mysqlimport.c8
-rw-r--r--man/mysqldump.130
-rw-r--r--mysql-test/main/func_group.result25
-rw-r--r--mysql-test/main/func_group.test19
-rw-r--r--mysql-test/main/insert_select.result89
-rw-r--r--mysql-test/main/insert_select.test82
-rw-r--r--mysql-test/main/lock_view.result49
-rw-r--r--mysql-test/main/mysqldump-nl.result11
-rw-r--r--mysql-test/main/mysqldump-timing.result71
-rw-r--r--mysql-test/main/mysqldump-timing.test26
-rw-r--r--mysql-test/main/mysqldump.result117
-rw-r--r--mysql-test/suite/innodb_fts/r/ft_result_cache_limit.result39
-rw-r--r--mysql-test/suite/innodb_fts/t/ft_result_cache_limit.test57
-rw-r--r--mysql-test/suite/roles/definer.result47
-rw-r--r--sql/item_cmpfunc.cc13
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/sql_delete.cc4
-rw-r--r--sql/sql_lex.cc7
-rw-r--r--sql/sql_select.cc25
-rw-r--r--sql/sql_select.h1
-rw-r--r--storage/innobase/fts/fts0que.cc15
22 files changed, 622 insertions, 180 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 34a207208f8..5dfa42aefbc 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -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)
{
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index e72eb12cb99..1d2119c7b89 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -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);
}
diff --git a/man/mysqldump.1 b/man/mysqldump.1
index 1151c472df7..f1d0ba73474 100644
--- a/man/mysqldump.1
+++ b/man/mysqldump.1
@@ -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
diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result
index 071c155cd6b..afe8a2e2ddc 100644
--- a/mysql-test/main/func_group.result
+++ b/mysql-test/main/func_group.result
@@ -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
#
diff --git a/mysql-test/main/func_group.test b/mysql-test/main/func_group.test
index a28b39c28f6..d536f6ead1f 100644
--- a/mysql-test/main/func_group.test
+++ b/mysql-test/main/func_group.test
@@ -1758,5 +1758,24 @@ 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 #
diff --git a/mysql-test/main/insert_select.result b/mysql-test/main/insert_select.result
index ea770535e8f..3f9ac8c6322 100644
--- a/mysql-test/main/insert_select.result
+++ b/mysql-test/main/insert_select.result
@@ -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
diff --git a/mysql-test/main/insert_select.test b/mysql-test/main/insert_select.test
index 1f672acc203..6baa7e43c34 100644
--- a/mysql-test/main/insert_select.test
+++ b/mysql-test/main/insert_select.test
@@ -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
diff --git a/mysql-test/main/lock_view.result b/mysql-test/main/lock_view.result
index 48c45dcf23d..6cc788f86f1 100644
--- a/mysql-test/main/lock_view.result
+++ b/mysql-test/main/lock_view.result
@@ -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 */;
diff --git a/mysql-test/main/mysqldump-nl.result b/mysql-test/main/mysqldump-nl.result
index 89fb3144867..bac1ccb6ea0 100644
--- a/mysql-test/main/mysqldump-nl.result
+++ b/mysql-test/main/mysqldump-nl.result
@@ -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 */;
diff --git a/mysql-test/main/mysqldump-timing.result b/mysql-test/main/mysqldump-timing.result
new file mode 100644
index 00000000000..71120ebf2d5
--- /dev/null
+++ b/mysql-test/main/mysqldump-timing.result
@@ -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
+#
diff --git a/mysql-test/main/mysqldump-timing.test b/mysql-test/main/mysqldump-timing.test
new file mode 100644
index 00000000000..25921fdd0cd
--- /dev/null
+++ b/mysql-test/main/mysqldump-timing.test
@@ -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 #
diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result
index 33fb00a2876..d61d77e7478 100644
--- a/mysql-test/main/mysqldump.result
+++ b/mysql-test/main/mysqldump.result
@@ -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 */;
diff --git a/mysql-test/suite/innodb_fts/r/ft_result_cache_limit.result b/mysql-test/suite/innodb_fts/r/ft_result_cache_limit.result
new file mode 100644
index 00000000000..2dbdd5a04bc
--- /dev/null
+++ b/mysql-test/suite/innodb_fts/r/ft_result_cache_limit.result
@@ -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;
diff --git a/mysql-test/suite/innodb_fts/t/ft_result_cache_limit.test b/mysql-test/suite/innodb_fts/t/ft_result_cache_limit.test
new file mode 100644
index 00000000000..84254a182d7
--- /dev/null
+++ b/mysql-test/suite/innodb_fts/t/ft_result_cache_limit.test
@@ -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;
diff --git a/mysql-test/suite/roles/definer.result b/mysql-test/suite/roles/definer.result
index a5551e7dede..bc79ad8a98c 100644
--- a/mysql-test/suite/roles/definer.result
+++ b/mysql-test/suite/roles/definer.result
@@ -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 */;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 71a26994558..c7b83fae70d 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -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);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 935208423a4..8d63a7af05c 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -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;
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 4d6b6ab57c8..82d4dc48440 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -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);
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index b2283e5c77d..8ca39471664 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -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();
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 6509f25a41f..a91b4571b21 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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);
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 86852dc5a2f..9051b7fd2b8 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -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[] */
diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc
index 7ab7301ce8c..06311551cbe 100644
--- a/storage/innobase/fts/fts0que.cc
+++ b/storage/innobase/fts/fts0que.cc
@@ -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);
}