From bd4e65515f556b6bca45d06d81370d99cf649647 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 31 Jan 2009 23:22:44 +0200 Subject: Fixed compiler warnings found by gcc 4.3.2 - Added braces around expressions with &&, ||, & and | - Added empty line before ; for empty while and for loops - Added () around if with assignments - Removed const before function returning simple type Changed BUILD scripts to not build with NDB BUILD/SETUP.sh: By default, don't build ndb with --max in Maria tree. NDB is not kept up to date anyway in 5.1 client/mysql.cc: Added braces around && to get rid of compiler warnings sql/event_db_repository.cc: Added braces around && to get rid of compiler warnings sql/events.cc: Added braces around && to get rid of compiler warnings sql/field.cc: Added braces around && to get rid of compiler warnings Fixed for loops sql/field.h: Added braces around & to get rid of compiler warnings sql/field_conv.cc: Added braces around && to get rid of compiler warnings Fixed bug when copying between DATETIME fields and strict dates are used Removed not needeed else sql/gstream.cc: Added braces around && to get rid of compiler warnings sql/ha_ndbcluster.cc: Added braces around && to get rid of compiler warnings Added {} to get rid of compiler warnings sql/handler.cc: Added braces around && to get rid of compiler warnings sql/item.cc: Added braces around && to get rid of compiler warnings sql/item_cmpfunc.cc: Added braces around && to get rid of compiler warnings Removed some not needed space sql/item_func.cc: Added braces around && to get rid of compiler warnings sql/item_strfunc.cc: Added braces around && to get rid of compiler warnings sql/item_subselect.cc: Added braces around && to get rid of compiler warnings sql/item_sum.cc: Added braces around && to get rid of compiler warnings sql/item_timefunc.cc: Added braces around && to get rid of compiler warnings sql/item_xmlfunc.cc: Added empty line before ; for empty while and for loops sql/log.cc: Added braces around && to get rid of compiler warnings sql/log_event.cc: Added braces around && to get rid of compiler warnings Removed not needed else sql/log_event_old.cc: Added braces around && to get rid of compiler warnings sql/opt_range.cc: Added braces around && to get rid of compiler warnings sql/opt_sum.cc: Added braces around && to get rid of compiler warnings sql/set_var.cc: Added empty line before ; for empty while and for loops Added () around if with assignments sql/slave.cc: Added braces around && to get rid of compiler warnings Added empty line before ; for empty while and for loops sql/spatial.h: Added braces around && to get rid of compiler warnings sql/sql_acl.cc: Added braces around && to get rid of compiler warnings sql/sql_analyse.cc: Added empty line before ; for empty while and for loops sql/sql_base.cc: Added braces around && to get rid of compiler warnings sql/sql_connect.cc: Added braces around && to get rid of compiler warnings sql/sql_db.cc: Added braces around && to get rid of compiler warnings sql/sql_delete.cc: Added braces around && to get rid of compiler warnings sql/sql_help.cc: Added empty line before ; for empty while and for loops sql/sql_insert.cc: Added braces around && to get rid of compiler warnings Added () around if with assignments sql/sql_lex.cc: Cast char array references to uchar; Fixed wrong array referencing when using characters > ASCII 128 in SQL statments Added empty line before ; for empty while and for loops Trivial indent fixes Added braces around && to get rid of compiler warnings sql/sql_load.cc: Added braces around && to get rid of compiler warnings sql/sql_parse.cc: Added braces around && to get rid of compiler warnings sql/sql_partition.cc: Added braces around && to get rid of compiler warnings sql/sql_plugin.cc: Fixed bug in detecing if option variable should be readonly Added empty line before ; for empty while and for loops sql/sql_prepare.cc: Added braces around && to get rid of compiler warnings sql/sql_select.cc: Added braces around && to get rid of compiler warnings Added () around if with assignments Added empty line before ; for empty while and for loops sql/sql_show.cc: Added braces around && to get rid of compiler warnings sql/sql_table.cc: Added braces around && to get rid of compiler warnings sql/sql_trigger.cc: Added braces around && to get rid of compiler warnings sql/sql_update.cc: Added braces around && to get rid of compiler warnings sql/sql_yacc.yy: Added braces around && to get rid of compiler warnings sql/table.cc: Added braces around && to get rid of compiler warnings sql/table.h: Added braces around && to get rid of compiler warnings sql/time.cc: Added braces around && to get rid of compiler warnings sql/tztime.cc: Added braces around && to get rid of compiler warnings sql/uniques.cc: Added braces around && to get rid of compiler warnings storage/federated/ha_federated.cc: Fixed bug in testing of variable to ha_info() (Not critical) storage/heap/ha_heap.cc: Added braces around && to get rid of compiler warnings storage/maria/ha_maria.cc: Fixed bug: Mark that maria_log_dir_path is readonly Added braces around && to get rid of compiler warnings storage/ndb/include/ndbapi/NdbEventOperation.hpp: Removed const before function returning simple type storage/ndb/include/ndbapi/NdbOperation.hpp: Removed const before function returning simple type storage/ndb/src/ndbapi/Ndb.cpp: Added empty line before ; for empty while and for loops storage/ndb/src/ndbapi/NdbEventOperation.cpp: Removed const before function returning simple type storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp: Removed const before function returning simple type storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp: Removed const before function returning simple type storage/ndb/src/ndbapi/NdbRecAttr.cpp: Added empty line before ; for empty while and for loops storage/ndb/src/ndbapi/TransporterFacade.hpp: Added braces around && to get rid of compiler warnings --- sql/tztime.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/tztime.cc') diff --git a/sql/tztime.cc b/sql/tztime.cc index 53870915973..860a604b545 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -447,8 +447,8 @@ prepare_tz_info(TIME_ZONE_INFO *sp, MEM_ROOT *storage) } if (end_t == MY_TIME_T_MAX || - (cur_off_and_corr > 0) && - (end_t >= MY_TIME_T_MAX - cur_off_and_corr)) + ((cur_off_and_corr > 0) && + (end_t >= MY_TIME_T_MAX - cur_off_and_corr))) /* end of t space */ break; -- cgit v1.2.1 From ab0905c6d7041928b260adb60ff551275e8153bc Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 19 Oct 2009 20:14:48 +0300 Subject: This is based on the userstatv2 patch from Percona and OurDelta. The original code comes, as far as I know, from Google (Mark Callaghan's team) with additional work from Percona, Ourdelta and Weldon Whipple. This code provides the same functionallity, but with a lot of changes to make it faster and better fit the MariaDB infrastucture. Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_sent, Rows_read Added new variable / startup option 'userstat' to control if user statistics should be enabled or not Added my_getcputime(); Returns cpu time used by this thread. New FLUSH commands: - FLUSH SLOW QUERY LOG - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS New SHOW commands: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS New Information schemas: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Added support for all new flush commands to mysqladmin Added handler::ha_... wrappers for all handler read calls to do statistics counting - Changed all code to use new ha_... calls - Count number of read rows, changed rows and rows read trough an index Added counting of number of bytes sent to binary log (status variable Binlog_bytes_written) Added counting of access denied errors (status variable Access_denied_erors) Bugs fixed: - Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long - CLOCK_GETTIME was not propely working on Linuxm client/mysqladmin.cc: Added support for all new flush commmands and some common combinations: flush-slow-log flush-table-statistics flush-index-statistics flush-user-statistics flush-client-statistics flush-all-status flush-all-statistics configure.in: Added checking if clock_gettime needs the librt. (Fixes Bug #37639 clock_gettime is never used/enabled in Linux/Unix) include/my_sys.h: Added my_getcputime() include/mysql_com.h: Added LIST_PROCESS_HOST_LEN & new REFRESH target defines mysql-test/r/information_schema.result: New information schema tables added mysql-test/r/information_schema_all_engines.result: New information schema tables added mysql-test/r/information_schema_db.result: New information schema tables added mysql-test/r/log_slow.result: Added testing that flosh slow query logs is accepted mysql-test/r/status_user.result: Basic testing of user, client, table and index statistics mysql-test/t/log_slow.test: Added testing that flosh slow query logs is accepted mysql-test/t/status_user-master.opt: Ensure that we get a fresh restart before running status_user.test mysql-test/t/status_user.test: Basic testing of user, client, table and index statistics mysys/my_getsystime.c: Added my_getcputime() Returns cpu time used by this thread. sql/authors.h: Updated authors to have core and original MySQL developers first. sql/event_data_objects.cc: Updated call to mysql_reset_thd_for_next_command() sql/event_db_repository.cc: Changed to use new ha_... calls sql/filesort.cc: Changed to use new ha_... calls sql/ha_partition.cc: Changed to use new ha_... calls Fixed comment syntax sql/handler.cc: Changed to use new ha_... calls Reset table statistics Added code to update global table and index status Added counting of rows changed sql/handler.h: Added table and index statistics variables Added function reset_statistics() Added handler::ha_... wrappers for all handler read calls to do statistics counting Protected all normal read calls to ensure we use the new calls in the server. Made ha_partition a friend class so that partition code can call the old read functions sql/item_subselect.cc: Changed to use new ha_... calls sql/lex.h: Added keywords for new information schema tables and flush commands sql/log.cc: Added flush_slow_log() Added counting of number of bytes sent to binary log Removed not needed test of thd (It's used before, so it's safe to use) Added THD object to MYSQL_BIN_LOG::write_cache() to simplify statistics counting sql/log.h: Added new parameter to write_cache() Added flush_slow_log() functions. sql/log_event.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/log_event_old.cc: Updated call to mysql_reset_thd_for_next_command() Changed to use new ha_... calls sql/mysql_priv.h: Updated call to mysql_reset_thd_for_next_command() Added new statistics functions and variables needed by these. sql/mysqld.cc: Added new statistics variables and structures to handle these Added new status variables: - Com_show_client_statistics, Com_show_index_statistics, Com_show_table_statistics, Com_show_user_statistics - Access_denied_errors, Busy_time (clock time), Binlog_bytes_written, Cpu_time, Empty_queries, Rows_set, Rows_read Added new option 'userstat' to control if user statistics should be enabled or not sql/opt_range.cc: Changed to use new ha_... calls sql/opt_range.h: Changed to use new ha_... calls sql/opt_sum.cc: Changed to use new ha_... calls sql/records.cc: Changed to use new ha_... calls sql/set_var.cc: Added variable 'userstat' sql/sp.cc: Changed to use new ha_... calls sql/sql_acl.cc: Changed to use new ha_... calls Added counting of access_denied_errors sql/sql_base.cc: Added call to statistics functions sql/sql_class.cc: Added usage of org_status_var, to store status variables at start of command Added functions THD::update_stats(), THD::update_all_stats() Fixed bug in add_to_status() and add_diff_to_status() where longlong variables where threated as long sql/sql_class.h: Added new status variables to status_var Moved variables that was not ulong in status_var last. Added variables to THD for storing temporary values during statistics counting sql/sql_connect.cc: Variables and functions to calculate user and client statistics Added counting of access_denied_errors and lost_connections sql/sql_cursor.cc: Changed to use new ha_... calls sql/sql_handler.cc: Changed to use new ha_... calls sql/sql_help.cc: Changed to use new ha_... calls sql/sql_insert.cc: Changed to use new ha_... calls sql/sql_lex.h: Added SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS, SQLCOM_SHOW_CLIENT_STATS sql/sql_parse.cc: Added handling of: - SHOW CLIENT_STATISTICS - SHOW USER_STATISTICS - SHOW TABLE_STATISTICS - SHOW INDEX_STATISTICS Added handling of new FLUSH commands: - FLUSH SLOW QUERY LOGS - FLUSH TABLE_STATISTICS - FLUSH INDEX_STATISTICS - FLUSH USER_STATISTICS - FLUSH CLIENT_STATISTICS Added THD parameter to mysql_reset_thd_for_next_command() Added initialization and calls to user statistics functions Added increment of statistics variables empty_queries, rows_sent and access_denied_errors. Added counting of cpu time per query sql/sql_plugin.cc: Changed to use new ha_... calls sql/sql_prepare.cc: Updated call to mysql_reset_thd_for_next_command() sql/sql_select.cc: Changed to use new ha_... calls Indentation changes sql/sql_servers.cc: Changed to use new ha_... calls sql/sql_show.cc: Added counting of access denied errors Added function for new information schema tables: - CLIENT_STATISTICS - USER_STATISTICS - INDEX_STATISTICS - TABLE_STATISTICS Changed to use new ha_... calls sql/sql_table.cc: Changed to use new ha_... calls sql/sql_udf.cc: Changed to use new ha_... calls sql/sql_update.cc: Changed to use new ha_... calls sql/sql_yacc.yy: Add new show and flush commands sql/structs.h: Add name_length to KEY to avoid some strlen Added cache_name to KEY for fast storage of keyvalue in cache Added structs USER_STATS, TABLE_STATS, INDEX_STATS Added function prototypes for statistics functions sql/table.cc: Store db+table+index name into keyinfo->cache_name sql/table.h: Added new information schema tables sql/tztime.cc: Changed to use new ha_... calls --- sql/tztime.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'sql/tztime.cc') diff --git a/sql/tztime.cc b/sql/tztime.cc index cd6e63be039..3802c284057 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1676,7 +1676,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) tz_leapcnt= 0; - res= table->file->index_first(table->record[0]); + res= table->file->ha_index_first(table->record[0]); while (!res) { @@ -1698,7 +1698,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) tz_leapcnt, (ulong) tz_lsis[tz_leapcnt-1].ls_trans, tz_lsis[tz_leapcnt-1].ls_corr)); - res= table->file->index_next(table->record[0]); + res= table->file->ha_index_next(table->record[0]); } (void)table->file->ha_index_end(); @@ -1865,8 +1865,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) */ (void)table->file->ha_index_init(0, 1); - if (table->file->index_read_map(table->record[0], table->field[0]->ptr, - HA_WHOLE_KEY, HA_READ_KEY_EXACT)) + if (table->file->ha_index_read_map(table->record[0], table->field[0]->ptr, + HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { #ifdef EXTRA_DEBUG /* @@ -1893,8 +1893,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - if (table->file->index_read_map(table->record[0], table->field[0]->ptr, - HA_WHOLE_KEY, HA_READ_KEY_EXACT)) + if (table->file->ha_index_read_map(table->record[0], table->field[0]->ptr, + HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { sql_print_error("Can't find description of time zone '%u'", tzid); goto end; @@ -1920,8 +1920,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - res= table->file->index_read_map(table->record[0], table->field[0]->ptr, - (key_part_map)1, HA_READ_KEY_EXACT); + res= table->file->ha_index_read_map(table->record[0], table->field[0]->ptr, + (key_part_map)1, HA_READ_KEY_EXACT); while (!res) { ttid= (uint)table->field[1]->val_int(); @@ -1968,8 +1968,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) tmp_tz_info.typecnt= ttid + 1; - res= table->file->index_next_same(table->record[0], - table->field[0]->ptr, 4); + res= table->file->ha_index_next_same(table->record[0], + table->field[0]->ptr, 4); } if (res != HA_ERR_END_OF_FILE) @@ -1991,8 +1991,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - res= table->file->index_read_map(table->record[0], table->field[0]->ptr, - (key_part_map)1, HA_READ_KEY_EXACT); + res= table->file->ha_index_read_map(table->record[0], table->field[0]->ptr, + (key_part_map)1, HA_READ_KEY_EXACT); while (!res) { ttime= (my_time_t)table->field[1]->val_int(); @@ -2021,8 +2021,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ("time_zone_transition table: tz_id: %u tt_time: %lu tt_id: %u", tzid, (ulong) ttime, ttid)); - res= table->file->index_next_same(table->record[0], - table->field[0]->ptr, 4); + res= table->file->ha_index_next_same(table->record[0], + table->field[0]->ptr, 4); } /* -- cgit v1.2.1 From ac6b3c44308b61ebf0ed5ac20e93a1ee3cd61b99 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 5 Jun 2010 16:53:36 +0200 Subject: few small MySQL bugs/issues that impact the engines, as discussed in the SE summit * remove handler::index_read_last() * create handler::keyread_read_time() (was get_index_only_read_time() in opt_range.cc) * ha_show_status() allows engine's show_status() to fail * remove HTON_FLUSH_AFTER_RENAME * fix key_cmp_if_same() to work for floats and doubles * set table->status in the server, don't force engines to do it * increment status vars in the server, don't force engines to do it mysql-test/r/status_user.result: correct test results - innodb was wrongly counting internal index searches as handler_read_* calls. sql/ha_partition.cc: compensate for handler incrementing status counters - we want to count only calls to underlying engines sql/handler.h: inline methods moved to sql_class.h sql/key.cc: simplify the check sql/opt_range.cc: move get_index_only_read_time to the handler class sql/sp.cc: don't use a key that's stored in the record buffer - the engine can overwrite the buffer with anything, destroying the key sql/sql_class.h: inline handler methods that need to see THD and TABLE definitions sql/sql_select.cc: no ha_index_read_last_map anymore sql/sql_table.cc: remove HTON_FLUSH_AFTER_RENAME sql/table.cc: set HA_CAN_MEMCMP as appropriate sql/tztime.cc: don't use a key that's stored in the record buffer - the engine can overwrite the buffer with anything, destroying the key storage/myisam/ha_myisam.cc: engines don't need to update table->status or use ha_statistic_increment anymore storage/myisam/ha_myisam.h: index_read_last_map is no more --- sql/tztime.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'sql/tztime.cc') diff --git a/sql/tztime.cc b/sql/tztime.cc index 3802c284057..457bbeec676 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1813,6 +1813,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) uint tzid, ttid; my_time_t ttime; char buff[MAX_FIELD_WIDTH]; + uchar keybuff[32]; String abbr(buff, sizeof(buff), &my_charset_latin1); char *alloc_buff, *tz_name_buff; /* @@ -1891,9 +1892,10 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table= tz_tables->table; tz_tables= tz_tables->next_local; table->field[0]->store((longlong) tzid, TRUE); + table->field[0]->get_key_image(keybuff, sizeof(keybuff), Field::itRAW); (void)table->file->ha_index_init(0, 1); - if (table->file->ha_index_read_map(table->record[0], table->field[0]->ptr, + if (table->file->ha_index_read_map(table->record[0], keybuff, HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { sql_print_error("Can't find description of time zone '%u'", tzid); @@ -1918,9 +1920,10 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table= tz_tables->table; tz_tables= tz_tables->next_local; table->field[0]->store((longlong) tzid, TRUE); + table->field[0]->get_key_image(keybuff, sizeof(keybuff), Field::itRAW); (void)table->file->ha_index_init(0, 1); - res= table->file->ha_index_read_map(table->record[0], table->field[0]->ptr, + res= table->file->ha_index_read_map(table->record[0], keybuff, (key_part_map)1, HA_READ_KEY_EXACT); while (!res) { @@ -1968,8 +1971,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) tmp_tz_info.typecnt= ttid + 1; - res= table->file->ha_index_next_same(table->record[0], - table->field[0]->ptr, 4); + res= table->file->ha_index_next_same(table->record[0], keybuff, 4); } if (res != HA_ERR_END_OF_FILE) @@ -1991,7 +1993,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - res= table->file->ha_index_read_map(table->record[0], table->field[0]->ptr, + res= table->file->ha_index_read_map(table->record[0], keybuff, (key_part_map)1, HA_READ_KEY_EXACT); while (!res) { @@ -2021,8 +2023,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ("time_zone_transition table: tz_id: %u tt_time: %lu tt_id: %u", tzid, (ulong) ttime, ttid)); - res= table->file->ha_index_next_same(table->record[0], - table->field[0]->ptr, 4); + res= table->file->ha_index_next_same(table->record[0], keybuff, 4); } /* -- cgit v1.2.1 From 5b80e6cd5df050104aa59d16ceb4c11cf1062484 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 17 Jun 2010 15:52:23 +0200 Subject: fix for valgrind warning --- sql/tztime.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'sql/tztime.cc') diff --git a/sql/tztime.cc b/sql/tztime.cc index 457bbeec676..3f3060fbc10 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1814,6 +1814,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) my_time_t ttime; char buff[MAX_FIELD_WIDTH]; uchar keybuff[32]; + Field *field; String abbr(buff, sizeof(buff), &my_charset_latin1); char *alloc_buff, *tz_name_buff; /* @@ -1891,8 +1892,12 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) */ table= tz_tables->table; tz_tables= tz_tables->next_local; - table->field[0]->store((longlong) tzid, TRUE); - table->field[0]->get_key_image(keybuff, sizeof(keybuff), Field::itRAW); + field= table->field[0]; + field->store((longlong) tzid, TRUE); + DBUG_ASSERT(field->key_length() <= sizeof(keybuff)); + field->get_key_image(keybuff, + min(field->key_length(), sizeof(keybuff)), + Field::itRAW); (void)table->file->ha_index_init(0, 1); if (table->file->ha_index_read_map(table->record[0], keybuff, @@ -1919,8 +1924,12 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) */ table= tz_tables->table; tz_tables= tz_tables->next_local; - table->field[0]->store((longlong) tzid, TRUE); - table->field[0]->get_key_image(keybuff, sizeof(keybuff), Field::itRAW); + field= table->field[0]; + field->store((longlong) tzid, TRUE); + DBUG_ASSERT(field->key_length() <= sizeof(keybuff)); + field->get_key_image(keybuff, + min(field->key_length(), sizeof(keybuff)), + Field::itRAW); (void)table->file->ha_index_init(0, 1); res= table->file->ha_index_read_map(table->record[0], keybuff, -- cgit v1.2.1