diff options
author | unknown <monty@mysql.com> | 2006-03-29 14:27:36 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2006-03-29 14:27:36 +0300 |
commit | 59eaf292de3ab637be34fb5199da98a6192fa650 (patch) | |
tree | 4d8a2c78f1c611f41d2ea762390198c528239c80 /sql | |
parent | 73970addd82584a9ec6ad4c95ba5d54dfe0f640c (diff) | |
download | mariadb-git-59eaf292de3ab637be34fb5199da98a6192fa650.tar.gz |
Fixed compiler and valgrind warnings
Added missing DBUG_xxx_RETURN statements
Fixed some usage of not initialized variables (as found by valgrind)
Ensure that we don't remove locked tables used as name locks from open table cache until unlock_table_names() are called.
This was fixed by having drop_locked_name() returning any table used as a name lock so that we can free it in unlock_table_names()
This will allow Tomas to continue with his work to use namelocks to syncronize things.
Note: valgrind still produces a lot of warnings about using not initialized code and shows memory loss errors when running the ndb tests
BitKeeper/etc/ignore:
added mysql-test/r/*.log
client/mysqltest.c:
Change type of variables to get rid of compiler warnings
More debugging
Fix memory leak
mysql-test/mysql-test-run.sh:
Collect warnings about missing DBUG_RETURN statements
mysql-test/r/lock_multi.result:
Add test of new code
mysql-test/r/ndb_condition_pushdown.result:
Drop used tables before test
mysql-test/t/lock_multi.test:
Add test of new code
mysql-test/t/ndb_condition_pushdown.test:
Drop used tables before test
mysql-test/valgrind.supp:
Ignore 'safe' warnings from libz (when used with archive)
sql/event.cc:
More comments
Simplify code
Fixed memory leak found by valgrind
sql/ha_archive.cc:
Remove compiler warnings (Wrong handlerton structure and signed/unsigned comparison)
sql/ha_berkeley.cc:
Fixed compiler warning
sql/ha_blackhole.cc:
Fixed compiler warning
sql/ha_federated.cc:
Fixed compiler warning
sql/ha_heap.cc:
Fixed compiler warning
sql/ha_myisam.cc:
Fixed compiler warning
sql/ha_myisammrg.cc:
Fixed compiler warning
sql/ha_ndbcluster.cc:
Fixed compiler warnings
sql/ha_partition.cc:
Fixed compiler warning
Fixed error noticed by valgrind in ha_partition::rnd_init()
sql/handler.cc:
Fixed compiler warning
sql/handler.h:
Fixed compiler warning
sql/item.cc:
Fixed compiler warning
sql/item_xmlfunc.cc:
Fixed warning from valgrind when calling memcpy with wrong address
sql/lock.cc:
More debugging
sql/log.cc:
Fixed compiler warning
Indentation fixes
sql/log.h:
Fixed compiler warning
sql/mysql_priv.h:
Changed prototype for 'drop_locked_tables'
sql/opt_range.cc:
Indentation fix
sql/password.c:
Removed compiler warnings
sql/set_var.cc:
Fixed compiler warning
sql/slave.cc:
Fixed compiler warning
sql/sp_head.cc:
Fixed compiler warning
sql/sql_acl.cc:
Fixed compiler warning
sql/sql_analyse.cc:
Added missing DBUG_RETURN statements
sql/sql_base.cc:
Removed de-reference of not initialized pointer
More comments
drop_locked_tables() changed to not delete tables used for name locking
Fixed compiler warnings
sql/sql_delete.cc:
Fixed usage of not initialized variable
(deleted could be referenced in some not common error conditions)
sql/sql_parse.cc:
Added missing DBUG_VOID_RETURN
Simplify code
sql/sql_partition.cc:
Fixed usage of wrong variable (noticed by valgrind)
sql/sql_plugin.cc:
Removed compiler warning
sql/sql_show.cc:
Removed compiler warning
sql/sql_table.cc:
Ensure that we don't remove locked tables used as name locks from open table cache until unlock_table_names() are called.
This was fixed by having drop_locked_name() returning any table used as a name lock so that we can free it in unlock_table_names()
This will allow Tomas to continue with his work to use namelocks to syncronize things.
Fixed wrong test of 'table_type' (path_length could otherwise be accessed uninitialized)
Remove compile warnings about not initialized variables.
sql/sql_yacc.yy:
Ensure that no_write_to_binlog is properly initialized
(Was accessed uninitialized by partition code)
sql/table.cc:
Removed valgrind warnings (not fatal)
Removed compiler warnings
sql/tztime.cc:
Removed valgrind warning
storage/ndb/include/ndbapi/NdbIndexStat.hpp:
Removed compiler warning
Diffstat (limited to 'sql')
-rw-r--r-- | sql/event.cc | 21 | ||||
-rw-r--r-- | sql/ha_archive.cc | 11 | ||||
-rw-r--r-- | sql/ha_berkeley.cc | 3 | ||||
-rw-r--r-- | sql/ha_blackhole.cc | 5 | ||||
-rw-r--r-- | sql/ha_federated.cc | 3 | ||||
-rw-r--r-- | sql/ha_heap.cc | 3 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 3 | ||||
-rw-r--r-- | sql/ha_myisammrg.cc | 3 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 3 | ||||
-rw-r--r-- | sql/ha_partition.cc | 12 | ||||
-rw-r--r-- | sql/handler.cc | 3 | ||||
-rw-r--r-- | sql/handler.h | 2 | ||||
-rw-r--r-- | sql/item.cc | 3 | ||||
-rw-r--r-- | sql/item_xmlfunc.cc | 3 | ||||
-rw-r--r-- | sql/lock.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 14 | ||||
-rw-r--r-- | sql/log.h | 4 | ||||
-rw-r--r-- | sql/mysql_priv.h | 2 | ||||
-rw-r--r-- | sql/opt_range.cc | 3 | ||||
-rw-r--r-- | sql/password.c | 6 | ||||
-rw-r--r-- | sql/set_var.cc | 2 | ||||
-rw-r--r-- | sql/slave.cc | 3 | ||||
-rw-r--r-- | sql/sp_head.cc | 2 | ||||
-rw-r--r-- | sql/sql_acl.cc | 5 | ||||
-rw-r--r-- | sql/sql_analyse.cc | 35 | ||||
-rw-r--r-- | sql/sql_base.cc | 56 | ||||
-rw-r--r-- | sql/sql_delete.cc | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 33 | ||||
-rw-r--r-- | sql/sql_partition.cc | 2 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 3 | ||||
-rw-r--r-- | sql/sql_show.cc | 10 | ||||
-rw-r--r-- | sql/sql_table.cc | 24 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 3 | ||||
-rw-r--r-- | sql/table.cc | 18 | ||||
-rw-r--r-- | sql/tztime.cc | 7 |
35 files changed, 209 insertions, 106 deletions
diff --git a/sql/event.cc b/sql/event.cc index 8eca4b1dcd3..3bfbfbec483 100644 --- a/sql/event.cc +++ b/sql/event.cc @@ -952,6 +952,10 @@ err: NOTES 1) Use sp_name for look up, return in **ett if found 2) tbl is not closed at exit + + RETURN + 0 ok In this case *ett is set to the event + # error *ett == 0 */ static int @@ -960,7 +964,7 @@ db_find_event(THD *thd, sp_name *name, LEX_STRING *definer, Event_timed **ett, { TABLE *table; int ret; - Event_timed *et=NULL; + Event_timed *et= 0; DBUG_ENTER("db_find_event"); DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str)); @@ -997,7 +1001,7 @@ db_find_event(THD *thd, sp_name *name, LEX_STRING *definer, Event_timed **ett, } done: - if (ret && et) + if (ret) { delete et; et= 0; @@ -1382,7 +1386,7 @@ evex_show_create_event(THD *thd, sp_name *spn, LEX_STRING definer) ret= db_find_event(thd, spn, &definer, &et, NULL, thd->mem_root); thd->restore_backup_open_tables_state(&backup); - if (!ret && et) + if (et) { Protocol *protocol= thd->protocol; char show_str_buf[768]; @@ -1392,10 +1396,12 @@ evex_show_create_event(THD *thd, sp_name *spn, LEX_STRING definer) ulong sql_mode_len=0; show_str.length(0); - show_str.set_charset(system_charset_info); if (et->get_create_event(thd, &show_str)) + { + delete et; DBUG_RETURN(1); + } field_list.push_back(new Item_empty_string("Event", NAME_LEN)); @@ -1409,16 +1415,19 @@ evex_show_create_event(THD *thd, sp_name *spn, LEX_STRING definer) show_str.length())); if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + { + delete et; DBUG_RETURN(1); - + } protocol->prepare_for_resend(); protocol->store(et->name.str, et->name.length, system_charset_info); protocol->store((char*) sql_mode_str, sql_mode_len, system_charset_info); - protocol->store(show_str.c_ptr(), show_str.length(), system_charset_info); + protocol->store(show_str.ptr(), show_str.length(), system_charset_info); ret= protocol->write(); send_eof(thd); + delete et; } DBUG_RETURN(ret); diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index a8bc0822a85..403855b6a01 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -180,7 +180,9 @@ handlerton archive_hton = { NULL, /* fill_files_table */ HTON_NO_FLAGS, NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ + }; static handler *archive_create_handler(TABLE_SHARE *table) @@ -1228,10 +1230,11 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) if (table->found_next_number_field) { Field *field= table->found_next_number_field; - if (share->auto_increment_value < - field->val_int((char*)(buf + field->offset()))) + ulonglong auto_value= + (ulonglong) field->val_int((char*)(buf + field->offset())); + if (share->auto_increment_value < auto_value) auto_increment_value= share->auto_increment_value= - field->val_int((char*)(buf + field->offset())); + auto_value; } share->rows_recorded++; } diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 910a703fdeb..6ea4cc9aeb5 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -155,7 +155,8 @@ handlerton berkeley_hton = { NULL, /* Fill Files Table */ HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME, NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ }; handler *berkeley_create_handler(TABLE_SHARE *table) diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc index 7d28344a0a4..2f5e8ee0abc 100644 --- a/sql/ha_blackhole.cc +++ b/sql/ha_blackhole.cc @@ -62,8 +62,9 @@ handlerton blackhole_hton= { NULL, /* Alter Tablespace */ NULL, /* Fill FILES table */ HTON_CAN_RECREATE, - NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_func */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ }; diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 947c936c2e9..129a44b5721 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -400,7 +400,8 @@ handlerton federated_hton= { NULL, /* Fill FILES table */ HTON_ALTER_NOT_SUPPORTED, NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ }; diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 96f760a7a44..bba794f79b6 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -60,7 +60,8 @@ handlerton heap_hton= { NULL, /* Fill Files Table */ HTON_CAN_RECREATE, NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ }; static handler *heap_create_handler(TABLE_SHARE *table) diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index fba36450d81..ec39ee00efc 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -92,7 +92,8 @@ handlerton myisam_hton= { NULL, /* Fill Files Table */ HTON_CAN_RECREATE, NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ }; diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index ec015c5e320..0ce4e1d8bcb 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -70,7 +70,8 @@ handlerton myisammrg_hton= { NULL, /* Fill Files Table */ HTON_CAN_RECREATE, NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ }; static handler *myisammrg_create_handler(TABLE_SHARE *table) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 795da2bdec2..ddc7047ef8f 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2336,7 +2336,7 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key, if (generate_scan_filter(m_cond_stack, op)) DBUG_RETURN(ndb_err(trans)); - if (res= define_read_attrs(buf, op)) + if ((res= define_read_attrs(buf, op))) { DBUG_RETURN(res); } @@ -9681,6 +9681,7 @@ int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info) NDBDICT *dict = ndb->getDictionary(); int error; const char * errmsg; + LINT_INIT(errmsg); switch (info->ts_cmd_type){ case (CREATE_TABLESPACE): diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 0a8f92d6813..d9c265cf633 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -103,8 +103,9 @@ handlerton partition_hton = { NULL, /* Alter Tablespace */ NULL, /* Fill FILES table */ HTON_NOT_USER_SELECTABLE | HTON_HIDDEN, - NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_func */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ }; /* @@ -2914,12 +2915,15 @@ int ha_partition::rnd_init(bool scan) /* Now we see what the index of our first important partition is */ DBUG_PRINT("info", ("m_part_info->used_partitions 0x%x", - m_part_info->used_partitions.bitmap)); + m_part_info->used_partitions.bitmap)); part_id= bitmap_get_first_set(&(m_part_info->used_partitions)); DBUG_PRINT("info", ("m_part_spec.start_part %d", part_id)); if (MY_BIT_NONE == part_id) + { + error= 0; goto err1; + } /* We have a partition and we are scanning with rnd_next @@ -2958,7 +2962,7 @@ err: while ((int)--i >= (int)part_id) { if (bitmap_is_set(&(m_part_info->used_partitions), i)) - m_file[i]->ha_rnd_end(); + m_file[i]->ha_rnd_end(); } err1: m_scan_value= 2; diff --git a/sql/handler.cc b/sql/handler.cc index 16381972200..74968d4bd97 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -68,7 +68,8 @@ const handlerton default_hton = NULL, /* fill_files_table */ HTON_NO_FLAGS, /* flags */ NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ }; static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES; diff --git a/sql/handler.h b/sql/handler.h index 25947983fb6..261a813bbfa 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -686,6 +686,8 @@ public: { do_prelock(tables, count); } + virtual ~TABLEOP_HOOKS() {} + TABLEOP_HOOKS() {} private: /* Function primitive that is called prior to locking tables */ diff --git a/sql/item.cc b/sql/item.cc index b86cbece568..37fde11ad7f 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1362,6 +1362,9 @@ bool agg_item_charsets(DTCollation &coll, const char *fname, Item **args, uint nargs, uint flags) { Item **arg, **last, *safe_args[2]; + + LINT_INIT(safe_args[0]); + LINT_INIT(safe_args[1]); if (agg_item_collations(coll, fname, args, nargs, flags)) return TRUE; diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index ae626b7c368..91f958d5b70 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2403,8 +2403,7 @@ void Item_xml_str_func::fix_length_and_dec() char context[32]; uint clen= xpath.query.end - xpath.lasttok.beg; set_if_bigger(clen, sizeof(context) - 1); - memcpy(context, xpath.lasttok.beg, clen); - context[clen]= '\0'; + strmake(context, xpath.lasttok.beg, clen); my_printf_error(ER_UNKNOWN_ERROR, "XPATH syntax error: '%s'", MYF(0), context); return; diff --git a/sql/lock.cc b/sql/lock.cc index 40a7a29942b..d552534b1c6 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -911,11 +911,13 @@ end: void unlock_table_names(THD *thd, TABLE_LIST *table_list, TABLE_LIST *last_table) { + DBUG_ENTER("unlock_table_names"); for (TABLE_LIST *table= table_list; table != last_table; table= table->next_local) unlock_table_name(thd,table); pthread_cond_broadcast(&COND_refresh); + DBUG_VOID_RETURN; } diff --git a/sql/log.cc b/sql/log.cc index 02bf5ec3015..1df73b7f0c1 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -63,9 +63,11 @@ static int binlog_prepare(THD *thd, bool all); Don't add constructors, destructors, or virtual functions. */ struct binlog_trx_data { - bool empty() const { + bool empty() const + { return pending == NULL && my_b_tell(&trans_log) == 0; } + binlog_trx_data() {} IO_CACHE trans_log; // The transaction cache Rows_log_event *pending; // The pending binrows event }; @@ -104,7 +106,8 @@ handlerton binlog_hton = { NULL, /* Fill FILES table */ HTON_NOT_USER_SELECTABLE | HTON_HIDDEN, NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_log_query */ + NULL /* release_temporary_latches */ }; @@ -2637,8 +2640,9 @@ int THD::binlog_setup_trx_data() int THD::binlog_write_table_map(TABLE *table, bool is_trans) { + int error; DBUG_ENTER("THD::binlog_write_table_map"); - DBUG_PRINT("enter", ("table=%p (%s: #%u)", + DBUG_PRINT("enter", ("table: %p (%s: #%u)", table, table->s->table_name, table->s->table_map_id)); /* Pre-conditions */ @@ -2655,10 +2659,10 @@ int THD::binlog_write_table_map(TABLE *table, bool is_trans) trans_register_ha(this, options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), &binlog_hton); - if (int error= mysql_bin_log.write(&the_event)) + if ((error= mysql_bin_log.write(&the_event))) DBUG_RETURN(error); - ++binlog_table_maps; + binlog_table_maps++; table->s->table_map_version= mysql_bin_log.table_map_version(); DBUG_RETURN(0); } diff --git a/sql/log.h b/sql/log.h index 391ef54dff7..03d5466e549 100644 --- a/sql/log.h +++ b/sql/log.h @@ -40,7 +40,8 @@ class TC_LOG class TC_LOG_DUMMY: public TC_LOG // use it to disable the logging { - public: +public: + TC_LOG_DUMMY() {} int open(const char *opt_name) { return 0; } void close() { } int log(THD *thd, my_xid xid) { return 1; } @@ -354,6 +355,7 @@ public: class Log_event_handler { public: + Log_event_handler() {} virtual bool init()= 0; virtual void cleanup()= 0; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index a9d6f16fef3..f79472a54f8 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -838,7 +838,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh); bool close_data_tables(THD *thd,const char *db, const char *table_name); bool wait_for_tables(THD *thd); bool table_is_used(TABLE *table, bool wait_for_name_lock); -bool drop_locked_tables(THD *thd,const char *db, const char *table_name); +TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name); void abort_locked_tables(THD *thd,const char *db, const char *table_name); void execute_init_command(THD *thd, sys_var_str *init_command_var, rw_lock_t *var_mutex); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e9ebd9cbccb..07f27efabeb 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -6039,7 +6039,8 @@ SEL_ARG * SEL_ARG::insert(SEL_ARG *key) { SEL_ARG *element,**par,*last_element; - LINT_INIT(par); LINT_INIT(last_element); + LINT_INIT(par); + LINT_INIT(last_element); for (element= this; element != &null_element ; ) { diff --git a/sql/password.c b/sql/password.c index 506e1aa36a2..c6d904bc45b 100644 --- a/sql/password.c +++ b/sql/password.c @@ -323,7 +323,7 @@ void create_random_string(char *to, uint length, struct rand_struct *rand_st) char *octet2hex(char *to, const char *str, uint len) { - const byte *str_end= str + len; + const char *str_end= str + len; for (; str != str_end; ++str) { *to++= _dig_vec_upper[((uchar) *str) >> 4]; @@ -406,7 +406,7 @@ make_scrambled_password(char *to, const char *password) mysql_sha1_result(&sha1_context, hash_stage2); /* convert hash_stage2 to hex string */ *to++= PVERSION41_CHAR; - octet2hex(to, hash_stage2, SHA1_HASH_SIZE); + octet2hex(to, (const char*) hash_stage2, SHA1_HASH_SIZE); } @@ -520,5 +520,5 @@ void get_salt_from_password(uint8 *hash_stage2, const char *password) void make_password_from_salt(char *to, const uint8 *hash_stage2) { *to++= PVERSION41_CHAR; - octet2hex(to, hash_stage2, SHA1_HASH_SIZE); + octet2hex(to, (const char*) hash_stage2, SHA1_HASH_SIZE); } diff --git a/sql/set_var.cc b/sql/set_var.cc index 213b52cc20c..f2694f651f4 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1965,6 +1965,7 @@ CHARSET_INFO *get_old_charset_by_name(const char *name) bool sys_var_collation::check(THD *thd, set_var *var) { CHARSET_INFO *tmp; + LINT_INIT(tmp); if (var->value->result_type() == STRING_RESULT) { @@ -1999,6 +2000,7 @@ bool sys_var_collation::check(THD *thd, set_var *var) bool sys_var_character_set::check(THD *thd, set_var *var) { CHARSET_INFO *tmp; + LINT_INIT(tmp); if (var->value->result_type() == STRING_RESULT) { diff --git a/sql/slave.cc b/sql/slave.cc index 484d669de62..04ecc04ab17 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3613,7 +3613,7 @@ Slave SQL thread aborted. Can't execute init_slave query"); thd->net.last_error ? thd->net.last_error : "<no message>"); } - else if (rli->last_slave_errno != thd->net.last_errno) + else if (rli->last_slave_errno != (int) thd->net.last_errno) { sql_print_error("Slave (additional info): %s Error_code: %d", thd->net.last_error ? @@ -4095,6 +4095,7 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len) buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT /* a way to escape */) DBUG_RETURN(queue_old_event(mi,buf,event_len)); + LINT_INIT(inc_pos); pthread_mutex_lock(&mi->data_lock); switch (buf[EVENT_TYPE_OFFSET]) { diff --git a/sql/sp_head.cc b/sql/sp_head.cc index cec3a19a542..cb82d6eb1a4 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1224,10 +1224,10 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, sp_rcontext *octx = thd->spcont; sp_rcontext *nctx = NULL; bool err_status= FALSE; - DBUG_ENTER("sp_head::execute_function"); DBUG_PRINT("info", ("function %s", m_name.str)); + LINT_INIT(binlog_save_options); params = m_pcont->context_pvars(); /* diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index aa426cb33f9..09b684c8706 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5037,6 +5037,8 @@ static int handle_grant_struct(uint struct_no, bool drop, LINT_INIT(acl_user); LINT_INIT(acl_db); LINT_INIT(grant_name); + LINT_INIT(user); + LINT_INIT(host); /* Get the number of elements in the in-memory structure. */ switch (struct_no) { @@ -5109,8 +5111,7 @@ static int handle_grant_struct(uint struct_no, bool drop, result= 1; /* At least one element found. */ if ( drop ) { - switch ( struct_no ) - { + switch ( struct_no ) { case 0: delete_dynamic_element(&acl_users, idx); break; diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index af9246c673a..f372c55c13e 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -176,8 +176,7 @@ err: bool test_if_number(NUM_INFO *info, const char *str, uint str_len) { - const char *begin, *end = str + str_len; - + const char *begin, *end= str + str_len; DBUG_ENTER("test_if_number"); /* @@ -186,13 +185,13 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len) */ for (; str != end && my_isspace(system_charset_info, *str); str++) ; if (str == end) - return 0; + DBUG_RETURN(0); if (*str == '-') { info->negative = 1; - if (++str == end || *str == '0') // converting -0 to a number - return 0; // might lose information + if (++str == end || *str == '0') // converting -0 to a number + DBUG_RETURN(0); // might lose information } else info->negative = 0; @@ -210,33 +209,33 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len) int error; info->ullval= (ulonglong) my_strtoll10(begin, &endpos, &error); if (info->integers == 1) - return 0; // a single number can't be zerofill + DBUG_RETURN(0); // single number can't be zerofill info->maybe_zerofill = 1; - return 1; // a zerofill number, or an integer + DBUG_RETURN(1); // a zerofill number, or an integer } if (*str == '.' || *str == 'e' || *str == 'E') { - if (info->zerofill) // can't be zerofill anymore - return 0; - if ((str + 1) == end) // number was something like '123[.eE]' + if (info->zerofill) // can't be zerofill anymore + DBUG_RETURN(0); + if ((str + 1) == end) // number was something like '123[.eE]' { char *endpos= (char*) str; int error; info->ullval= (ulonglong) my_strtoll10(begin, &endpos, &error); - return 1; + DBUG_RETURN(1); } - if (*str == 'e' || *str == 'E') // number may be something like '1e+50' + if (*str == 'e' || *str == 'E') // number may be something like '1e+50' { str++; if (*str != '-' && *str != '+') - return 0; + DBUG_RETURN(0); for (str++; str != end && my_isdigit(system_charset_info,*str); str++) ; if (str == end) { - info->is_float = 1; // we can't use variable decimals here + info->is_float = 1; // we can't use variable decimals here return 1; } - return 0; + DBUG_RETURN(0); } for (str++; *(end - 1) == '0'; end--); // jump over zeros at the end if (str == end) // number was something like '123.000' @@ -244,17 +243,17 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len) char *endpos= (char*) str; int error; info->ullval= (ulonglong) my_strtoll10(begin, &endpos, &error); - return 1; + DBUG_RETURN(1); } for (; str != end && my_isdigit(system_charset_info,*str); str++) info->decimals++; if (str == end) { info->dval = my_atof(begin); - return 1; + DBUG_RETURN(1); } } - return 0; + DBUG_RETURN(0); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6c2ca06164f..d4da9212046 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1877,7 +1877,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, if (!thd->open_tables) thd->version=refresh_version; else if ((thd->version != refresh_version) && - ! (flags & MYSQL_LOCK_IGNORE_FLUSH) && !table->s->log_table) + ! (flags & MYSQL_LOCK_IGNORE_FLUSH)) { /* Someone did a refresh while thread was opening tables */ if (refresh) @@ -2349,13 +2349,36 @@ bool wait_for_tables(THD *thd) } -/* drop tables from locked list */ +/* + drop tables from locked list + + SYNOPSIS + drop_locked_tables() + thd Thread thandler + db Database + table_name Table name -bool drop_locked_tables(THD *thd,const char *db, const char *table_name) + INFORMATION + This is only called on drop tables + + The TABLE object for the dropped table is unlocked but still kept around + as a name lock, which means that the table will be available for other + thread as soon as we call unlock_table_names(). + If there is multiple copies of the table locked, all copies except + the first, which acts as a name lock, is removed. + + RETURN + # If table existed, return table + 0 Table was not locked +*/ + + +TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name) { - TABLE *table,*next,**prev; - bool found=0; + TABLE *table,*next,**prev, *found= 0; prev= &thd->open_tables; + DBUG_ENTER("drop_locked_tables"); + for (table= thd->open_tables; table ; table=next) { next=table->next; @@ -2363,8 +2386,21 @@ bool drop_locked_tables(THD *thd,const char *db, const char *table_name) !strcmp(table->s->db.str, db)) { mysql_lock_remove(thd, thd->locked_tables,table); - VOID(hash_delete(&open_cache,(byte*) table)); - found=1; + if (!found) + { + found= table; + /* Close engine table, but keep object around as a name lock */ + if (table->db_stat) + { + table->db_stat= 0; + table->file->close(); + } + } + else + { + /* We already have a name lock, remove copy */ + VOID(hash_delete(&open_cache,(byte*) table)); + } } else { @@ -2373,14 +2409,12 @@ bool drop_locked_tables(THD *thd,const char *db, const char *table_name) } } *prev=0; - if (found) - VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh if (thd->locked_tables && thd->locked_tables->table_count == 0) { my_free((gptr) thd->locked_tables,MYF(0)); thd->locked_tables=0; } - return found; + DBUG_RETURN(found); } @@ -3489,6 +3523,7 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list, Field_iterator_view field_it; field_it.set(table_list); Query_arena *arena, backup; + LINT_INIT(arena); DBUG_ASSERT(table_list->schema_table_reformed || (ref != 0 && table_list->view != 0)); @@ -3578,6 +3613,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, DBUG_ASSERT(table_ref->is_natural_join && table_ref->join_columns); DBUG_ASSERT(*actual_table == NULL); + LINT_INIT(arena); LINT_INIT(found_field); for (;;) diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index f4186120766..181b91781d7 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -37,7 +37,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, READ_RECORD info; bool using_limit=limit != HA_POS_ERROR; bool transactional_table, safe_update, const_cond; - ha_rows deleted; + ha_rows deleted= 0; uint usable_index= MAX_KEY; SELECT_LEX *select_lex= &thd->lex->select_lex; bool ha_delete_all_rows= 0; @@ -212,7 +212,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, else init_read_record_idx(&info, thd, table, 1, usable_index); - deleted=0L; init_ftfuncs(thd, select_lex, 1); thd->proc_info="updating"; will_batch= !table->file->start_bulk_delete(); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index eea2ae57e75..c33257ff602 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2112,8 +2112,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, void log_slow_statement(THD *thd) { - DBUG_ENTER("log_slow_statement"); time_t start_of_query; + DBUG_ENTER("log_slow_statement"); /* The following should never be true with our current code base, @@ -2121,7 +2121,7 @@ void log_slow_statement(THD *thd) statement in a trigger or stored function */ if (unlikely(thd->in_sub_stmt)) - return; // Don't set time for sub stmt + DBUG_VOID_RETURN; // Don't set time for sub stmt start_of_query= thd->start_time; thd->end_time(); // Set start time @@ -5864,18 +5864,15 @@ void mysql_parse(THD *thd, char *inBuf, uint length) { if (thd->net.report_error) { - if (thd->lex->sphead) - { - delete thd->lex->sphead; - thd->lex->sphead= NULL; - } - if (thd->lex->et) + delete lex->sphead; + lex->sphead= NULL; + if (lex->et) { - thd->lex->et->free_sphead_on_delete= true; + lex->et->free_sphead_on_delete= true; /* alloced on thd->mem_root so no real memory free but dtor call */ - thd->lex->et->free_sp(); - thd->lex->et->deinit_mutexes(); - thd->lex->et= NULL; + lex->et->free_sp(); + lex->et->deinit_mutexes(); + lex->et= NULL; } } else @@ -5906,18 +5903,18 @@ void mysql_parse(THD *thd, char *inBuf, uint length) thd->is_fatal_error)); query_cache_abort(&thd->net); lex->unit.cleanup(); - if (thd->lex->sphead) + if (lex->sphead) { /* Clean up after failed stored procedure/function */ - delete thd->lex->sphead; - thd->lex->sphead= NULL; + delete lex->sphead; + lex->sphead= NULL; } - if (thd->lex->et) + if (lex->et) { - thd->lex->et->free_sphead_on_delete= true; + lex->et->free_sphead_on_delete= true; lex->et->free_sp(); lex->et->deinit_mutexes(); - thd->lex->et= NULL; + lex->et= NULL; } } thd->proc_info="freeing items"; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 682c74dc31e..140dd0a0441 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4924,7 +4924,7 @@ the generated partition syntax in a correct manner. */ if (table->part_info) { - if (thd->lex->alter_info.flags & ALTER_REMOVE_PARTITIONING) + if (alter_info->flags & ALTER_REMOVE_PARTITIONING) { DBUG_PRINT("info", ("Remove partitioning")); if (!(thd->lex->create_info.used_fields & HA_CREATE_USED_ENGINE)) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 74852716f74..3d42bfea104 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -192,7 +192,8 @@ static st_plugin_dl *plugin_dl_add(LEX_STRING *dl, int report) if (plugin_dl.version != MYSQL_PLUGIN_INTERFACE_VERSION) { - int i, sizeof_st_plugin; + int i; + uint sizeof_st_plugin; struct st_mysql_plugin *old, *cur; char *ptr= (char *)sym; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index da372d9063d..6b432968cf1 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1770,18 +1770,19 @@ void free_status_vars() there's lots of room for optimizing this, especially in non-sorted mode, but nobody cares - it may be called only in case of failed plugin initialization in the mysqld startup. - */ + void remove_status_vars(SHOW_VAR *list) { if (status_vars_inited) { pthread_mutex_lock(&LOCK_status); SHOW_VAR *all= dynamic_element(&all_status_vars, 0, SHOW_VAR *); - int a= 0, b= all_status_vars.elements, c= (a+b)/2, res; + int a= 0, b= all_status_vars.elements, c= (a+b)/2; for (; list->name; list++) { + int res= 0; for (a= 0, b= all_status_vars.elements; b-a > 1; c= (a+b)/2) { res= show_var_cmp(list, all+c); @@ -1789,7 +1790,8 @@ void remove_status_vars(SHOW_VAR *list) b= c; else if (res > 0) a= c; - else break; + else + break; } if (res == 0) all[c].type= SHOW_UNDEF; @@ -1800,7 +1802,7 @@ void remove_status_vars(SHOW_VAR *list) else { SHOW_VAR *all= dynamic_element(&all_status_vars, 0, SHOW_VAR *); - int i; + uint i; for (; list->name; list++) { for (i= 0; i < all_status_vars.elements; i++) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 06e8b3915eb..76232faff43 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -565,6 +565,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, String built_query; DBUG_ENTER("mysql_rm_table_part2"); + LINT_INIT(alias); + LINT_INIT(path_length); + safe_mutex_assert_owner(&LOCK_open); + if (thd->current_stmt_binlog_row_based && !dont_log_query) { built_query.set_charset(system_charset_info); @@ -614,7 +618,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, */ if (thd->current_stmt_binlog_row_based && !dont_log_query) { - ++non_temp_tables_count; + non_temp_tables_count++; /* Don't write the database name if it is the current one (or if thd->db is NULL). @@ -634,11 +638,18 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, table_type= table->db_type; if (!drop_temporary) { + TABLE *locked_table; abort_locked_tables(thd, db, table->table_name); remove_table_from_cache(thd, db, table->table_name, RTFC_WAIT_OTHER_THREAD_FLAG | RTFC_CHECK_KILLED_FLAG); - drop_locked_tables(thd, db, table->table_name); + /* + If the table was used in lock tables, remember it so that + unlock_table_names can free it + */ + if ((locked_table= drop_locked_tables(thd, db, table->table_name))) + table->table= locked_table; + if (thd->killed) { thd->no_warnings_for_error= 0; @@ -649,8 +660,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext); } - if (table_type == NULL && - (drop_temporary || + if (drop_temporary || + (table_type == NULL && (access(path, F_OK) && ha_create_table_from_engine(thd, db, alias)) || (!drop_view && @@ -3962,6 +3973,11 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, bool committed= 0; DBUG_ENTER("mysql_alter_table"); + LINT_INIT(index_add_count); + LINT_INIT(index_drop_count); + LINT_INIT(index_add_buffer); + LINT_INIT(index_drop_buffer); + thd->proc_info="init"; table_name=table_list->table_name; alias= (lower_case_table_names == 2) ? table_list->alias : table_name; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9304bc3f27c..e9379ab2f18 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4726,13 +4726,14 @@ alter: lex->col_list.empty(); lex->select_lex.init_order(); lex->select_lex.db=lex->name= 0; - lex->like_name= 0; + lex->like_name= 0; bzero((char*) &lex->create_info,sizeof(lex->create_info)); lex->create_info.db_type= (handlerton*) &default_hton; lex->create_info.default_table_charset= NULL; lex->create_info.row_type= ROW_TYPE_NOT_USED; lex->alter_info.reset(); lex->alter_info.flags= 0; + lex->no_write_to_binlog= 0; } alter_commands {} diff --git a/sql/table.cc b/sql/table.cc index 90d8569425a..4807d9d0cf0 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1556,7 +1556,15 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, DBUG_RETURN (error); } - /* close a .frm file and it's tables */ + +/* + Free information allocated by openfrm + + SYNOPSIS + closefrm() + table TABLE object to free + free_share Is 1 if we also want to free table_share +*/ int closefrm(register TABLE *table, bool free_share) { @@ -1564,6 +1572,7 @@ int closefrm(register TABLE *table, bool free_share) uint idx; KEY *key_info; DBUG_ENTER("closefrm"); + if (table->db_stat) error=table->file->close(); key_info= table->key_info; @@ -2395,12 +2404,14 @@ table_check_intact(TABLE *table, uint table_f_count, table running on a old server will be valid. */ field->sql_type(sql_type); - if (strncmp(sql_type.c_ptr(), table_def->type.str, + if (sql_type.length() < table_def->type.length - 1 || + strncmp(sql_type.ptr(), + table_def->type.str, table_def->type.length - 1)) { sql_print_error("(%s) Expected field %s at position %d to have type " "%s, found %s", table->alias, table_def->name.str, - i, table_def->type.str, sql_type.c_ptr()); + i, table_def->type.str, sql_type.c_ptr_safe()); error= TRUE; } else if (table_def->cset.str && !field->has_charset()) @@ -3621,6 +3632,7 @@ Field_iterator_table_ref::get_or_create_column_ref(TABLE_LIST *parent_table_ref) TABLE_LIST *add_table_ref= parent_table_ref ? parent_table_ref : table_ref; + LINT_INIT(field_count); if (field_it == &table_field_it) { /* The field belongs to a stored table. */ diff --git a/sql/tztime.cc b/sql/tztime.cc index 94c1eb8ac63..1be2321200b 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2189,12 +2189,11 @@ my_tz_find(const String * name, TABLE_LIST *tz_tables) TZ_NAMES_ENTRY *tmp_tzname; Time_zone *result_tz= 0; long offset; - DBUG_ENTER("my_tz_find"); DBUG_PRINT("enter", ("time zone name='%s'", - name ? ((String *)name)->c_ptr() : "NULL")); - - DBUG_ASSERT(!time_zone_tables_exist || tz_tables || current_thd->slave_thread); + name ? ((String *)name)->c_ptr_safe() : "NULL")); + DBUG_ASSERT(!time_zone_tables_exist || tz_tables || + current_thd->slave_thread); if (!name) DBUG_RETURN(0); |