Skip to content

Commit ee620a7

Browse files
committed
Merge branch '10.5' into 10.6
2 parents 558f1ef + 3b071ba commit ee620a7

28 files changed

+645
-183
lines changed

client/mysqldump.c

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static ulonglong opt_system= 0ULL;
148148
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0,
149149
select_field_names_inited= 0;
150150
static ulong opt_max_allowed_packet, opt_net_buffer_length;
151+
static double opt_max_statement_time= 0.0;
151152
static MYSQL mysql_connection,*mysql=0;
152153
static DYNAMIC_STRING insert_pat, select_field_names;
153154
static char *opt_password=0,*current_user=0,
@@ -164,6 +165,7 @@ static my_bool server_supports_switching_charsets= TRUE;
164165
static ulong opt_compatible_mode= 0;
165166
#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
166167
#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2
168+
#define MYSQL_OPT_MAX_STATEMENT_TIME 0
167169
#define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL 1
168170
#define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL 2
169171
static uint opt_mysql_port= 0, opt_master_data;
@@ -470,6 +472,10 @@ static struct my_option my_long_options[] =
470472
&opt_max_allowed_packet, &opt_max_allowed_packet, 0,
471473
GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096,
472474
(longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
475+
{"max-statement-time", MYSQL_OPT_MAX_STATEMENT_TIME,
476+
"Max statement execution time. If unset, overrides server default with 0.",
477+
&opt_max_statement_time, &opt_max_statement_time, 0, GET_DOUBLE,
478+
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
473479
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
474480
"The buffer size for TCP/IP and socket communication.",
475481
&opt_net_buffer_length, &opt_net_buffer_length, 0,
@@ -3177,9 +3183,8 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
31773183
if (strcmp(field->name, "View") == 0)
31783184
{
31793185
char *scv_buff= NULL;
3180-
my_ulonglong n_cols;
31813186

3182-
verbose_msg("-- It's a view, create dummy table for view\n");
3187+
verbose_msg("-- It's a view, create dummy view for view\n");
31833188

31843189
/* save "show create" statement for later */
31853190
if ((row= mysql_fetch_row(result)) && (scv_buff=row[1]))
@@ -3188,9 +3193,9 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
31883193
mysql_free_result(result);
31893194

31903195
/*
3191-
Create a table with the same name as the view and with columns of
3196+
Create a view with the same name as the view and with columns of
31923197
the same name in order to satisfy views that depend on this view.
3193-
The table will be removed when the actual view is created.
3198+
The view will be removed when the actual view is created.
31943199
31953200
The properties of each column, are not preserved in this temporary
31963201
table, because they are not necessary.
@@ -3222,23 +3227,9 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
32223227
else
32233228
my_free(scv_buff);
32243229

3225-
n_cols= mysql_num_rows(result);
3226-
if (0 != n_cols)
3230+
if (mysql_num_rows(result) != 0)
32273231
{
32283232

3229-
/*
3230-
The actual formula is based on the column names and how the .FRM
3231-
files are stored and is too volatile to be repeated here.
3232-
Thus we simply warn the user if the columns exceed a limit we
3233-
know works most of the time.
3234-
*/
3235-
if (n_cols >= 1000)
3236-
fprintf(stderr,
3237-
"-- Warning: Creating a stand-in table for view %s may"
3238-
" fail when replaying the dump file produced because "
3239-
"of the number of columns exceeding 1000. Exercise "
3240-
"caution when replaying the produced dump file.\n",
3241-
table);
32423233
if (opt_drop)
32433234
{
32443235
/*
@@ -3254,7 +3245,7 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
32543245
fprintf(sql_file,
32553246
"SET @saved_cs_client = @@character_set_client;\n"
32563247
"SET character_set_client = utf8;\n"
3257-
"/*!50001 CREATE TABLE %s (\n",
3248+
"/*!50001 CREATE VIEW %s AS SELECT\n",
32583249
result_table);
32593250

32603251
/*
@@ -3266,28 +3257,21 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
32663257
row= mysql_fetch_row(result);
32673258

32683259
/*
3269-
The actual column type doesn't matter anyway, since the table will
3260+
The actual column value doesn't matter anyway, since the view will
32703261
be dropped at run time.
3271-
We do tinyint to avoid hitting the row size limit.
32723262
*/
3273-
fprintf(sql_file, " %s tinyint NOT NULL",
3263+
fprintf(sql_file, " 1 AS %s",
32743264
quote_name(row[0], name_buff, 0));
32753265

32763266
while((row= mysql_fetch_row(result)))
32773267
{
32783268
/* col name, col type */
3279-
fprintf(sql_file, ",\n %s tinyint NOT NULL",
3269+
fprintf(sql_file, ",\n 1 AS %s",
32803270
quote_name(row[0], name_buff, 0));
32813271
}
32823272

3283-
/*
3284-
Stand-in tables are always MyISAM tables as the default
3285-
engine might have a column-limit that's lower than the
3286-
number of columns in the view, and MyISAM support is
3287-
guaranteed to be in the server anyway.
3288-
*/
32893273
fprintf(sql_file,
3290-
"\n) ENGINE=MyISAM */;\n"
3274+
" */;\n"
32913275
"SET character_set_client = @saved_cs_client;\n");
32923276

32933277
check_io(sql_file);
@@ -6789,15 +6773,8 @@ static my_bool get_view_structure(char *table, char* db)
67896773
"\n--\n-- Final view structure for view %s\n--\n\n",
67906774
fix_for_comment(result_table));
67916775

6792-
/* Table might not exist if this view was dumped with --tab. */
6793-
fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table);
6794-
if (opt_drop)
6795-
{
6796-
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
6797-
opt_quoted_table);
6798-
check_io(sql_file);
6799-
}
6800-
6776+
/* View might not exist if this view was dumped with --tab. */
6777+
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n", opt_quoted_table);
68016778

68026779
my_snprintf(query, sizeof(query),
68036780
"SELECT CHECK_OPTION, DEFINER, SECURITY_TYPE, "
@@ -6969,6 +6946,7 @@ static void dynstr_realloc_checked(DYNAMIC_STRING *str, ulong additional_size)
69696946

69706947
int main(int argc, char **argv)
69716948
{
6949+
char query[48];
69726950
char bin_log_name[FN_REFLEN];
69736951
int exit_code;
69746952
int consistent_binlog_pos= 0;
@@ -7010,6 +6988,13 @@ int main(int argc, char **argv)
70106988
if (!path)
70116989
write_header(md_result_file, *argv);
70126990

6991+
/* Set MAX_STATEMENT_TIME to 0 unless set in client */
6992+
my_snprintf(query, sizeof(query), "/*!100100 SET @@MAX_STATEMENT_TIME=%f */", opt_max_statement_time);
6993+
mysql_query(mysql, query);
6994+
6995+
/* Set server side timeout between client commands to server compiled-in default */
6996+
mysql_query(mysql, "/*!100100 SET WAIT_TIMEOUT=DEFAULT */");
6997+
70136998
/* Check if the server support multi source */
70146999
if (mysql_get_server_version(mysql) >= 100000)
70157000
{

client/mysqlimport.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,13 +573,15 @@ static void safe_exit(int error, MYSQL *mysql)
573573
if (mysql)
574574
mysql_close(mysql);
575575

576-
mysql_library_end();
577-
free_defaults(argv_to_free);
578-
my_free(opt_password);
579576
if (error)
580577
sf_leaking_memory= 1; /* dirty exit, some threads are still running */
581578
else
579+
{
580+
mysql_library_end();
581+
free_defaults(argv_to_free);
582+
my_free(opt_password);
582583
my_end(my_end_arg); /* clean exit */
584+
}
583585
exit(error);
584586
}
585587

cmake/cpack_rpm.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7")
270270
ALTERNATIVE_NAME("server" "mariadb-server")
271271
ALTERNATIVE_NAME("server" "mysql-compat-server")
272272
ALTERNATIVE_NAME("test" "mariadb-test")
273-
ELSEIF(RPM MATCHES "(rhel|centos)8")
273+
ELSEIF(RPM MATCHES "(rhel|centos|rocky)[89]")
274274
SET(epoch 3:)
275275
ALTERNATIVE_NAME("backup" "mariadb-backup")
276276
ALTERNATIVE_NAME("client" "mariadb")

man/mysqldump.1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,21 @@ Sets the maximum packet length to send to or receive from server\&.
13771377
.sp -1
13781378
.IP \(bu 2.3
13791379
.\}
1380+
.\" mysqldump: max-statement-time option
1381+
.\" max-statement-time option: mysqldump
1382+
\fB\-\-max\-statement\-time=\fR\fB\fIseconds\fR\fR
1383+
.sp
1384+
Sets the maximum time any statement can run before being timed out by the server. (Default value is 0 (no limit))\&
1385+
.RE
1386+
.sp
1387+
.RS 4
1388+
.ie n \{\
1389+
\h'-04'\(bu\h'+03'\c
1390+
.\}
1391+
.el \{\
1392+
.sp -1
1393+
.IP \(bu 2.3
1394+
.\}
13801395
.\" mysqldump: net-buffer-length option
13811396
.\" net-buffer-length option: mysqldump
13821397
\fB\-\-net\-buffer\-length=\fR\fB\fIlength\fR\fR
@@ -2637,6 +2652,21 @@ The maximum size of the buffer for client/server communication\&. The maximum is
26372652
.sp -1
26382653
.IP \(bu 2.3
26392654
.\}
2655+
max_statement_time
2656+
.sp
2657+
A query that has taken more than max_statement_time seconds will be aborted and the backup will
2658+
fail\&. The argument will be treated as a decimal value with microsecond precision\&. A value
2659+
of 0 (default) means no timeout\&. The maximum timeout is 31536000 seconds\&.
2660+
.RE
2661+
.sp
2662+
.RS 4
2663+
.ie n \{\
2664+
\h'-04'\(bu\h'+03'\c
2665+
.\}
2666+
.el \{\
2667+
.sp -1
2668+
.IP \(bu 2.3
2669+
.\}
26402670
net_buffer_length
26412671
.sp
26422672
The initial size of the buffer for client/server communication\&. When creating multiple\-row

mysql-test/include/default_my.cnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ disable-force-if-open
3333
[ENV]
3434
MASTER_MYPORT= @mysqld.1.port
3535
MASTER_MYSOCK= @mysqld.1.socket
36+
OPENSSL_ENABLE_SHA1_SIGNATURES= 1

mysql-test/main/func_group.result

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,5 +2524,30 @@ DROP TABLE t2;
25242524
DROP VIEW v1;
25252525
DROP TABLE t1;
25262526
#
2527+
# MDEV-23809: Server crash in JOIN_CACHE::free or ...
2528+
#
2529+
CREATE TABLE t1 (a INT);
2530+
INSERT INTO t1 VALUES (1),(2);
2531+
SELECT DISTINCT CASE CONVERT(EXPORT_SET(0, COLLATION(BENCHMARK(1, BIT_OR(0))),0),TIME) WHEN a THEN 1 END AS f FROM t1;
2532+
f
2533+
NULL
2534+
Warnings:
2535+
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'
2536+
DROP TABLE t1;
2537+
CREATE TABLE t1 (a VARCHAR(8) NULL, b BIGINT);
2538+
INSERT INTO t1 (a,b) VALUES (NULL,NULL),('foo',NULL);
2539+
SELECT DISTINCT STRCMP((b > COLLATION(STDDEV_SAMP(15750))), a) AS f FROM t1;
2540+
f
2541+
NULL
2542+
DROP TABLE t1;
2543+
CREATE TABLE t1 (a BIGINT) AS SELECT 1 AS v3 UNION SELECT FALSE ;
2544+
SELECT DISTINCT a IN ( COLLATION (AVG ('x'))) FROM t1 ;
2545+
a IN ( COLLATION (AVG ('x')))
2546+
NULL
2547+
Warnings:
2548+
Warning 1292 Truncated incorrect DOUBLE value: 'x'
2549+
Warning 1292 Truncated incorrect DOUBLE value: 'x'
2550+
DROP TABLE t1;
2551+
#
25272552
# End of 10.3 tests
25282553
#

mysql-test/main/func_group.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,25 @@ DROP TABLE t2;
17631763
DROP VIEW v1;
17641764
DROP TABLE t1;
17651765

1766+
--echo #
1767+
--echo # MDEV-23809: Server crash in JOIN_CACHE::free or ...
1768+
--echo #
1769+
1770+
CREATE TABLE t1 (a INT);
1771+
INSERT INTO t1 VALUES (1),(2);
1772+
SELECT DISTINCT CASE CONVERT(EXPORT_SET(0, COLLATION(BENCHMARK(1, BIT_OR(0))),0),TIME) WHEN a THEN 1 END AS f FROM t1;
1773+
DROP TABLE t1;
1774+
1775+
1776+
CREATE TABLE t1 (a VARCHAR(8) NULL, b BIGINT);
1777+
INSERT INTO t1 (a,b) VALUES (NULL,NULL),('foo',NULL);
1778+
SELECT DISTINCT STRCMP((b > COLLATION(STDDEV_SAMP(15750))), a) AS f FROM t1;
1779+
DROP TABLE t1;
1780+
1781+
CREATE TABLE t1 (a BIGINT) AS SELECT 1 AS v3 UNION SELECT FALSE ;
1782+
SELECT DISTINCT a IN ( COLLATION (AVG ('x'))) FROM t1 ;
1783+
DROP TABLE t1;
1784+
17661785
--echo #
17671786
--echo # End of 10.3 tests
17681787
--echo #

mysql-test/main/insert_select.result

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,3 +954,92 @@ ERROR 23000: Duplicate entry '-128' for key 'a'
954954
DROP TABLE t1, t2;
955955
DROP PROCEDURE p1;
956956
# End of 10.2 test
957+
#
958+
# MDEV-28617: INSERT ... SELECT with redundant IN subquery in GROUP BY
959+
# list that uses mergeable derived table containing
960+
# reference to target table
961+
#
962+
create table t1 (a int);
963+
create table t2 (b int);
964+
create table t3 (c int);
965+
insert into t1 values (3), (1);
966+
insert into t2 values (3), (2);
967+
insert into t3 values (4), (2);
968+
insert into t1
969+
select b from t2
970+
where b in (select c from t3
971+
group by (select * from (select a from t1) dt where a = 1));
972+
select * from t1;
973+
a
974+
3
975+
1
976+
2
977+
delete from t1;
978+
insert into t1 values (3), (1);
979+
insert into t1
980+
select b from t2
981+
where b >= any (select c from t3
982+
group by (select * from (select a from t1) dt where a = 1));
983+
select * from t1;
984+
a
985+
3
986+
1
987+
3
988+
2
989+
delete from t1;
990+
insert into t1 values (3), (1);
991+
insert into t1
992+
select b from t2
993+
where b <= all (select c from t3
994+
group by (select * from (select a from t1) dt where a = 1));
995+
select * from t1;
996+
a
997+
3
998+
1
999+
2
1000+
delete from t1;
1001+
insert into t1 values (3), (1);
1002+
insert into t1
1003+
select b from t2
1004+
where exists (select c from t3
1005+
group by (select * from (select a from t1) dt where a = 1));
1006+
select * from t1;
1007+
a
1008+
3
1009+
1
1010+
3
1011+
2
1012+
delete from t1;
1013+
insert into t1 values (3), (1);
1014+
prepare stmt from "
1015+
insert into t1
1016+
select b from t2
1017+
where b in (select c from t3
1018+
group by (select * from (select a from t1) dt where a = 1));
1019+
";
1020+
execute stmt;
1021+
select * from t1;
1022+
a
1023+
3
1024+
1
1025+
2
1026+
delete from t1;
1027+
insert into t1 values (3), (1);
1028+
execute stmt;
1029+
select * from t1;
1030+
a
1031+
3
1032+
1
1033+
2
1034+
delete from t1;
1035+
insert into t1 values (3), (1);
1036+
delete from t1
1037+
where exists (select b from t2
1038+
where b in (select c from t3
1039+
group by (select * from (select a from t1) dt
1040+
where a = 1)));
1041+
select * from t1;
1042+
a
1043+
deallocate prepare stmt;
1044+
drop table t1,t2,t3;
1045+
# End of 10.3 test

0 commit comments

Comments
 (0)