diff options
author | Michael Widenius <monty@askmonty.org> | 2011-07-01 15:08:30 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-07-01 15:08:30 +0300 |
commit | 3c78bfe7f1a1530daea83f5dae091bd654ea6d37 (patch) | |
tree | b54abedc9d4f6ac33b7aa2128454fcd37d739d78 /sql/sql_table.cc | |
parent | 62e47b4402678abc85a689a820d201248dabbc36 (diff) | |
download | mariadb-git-3c78bfe7f1a1530daea83f5dae091bd654ea6d37.tar.gz |
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
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c6730bc0853..299e88107d7 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -36,7 +36,8 @@ const char *primary_key_name="PRIMARY"; static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end); static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end); -static int copy_data_between_tables(TABLE *,TABLE *, List<Create_field> &, bool, +static int copy_data_between_tables(THD *thd, TABLE *,TABLE *, + List<Create_field> &, bool, uint, ORDER *, ha_rows *,ha_rows *, enum enum_enable_or_disable, bool); @@ -7497,8 +7498,7 @@ view_err: /* We don't want update TIMESTAMP fields during ALTER TABLE. */ new_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; new_table->next_number_field=new_table->found_next_number_field; - thd_proc_info(thd, "copy to tmp table"); - error= copy_data_between_tables(table, new_table, + error= copy_data_between_tables(thd, table, new_table, alter_info->create_list, ignore, order_num, order, &copied, &deleted, alter_info->keys_onoff, @@ -7905,7 +7905,7 @@ err_with_placeholders: /* Copy all rows from one table to another */ static int -copy_data_between_tables(TABLE *from,TABLE *to, +copy_data_between_tables(THD *thd, TABLE *from,TABLE *to, List<Create_field> &create, bool ignore, uint order_num, ORDER *order, @@ -7917,7 +7917,6 @@ copy_data_between_tables(TABLE *from,TABLE *to, int error= 1, errpos= 0; Copy_field *copy= NULL, *copy_end; ha_rows found_count= 0, delete_count= 0; - THD *thd= current_thd; uint length= 0; SORT_FIELD *sortorder; READ_RECORD info; @@ -7927,11 +7926,14 @@ copy_data_between_tables(TABLE *from,TABLE *to, ha_rows examined_rows; bool auto_increment_field_copied= 0; ulong save_sql_mode= thd->variables.sql_mode; - ulonglong prev_insert_id; + ulonglong prev_insert_id, time_to_report_progress; List_iterator<Create_field> it(create); Create_field *def; DBUG_ENTER("copy_data_between_tables"); + /* Two or 3 stages; Sorting, copying data and update indexes */ + thd_progress_init(thd, 2 + test(order)); + /* Turn off recovery logging since rollback of an alter table is to delete the new table so there is no need to log the changes to it. @@ -8005,6 +8007,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, tables.alias= tables.table_name= from->s->table_name.str; tables.db= from->s->db.str; + thd_proc_info(thd, "Sorting"); if (thd->lex->select_lex.setup_ref_array(thd, order_num) || setup_order(thd, thd->lex->select_lex.ref_pointer_array, &tables, fields, all_fields, order) || @@ -8015,8 +8018,10 @@ copy_data_between_tables(TABLE *from,TABLE *to, HA_POS_ERROR) goto err; } - }; + thd_progress_next_stage(thd); + } + thd_proc_info(thd, "copy to tmp table"); /* Tell handler that we have values for all columns in the to table */ to->use_all_columns(); to->mark_virtual_columns_for_write(TRUE); @@ -8027,6 +8032,10 @@ copy_data_between_tables(TABLE *from,TABLE *to, to->file->extra(HA_EXTRA_IGNORE_DUP_KEY); thd->row_count= 0; restore_record(to, s->default_values); // Create empty record + + thd->progress.max_counter= from->file->records(); + time_to_report_progress= MY_HOW_OFTEN_TO_WRITE/10; + while (!(error=info.read_record(&info))) { if (thd->killed) @@ -8037,6 +8046,13 @@ copy_data_between_tables(TABLE *from,TABLE *to, } update_virtual_fields(thd, from); thd->row_count++; + if (++thd->progress.counter >= time_to_report_progress) + { + time_to_report_progress+= MY_HOW_OFTEN_TO_WRITE/10; + thd_progress_report(thd, thd->progress.counter, + thd->progress.max_counter); + } + /* Return error if source table isn't empty. */ if (error_if_not_empty) { @@ -8100,6 +8116,9 @@ err: free_io_cache(from); delete [] copy; + thd_proc_info(thd, "Enabling keys"); + thd_progress_next_stage(thd); + if (error > 0) to->file->extra(HA_EXTRA_PREPARE_FOR_DROP); if (errpos >= 3 && to->file->ha_end_bulk_insert() && error <= 0) |