Skip to content

Commit

Permalink
Merge branch '10.5' into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Aug 4, 2022
2 parents 558f1ef + 3b071ba commit ee620a7
Show file tree
Hide file tree
Showing 28 changed files with 645 additions and 183 deletions.
65 changes: 25 additions & 40 deletions client/mysqldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,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,
Expand All @@ -164,6 +165,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;
Expand Down Expand Up @@ -470,6 +472,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,
Expand Down Expand Up @@ -3177,9 +3183,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]))
Expand All @@ -3188,9 +3193,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.
Expand Down Expand Up @@ -3222,23 +3227,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)
{
/*
Expand All @@ -3254,7 +3245,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);

/*
Expand All @@ -3266,28 +3257,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);
Expand Down Expand Up @@ -6789,15 +6773,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, "
Expand Down Expand Up @@ -6969,6 +6946,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;
Expand Down Expand Up @@ -7010,6 +6988,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)
{
Expand Down
8 changes: 5 additions & 3 deletions client/mysqlimport.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,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);
}

Expand Down
2 changes: 1 addition & 1 deletion cmake/cpack_rpm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7")
ALTERNATIVE_NAME("server" "mariadb-server")
ALTERNATIVE_NAME("server" "mysql-compat-server")
ALTERNATIVE_NAME("test" "mariadb-test")
ELSEIF(RPM MATCHES "(rhel|centos)8")
ELSEIF(RPM MATCHES "(rhel|centos|rocky)[89]")
SET(epoch 3:)
ALTERNATIVE_NAME("backup" "mariadb-backup")
ALTERNATIVE_NAME("client" "mariadb")
Expand Down
30 changes: 30 additions & 0 deletions man/mysqldump.1
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,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
Expand Down Expand Up @@ -2637,6 +2652,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
Expand Down
1 change: 1 addition & 0 deletions mysql-test/include/default_my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ disable-force-if-open
[ENV]
MASTER_MYPORT= @mysqld.1.port
MASTER_MYSOCK= @mysqld.1.socket
OPENSSL_ENABLE_SHA1_SIGNATURES= 1
25 changes: 25 additions & 0 deletions mysql-test/main/func_group.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
19 changes: 19 additions & 0 deletions mysql-test/main/func_group.test
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,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 #
89 changes: 89 additions & 0 deletions mysql-test/main/insert_select.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit ee620a7

Please sign in to comment.