diff options
author | He Zhenxing <zhenxing.he@sun.com> | 2009-01-14 17:32:25 +0800 |
---|---|---|
committer | He Zhenxing <zhenxing.he@sun.com> | 2009-01-14 17:32:25 +0800 |
commit | 45140a8ea3b7a05e0deb94b0586d66eaf6794c7a (patch) | |
tree | 22e45c100dd34582476ec2c775a40a827678be66 /sql | |
parent | f2c122bf9080d9f0e2e61890edea697e76be5bf6 (diff) | |
parent | ec1b0874b6b00f60192b9b6f91a0ff0a825d4ff0 (diff) | |
download | mariadb-git-45140a8ea3b7a05e0deb94b0586d66eaf6794c7a.tar.gz |
Auto merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/filesort.cc | 3 | ||||
-rw-r--r-- | sql/ha_partition.cc | 6 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 6 | ||||
-rw-r--r-- | sql/log_event.cc | 54 | ||||
-rw-r--r-- | sql/log_event.h | 30 | ||||
-rw-r--r-- | sql/mysqld.cc | 2 | ||||
-rw-r--r-- | sql/repl_failsafe.cc | 10 | ||||
-rw-r--r-- | sql/slave.cc | 39 | ||||
-rw-r--r-- | sql/sql_base.cc | 23 | ||||
-rw-r--r-- | sql/sql_binlog.cc | 5 | ||||
-rw-r--r-- | sql/sql_delete.cc | 40 | ||||
-rw-r--r-- | sql/sql_lex.h | 9 | ||||
-rw-r--r-- | sql/sql_partition.cc | 6 | ||||
-rw-r--r-- | sql/sql_profile.cc | 4 | ||||
-rw-r--r-- | sql/sql_repl.cc | 123 |
15 files changed, 284 insertions, 76 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 2850ada1ffb..5d8b4e869c8 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -562,10 +562,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, if (quick_select) { if ((error= select->quick->get_next())) - { - error= HA_ERR_END_OF_FILE; break; - } file->position(sort_form->record[0]); DBUG_EXECUTE_IF("debug_filesort", dbug_print_record(sort_form, TRUE);); } diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 9617b9941bc..0e36a868b3e 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4815,7 +4815,7 @@ int ha_partition::info(uint flag) /* Calculates statistical variables records: Estimate of number records in table - We report sum (always at least 2) + We report sum (always at least 2 if not empty) deleted: Estimate of number holes in the table due to deletes We report sum @@ -4854,13 +4854,13 @@ int ha_partition::info(uint flag) stats.check_time= file->stats.check_time; } } while (*(++file_array)); - if (stats.records < 2 && + if (stats.records && stats.records < 2 && !(m_file[0]->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT)) stats.records= 2; if (stats.records > 0) stats.mean_rec_length= (ulong) (stats.data_file_length / stats.records); else - stats.mean_rec_length= 1; //? What should we set here + stats.mean_rec_length= 0; } if (flag & HA_STATUS_CONST) { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index bb3f4821c4f..fc9375e68a5 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1782,6 +1782,12 @@ Item *Item_func_sysconst::safe_charset_converter(CHARSET_INFO *tocs) Item_string *conv; uint conv_errors; String tmp, cstr, *ostr= val_str(&tmp); + if (null_value) + { + Item *null_item= new Item_null((char *) fully_qualified_func_name()); + null_item->collation.set (tocs); + return null_item; + } cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors); if (conv_errors || !(conv= new Item_static_string_func(fully_qualified_func_name(), diff --git a/sql/log_event.cc b/sql/log_event.cc index cf338d8fd80..3a3350a4eb8 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -3425,7 +3425,8 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) number_of_event_types= LOG_EVENT_TYPES; /* we'll catch my_malloc() error in is_valid() */ post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8), - MYF(MY_ZEROFILL)); + MYF(0)); + /* This long list of assignments is not beautiful, but I see no way to make it nicer, as the right members are #defines, not array members, so @@ -3433,16 +3434,40 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) */ if (post_header_len) { + // Allows us to sanity-check that all events initialized their + // events (see the end of this 'if' block). + IF_DBUG(memset(post_header_len, 255, + number_of_event_types*sizeof(uint8));); + + /* Note: all event types must explicitly fill in their lengths here. */ post_header_len[START_EVENT_V3-1]= START_V3_HEADER_LEN; post_header_len[QUERY_EVENT-1]= QUERY_HEADER_LEN; + post_header_len[STOP_EVENT-1]= STOP_HEADER_LEN; post_header_len[ROTATE_EVENT-1]= ROTATE_HEADER_LEN; + post_header_len[INTVAR_EVENT-1]= INTVAR_HEADER_LEN; post_header_len[LOAD_EVENT-1]= LOAD_HEADER_LEN; + post_header_len[SLAVE_EVENT-1]= SLAVE_HEADER_LEN; post_header_len[CREATE_FILE_EVENT-1]= CREATE_FILE_HEADER_LEN; post_header_len[APPEND_BLOCK_EVENT-1]= APPEND_BLOCK_HEADER_LEN; post_header_len[EXEC_LOAD_EVENT-1]= EXEC_LOAD_HEADER_LEN; post_header_len[DELETE_FILE_EVENT-1]= DELETE_FILE_HEADER_LEN; - post_header_len[NEW_LOAD_EVENT-1]= post_header_len[LOAD_EVENT-1]; + post_header_len[NEW_LOAD_EVENT-1]= NEW_LOAD_HEADER_LEN; + post_header_len[RAND_EVENT-1]= RAND_HEADER_LEN; + post_header_len[USER_VAR_EVENT-1]= USER_VAR_HEADER_LEN; post_header_len[FORMAT_DESCRIPTION_EVENT-1]= FORMAT_DESCRIPTION_HEADER_LEN; + post_header_len[XID_EVENT-1]= XID_HEADER_LEN; + post_header_len[BEGIN_LOAD_QUERY_EVENT-1]= BEGIN_LOAD_QUERY_HEADER_LEN; + post_header_len[EXECUTE_LOAD_QUERY_EVENT-1]= EXECUTE_LOAD_QUERY_HEADER_LEN; + /* + The PRE_GA events are never be written to any binlog, but + their lengths are included in Format_description_log_event. + Hence, we need to be assign some value here, to avoid reading + uninitialized memory when the array is written to disk. + */ + post_header_len[PRE_GA_WRITE_ROWS_EVENT-1] = 0; + post_header_len[PRE_GA_UPDATE_ROWS_EVENT-1] = 0; + post_header_len[PRE_GA_DELETE_ROWS_EVENT-1] = 0; + post_header_len[TABLE_MAP_EVENT-1]= TABLE_MAP_HEADER_LEN; post_header_len[WRITE_ROWS_EVENT-1]= ROWS_HEADER_LEN; post_header_len[UPDATE_ROWS_EVENT-1]= ROWS_HEADER_LEN; @@ -3462,9 +3487,14 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) post_header_len[WRITE_ROWS_EVENT-1]= post_header_len[UPDATE_ROWS_EVENT-1]= post_header_len[DELETE_ROWS_EVENT-1]= 6;); - post_header_len[BEGIN_LOAD_QUERY_EVENT-1]= post_header_len[APPEND_BLOCK_EVENT-1]; - post_header_len[EXECUTE_LOAD_QUERY_EVENT-1]= EXECUTE_LOAD_QUERY_HEADER_LEN; post_header_len[INCIDENT_EVENT-1]= INCIDENT_HEADER_LEN; + + // Sanity-check that all post header lengths are initialized. + IF_DBUG({ + int i; + for (i=0; i<number_of_event_types; i++) + assert(post_header_len[i] != 255); + }); } break; @@ -4813,7 +4843,9 @@ Intvar_log_event::Intvar_log_event(const char* buf, const Format_description_log_event* description_event) :Log_event(buf, description_event) { - buf+= description_event->common_header_len; + /* The Post-Header is empty. The Varible Data part begins immediately. */ + buf+= description_event->common_header_len + + description_event->post_header_len[INTVAR_EVENT-1]; type= buf[I_TYPE_OFFSET]; val= uint8korr(buf+I_VAL_OFFSET); } @@ -4957,7 +4989,9 @@ Rand_log_event::Rand_log_event(const char* buf, const Format_description_log_event* description_event) :Log_event(buf, description_event) { - buf+= description_event->common_header_len; + /* The Post-Header is empty. The Variable Data part begins immediately. */ + buf+= description_event->common_header_len + + description_event->post_header_len[RAND_EVENT-1]; seed1= uint8korr(buf+RAND_SEED1_OFFSET); seed2= uint8korr(buf+RAND_SEED2_OFFSET); } @@ -5061,7 +5095,9 @@ Xid_log_event(const char* buf, const Format_description_log_event *description_event) :Log_event(buf, description_event) { - buf+= description_event->common_header_len; + /* The Post-Header is empty. The Variable Data part begins immediately. */ + buf+= description_event->common_header_len + + description_event->post_header_len[XID_EVENT-1]; memcpy((char*) &xid, buf, sizeof(xid)); } @@ -5207,7 +5243,9 @@ User_var_log_event(const char* buf, const Format_description_log_event* description_event) :Log_event(buf, description_event) { - buf+= description_event->common_header_len; + /* The Post-Header is empty. The Variable Data part begins immediately. */ + buf+= description_event->common_header_len + + description_event->post_header_len[USER_VAR_EVENT-1]; name_len= uint4korr(buf); name= (char *) buf + UV_NAME_LEN_SIZE; buf+= UV_NAME_LEN_SIZE + name_len; diff --git a/sql/log_event.h b/sql/log_event.h index db14341b51d..e546cff8b7b 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -227,14 +227,22 @@ struct sql_ex_info #define QUERY_HEADER_MINIMAL_LEN (4 + 4 + 1 + 2) // where 5.0 differs: 2 for len of N-bytes vars. #define QUERY_HEADER_LEN (QUERY_HEADER_MINIMAL_LEN + 2) +#define STOP_HEADER_LEN 0 #define LOAD_HEADER_LEN (4 + 4 + 4 + 1 +1 + 4) +#define SLAVE_HEADER_LEN 0 #define START_V3_HEADER_LEN (2 + ST_SERVER_VER_LEN + 4) #define ROTATE_HEADER_LEN 8 // this is FROZEN (the Rotate post-header is frozen) +#define INTVAR_HEADER_LEN 0 #define CREATE_FILE_HEADER_LEN 4 #define APPEND_BLOCK_HEADER_LEN 4 #define EXEC_LOAD_HEADER_LEN 4 #define DELETE_FILE_HEADER_LEN 4 +#define NEW_LOAD_HEADER_LEN LOAD_HEADER_LEN +#define RAND_HEADER_LEN 0 +#define USER_VAR_HEADER_LEN 0 #define FORMAT_DESCRIPTION_HEADER_LEN (START_V3_HEADER_LEN+1+LOG_EVENT_TYPES) +#define XID_HEADER_LEN 0 +#define BEGIN_LOAD_QUERY_HEADER_LEN APPEND_BLOCK_HEADER_LEN #define ROWS_HEADER_LEN 8 #define TABLE_MAP_HEADER_LEN 8 #define EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN (4 + 4 + 4 + 1) @@ -319,18 +327,16 @@ struct sql_ex_info #define Q_CHARSET_DATABASE_CODE 8 #define Q_TABLE_MAP_FOR_UPDATE_CODE 9 -/* Intvar event post-header */ +/* Intvar event data */ #define I_TYPE_OFFSET 0 #define I_VAL_OFFSET 1 -/* Rand event post-header */ - +/* Rand event data */ #define RAND_SEED1_OFFSET 0 #define RAND_SEED2_OFFSET 8 -/* User_var event post-header */ - +/* User_var event data */ #define UV_VAL_LEN_SIZE 4 #define UV_VAL_IS_NULL 1 #define UV_VAL_TYPE_SIZE 1 @@ -338,7 +344,6 @@ struct sql_ex_info #define UV_CHARSET_NUMBER_SIZE 4 /* Load event post-header */ - #define L_THREAD_ID_OFFSET 0 #define L_EXEC_TIME_OFFSET 4 #define L_SKIP_LINES_OFFSET 8 @@ -349,7 +354,6 @@ struct sql_ex_info #define L_DATA_OFFSET LOAD_HEADER_LEN /* Rotate event post-header */ - #define R_POS_OFFSET 0 #define R_IDENT_OFFSET 8 @@ -2206,10 +2210,11 @@ protected: @section Intvar_log_event_binary_format Binary Format - The Post-Header has two components: + The Post-Header for this event type is empty. The Body has two + components: <table> - <caption>Post-Header for Intvar_log_event</caption> + <caption>Body for Intvar_log_event</caption> <tr> <th>Name</th> @@ -2283,11 +2288,12 @@ private: which are stored internally as two 64-bit numbers. @section Rand_log_event_binary_format Binary Format - This event type has no Post-Header. The Body of this event type has - two components: + + The Post-Header for this event type is empty. The Body has two + components: <table> - <caption>Post-Header for Intvar_log_event</caption> + <caption>Body for Rand_log_event</caption> <tr> <th>Name</th> diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1e9d942b1dd..a2ccbc42e77 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6611,7 +6611,7 @@ The minimum value for this variable is 4096.", {"max_user_connections", OPT_MAX_USER_CONNECTIONS, "The maximum number of active connections for a single user (0 = no limit).", (uchar**) &max_user_connections, (uchar**) &max_user_connections, 0, GET_UINT, - REQUIRED_ARG, 0, 1, UINT_MAX, 0, 1, 0}, + REQUIRED_ARG, 0, 0, UINT_MAX, 0, 1, 0}, {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT, "After this many write locks, allow some read locks to run in between.", (uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0, GET_ULONG, diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index d7e783f534f..582348608de 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -644,6 +644,16 @@ err: } #endif + +/** + Execute a SHOW SLAVE HOSTS statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @retval FALSE success + @retval TRUE failure +*/ bool show_slave_hosts(THD* thd) { List<Item> field_list; diff --git a/sql/slave.cc b/sql/slave.cc index 43b70f29a68..22c61b3ec6c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1357,6 +1357,17 @@ int register_slave_on_master(MYSQL* mysql, Master_info *mi, } +/** + Execute a SHOW SLAVE STATUS statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param mi Pointer to Master_info object for the IO thread. + + @retval FALSE success + @retval TRUE failure +*/ bool show_master_info(THD* thd, Master_info* mi) { // TODO: fix this for multi-master @@ -2062,7 +2073,7 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli, fewer times, 0 is returned. - init_master_info or init_relay_log_pos failed. (These are called - if a failure occurs when applying the event.)</li> + if a failure occurs when applying the event.) - An error occurred when updating the binlog position. @@ -2307,8 +2318,14 @@ static int try_to_reconnect(THD *thd, MYSQL *mysql, Master_info *mi, } -/* Slave I/O Thread entry point */ +/** + Slave IO thread entry point. + + @param arg Pointer to Master_info struct that holds information for + the IO thread. + @return Always 0. +*/ pthread_handler_t handle_slave_io(void *arg) { THD *thd; // needs to be first for thread_stack @@ -2616,8 +2633,14 @@ err: } -/* Slave SQL Thread entry point */ +/** + Slave SQL thread entry point. + + @param arg Pointer to Relay_log_info object that holds information + for the SQL thread. + @return Always 0. +*/ pthread_handler_t handle_slave_sql(void *arg) { THD *thd; /* needs to be first for thread_stack */ @@ -3710,6 +3733,16 @@ static IO_CACHE *reopen_relay_log(Relay_log_info *rli, const char **errmsg) } +/** + Reads next event from the relay log. Should be called from the + slave IO thread. + + @param rli Relay_log_info structure for the slave IO thread. + + @return The event read, or NULL on error. If an error occurs, the + error is reported through the sql_print_information() or + sql_print_error() functions. +*/ static Log_event* next_event(Relay_log_info* rli) { Log_event* ev; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index ea664cd5091..6db9f1df0f2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1111,6 +1111,27 @@ static void mark_temp_tables_as_free_for_reuse(THD *thd) */ if (table->child_l || table->parent) detach_merge_children(table, TRUE); + /* + Reset temporary table lock type to it's default value (TL_WRITE). + + Statements such as INSERT INTO .. SELECT FROM tmp, CREATE TABLE + .. SELECT FROM tmp and UPDATE may under some circumstances modify + the lock type of the tables participating in the statement. This + isn't a problem for non-temporary tables since their lock type is + reset at every open, but the same does not occur for temporary + tables for historical reasons. + + Furthermore, the lock type of temporary tables is not really that + important because they can only be used by one query at a time and + not even twice in a query -- a temporary table is represented by + only one TABLE object. Nonetheless, it's safer from a maintenance + point of view to reset the lock type of this singleton TABLE object + as to not cause problems when the table is reused. + + Even under LOCK TABLES mode its okay to reset the lock type as + LOCK TABLES is allowed (but ignored) for a temporary table. + */ + table->reginfo.lock_type= TL_WRITE; } } } @@ -4681,7 +4702,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) else if (tables->lock_type == TL_READ_DEFAULT) tables->table->reginfo.lock_type= read_lock_type_for_table(thd, tables->table); - else if (tables->table->s->tmp_table == NO_TMP_TABLE) + else tables->table->reginfo.lock_type= tables->lock_type; } tables->table->grant= tables->grant; diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 7ca7bef3a56..96e99b57e3c 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -18,7 +18,7 @@ #include "base64.h" /** - Execute a BINLOG statement + Execute a BINLOG statement. To execute the BINLOG command properly the server needs to know which format the BINLOG command's event is in. Therefore, the first @@ -26,6 +26,9 @@ Format_description_log_event, as outputted by mysqlbinlog. This Format_description_log_event is cached in rli->description_event_for_exec. + + @param thd Pointer to THD object for the client thread executing the + statement. */ void mysql_client_binlog_statement(THD* thd) diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index f7c44152571..b56e042e3d5 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -951,6 +951,26 @@ bool multi_delete::send_eof() ****************************************************************************/ /* + Row-by-row truncation if the engine does not support table recreation. + Probably a InnoDB table. +*/ + +static bool mysql_truncate_by_delete(THD *thd, TABLE_LIST *table_list) +{ + bool error, save_binlog_row_based= thd->current_stmt_binlog_row_based; + DBUG_ENTER("mysql_truncate_by_delete"); + table_list->lock_type= TL_WRITE; + mysql_init_select(thd->lex); + thd->clear_current_stmt_binlog_row_based(); + error= mysql_delete(thd, table_list, NULL, NULL, HA_POS_ERROR, LL(0), TRUE); + ha_autocommit_or_rollback(thd, error); + end_trans(thd, error ? ROLLBACK : COMMIT); + thd->current_stmt_binlog_row_based= save_binlog_row_based; + DBUG_RETURN(error); +} + + +/* Optimize delete of all rows by doing a full generate of the table This will work even if the .ISM and .ISD tables are destroyed @@ -1055,24 +1075,6 @@ end: DBUG_RETURN(error); trunc_by_del: - /* Probably InnoDB table */ - ulonglong save_options= thd->options; - table_list->lock_type= TL_WRITE; - thd->options&= ~(OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT); - ha_enable_transaction(thd, FALSE); - mysql_init_select(thd->lex); - bool save_binlog_row_based= thd->current_stmt_binlog_row_based; - thd->clear_current_stmt_binlog_row_based(); - error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0, - HA_POS_ERROR, LL(0), TRUE); - ha_enable_transaction(thd, TRUE); - /* - Safety, in case the engine ignored ha_enable_transaction(FALSE) - above. Also clears thd->transaction.*. - */ - error= ha_autocommit_or_rollback(thd, error); - ha_commit(thd); - thd->options= save_options; - thd->current_stmt_binlog_row_based= save_binlog_row_based; + error= mysql_truncate_by_delete(thd, table_list); DBUG_RETURN(error); } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 26bd8d18750..ed6b9e7d8df 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -190,6 +190,15 @@ typedef struct st_lex_server_options char *server_name, *host, *db, *username, *password, *scheme, *socket, *owner; } LEX_SERVER_OPTIONS; + +/** + Structure to hold parameters for CHANGE MASTER or START/STOP SLAVE + or SHOW NEW MASTER. + + Remark: this should not be confused with Master_info (and perhaps + would better be renamed to st_lex_replication_info). Some fields, + e.g., delay, are saved in Relay_log_info, not in Master_info. +*/ typedef struct st_lex_master_info { char *host, *user, *password, *log_file_name; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index e96d9c11a84..ae55c194c3c 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6678,6 +6678,7 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, uint32 max_endpoint_val; get_endpoint_func get_endpoint; uint field_len= field->pack_length_in_rec(); + part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE; if (part_info->part_type == RANGE_PARTITION) { @@ -6698,7 +6699,6 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, max_endpoint_val= part_info->no_list_values; part_iter->get_next= get_next_partition_id_list; part_iter->part_info= part_info; - part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE; if (max_endpoint_val == 0) { /* @@ -6760,7 +6760,7 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, store_key_image_to_rec(field, max_value, field_len); bool include_endp= !test(flags & NEAR_MAX); part_iter->part_nums.end= get_endpoint(part_info, 0, include_endp); - if (part_iter->part_nums.start == part_iter->part_nums.end && + if (part_iter->part_nums.start >= part_iter->part_nums.end && !part_iter->ret_null_part) return 0; /* No partitions */ } @@ -6938,7 +6938,7 @@ int get_part_iter_for_interval_via_walking(partition_info *part_info, uint32 get_next_partition_id_range(PARTITION_ITERATOR* part_iter) { - if (part_iter->part_nums.cur == part_iter->part_nums.end) + if (part_iter->part_nums.cur >= part_iter->part_nums.end) { part_iter->part_nums.cur= part_iter->part_nums.start; return NOT_A_PARTITION_ID; diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index c62cf6401ba..cb5b3722559 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -552,8 +552,8 @@ int PROFILING::fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond) The order of these fields is set by the query_profile_statistics_info array. */ - table->field[0]->store((ulonglong) query->profiling_query_id); - table->field[1]->store((ulonglong) seq); /* the step in the sequence */ + table->field[0]->store((ulonglong) query->profiling_query_id, TRUE); + table->field[1]->store((ulonglong) seq, TRUE); /* the step in the sequence */ /* This entry, n, has a point in time, T(n), and a status phrase, S(n). The status phrase S(n) describes the period of time that begins at diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index eac7a50417a..646bfdaefe8 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -257,6 +257,17 @@ bool purge_error_message(THD* thd, int res) } +/** + Execute a PURGE BINARY LOGS TO <log> command. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param to_log Name of the last log to purge. + + @retval FALSE success + @retval TRUE failure +*/ bool purge_master_logs(THD* thd, const char* to_log) { char search_file_name[FN_REFLEN]; @@ -273,6 +284,17 @@ bool purge_master_logs(THD* thd, const char* to_log) } +/** + Execute a PURGE BINARY LOGS BEFORE <date> command. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param purge_time Date before which logs should be purged. + + @retval FALSE success + @retval TRUE failure +*/ bool purge_master_logs_before_date(THD* thd, time_t purge_time) { if (!mysql_bin_log.is_open()) @@ -765,6 +787,20 @@ err: DBUG_VOID_RETURN; } + +/** + Execute a START SLAVE statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param mi Pointer to Master_info object for the slave's IO thread. + + @param net_report If true, saves the exit status into thd->main_da. + + @retval 0 success + @retval 1 error +*/ int start_slave(THD* thd , Master_info* mi, bool net_report) { int slave_errno= 0; @@ -890,6 +926,19 @@ int start_slave(THD* thd , Master_info* mi, bool net_report) } +/** + Execute a STOP SLAVE statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param mi Pointer to Master_info object for the slave's IO thread. + + @param net_report If true, saves the exit status into thd->main_da. + + @retval 0 success + @retval 1 error +*/ int stop_slave(THD* thd, Master_info* mi, bool net_report ) { DBUG_ENTER("stop_slave"); @@ -942,20 +991,17 @@ int stop_slave(THD* thd, Master_info* mi, bool net_report ) } -/* - Remove all relay logs and start replication from the start - - SYNOPSIS - reset_slave() - thd Thread handler - mi Master info for the slave +/** + Execute a RESET SLAVE statement. - RETURN - 0 ok - 1 error -*/ + @param thd Pointer to THD object of the client thread executing the + statement. + @param mi Pointer to Master_info object for the slave. + @retval 0 success + @retval 1 error +*/ int reset_slave(THD *thd, Master_info* mi) { MY_STAT stat_area; @@ -1070,6 +1116,18 @@ void kill_zombie_dump_threads(uint32 slave_server_id) } +/** + Execute a CHANGE MASTER statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @param mi Pointer to Master_info object belonging to the slave's IO + thread. + + @retval FALSE success + @retval TRUE error +*/ bool change_master(THD* thd, Master_info* mi) { int thread_mask; @@ -1283,6 +1341,16 @@ bool change_master(THD* thd, Master_info* mi) DBUG_RETURN(FALSE); } + +/** + Execute a RESET MASTER statement. + + @param thd Pointer to THD object of the client thread executing the + statement. + + @retval 0 success + @retval 1 error +*/ int reset_master(THD* thd) { if (!mysql_bin_log.is_open()) @@ -1312,6 +1380,15 @@ int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1, } +/** + Execute a SHOW BINLOG EVENTS statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @retval FALSE success + @retval TRUE failure +*/ bool mysql_show_binlog_events(THD* thd) { Protocol *protocol= thd->protocol; @@ -1462,6 +1539,15 @@ err: } +/** + Execute a SHOW MASTER STATUS statement. + + @param thd Pointer to THD object for the client thread executing the + statement. + + @retval FALSE success + @retval TRUE failure +*/ bool show_binlog_info(THD* thd) { Protocol *protocol= thd->protocol; @@ -1495,18 +1581,15 @@ bool show_binlog_info(THD* thd) } -/* - Send a list of all binary logs to client +/** + Execute a SHOW BINARY LOGS statement. - SYNOPSIS - show_binlogs() - thd Thread specific variable + @param thd Pointer to THD object for the client thread executing the + statement. - RETURN VALUES - FALSE OK - TRUE error + @retval FALSE success + @retval TRUE failure */ - bool show_binlogs(THD* thd) { IO_CACHE *index_file; |