Below is the list of changes that have just been committed into a local
5.0 repository of serg. When serg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2004 05/12/31 13:33:00 serg@stripped +38 -0
many warnings (practically safe but annoying) corrected
sql/uniques.cc
1.24 05/12/31 13:32:44 serg@stripped +61 -61
"return value ignored" warning,
endspaces deleted.
sql/table.cc
1.214 05/12/31 13:32:44 serg@stripped +4 -1
memory leak
sql/sql_test.cc
1.44 05/12/31 13:32:44 serg@stripped +1 -1
"return value ignored" warning
sql/sql_show.cc
1.303 05/12/31 13:32:43 serg@stripped +12 -11
"return value ignored" and "NULL dereference" warnings
sql/sql_repl.cc
1.147 05/12/31 13:32:43 serg@stripped +9 -3
"return value ignored" and memory leak warnings
sql/sql_parse.cc
1.519 05/12/31 13:32:43 serg@stripped +9 -3
"return value ignored" warning
one more DBUG_ASSERT.
sql/sql_insert.cc
1.181 05/12/31 13:32:42 serg@stripped +2 -1
"return value ignored" warning
sql/sql_help.cc
1.52 05/12/31 13:32:42 serg@stripped +1 -1
"NULL dereference" warning
sql/sql_handler.cc
1.77 05/12/31 13:32:42 serg@stripped +3 -5
"NULL dereference" warning
sql/sql_db.cc
1.122 05/12/31 13:32:42 serg@stripped +58 -54
"return value ignored" warning
sql/sql_acl.cc
1.185 05/12/31 13:32:41 serg@stripped +2 -4
deadcode and "NULL dereference" warnings
sql/slave.h
1.92 05/12/31 13:32:41 serg@stripped +1 -1
new prototype
sql/slave.cc
1.264 05/12/31 13:32:41 serg@stripped +24 -14
"return value ignored" warnings
sql/set_var.cc
1.146 05/12/31 13:32:41 serg@stripped +0 -1
"return value ignored" warning
sql/repl_failsafe.cc
1.60 05/12/31 13:32:40 serg@stripped +2 -1
"return value ignored" warning
sql/opt_range.h
1.58 05/12/31 13:32:40 serg@stripped +1 -1
"return value ignored" warning
sql/opt_range.cc
1.202 05/12/31 13:32:40 serg@stripped +2 -5
"double free" and uninitialized warnings
sql/log_event.cc
1.200 05/12/31 13:32:39 serg@stripped +4 -0
uninitialized warning
sql/item_func.cc
1.271 05/12/31 13:32:39 serg@stripped +10 -5
"return value ignored" warnings
sql/item.cc
1.202 05/12/31 13:32:39 serg@stripped +4 -4
"return value ignored" warnings
changed constructor
sql/ha_myisam.cc
1.165 05/12/31 13:32:39 serg@stripped +10 -7
"return value ignored" warnings
sql/field.h
1.171 05/12/31 13:32:38 serg@stripped +2 -2
unused parameters removed from constructor
sql/field.cc
1.296 05/12/31 13:32:38 serg@stripped +8 -14
deadcode, "NULL dereference", uninitialized warnings
sql-common/client.c
1.82 05/12/31 13:32:38 serg@stripped +1 -1
"NULL dereference" warning
server-tools/instance-manager/parse.cc
1.10 05/12/31 13:32:38 serg@stripped +1 -1
"NULL dereference" warning
mysys/my_error.c
1.21 05/12/31 13:32:38 serg@stripped +3 -0
memory leak
mysys/my_bitmap.c
1.29 05/12/31 13:32:37 serg@stripped +1 -1
s/return/DBUG_RETURN/
mysys/mf_iocache2.c
1.26 05/12/31 13:32:37 serg@stripped +5 -5
"return value ignored" warnings
mysys/default_modify.c
1.11 05/12/31 13:32:37 serg@stripped +1 -1
"double free" warning
myisam/sort.c
1.50 05/12/31 13:32:37 serg@stripped +3 -0
"double free" warning
myisam/myisampack.c
1.52 05/12/31 13:32:37 serg@stripped +1 -1
"out-of-bound access" warning
myisam/mi_delete.c
1.37 05/12/31 13:32:37 serg@stripped +2 -1
"return value ignored" warning
libmysql/libmysql.c
1.231 05/12/31 13:32:36 serg@stripped +1 -1
"return value ignored" warning
include/my_base.h
1.75 05/12/31 13:32:36 serg@stripped +2 -1
cleanup
cmd-line-utils/libedit/history.c
1.9 05/12/31 13:32:36 serg@stripped +2 -2
memory leak
client/mysqldump.c
1.218 05/12/31 13:32:36 serg@stripped +15 -12
many "ignore return value" warnings, one "NULL dereference"
client/mysqlbinlog.cc
1.124 05/12/31 13:32:35 serg@stripped +5 -4
memory leak
client/mysqladmin.cc
1.114 05/12/31 13:32:35 serg@stripped +1 -0
don't use the handler after it's closed
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: serg
# Host: serg.mylan
# Root: /usr/home/serg/Abk/mysql-5.0
--- 1.113/client/mysqladmin.cc Sun Dec 4 19:55:14 2005
+++ 1.114/client/mysqladmin.cc Sat Dec 31 13:32:35 2005
@@ -569,6 +569,7 @@ static int execute_commands(MYSQL *mysql
return -1;
}
mysql_close(mysql); /* Close connection to avoid error messages */
+ argc=1; /* force SHUTDOWN to be the last command */
if (got_pidfile)
{
if (opt_verbose)
--- 1.217/client/mysqldump.c Sun Dec 4 19:55:14 2005
+++ 1.218/client/mysqldump.c Sat Dec 31 13:32:36 2005
@@ -1306,7 +1306,7 @@ static uint dump_routines_for_db(char *d
fprintf(sql_file, "DELIMITER ;\n");
if (lock_tables)
- mysql_query_with_error_report(sock, 0, "UNLOCK TABLES");
+ VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES"));
DBUG_RETURN(0);
}
@@ -2095,7 +2095,10 @@ static void dump_table(char *table, char
else
res=mysql_store_result(sock);
if (!res)
+ {
DB_error(sock, "when retrieving data from server");
+ goto err;
+ }
if (verbose)
fprintf(stderr, "-- Retrieving rows...\n");
if (mysql_num_fields(res) != num_fields)
@@ -2625,7 +2628,7 @@ static int dump_all_tables_in_db(char *d
check_io(md_result_file);
}
if (lock_tables)
- mysql_query_with_error_report(sock, 0, "UNLOCK TABLES");
+ VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES"));
return 0;
} /* dump_all_tables_in_db */
@@ -2680,23 +2683,23 @@ static my_bool dump_all_views_in_db(char
check_io(md_result_file);
}
if (lock_tables)
- mysql_query(sock,"UNLOCK TABLES");
+ VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES"));
return 0;
} /* dump_all_tables_in_db */
/*
- get_actual_table_name -- executes a SHOW TABLES LIKE '%s' to get the actual
- table name from the server for the table name given on the command line.
- we do this because the table name given on the command line may be a
+ get_actual_table_name -- executes a SHOW TABLES LIKE '%s' to get the actual
+ table name from the server for the table name given on the command line.
+ we do this because the table name given on the command line may be a
different case (e.g. T1 vs t1)
-
+
RETURN
int - 0 if a tablename was retrieved. 1 if not
*/
-static int get_actual_table_name(const char *old_table_name,
- char *new_table_name,
+static int get_actual_table_name(const char *old_table_name,
+ char *new_table_name,
int buf_size)
{
int retval;
@@ -2708,7 +2711,7 @@ static int get_actual_table_name(const c
/* Check memory for quote_for_like() */
DBUG_ASSERT(2*sizeof(old_table_name) < sizeof(show_name_buff));
- my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s",
+ my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s",
quote_for_like(old_table_name, show_name_buff));
if (mysql_query_with_error_report(sock, 0, query))
@@ -2717,7 +2720,7 @@ static int get_actual_table_name(const c
}
retval = 1;
-
+
if ((table_res= mysql_store_result(sock)))
{
my_ulonglong num_rows= mysql_num_rows(table_res);
@@ -2839,7 +2842,7 @@ static int dump_selected_tables(char *db
check_io(md_result_file);
}
if (lock_tables)
- mysql_query_with_error_report(sock, 0, "UNLOCK TABLES");
+ VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES"));
DBUG_RETURN(0);
} /* dump_selected_tables */
--- 1.74/include/my_base.h Sat Nov 26 08:56:43 2005
+++ 1.75/include/my_base.h Sat Dec 31 13:32:36 2005
@@ -404,7 +404,8 @@ enum ha_base_keytype {
enum en_fieldtype {
FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIP_ENDSPACE,FIELD_SKIP_PRESPACE,
FIELD_SKIP_ZERO,FIELD_BLOB,FIELD_CONSTANT,FIELD_INTERVALL,FIELD_ZERO,
- FIELD_VARCHAR,FIELD_CHECK
+ FIELD_VARCHAR,FIELD_CHECK,
+ FIELD_enum_val_count
};
enum data_file_type {
--- 1.230/libmysql/libmysql.c Thu Aug 4 13:25:02 2005
+++ 1.231/libmysql/libmysql.c Sat Dec 31 13:32:36 2005
@@ -818,7 +818,7 @@ my_bool handle_local_infile(MYSQL *mysql
if ((*options->local_infile_init)(&li_ptr, net_filename,
options->local_infile_userdata))
{
- my_net_write(net,"",0); /* Server needs one packet */
+ VOID(my_net_write(net,"",0)); /* Server needs one packet */
net_flush(net);
strmov(net->sqlstate, unknown_sqlstate);
net->last_errno= (*options->local_infile_error)(li_ptr,
--- 1.36/myisam/mi_delete.c Thu Oct 27 19:04:31 2005
+++ 1.37/myisam/mi_delete.c Sat Dec 31 13:32:37 2005
@@ -276,7 +276,8 @@ static int d_search(register MI_INFO *in
if (subkeys == -1)
{
/* the last entry in sub-tree */
- _mi_dispose(info, keyinfo, root,DFLT_INIT_HITS);
+ if (_mi_dispose(info, keyinfo, root,DFLT_INIT_HITS))
+ DBUG_RETURN(-1);
/* fall through to normal delete */
}
else
--- 1.51/myisam/myisampack.c Sun Dec 4 19:55:15 2005
+++ 1.52/myisam/myisampack.c Sat Dec 31 13:32:37 2005
@@ -1159,7 +1159,7 @@ static int compare_huff_elements(void *n
static void check_counts(HUFF_COUNTS *huff_counts, uint trees,
my_off_t records)
{
- uint space_fields,fill_zero_fields,field_count[(int) FIELD_VARCHAR+1];
+ uint space_fields,fill_zero_fields,field_count[(int) FIELD_enum_val_count];
my_off_t old_length,new_length,length;
DBUG_ENTER("check_counts");
--- 1.49/myisam/sort.c Thu Oct 27 19:04:31 2005
+++ 1.50/myisam/sort.c Sat Dec 31 13:32:37 2005
@@ -376,7 +376,10 @@ pthread_handler_t thr_find_all_keys(void
{
if (my_init_dynamic_array(&info->buffpek, sizeof(BUFFPEK),
maxbuffer, maxbuffer/2))
+ {
my_free((gptr) sort_keys,MYF(0));
+ sort_keys= (uchar **) NULL; /* for err: label */
+ }
else
break;
}
--- 1.20/mysys/my_error.c Thu Dec 23 20:11:32 2004
+++ 1.21/mysys/my_error.c Sat Dec 31 13:32:38 2005
@@ -189,7 +189,10 @@ int my_error_register(const char **errms
/* Error numbers must be unique. No overlapping is allowed. */
if (*search_meh_pp && ((*search_meh_pp)->meh_first <= last))
+ {
+ my_free((gptr)meh_p, MYF(0));
return 1;
+ }
/* Insert header into the chain. */
meh_p->meh_next= *search_meh_pp;
--- 1.295/sql/field.cc Wed Dec 7 15:02:38 2005
+++ 1.296/sql/field.cc Sat Dec 31 13:32:38 2005
@@ -1570,7 +1570,6 @@ Field *Field::new_key_field(MEM_ROOT *ro
bool Field::quote_data(String *unquoted_string)
{
char escaped_string[IO_SIZE];
- char *unquoted_string_buffer= (char *)(unquoted_string->ptr());
DBUG_ENTER("Field::quote_data");
if (!needs_quotes())
@@ -4541,8 +4540,6 @@ int Field_timestamp::store(const char *f
error= 1;
}
}
- if (error > 1)
- error= 2;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
@@ -7067,7 +7064,7 @@ void Field_blob::get_key_image(char *buf
}
get_ptr(&blob);
gobj= Geometry::construct(&buffer, blob, blob_length);
- if (gobj->get_mbr(&mbr, &dummy))
+ if (!gobj || gobj->get_mbr(&mbr, &dummy))
bzero(buff, SIZEOF_STORED_DOUBLE*4);
else
{
@@ -7396,7 +7393,7 @@ void Field_geom::get_key_image(char *buf
}
get_ptr(&blob);
gobj= Geometry::construct(&buffer, blob, blob_length);
- if (gobj->get_mbr(&mbr, &dummy))
+ if (!gobj || gobj->get_mbr(&mbr, &dummy))
bzero(buff, SIZEOF_STORED_DOUBLE*4);
else
{
@@ -8154,17 +8151,14 @@ const char *Field_bit::unpack(char *to,
*/
Field_bit_as_char::Field_bit_as_char(char *ptr_arg, uint32 len_arg,
- uchar *null_ptr_arg, uchar null_bit_arg,
- uchar *bit_ptr_arg, uchar bit_ofs_arg,
- enum utype unireg_check_arg,
+ uchar *null_ptr_arg, uchar null_bit_arg,
+ enum utype unireg_check_arg,
const char *field_name_arg,
struct st_table *table_arg)
- : Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, bit_ptr_arg,
- bit_ofs_arg, unireg_check_arg, field_name_arg, table_arg),
+ : Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0,
+ 0, unireg_check_arg, field_name_arg, table_arg),
create_length(len_arg)
{
- bit_ptr= 0;
- bit_ofs= 0;
bit_len= 0;
field_length= ((len_arg + 7) & ~7) / 8;
}
@@ -8865,8 +8859,8 @@ Field *make_field(char *ptr, uint32 fiel
return new Field_null(ptr,field_length,unireg_check,field_name,table, field_charset);
case FIELD_TYPE_BIT:
return f_bit_as_char(pack_flag) ?
- new Field_bit_as_char(ptr, field_length, null_pos, null_bit, bit_ptr,
- bit_offset, unireg_check, field_name, table) :
+ new Field_bit_as_char(ptr, field_length, null_pos, null_bit,
+ unireg_check, field_name, table) :
new Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr,
bit_offset, unireg_check, field_name, table);
default: // Impossible (Wrong version)
--- 1.170/sql/field.h Wed Dec 7 15:01:07 2005
+++ 1.171/sql/field.h Sat Dec 31 13:32:38 2005
@@ -1348,12 +1348,12 @@ public:
}
};
-
+
class Field_bit_as_char: public Field_bit {
public:
uchar create_length;
Field_bit_as_char(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
- uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
+ uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg);
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
--- 1.164/sql/ha_myisam.cc Thu Oct 27 19:04:32 2005
+++ 1.165/sql/ha_myisam.cc Sat Dec 31 13:32:39 2005
@@ -266,7 +266,8 @@ int ha_myisam::dump(THD* thd, int fd)
if (fd < 0)
{
- my_net_write(net, "", 0);
+ if (my_net_write(net, "", 0))
+ error = errno ? errno : EPIPE;
net_flush(net);
}
@@ -365,12 +366,14 @@ int ha_myisam::check(THD* thd, HA_CHECK_
{
uint old_testflag=param.testflag;
param.testflag|=T_MEDIUM;
- init_io_cache(¶m.read_cache, file->dfile,
- my_default_record_cache_size, READ_CACHE,
- share->pack.header_length, 1, MYF(MY_WME));
- error |= chk_data_link(¶m, file, param.testflag & T_EXTEND);
- end_io_cache(&(param.read_cache));
- param.testflag=old_testflag;
+ if (!(error= init_io_cache(¶m.read_cache, file->dfile,
+ my_default_record_cache_size, READ_CACHE,
+ share->pack.header_length, 1, MYF(MY_WME))))
+ {
+ error= chk_data_link(¶m, file, param.testflag & T_EXTEND);
+ end_io_cache(&(param.read_cache));
+ }
+ param.testflag= old_testflag;
}
}
if (!error)
--- 1.201/sql/item.cc Wed Dec 21 15:17:45 2005
+++ 1.202/sql/item.cc Sat Dec 31 13:32:39 2005
@@ -937,9 +937,9 @@ Item_splocal::this_item_addr(THD *thd, I
void Item_splocal::print(String *str)
{
- str->reserve(m_name.length+8);
- str->append(m_name.str, m_name.length);
- str->append('@');
+ VOID(str->reserve(m_name.length+8));
+ VOID(str->append(m_name.str, m_name.length));
+ VOID(str->append('@'));
str->qs_append(m_var_idx);
}
@@ -3843,7 +3843,7 @@ Field *Item::tmp_table_field_from_field_
return new Field_year((char*) 0, max_length, null_ptr, 0, Field::NONE,
name, table);
case MYSQL_TYPE_BIT:
- return new Field_bit_as_char(NULL, max_length, null_ptr, 0, NULL, 0,
+ return new Field_bit_as_char(NULL, max_length, null_ptr, 0,
Field::NONE, name, table);
default:
/* This case should never be chosen */
--- 1.270/sql/item_func.cc Sun Dec 11 08:30:51 2005
+++ 1.271/sql/item_func.cc Sat Dec 31 13:32:39 2005
@@ -888,7 +888,7 @@ String *Item_decimal_typecast::val_str(S
my_decimal tmp_buf, *tmp= val_decimal(&tmp_buf);
if (null_value)
return NULL;
- my_decimal2string(E_DEC_FATAL_ERROR, &tmp_buf, 0, 0, 0, str);
+ my_decimal2string(E_DEC_FATAL_ERROR, tmp, 0, 0, 0, str);
return str;
}
@@ -4709,7 +4709,7 @@ Item_func_sp::sp_result_field(void) cons
{
char *empty_name= (char *) "";
TABLE_SHARE *share;
- dummy_table->s= share= &dummy_table->share_not_to_be_used;
+ dummy_table->s= share= &dummy_table->share_not_to_be_used;
dummy_table->alias = empty_name;
dummy_table->maybe_null = maybe_null;
dummy_table->in_use= current_thd;
@@ -4739,11 +4739,16 @@ Item_func_sp::execute(Field **flp)
Get field in virtual tmp table to store result. Create the field if
invoked first time.
*/
-
+
if (!(f= *flp))
{
- *flp= f= sp_result_field();
- f->move_field((f->pack_length() > sizeof(result_buf)) ?
+ if (!(*flp= f= sp_result_field()))
+ {
+ my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
+ return 0;
+ }
+
+ f->move_field((f->pack_length() > sizeof(result_buf)) ?
sql_alloc(f->pack_length()) : result_buf);
f->null_ptr= (uchar *)&null_value;
f->null_bit= 1;
--- 1.199/sql/log_event.cc Mon Nov 28 16:28:59 2005
+++ 1.200/sql/log_event.cc Sat Dec 31 13:32:39 2005
@@ -3253,6 +3253,10 @@ void Intvar_log_event::print(FILE* file,
case INSERT_ID_EVENT:
msg="INSERT_ID";
break;
+ case INVALID_INT_EVENT:
+ default: // cannot happen
+ msg="INVALID_INT";
+ break;
}
fprintf(file, "%s=%s;\n", msg, llstr(val,llbuff));
fflush(file);
--- 1.123/client/mysqlbinlog.cc Sun Dec 4 19:55:14 2005
+++ 1.124/client/mysqlbinlog.cc Sat Dec 31 13:32:35 2005
@@ -1266,12 +1266,13 @@ at offset %lu ; this could be a log form
}
else if (buf[4] == ROTATE_EVENT)
{
+ Log_event *ev;
my_b_seek(file, tmp_pos); /* seek back to event's start */
- if (!Log_event::read_log_event(file, *description_event))
+ if (!(ev= Log_event::read_log_event(file, *description_event)))
/* EOF can't be hit here normally, so it's a real error */
- die("Could not read a Rotate_log_event event \
-at offset %lu ; this could be a log format error or read error",
- tmp_pos);
+ die("Could not read a Rotate_log_event event at offset %lu ;"
+ " this could be a log format error or read error", tmp_pos);
+ delete ev;
}
else
break;
--- 1.201/sql/opt_range.cc Fri Dec 2 16:27:13 2005
+++ 1.202/sql/opt_range.cc Sat Dec 31 13:32:40 2005
@@ -652,7 +652,6 @@ SQL_SELECT *make_select(TABLE *head, tab
table_map read_tables, COND *conds,
bool allow_null_cond,
int *error)
-
{
SQL_SELECT *select;
DBUG_ENTER("make_select");
@@ -5775,10 +5774,7 @@ QUICK_RANGE_SELECT *get_quick_select_for
if (!quick)
return 0; /* no ranges found */
if (quick->init())
- {
- delete quick;
goto err;
- }
quick->records= records;
if (cp_buffer_from_ref(thd,ref) && thd->is_fatal_error ||
@@ -7112,7 +7108,7 @@ get_best_group_min_max(PARAM *param, SEL
ha_rows cur_records;
SEL_ARG *cur_index_tree= NULL;
ha_rows cur_quick_prefix_records= 0;
- uint cur_param_idx;
+ uint cur_param_idx=MAX_KEY;
key_map cur_used_key_parts;
uint pk= param->table->s->primary_key;
@@ -7328,6 +7324,7 @@ get_best_group_min_max(PARAM *param, SEL
*/
if (cur_read_cost < best_read_cost - (DBL_EPSILON * cur_read_cost))
{
+ DBUG_ASSERT(tree != 0 || cur_param_idx == MAX_KEY);
index_info= cur_index_info;
index= cur_index;
best_read_cost= cur_read_cost;
--- 1.57/sql/opt_range.h Tue Oct 18 23:52:02 2005
+++ 1.58/sql/opt_range.h Sat Dec 31 13:32:40 2005
@@ -705,7 +705,7 @@ class SQL_SELECT :public Sql_alloc {
class FT_SELECT: public QUICK_RANGE_SELECT {
public:
FT_SELECT(THD *thd, TABLE *table, uint key) :
- QUICK_RANGE_SELECT (thd, table, key, 1) { init(); }
+ QUICK_RANGE_SELECT (thd, table, key, 1) { VOID(init()); }
~FT_SELECT() { file->ft_end(); }
int init() { return error=file->ft_init(); }
int reset() { return 0; }
--- 1.263/sql/slave.cc Wed Nov 23 19:18:04 2005
+++ 1.264/sql/slave.cc Sat Dec 31 13:32:41 2005
@@ -2017,7 +2017,8 @@ static void write_ignored_events_info_to
" to the relay log, "
"SHOW SLAVE STATUS may be inaccurate");
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
- flush_master_info(mi, 1);
+ if (flush_master_info(mi, 1))
+ sql_print_error("Failed to flush master info file");
delete ev;
}
else
@@ -2555,7 +2556,7 @@ bool show_master_info(THD* thd, MASTER_I
pthread_mutex_unlock(&mi->rli.data_lock);
pthread_mutex_unlock(&mi->data_lock);
-
+
if (my_net_write(&thd->net, (char*)thd->packet.ptr(), packet->length()))
DBUG_RETURN(TRUE);
}
@@ -2563,8 +2564,13 @@ bool show_master_info(THD* thd, MASTER_I
DBUG_RETURN(FALSE);
}
-
-bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache)
+/*
+ RETURN
+ 2 - flush relay log failed
+ 1 - flush master info failed
+ 0 - all ok
+*/
+int flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache)
{
IO_CACHE* file = &mi->file;
char lbuf[22];
@@ -2583,8 +2589,9 @@ bool flush_master_info(MASTER_INFO* mi,
When we come to this place in code, relay log may or not be initialized;
the caller is responsible for setting 'flush_relay_log_cache' accordingly.
*/
- if (flush_relay_log_cache)
- flush_io_cache(mi->rli.relay_log.get_log_file());
+ if (flush_relay_log_cache &&
+ flush_io_cache(mi->rli.relay_log.get_log_file()))
+ DBUG_RETURN(2);
/*
We flushed the relay log BEFORE the master.info file, because if we crash
@@ -2596,13 +2603,13 @@ bool flush_master_info(MASTER_INFO* mi,
*/
/*
- In certain cases this code may create master.info files that seems
- corrupted, because of extra lines filled with garbage in the end
- file (this happens if new contents take less space than previous
- contents of file). But because of number of lines in the first line
+ In certain cases this code may create master.info files that seems
+ corrupted, because of extra lines filled with garbage in the end
+ file (this happens if new contents take less space than previous
+ contents of file). But because of number of lines in the first line
of file we don't care about this garbage.
*/
-
+
my_b_seek(file, 0L);
my_b_printf(file, "%u\n%s\n%s\n%s\n%s\n%s\n%d\n%d\n%d\n%s\n%s\n%s\n%s\n%s\n",
LINES_IN_MASTER_INFO_WITH_SSL,
@@ -2611,8 +2618,7 @@ bool flush_master_info(MASTER_INFO* mi,
mi->password, mi->port, mi->connect_retry,
(int)(mi->ssl), mi->ssl_ca, mi->ssl_capath, mi->ssl_cert,
mi->ssl_cipher, mi->ssl_key);
- flush_io_cache(file);
- DBUG_RETURN(0);
+ DBUG_RETURN(-flush_io_cache(file));
}
@@ -3644,7 +3650,11 @@ reconnect done to recover from failed re
sql_print_error("Slave I/O thread could not queue event from master");
goto err;
}
- flush_master_info(mi, 1); /* sure that we can flush the relay log */
+ if (flush_master_info(mi, 1))
+ {
+ sql_print_error("Failed to flush master info file");
+ goto err;
+ }
/*
See if the relay logs take too much space.
We don't lock mi->rli.log_space_lock here; this dirty read saves time
--- 1.184/sql/sql_acl.cc Tue Dec 6 17:04:21 2005
+++ 1.185/sql/sql_acl.cc Sat Dec 31 13:32:41 2005
@@ -937,7 +937,7 @@ bool acl_getroot_no_password(Security_co
DBUG_PRINT("enter", ("Host: '%s', Ip: '%s', User: '%s', db: '%s'",
(host ? host : "(NULL)"), (ip ? ip : "(NULL)"),
- (user ? user : "(NULL)"), (db ? db : "(NULL)")));
+ user, (db ? db : "(NULL)")));
sctx->user= user;
sctx->host= host;
sctx->ip= ip;
@@ -966,7 +966,7 @@ bool acl_getroot_no_password(Security_co
for (i=0 ; i < acl_users.elements ; i++)
{
acl_user= dynamic_element(&acl_users,i,ACL_USER*);
- if ((!acl_user->user && (!user || !user[0])) ||
+ if ((!acl_user->user && !user[0]) ||
(acl_user->user && strcmp(user, acl_user->user) == 0))
{
if (compare_hostname(&acl_user->host, host, ip))
@@ -4939,8 +4939,6 @@ static int handle_grant_struct(uint stru
}
if (! user)
user= "";
- if (! host)
- host= "";
#ifdef EXTRA_DEBUG
DBUG_PRINT("loop",("scan struct: %u index: %u user: '%s' host: '%s'",
struct_no, idx, user, host));
--- 1.121/sql/sql_db.cc Sun Dec 11 15:06:27 2005
+++ 1.122/sql/sql_db.cc Sat Dec 31 13:32:42 2005
@@ -287,7 +287,7 @@ static bool write_db_opt(THD *thd, const
}
-/*
+/*
Load database options file
load_db_opt()
@@ -313,68 +313,72 @@ bool load_db_opt(THD *thd, const char *p
bzero((char*) create,sizeof(*create));
create->default_table_charset= thd->variables.collation_server;
-
+
/* Check if options for this database are already in the hash */
if (!get_dbopt(path, create))
- DBUG_RETURN(0);
-
+ DBUG_RETURN(0);
+
/* Otherwise, load options from the .opt file */
- if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0)
- {
- IO_CACHE cache;
- init_io_cache(&cache, file, IO_SIZE, READ_CACHE, 0, 0, MYF(0));
+ if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) < 0)
+ goto err1;
+
+ IO_CACHE cache;
+ if (init_io_cache(&cache, file, IO_SIZE, READ_CACHE, 0, 0, MYF(0)))
+ goto err2;
- while ((int) (nbytes= my_b_gets(&cache, (char*) buf, sizeof(buf))) > 0)
+ while ((int) (nbytes= my_b_gets(&cache, (char*) buf, sizeof(buf))) > 0)
+ {
+ char *pos= buf+nbytes-1;
+ /* Remove end space and control characters */
+ while (pos > buf && !my_isgraph(&my_charset_latin1, pos[-1]))
+ pos--;
+ *pos=0;
+ if ((pos= strchr(buf, '=')))
{
- char *pos= buf+nbytes-1;
- /* Remove end space and control characters */
- while (pos > buf && !my_isgraph(&my_charset_latin1, pos[-1]))
- pos--;
- *pos=0;
- if ((pos= strchr(buf, '=')))
+ if (!strncmp(buf,"default-character-set", (pos-buf)))
+ {
+ /*
+ Try character set name, and if it fails
+ try collation name, probably it's an old
+ 4.1.0 db.opt file, which didn't have
+ separate default-character-set and
+ default-collation commands.
+ */
+ if (!(create->default_table_charset=
+ get_charset_by_csname(pos+1, MY_CS_PRIMARY, MYF(0))) &&
+ !(create->default_table_charset=
+ get_charset_by_name(pos+1, MYF(0))))
+ {
+ sql_print_error("Error while loading database options: '%s':",path);
+ sql_print_error(ER(ER_UNKNOWN_CHARACTER_SET),pos+1);
+ create->default_table_charset= default_charset_info;
+ }
+ }
+ else if (!strncmp(buf,"default-collation", (pos-buf)))
{
- if (!strncmp(buf,"default-character-set", (pos-buf)))
- {
- /*
- Try character set name, and if it fails
- try collation name, probably it's an old
- 4.1.0 db.opt file, which didn't have
- separate default-character-set and
- default-collation commands.
- */
- if (!(create->default_table_charset=
- get_charset_by_csname(pos+1, MY_CS_PRIMARY, MYF(0))) &&
- !(create->default_table_charset=
- get_charset_by_name(pos+1, MYF(0))))
- {
- sql_print_error("Error while loading database options: '%s':",path);
- sql_print_error(ER(ER_UNKNOWN_CHARACTER_SET),pos+1);
- create->default_table_charset= default_charset_info;
- }
- }
- else if (!strncmp(buf,"default-collation", (pos-buf)))
- {
- if (!(create->default_table_charset= get_charset_by_name(pos+1,
- MYF(0))))
- {
- sql_print_error("Error while loading database options: '%s':",path);
- sql_print_error(ER(ER_UNKNOWN_COLLATION),pos+1);
- create->default_table_charset= default_charset_info;
- }
- }
+ if (!(create->default_table_charset= get_charset_by_name(pos+1,
+ MYF(0))))
+ {
+ sql_print_error("Error while loading database options: '%s':",path);
+ sql_print_error(ER(ER_UNKNOWN_COLLATION),pos+1);
+ create->default_table_charset= default_charset_info;
+ }
}
}
- end_io_cache(&cache);
- my_close(file,MYF(0));
- /*
- Put the loaded value into the hash.
- Note that another thread could've added the same
- entry to the hash after we called get_dbopt(),
- but it's not an error, as put_dbopt() takes this
- possibility into account.
- */
- error= put_dbopt(path, create);
}
+ /*
+ Put the loaded value into the hash.
+ Note that another thread could've added the same
+ entry to the hash after we called get_dbopt(),
+ but it's not an error, as put_dbopt() takes this
+ possibility into account.
+ */
+ error= put_dbopt(path, create);
+
+ end_io_cache(&cache);
+err2:
+ my_close(file,MYF(0));
+err1:
DBUG_RETURN(error);
}
--- 1.180/sql/sql_insert.cc Mon Dec 12 19:11:53 2005
+++ 1.181/sql/sql_insert.cc Sat Dec 31 13:32:42 2005
@@ -669,7 +669,8 @@ static bool check_view_insertability(THD
DBUG_ASSERT(view->table != 0 && view->field_translation != 0);
- bitmap_init(&used_fields, used_fields_buff, used_fields_buff_size * 8, 0);
+ VOID(bitmap_init(&used_fields, used_fields_buff, used_fields_buff_size * 8,
+ 0));
bitmap_clear_all(&used_fields);
view->contain_auto_increment= 0;
--- 1.518/sql/sql_parse.cc Sun Dec 11 08:30:53 2005
+++ 1.519/sql/sql_parse.cc Sat Dec 31 13:32:43 2005
@@ -1593,6 +1593,11 @@ bool dispatch_command(enum enum_server_c
statistic_increment(thd->status_var.com_other, &LOCK_status);
thd->enable_slow_log= opt_log_slow_admin_statements;
db= thd->alloc(db_len + tbl_len + 2);
+ if (!db)
+ {
+ my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
+ break;
+ }
tbl_name= strmake(db, packet + 1, db_len)+1;
strmake(tbl_name, packet + db_len + 2, tbl_len);
mysql_table_dump(thd, db, tbl_name, -1);
@@ -1606,14 +1611,14 @@ bool dispatch_command(enum enum_server_c
statistic_increment(thd->status_var.com_other, &LOCK_status);
char *user= (char*) packet;
char *passwd= strend(user)+1;
- /*
+ /*
Old clients send null-terminated string ('\0' for empty string) for
password. New clients send the size (1 byte) + string (not null
terminated, so also '\0' for empty string).
*/
- char db_buff[NAME_LEN+1]; // buffer to store db in utf8
+ char db_buff[NAME_LEN+1]; // buffer to store db in utf8
char *db= passwd;
- uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
+ uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
*passwd++ : strlen(passwd);
db+= passwd_len + 1;
#ifndef EMBEDDED_LIBRARY
@@ -6547,6 +6552,7 @@ bool reload_acl_and_cache(THD *thd, ulon
#ifdef HAVE_REPLICATION
if (options & REFRESH_MASTER)
{
+ DBUG_ASSERT(thd);
tmp_write_to_binlog= 0;
if (reset_master(thd))
{
--- 1.302/sql/sql_show.cc Mon Dec 19 13:20:56 2005
+++ 1.303/sql/sql_show.cc Sat Dec 31 13:32:43 2005
@@ -663,7 +663,7 @@ append_identifier(THD *thd, String *pack
it's a keyword
*/
- packet->reserve(length*2 + 2);
+ VOID(packet->reserve(length*2 + 2));
quote_char= (char) q;
packet->append("e_char, 1, system_charset_info);
@@ -950,13 +950,13 @@ store_create_info(THD *thd, TABLE_LIST *
if (key_part->field)
append_identifier(thd,packet,key_part->field->field_name,
strlen(key_part->field->field_name));
- if (!key_part->field ||
+ if (key_part->field &&
(key_part->length !=
table->field[key_part->fieldnr-1]->key_length() &&
!(key_info->flags & HA_FULLTEXT)))
{
buff[0] = '(';
- char* end=int10_to_str((long) key_part->length /
+ char* end=int10_to_str((long) key_part->length /
key_part->field->charset()->mbmaxlen,
buff + 1,10);
*end++ = ')';
@@ -1732,7 +1732,8 @@ LEX_STRING *make_lex_string(THD *thd, LE
{
MEM_ROOT *mem= thd->mem_root;
if (allocate_lex_string)
- lex_str= (LEX_STRING *)thd->alloc(sizeof(LEX_STRING));
+ if (!(lex_str= (LEX_STRING *)thd->alloc(sizeof(LEX_STRING))))
+ return 0;
lex_str->str= strmake_root(mem, str, length);
lex_str->length= length;
return lex_str;
@@ -2943,7 +2944,7 @@ static int get_schema_stat_record(THD *t
/*
I.e. we are in SELECT FROM INFORMATION_SCHEMA.STATISTICS
rather than in SHOW KEYS
- */
+ */
if (!tables->view)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
thd->net.last_errno, thd->net.last_error);
@@ -2956,7 +2957,7 @@ static int get_schema_stat_record(THD *t
{
TABLE *show_table= tables->table;
KEY *key_info=show_table->key_info;
- show_table->file->info(HA_STATUS_VARIABLE |
+ show_table->file->info(HA_STATUS_VARIABLE |
HA_STATUS_NO_LOCK |
HA_STATUS_TIME);
for (uint i=0 ; i < show_table->s->keys ; i++,key_info++)
@@ -2968,7 +2969,7 @@ static int get_schema_stat_record(THD *t
restore_record(table, s->default_values);
table->field[1]->store(base_name, strlen(base_name), cs);
table->field[2]->store(file_name, strlen(file_name), cs);
- table->field[3]->store((longlong) ((key_info->flags &
+ table->field[3]->store((longlong) ((key_info->flags &
HA_NOSAME) ? 0 : 1), TRUE);
table->field[4]->store(base_name, strlen(base_name), cs);
table->field[5]->store(key_info->name, strlen(key_info->name), cs);
@@ -2991,12 +2992,12 @@ static int get_schema_stat_record(THD *t
table->field[9]->store((longlong) records, TRUE);
table->field[9]->set_notnull();
}
- if (!(key_info->flags & HA_FULLTEXT) &&
- (!key_part->field ||
- key_part->length !=
+ if (!(key_info->flags & HA_FULLTEXT) &&
+ (key_part->field &&
+ key_part->length !=
show_table->field[key_part->fieldnr-1]->key_length()))
{
- table->field[10]->store((longlong) key_part->length /
+ table->field[10]->store((longlong) key_part->length /
key_part->field->charset()->mbmaxlen);
table->field[10]->set_notnull();
}
--- 1.43/sql/sql_test.cc Wed Sep 14 13:30:10 2005
+++ 1.44/sql/sql_test.cc Sat Dec 31 13:32:44 2005
@@ -450,7 +450,7 @@ void mysql_print_status()
calc_sum_of_all_status(&tmp);
printf("\nStatus information:\n\n");
- my_getwd(current_dir, sizeof(current_dir),MYF(0));
+ VOID(my_getwd(current_dir, sizeof(current_dir),MYF(0)));
printf("Current dir: %s\n", current_dir);
printf("Running threads: %d Stack size: %ld\n", thread_count,
(long) thread_stack);
--- 1.213/sql/table.cc Fri Dec 9 16:55:50 2005
+++ 1.214/sql/table.cc Sat Dec 31 13:32:44 2005
@@ -1040,7 +1040,10 @@ ulong get_form_pos(File file, uchar *hea
ret_value=uint4korr(pos);
}
if (! save_names)
- my_free((gptr) buf,MYF(0));
+ {
+ if (names)
+ my_free((gptr) buf,MYF(0));
+ }
else if (!names)
bzero((char*) save_names,sizeof(save_names));
else
--- 1.81/sql-common/client.c Wed Dec 7 00:49:58 2005
+++ 1.82/sql-common/client.c Sat Dec 31 13:32:38 2005
@@ -599,7 +599,7 @@ net_safe_read(MYSQL *mysql)
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d",
vio_description(net->vio),len));
#ifdef MYSQL_SERVER
- if (vio_was_interrupted(net->vio))
+ if (net->vio && vio_was_interrupted(net->vio))
return (packet_error);
#endif /*MYSQL_SERVER*/
end_server(mysql);
--- 1.10/mysys/default_modify.c Mon Jul 18 14:31:58 2005
+++ 1.11/mysys/default_modify.c Sat Dec 31 13:32:37 2005
@@ -197,7 +197,7 @@ int modify_defaults_file(const char *fil
goto err;
}
if (my_fclose(cnf_file, MYF(MY_WME)))
- goto err;
+ DBUG_RETURN(1);
my_free(file_buffer, MYF(0));
DBUG_RETURN(0);
--- 1.28/mysys/my_bitmap.c Tue Jul 19 14:13:38 2005
+++ 1.29/mysys/my_bitmap.c Sat Dec 31 13:32:37 2005
@@ -69,7 +69,7 @@ my_bool bitmap_init(MY_BITMAP *map, ucha
(thread_safe ?
sizeof(pthread_mutex_t) : 0),
MYF(MY_WME | MY_ZEROFILL))))
- return 1;
+ DBUG_RETURN(1);
map->bitmap_size=bitmap_size;
#ifdef THREAD
if (thread_safe)
--- 1.25/mysys/mf_iocache2.c Tue Jul 6 13:34:12 2004
+++ 1.26/mysys/mf_iocache2.c Sat Dec 31 13:32:37 2005
@@ -79,7 +79,7 @@ my_off_t my_b_safe_tell(IO_CACHE *info)
void my_b_seek(IO_CACHE *info,my_off_t pos)
{
- my_off_t offset;
+ my_off_t offset;
DBUG_ENTER("my_b_seek");
DBUG_PRINT("enter",("pos: %lu", (ulong) pos));
@@ -91,10 +91,10 @@ void my_b_seek(IO_CACHE *info,my_off_t p
b) see if there is a better way to make it work
*/
if (info->type == SEQ_READ_APPEND)
- flush_io_cache(info);
-
+ VOID(flush_io_cache(info));
+
offset=(pos - info->pos_in_file);
-
+
if (info->type == READ_CACHE || info->type == SEQ_READ_APPEND)
{
/* TODO: explain why this works if pos < info->pos_in_file */
@@ -119,7 +119,7 @@ void my_b_seek(IO_CACHE *info,my_off_t p
info->write_pos = info->write_buffer + offset;
DBUG_VOID_RETURN;
}
- flush_io_cache(info);
+ VOID(flush_io_cache(info));
/* Correct buffer end so that we write in increments of IO_SIZE */
info->write_end=(info->write_buffer+info->buffer_length-
(pos & (IO_SIZE-1)));
--- 1.23/sql/uniques.cc Wed Jun 1 15:35:05 2005
+++ 1.24/sql/uniques.cc Sat Dec 31 13:32:44 2005
@@ -38,8 +38,8 @@
int unique_write_to_file(gptr key, element_count count, Unique *unique)
{
/*
- Use unique->size (size of element stored in the tree) and not
- unique->tree.size_of_element. The latter is different from unique->size
+ Use unique->size (size of element stored in the tree) and not
+ unique->tree.size_of_element. The latter is different from unique->size
when tree implementation chooses to store pointer to key in TREE_ELEMENT
(instead of storing the element itself there)
*/
@@ -63,27 +63,27 @@ Unique::Unique(qsort_cmp2 comp_func, voi
comp_func_fixed_arg);
/* If the following fail's the next add will also fail */
my_init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16);
- /*
+ /*
If you change the following, change it in get_max_elements function, too.
*/
max_elements= max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+size);
- open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE,
- MYF(MY_WME));
+ VOID(open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE,
+ MYF(MY_WME)));
}
/*
Calculate log2(n!)
-
+
NOTES
Stirling's approximate formula is used:
-
- n! ~= sqrt(2*M_PI*n) * (n/M_E)^n
-
+
+ n! ~= sqrt(2*M_PI*n) * (n/M_E)^n
+
Derivation of formula used for calculations is as follows:
log2(n!) = log(n!)/log(2) = log(sqrt(2*M_PI*n)*(n/M_E)^n) / log(2) =
-
+
= (log(2*M_PI*n)/2 + n*log(n/M_E)) / log(2).
*/
@@ -94,7 +94,7 @@ inline double log2_n_fact(double x)
/*
- Calculate cost of merge_buffers function call for given sequence of
+ Calculate cost of merge_buffers function call for given sequence of
input stream lengths and store the number of rows in result stream in *last.
SYNOPSIS
@@ -103,21 +103,21 @@ inline double log2_n_fact(double x)
elem_size Size of element stored in buffer
first Pointer to first merged element size
last Pointer to last merged element size
-
+
RETURN
Cost of merge_buffers operation in disk seeks.
-
+
NOTES
It is assumed that no rows are eliminated during merge.
- The cost is calculated as
-
+ The cost is calculated as
+
cost(read_and_write) + cost(merge_comparisons).
-
- All bytes in the sequences is read and written back during merge so cost
+
+ All bytes in the sequences is read and written back during merge so cost
of disk io is 2*elem_size*total_buf_elems/IO_SIZE (2 is for read + write)
-
+
For comparisons cost calculations we assume that all merged sequences have
- the same length, so each of total_buf_size elements will be added to a sort
+ the same length, so each of total_buf_size elements will be added to a sort
heap with (n_buffers-1) elements. This gives the comparison cost:
total_buf_elems* log2(n_buffers) / TIME_FOR_COMPARE_ROWID;
@@ -125,16 +125,16 @@ inline double log2_n_fact(double x)
static double get_merge_buffers_cost(uint *buff_elems, uint elem_size,
uint *first, uint *last)
-{
+{
uint total_buf_elems= 0;
for (uint *pbuf= first; pbuf <= last; pbuf++)
total_buf_elems+= *pbuf;
*last= total_buf_elems;
-
+
int n_buffers= last - first + 1;
/* Using log2(n)=log(n)/log(2) formula */
- return 2*((double)total_buf_elems*elem_size) / IO_SIZE +
+ return 2*((double)total_buf_elems*elem_size) / IO_SIZE +
total_buf_elems*log((double) n_buffers) / (TIME_FOR_COMPARE_ROWID * M_LN2);
}
@@ -142,13 +142,13 @@ static double get_merge_buffers_cost(uin
/*
Calculate cost of merging buffers into one in Unique::get, i.e. calculate
how long (in terms of disk seeks) the two calls
- merge_many_buffs(...);
- merge_buffers(...);
+ merge_many_buffs(...);
+ merge_buffers(...);
will take.
SYNOPSIS
get_merge_many_buffs_cost()
- buffer buffer space for temporary data, at least
+ buffer buffer space for temporary data, at least
Unique::get_cost_calc_buff_size bytes
maxbuffer # of full buffers
max_n_elems # of elements in first maxbuffer buffers
@@ -156,12 +156,12 @@ static double get_merge_buffers_cost(uin
elem_size size of buffer element
NOTES
- maxbuffer+1 buffers are merged, where first maxbuffer buffers contain
+ maxbuffer+1 buffers are merged, where first maxbuffer buffers contain
max_n_elems elements each and last buffer contains last_n_elems elements.
The current implementation does a dumb simulation of merge_many_buffs
function actions.
-
+
RETURN
Cost of merge in disk seeks.
*/
@@ -173,17 +173,17 @@ static double get_merge_many_buffs_cost(
register int i;
double total_cost= 0.0;
uint *buff_elems= buffer; /* #s of elements in each of merged sequences */
-
- /*
+
+ /*
Set initial state: first maxbuffer sequences contain max_n_elems elements
each, last sequence contains last_n_elems elements.
*/
for (i = 0; i < (int)maxbuffer; i++)
- buff_elems[i]= max_n_elems;
+ buff_elems[i]= max_n_elems;
buff_elems[maxbuffer]= last_n_elems;
- /*
- Do it exactly as merge_many_buff function does, calling
+ /*
+ Do it exactly as merge_many_buff function does, calling
get_merge_buffers_cost to get cost of merge_buffers.
*/
if (maxbuffer >= MERGEBUFF2)
@@ -194,17 +194,17 @@ static double get_merge_many_buffs_cost(
for (i = 0; i <= (int) maxbuffer - MERGEBUFF*3/2; i += MERGEBUFF)
{
total_cost+=get_merge_buffers_cost(buff_elems, elem_size,
- buff_elems + i,
+ buff_elems + i,
buff_elems + i + MERGEBUFF-1);
lastbuff++;
}
total_cost+=get_merge_buffers_cost(buff_elems, elem_size,
- buff_elems + i,
+ buff_elems + i,
buff_elems + maxbuffer);
maxbuffer= lastbuff;
}
}
-
+
/* Simulate final merge_buff call. */
total_cost += get_merge_buffers_cost(buff_elems, elem_size,
buff_elems, buff_elems + maxbuffer);
@@ -213,7 +213,7 @@ static double get_merge_many_buffs_cost(
/*
- Calculate cost of using Unique for processing nkeys elements of size
+ Calculate cost of using Unique for processing nkeys elements of size
key_size using max_in_memory_size memory.
SYNOPSIS
@@ -223,12 +223,12 @@ static double get_merge_many_buffs_cost(
nkeys #of elements in Unique
key_size size of each elements in bytes
max_in_memory_size amount of memory Unique will be allowed to use
-
+
RETURN
Cost in disk seeks.
-
+
NOTES
- cost(using_unqiue) =
+ cost(using_unqiue) =
cost(create_trees) + (see #1)
cost(merge) + (see #2)
cost(read_result) (see #3)
@@ -237,42 +237,42 @@ static double get_merge_many_buffs_cost(
For each Unique::put operation there will be 2*log2(n+1) elements
comparisons, where n runs from 1 tree_size (we assume that all added
elements are different). Together this gives:
-
+
n_compares = 2*(log2(2) + log2(3) + ... + log2(N+1)) = 2*log2((N+1)!)
-
+
then cost(tree_creation) = n_compares*ROWID_COMPARE_COST;
Total cost of creating trees:
(n_trees - 1)*max_size_tree_cost + non_max_size_tree_cost.
Approximate value of log2(N!) is calculated by log2_n_fact function.
-
+
2. Cost of merging.
If only one tree is created by Unique no merging will be necessary.
Otherwise, we model execution of merge_many_buff function and count
- #of merges. (The reason behind this is that number of buffers is small,
- while size of buffers is big and we don't want to loose precision with
+ #of merges. (The reason behind this is that number of buffers is small,
+ while size of buffers is big and we don't want to loose precision with
O(x)-style formula)
-
+
3. If only one tree is created by Unique no disk io will happen.
- Otherwise, ceil(key_len*n_keys) disk seeks are necessary. We assume
+ Otherwise, ceil(key_len*n_keys) disk seeks are necessary. We assume
these will be random seeks.
*/
-double Unique::get_use_cost(uint *buffer, uint nkeys, uint key_size,
+double Unique::get_use_cost(uint *buffer, uint nkeys, uint key_size,
ulong max_in_memory_size)
{
ulong max_elements_in_tree;
ulong last_tree_elems;
int n_full_trees; /* number of trees in unique - 1 */
double result;
-
- max_elements_in_tree=
+
+ max_elements_in_tree=
max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size);
n_full_trees= nkeys / max_elements_in_tree;
last_tree_elems= nkeys % max_elements_in_tree;
-
+
/* Calculate cost of creating trees */
result= 2*log2_n_fact(last_tree_elems + 1.0);
if (n_full_trees)
@@ -285,13 +285,13 @@ double Unique::get_use_cost(uint *buffer
if (!n_full_trees)
return result;
-
- /*
+
+ /*
There is more then one tree and merging is necessary.
First, add cost of writing all trees to disk, assuming that all disk
writes are sequential.
*/
- result += DISK_SEEK_BASE_COST * n_full_trees *
+ result += DISK_SEEK_BASE_COST * n_full_trees *
ceil(((double) key_size)*max_elements_in_tree / IO_SIZE);
result += DISK_SEEK_BASE_COST * ceil(((double) key_size)*last_tree_elems / IO_SIZE);
@@ -303,8 +303,8 @@ double Unique::get_use_cost(uint *buffer
return merge_cost;
result += merge_cost;
- /*
- Add cost of reading the resulting sequence, assuming there were no
+ /*
+ Add cost of reading the resulting sequence, assuming there were no
duplicate elements.
*/
result += ceil((double)key_size*nkeys/IO_SIZE);
@@ -320,7 +320,7 @@ Unique::~Unique()
}
- /* Write tree to disk; clear tree */
+ /* Write tree to disk; clear tree */
bool Unique::flush()
{
BUFFPEK file_ptr;
@@ -359,7 +359,7 @@ Unique::reset()
}
elements= 0;
}
-
+
/*
The comparison function, passed to queue_init() in merge_walk() must
use comparison function of Uniques::tree, but compare members of struct
@@ -386,7 +386,7 @@ C_MODE_END
/*
DESCRIPTION
- Function is very similar to merge_buffers, but instead of writing sorted
+ Function is very similar to merge_buffers, but instead of writing sorted
unique keys to the output file, it invokes walk_action for each key.
This saves I/O if you need to pass through all unique keys only once.
SYNOPSIS
@@ -601,7 +601,7 @@ bool Unique::get(TABLE *table)
bool error=1;
/* Open cached file if it isn't open */
- outfile=table->sort.io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE),
+ outfile=table->sort.io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE),
MYF(MY_ZEROFILL));
if (!outfile || ! my_b_inited(outfile) &&
@@ -618,7 +618,7 @@ bool Unique::get(TABLE *table)
sort_param.keys= max_in_memory_size / sort_param.sort_length;
sort_param.not_killable=1;
- if (!(sort_buffer=(uchar*) my_malloc((sort_param.keys+1) *
+ if (!(sort_buffer=(uchar*) my_malloc((sort_param.keys+1) *
sort_param.sort_length,
MYF(0))))
return 1;
@@ -633,7 +633,7 @@ bool Unique::get(TABLE *table)
goto err;
if (merge_buffers(&sort_param, &file, outfile, sort_buffer, file_ptr,
file_ptr, file_ptr+maxbuffer,0))
- goto err;
+ goto err;
error=0;
err:
x_free((gptr) sort_buffer);
--- 1.145/sql/set_var.cc Wed Nov 23 00:12:35 2005
+++ 1.146/sql/set_var.cc Sat Dec 31 13:32:41 2005
@@ -2518,7 +2518,6 @@ bool sys_var_slave_skip_counter::update(
bool sys_var_sync_binlog_period::update(THD *thd, set_var *var)
{
- pthread_mutex_t *lock_log= mysql_bin_log.get_log_lock();
sync_binlog_period= (ulong) var->save_result.ulonglong_value;
return 0;
}
--- 1.9/server-tools/instance-manager/parse.cc Mon Aug 29 21:29:27 2005
+++ 1.10/server-tools/instance-manager/parse.cc Sat Dec 31 13:32:38 2005
@@ -107,7 +107,7 @@ Token shift_token(const char **text, uin
int get_text_id(const char **text, uint *word_len, const char **id)
{
get_word(text, word_len);
- if (word_len == 0)
+ if (*word_len == 0)
return 1;
*id= *text;
return 0;
--- 1.91/sql/slave.h Wed Oct 12 21:28:41 2005
+++ 1.92/sql/slave.h Sat Dec 31 13:32:41 2005
@@ -500,7 +500,7 @@ typedef struct st_table_rule_ent
int init_slave();
void init_slave_skip_errors(const char* arg);
-bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache);
+int flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache);
bool flush_relay_log_info(RELAY_LOG_INFO* rli);
int register_slave_on_master(MYSQL* mysql);
int terminate_slave_threads(MASTER_INFO* mi, int thread_mask,
--- 1.59/sql/repl_failsafe.cc Sun Nov 20 19:47:01 2005
+++ 1.60/sql/repl_failsafe.cc Sat Dec 31 13:32:40 2005
@@ -929,7 +929,8 @@ bool load_master_data(THD* thd)
host was specified; there could have been a problem when replication
started, which led to relay log's IO_CACHE to not be inited.
*/
- flush_master_info(active_mi, 0);
+ if (flush_master_info(active_mi, 0))
+ sql_print_error("Failed to flush master info file");
}
mysql_free_result(master_status_res);
}
--- 1.146/sql/sql_repl.cc Tue Nov 22 01:02:35 2005
+++ 1.147/sql/sql_repl.cc Sat Dec 31 13:32:43 2005
@@ -1197,7 +1197,12 @@ bool change_master(THD* thd, MASTER_INFO
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
a slave before).
*/
- flush_master_info(mi, 0);
+ if (flush_master_info(mi, 0))
+ {
+ my_error(ER_RELAY_LOG_INIT, MYF(0), "Failed to flush master info file");
+ unlock_slave_threads(mi);
+ DBUG_RETURN(TRUE);
+ }
if (need_relay_log_purge)
{
relay_log_purge= 1;
@@ -1307,13 +1312,14 @@ bool mysql_show_binlog_events(THD* thd)
bool ret = TRUE;
IO_CACHE log;
File file = -1;
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
Log_event::init_show_field_list(&field_list);
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
+
+ Format_description_log_event *description_event= new
+ Format_description_log_event(3); /* MySQL 4.0 by default */
if (mysql_bin_log.is_open())
{
--- 1.76/sql/sql_handler.cc Wed Nov 16 10:23:35 2005
+++ 1.77/sql/sql_handler.cc Sat Dec 31 13:32:42 2005
@@ -377,10 +377,8 @@ bool mysql_ha_read(THD *thd, TABLE_LIST
address of the 'next' pointer referencing this table
for close_thread_table().
*/
- for (table_ptr= &(thd->handler_tables);
- *table_ptr && (*table_ptr != table);
- table_ptr= &(*table_ptr)->next)
- {}
+ for (table_ptr= &(thd->handler_tables); *table_ptr != table;
+ table_ptr= &(*table_ptr)->next) /* no-op */ ;
(*table_ptr)->file->ha_index_or_rnd_end();
VOID(pthread_mutex_lock(&LOCK_open));
if (close_thread_table(thd, table_ptr))
@@ -750,7 +748,7 @@ static int mysql_ha_flush_table(THD *thd
/* Mark table as closed, ready for re-open. */
hash_tables->table= NULL;
}
- }
+ }
safe_mutex_assert_owner(&LOCK_open);
(*table_ptr)->file->ha_index_or_rnd_end();
--- 1.8/cmd-line-utils/libedit/history.c Thu Apr 21 12:06:38 2005
+++ 1.9/cmd-line-utils/libedit/history.c Sat Dec 31 13:32:36 2005
@@ -676,8 +676,8 @@ history_load(History *h, const char *fna
(void) strunvis(ptr, line);
line[sz] = c;
if (HENTER(h, &ev, ptr) == -1) {
- h_free((ptr_t)ptr);
- return -1;
+ i = -1;
+ goto oomem;
}
}
oomem:
--- 1.51/sql/sql_help.cc Fri Oct 21 03:01:32 2005
+++ 1.52/sql/sql_help.cc Sat Dec 31 13:32:42 2005
@@ -567,7 +567,7 @@ SQL_SELECT *prepare_simple_select(THD *t
SQL_SELECT *res= make_select(table, 0, 0, cond, 0, error);
if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR)) ||
- (res->quick && res->quick->reset()))
+ (res && res->quick && res->quick->reset()))
{
delete res;
res=0;
| Thread |
|---|
| • bk commit into 5.0 tree (serg:1.2004) | Sergei Golubchik | 31 Dec |