diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-08-04 08:30:03 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-08-04 08:30:03 +0200 |
commit | 1e71ea806b3b34c53babaea1965d8a67f6c631e2 (patch) | |
tree | c1afd54bec1a1ed12d243430af71d2f6a1aa8025 /client/mysqldump.c | |
parent | cd51854d7a69f6518a84403fa428af5035e946a8 (diff) | |
parent | e509065247b1a0cda0bc7863ac1d43d0fab9acc8 (diff) | |
download | mariadb-git-1e71ea806b3b34c53babaea1965d8a67f6c631e2.tar.gz |
Merge branch '10.4' into 10.5
Diffstat (limited to 'client/mysqldump.c')
-rw-r--r-- | client/mysqldump.c | 65 |
1 files changed, 25 insertions, 40 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c index 4d3fac02e35..1332da9ab00 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -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, @@ -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; @@ -468,6 +470,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, @@ -3110,9 +3116,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])) @@ -3121,9 +3126,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. @@ -3155,23 +3160,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) { /* @@ -3187,7 +3178,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); /* @@ -3199,28 +3190,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); @@ -6714,15 +6698,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, " @@ -6894,6 +6871,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; @@ -6935,6 +6913,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) { |