mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Added progress reporting for alter table, LOAD DATA INFILE and for aria tables: check table, repair table, analyze table.
- The client gets a progress report message that triggers a callback function if requested with mysql_options(MYSQL_PROGRESS_CALLBACK, function) - Added Progress field last to 'show processlist' - Stage, Max_stage and Progress field added to information_schema.progresslist - The 'mysql' client by defaults enables progress reports when the output is a tty. - Added progress_report_time time variable to configure how often progress reports is sent to client Added read only system variable 'in_transaction' which is 1 if we have executed a BEGIN statement. client/client_priv.h: Added OPT_REPORT_PROGRESS client/mysql.cc: Added option --progress-reports (on by default if not batch mode) Progress reports is written to stdout for long running commands include/Makefile.am: Added mysql/service_progress_report.h include/myisamchk.h: Added variables to be able to do progress reporting in Aria and later in MyISAM include/mysql.h: Added new mysql_options() parameter: MYSQL_PROGRESS_CALLBACK include/mysql.h.pp: Added new mysql_options() parameter: MYSQL_PROGRESS_CALLBACK include/mysql/plugin.h: Added functions for reporting progress. include/mysql/plugin_auth.h.pp: Added functions for reporting progress. include/mysql_com.h: Added CLIENT_PROGRESS mysql_real_connect() flag. include/sql_common.h: Added callback function for reporting progress mysql-test/r/old-mode.result: Ensure that SHOW PROGRESSLIST doesn't have the Progress column in old mode. mysql-test/suite/funcs_1/datadict/datadict_priv.inc: Added new column mysql-test/suite/funcs_1/datadict/processlist_priv.inc: Test all new PROCESSLIST columns mysql-test/suite/funcs_1/r/is_columns_is.result: Updated results mysql-test/suite/funcs_1/r/is_columns_is_embedded.result: Updated results mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result: Updated results mysql-test/suite/funcs_1/r/is_tables_is_embedded.result: Updated results mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result: Updated results mysql-test/suite/funcs_1/r/processlist_priv_ps.result: Updated results mysql-test/suite/funcs_1/r/processlist_val_no_prot.result: Updated results mysql-test/suite/funcs_1/r/processlist_val_ps.result: Updated results mysql-test/suite/pbxt/r/pbxt_locking.result: Updated results mysql-test/suite/pbxt/r/skip_name_resolve.result: Updated results mysql-test/t/old-mode.test: Ensure that SHOW PROGRESSLIST doesn't have the Progress column in old mode. plugin/handler_socket/handlersocket/Makefile.am: Added -lmysqlservices scripts/mytop.sh: Made 'State' field width dynamic. Added 'Progress' to process list display. sql-common/client.c: Added handling of progress messages. Removed check_license() function. sql/mysql_priv.h: Added opt_progress_report_time sql/mysqld.cc: Added progress_report_time time variable to configure how often progress reports is sent to client sql/protocol.cc: Added net_send_progress_packet() sql/protocol.h: New prototypes sql/set_var.cc: Added variables progress_report_time and in_transaction sql/sql_acl.cc: Safety fix: Made client_capabilities ulonglong sql/sql_class.cc: Added interface functions for progress reporting sql/sql_class.h: Added varibles in THD for progress reporting. Added CF_REPORT_PROGRESS sql/sql_load.cc: Added progress reporting for LOAD DATA INFILE sql/sql_parse.cc: Added CF_REPORT_PROGRESS for top level commands for which it's safe to send progress reports to client sql/sql_show.cc: Added Progress field last to 'show processlist' Stage, Max_stage and Progress field added to information_schema.progresslist sql/sql_table.cc: Added progress reporting for ALTER TABLE Added THD as argument to copy_data_between_tables() storage/maria/ha_maria.cc: Added progress reporting for check table, repair table, analyze table Fixed a bug in start_bulk_insert() that caused alter table to always run with all keys enabled. storage/maria/ma_check.c: Added progress reporting Remember old state before starting repair. This removes some warnings from optimize_table if create-with-sort fails. storage/maria/ma_check_standalone.h: Added dummy reporting function for standalone Aria programs. storage/maria/ma_sort.c: Added progress reporting storage/maria/maria_chk.c: Updated version storage/maria/maria_def.h: Added new prototypes tests/mysql_client_test.c: Added test case for progress reporting
This commit is contained in:
@ -49,7 +49,7 @@ and you are welcome to modify and redistribute it under the GPL v2 license\n"
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
const char *VER= "14.16";
|
||||
const char *VER= "15.0";
|
||||
|
||||
/* Don't try to make a nice table if the data is too big */
|
||||
#define MAX_COLUMN_LENGTH 1024
|
||||
@ -152,7 +152,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
|
||||
default_charset_used= 0, opt_secure_auth= 0,
|
||||
default_pager_set= 0, opt_sigint_ignore= 0,
|
||||
show_warnings= 0, executing_query= 0,
|
||||
ignore_spaces= 0;
|
||||
ignore_spaces= 0, opt_progress_reports;
|
||||
static my_bool debug_info_flag, debug_check_flag, batch_abort_on_error;
|
||||
static my_bool column_types_flag;
|
||||
static my_bool preserve_comments= 0;
|
||||
@ -248,6 +248,13 @@ static const char* construct_prompt();
|
||||
static char *get_arg(char *line, my_bool get_next_arg);
|
||||
static void init_username();
|
||||
static void add_int_to_prompt(int toadd);
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static uint last_progress_report_length= 0;
|
||||
static void report_progress(const MYSQL *mysql, uint stage, uint max_stage,
|
||||
double progress, const char *proc_info,
|
||||
uint proc_info_length);
|
||||
#endif
|
||||
static void report_progress_end();
|
||||
|
||||
/* A structure which contains information on the commands this program
|
||||
can understand. */
|
||||
@ -1498,6 +1505,10 @@ static struct my_option my_long_options[] =
|
||||
"built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
|
||||
&opt_mysql_port,
|
||||
&opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"progress-reports", OPT_REPORT_PROGRESS,
|
||||
"Get progress reports for long running commands (like ALTER TABLE)",
|
||||
&opt_progress_reports, &opt_progress_reports, 0, GET_BOOL, NO_ARG, 1, 0,
|
||||
0, 0, 0, 0},
|
||||
{"prompt", OPT_PROMPT, "Set the mysql prompt to this value.",
|
||||
¤t_prompt, ¤t_prompt, 0, GET_STR_ALLOC,
|
||||
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@ -1854,6 +1865,7 @@ static int get_options(int argc, char **argv)
|
||||
opt_outfile= 0;
|
||||
opt_reconnect= 0;
|
||||
connect_flag= 0; /* Not in interactive mode */
|
||||
opt_progress_reports= 0;
|
||||
}
|
||||
|
||||
if (strcmp(default_charset, charset_info->csname) &&
|
||||
@ -1881,6 +1893,9 @@ static int get_options(int argc, char **argv)
|
||||
if (ignore_spaces)
|
||||
connect_flag|= CLIENT_IGNORE_SPACE;
|
||||
|
||||
if (opt_progress_reports)
|
||||
connect_flag|= CLIENT_PROGRESS;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -3058,6 +3073,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
|
||||
timer=start_timer();
|
||||
executing_query= 1;
|
||||
error= mysql_real_query_for_lazy(buffer->ptr(),buffer->length());
|
||||
report_progress_end();
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
if (status.add_to_history)
|
||||
@ -4413,9 +4429,17 @@ sql_real_connect(char *host,char *database,char *user,char *password,
|
||||
}
|
||||
return -1; // Retryable
|
||||
}
|
||||
|
||||
connected=1;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
mysql.reconnect= debug_info_flag; // We want to know if this happens
|
||||
|
||||
/*
|
||||
CLIENT_PROGRESS is set only if we requsted it in mysql_real_connect()
|
||||
and the server also supports it
|
||||
*/
|
||||
if (mysql.client_flag & CLIENT_PROGRESS)
|
||||
mysql_options(&mysql, MYSQL_PROGRESS_CALLBACK, (void*) report_progress);
|
||||
#else
|
||||
mysql.reconnect= 1;
|
||||
#endif
|
||||
@ -5063,4 +5087,31 @@ void sql_element_free(void *ptr)
|
||||
{
|
||||
my_free(ptr,MYF(0));
|
||||
}
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
static void report_progress(const MYSQL *mysql, uint stage, uint max_stage,
|
||||
double progress, const char *proc_info,
|
||||
uint proc_info_length)
|
||||
{
|
||||
uint length= printf("Stage: %d of %d '%.*s' %6.3g%% of stage done",
|
||||
stage, max_stage, proc_info_length, proc_info,
|
||||
progress);
|
||||
if (length < last_progress_report_length)
|
||||
printf("%*s", last_progress_report_length - length, "");
|
||||
putc('\r', stdout);
|
||||
fflush(stdout);
|
||||
last_progress_report_length= length;
|
||||
}
|
||||
|
||||
static void report_progress_end()
|
||||
{
|
||||
if (last_progress_report_length)
|
||||
{
|
||||
printf("%*s\r", last_progress_report_length, "");
|
||||
last_progress_report_length= 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void report_progress_end()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user