Merge mysql.com:/home/kostja/mysql/tmp_merge

into  mysql.com:/home/kostja/mysql/mysql-5.1-merge


client/mysqlbinlog.cc:
  Auto merged
client/mysqldump.c:
  Auto merged
include/my_base.h:
  Auto merged
libmysql/libmysql.c:
  Auto merged
sql/field.h:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/opt_range.h:
  Auto merged
sql/repl_failsafe.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/slave.h:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_handler.cc:
  Auto merged
sql/sql_help.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_repl.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_test.cc:
  Auto merged
sql-common/client.c:
  Auto merged
sql/table.cc:
  Auto merged
storage/myisam/mi_delete.c:
  Auto merged
storage/myisam/myisampack.c:
  Auto merged
storage/myisam/sort.c:
  Auto merged
mysys/my_bitmap.c:
  Manual merge
sql/field.cc:
  e
  Manual merge
sql/item.cc:
  Manual merge (new Field_bit_as_char constructor signature)
sql/item_func.cc:
  Manual merge: use local
sql/sql_insert.cc:
  Manual merge: add VOID() around bitmap_init
This commit is contained in:
unknown 2006-02-02 16:57:34 +03:00
commit 97dae00306
37 changed files with 266 additions and 227 deletions

View File

@ -45,22 +45,22 @@ CLEAN_FILES: $(TXT_FILES)
GT = $(srcdir)/Support/generate-text-files.pl GT = $(srcdir)/Support/generate-text-files.pl
../INSTALL-SOURCE: mysql.info $(GT) ../INSTALL-SOURCE: mysql.info $(GT)
perl -w $(GT) $< "installing-source" "windows-source-build" > $@ perl -w $(GT) mysql.info "installing-source" "windows-source-build" > $@
../INSTALL-WIN-SOURCE: mysql.info $(GT) ../INSTALL-WIN-SOURCE: mysql.info $(GT)
perl -w $(GT) $< "windows-source-build" "post-installation" > $@ perl -w $(GT) mysql.info "windows-source-build" "post-installation" > $@
# We put the description for the binary installation here so that # We put the description for the binary installation here so that
# people who download source wont have to see it. It is moved up to # people who download source wont have to see it. It is moved up to
# the toplevel by the script that makes the binary tar files. # the toplevel by the script that makes the binary tar files.
INSTALL-BINARY: mysql.info $(GT) INSTALL-BINARY: mysql.info $(GT)
perl -w $(GT) $< "installing-binary" "installing-source" > $@ perl -w $(GT) mysql.info "installing-binary" "installing-source" > $@
../EXCEPTIONS-CLIENT: mysql.info $(GT) ../EXCEPTIONS-CLIENT: mysql.info $(GT)
perl -w $(GT) $< "mysql-floss-license-exception" "function-index" > $@ perl -w $(GT) mysql.info "mysql-floss-license-exception" "function-index" > $@
../support-files/MacOSX/ReadMe.txt: mysql.info $(GT) ../support-files/MacOSX/ReadMe.txt: mysql.info $(GT)
perl -w $(GT) $< "mac-os-x-installation" "netware-installation" > $@ perl -w $(GT) mysql.info "mac-os-x-installation" "netware-installation" > $@
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%

View File

@ -569,6 +569,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
return -1; return -1;
} }
mysql_close(mysql); /* Close connection to avoid error messages */ mysql_close(mysql); /* Close connection to avoid error messages */
argc=1; /* force SHUTDOWN to be the last command */
if (got_pidfile) if (got_pidfile)
{ {
if (opt_verbose) if (opt_verbose)

View File

@ -1293,12 +1293,13 @@ at offset %lu ; this could be a log format error or read error",
} }
else if (buf[4] == ROTATE_EVENT) else if (buf[4] == ROTATE_EVENT)
{ {
Log_event *ev;
my_b_seek(file, tmp_pos); /* seek back to event's start */ 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 */ /* EOF can't be hit here normally, so it's a real error */
die("Could not read a Rotate_log_event event \ die("Could not read a Rotate_log_event event at offset %lu ;"
at offset %lu ; this could be a log format error or read error", " this could be a log format error or read error", tmp_pos);
tmp_pos); delete ev;
} }
else else
break; break;

View File

@ -1311,7 +1311,7 @@ static uint dump_routines_for_db(char *db)
fprintf(sql_file, "DELIMITER ;\n"); fprintf(sql_file, "DELIMITER ;\n");
if (lock_tables) 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); DBUG_RETURN(0);
} }
@ -2134,7 +2134,10 @@ static void dump_table(char *table, char *db)
else else
res=mysql_store_result(sock); res=mysql_store_result(sock);
if (!res) if (!res)
{
DB_error(sock, "when retrieving data from server"); DB_error(sock, "when retrieving data from server");
goto err;
}
if (verbose) if (verbose)
fprintf(stderr, "-- Retrieving rows...\n"); fprintf(stderr, "-- Retrieving rows...\n");
if (mysql_num_fields(res) != num_fields) if (mysql_num_fields(res) != num_fields)
@ -2664,7 +2667,7 @@ static int dump_all_tables_in_db(char *database)
check_io(md_result_file); check_io(md_result_file);
} }
if (lock_tables) if (lock_tables)
mysql_query_with_error_report(sock, 0, "UNLOCK TABLES"); VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES"));
return 0; return 0;
} /* dump_all_tables_in_db */ } /* dump_all_tables_in_db */
@ -2719,7 +2722,7 @@ static my_bool dump_all_views_in_db(char *database)
check_io(md_result_file); check_io(md_result_file);
} }
if (lock_tables) if (lock_tables)
mysql_query(sock,"UNLOCK TABLES"); VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES"));
return 0; return 0;
} /* dump_all_tables_in_db */ } /* dump_all_tables_in_db */
@ -2878,7 +2881,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
check_io(md_result_file); check_io(md_result_file);
} }
if (lock_tables) 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); DBUG_RETURN(0);
} /* dump_selected_tables */ } /* dump_selected_tables */

View File

@ -676,8 +676,8 @@ history_load(History *h, const char *fname)
(void) strunvis(ptr, line); (void) strunvis(ptr, line);
line[sz] = c; line[sz] = c;
if (HENTER(h, &ev, ptr) == -1) { if (HENTER(h, &ev, ptr) == -1) {
h_free((ptr_t)ptr); i = -1;
return -1; goto oomem;
} }
} }
oomem: oomem:

View File

@ -426,7 +426,8 @@ enum ha_base_keytype {
enum en_fieldtype { enum en_fieldtype {
FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIP_ENDSPACE,FIELD_SKIP_PRESPACE, FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIP_ENDSPACE,FIELD_SKIP_PRESPACE,
FIELD_SKIP_ZERO,FIELD_BLOB,FIELD_CONSTANT,FIELD_INTERVALL,FIELD_ZERO, 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 { enum data_file_type {

View File

@ -818,7 +818,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename)
if ((*options->local_infile_init)(&li_ptr, net_filename, if ((*options->local_infile_init)(&li_ptr, net_filename,
options->local_infile_userdata)) 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); net_flush(net);
strmov(net->sqlstate, unknown_sqlstate); strmov(net->sqlstate, unknown_sqlstate);
net->last_errno= (*options->local_infile_error)(li_ptr, net->last_errno= (*options->local_infile_error)(li_ptr,

View File

@ -197,7 +197,7 @@ int modify_defaults_file(const char *file_location, const char *option,
goto err; goto err;
} }
if (my_fclose(cnf_file, MYF(MY_WME))) if (my_fclose(cnf_file, MYF(MY_WME)))
goto err; DBUG_RETURN(1);
my_free(file_buffer, MYF(0)); my_free(file_buffer, MYF(0));
DBUG_RETURN(0); DBUG_RETURN(0);

View File

@ -91,7 +91,7 @@ void my_b_seek(IO_CACHE *info,my_off_t pos)
b) see if there is a better way to make it work b) see if there is a better way to make it work
*/ */
if (info->type == SEQ_READ_APPEND) if (info->type == SEQ_READ_APPEND)
flush_io_cache(info); VOID(flush_io_cache(info));
offset=(pos - info->pos_in_file); offset=(pos - info->pos_in_file);
@ -119,7 +119,7 @@ void my_b_seek(IO_CACHE *info,my_off_t pos)
info->write_pos = info->write_buffer + offset; info->write_pos = info->write_buffer + offset;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
flush_io_cache(info); VOID(flush_io_cache(info));
/* Correct buffer end so that we write in increments of IO_SIZE */ /* Correct buffer end so that we write in increments of IO_SIZE */
info->write_end=(info->write_buffer+info->buffer_length- info->write_end=(info->write_buffer+info->buffer_length-
(pos & (IO_SIZE-1))); (pos & (IO_SIZE-1)));

View File

@ -114,7 +114,7 @@ my_bool bitmap_init(MY_BITMAP *map, uint32 *buf, uint n_bits,
#endif #endif
; ;
if (!(buf= (uint32*) my_malloc(size_in_bytes, MYF(MY_WME)))) if (!(buf= (uint32*) my_malloc(size_in_bytes, MYF(MY_WME))))
return 1; DBUG_RETURN(1);
} }
#ifdef THREAD #ifdef THREAD
else else

View File

@ -189,7 +189,10 @@ int my_error_register(const char **errmsgs, int first, int last)
/* Error numbers must be unique. No overlapping is allowed. */ /* Error numbers must be unique. No overlapping is allowed. */
if (*search_meh_pp && ((*search_meh_pp)->meh_first <= last)) if (*search_meh_pp && ((*search_meh_pp)->meh_first <= last))
{
my_free((gptr)meh_p, MYF(0));
return 1; return 1;
}
/* Insert header into the chain. */ /* Insert header into the chain. */
meh_p->meh_next= *search_meh_pp; meh_p->meh_next= *search_meh_pp;

View File

@ -107,7 +107,7 @@ Token shift_token(const char **text, uint *word_len)
int get_text_id(const char **text, uint *word_len, const char **id) int get_text_id(const char **text, uint *word_len, const char **id)
{ {
get_word(text, word_len); get_word(text, word_len);
if (word_len == 0) if (*word_len == 0)
return 1; return 1;
*id= *text; *id= *text;
return 0; return 0;

View File

@ -599,7 +599,7 @@ net_safe_read(MYSQL *mysql)
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d",
vio_description(net->vio),len)); vio_description(net->vio),len));
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
if (vio_was_interrupted(net->vio)) if (net->vio && vio_was_interrupted(net->vio))
return (packet_error); return (packet_error);
#endif /*MYSQL_SERVER*/ #endif /*MYSQL_SERVER*/
end_server(mysql); end_server(mysql);

View File

@ -1565,7 +1565,6 @@ Field *Field::new_key_field(MEM_ROOT *root, struct st_table *new_table,
bool Field::quote_data(String *unquoted_string) bool Field::quote_data(String *unquoted_string)
{ {
char escaped_string[IO_SIZE]; char escaped_string[IO_SIZE];
char *unquoted_string_buffer= (char *)(unquoted_string->ptr());
DBUG_ENTER("Field::quote_data"); DBUG_ENTER("Field::quote_data");
if (!needs_quotes()) if (!needs_quotes())
@ -4545,8 +4544,6 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
error= 1; error= 1;
} }
} }
if (error > 1)
error= 2;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first) if (table->s->db_low_byte_first)
@ -7113,7 +7110,7 @@ void Field_blob::get_key_image(char *buff, uint length, imagetype type)
} }
get_ptr(&blob); get_ptr(&blob);
gobj= Geometry::construct(&buffer, blob, blob_length); 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); bzero(buff, SIZEOF_STORED_DOUBLE*4);
else else
{ {
@ -7442,7 +7439,7 @@ void Field_geom::get_key_image(char *buff, uint length, imagetype type)
} }
get_ptr(&blob); get_ptr(&blob);
gobj= Geometry::construct(&buffer, blob, blob_length); 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); bzero(buff, SIZEOF_STORED_DOUBLE*4);
else else
{ {
@ -8240,15 +8237,12 @@ const char *Field_bit::unpack(char *to, const char *from)
Field_bit_as_char::Field_bit_as_char(char *ptr_arg, uint32 len_arg, Field_bit_as_char::Field_bit_as_char(char *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg, uchar *null_ptr_arg, uchar null_bit_arg,
uchar *bit_ptr_arg, uchar bit_ofs_arg,
enum utype unireg_check_arg, enum utype unireg_check_arg,
const char *field_name_arg) const char *field_name_arg)
:Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, bit_ptr_arg, :Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0, 0,
bit_ofs_arg, unireg_check_arg, field_name_arg), unireg_check_arg, field_name_arg),
create_length(len_arg) create_length(len_arg)
{ {
bit_ptr= 0;
bit_ofs= 0;
bit_len= 0; bit_len= 0;
field_length= ((len_arg + 7) & ~7) / 8; field_length= ((len_arg + 7) & ~7) / 8;
} }
@ -8951,7 +8945,7 @@ Field *make_field(TABLE_SHARE *share, char *ptr, uint32 field_length,
case FIELD_TYPE_BIT: case FIELD_TYPE_BIT:
return f_bit_as_char(pack_flag) ? return f_bit_as_char(pack_flag) ?
new Field_bit_as_char(ptr, field_length, null_pos, null_bit, new Field_bit_as_char(ptr, field_length, null_pos, null_bit,
bit_ptr, bit_offset, unireg_check, field_name) : unireg_check, field_name) :
new Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr, new Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr,
bit_offset, unireg_check, field_name); bit_offset, unireg_check, field_name);

View File

@ -1378,7 +1378,7 @@ class Field_bit_as_char: public Field_bit {
public: public:
uchar create_length; uchar create_length;
Field_bit_as_char(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, 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); enum utype unireg_check_arg, const char *field_name_arg);
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
uint32 max_length() { return (uint32) create_length; } uint32 max_length() { return (uint32) create_length; }

View File

@ -286,7 +286,8 @@ int ha_myisam::dump(THD* thd, int fd)
if (fd < 0) if (fd < 0)
{ {
my_net_write(net, "", 0); if (my_net_write(net, "", 0))
error = errno ? errno : EPIPE;
net_flush(net); net_flush(net);
} }
@ -420,11 +421,13 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
{ {
uint old_testflag=param.testflag; uint old_testflag=param.testflag;
param.testflag|=T_MEDIUM; param.testflag|=T_MEDIUM;
init_io_cache(&param.read_cache, file->dfile, if (!(error= init_io_cache(&param.read_cache, file->dfile,
my_default_record_cache_size, READ_CACHE, my_default_record_cache_size, READ_CACHE,
share->pack.header_length, 1, MYF(MY_WME)); share->pack.header_length, 1, MYF(MY_WME))))
error |= chk_data_link(&param, file, param.testflag & T_EXTEND); {
error= chk_data_link(&param, file, param.testflag & T_EXTEND);
end_io_cache(&(param.read_cache)); end_io_cache(&(param.read_cache));
}
param.testflag= old_testflag; param.testflag= old_testflag;
} }
} }

View File

@ -985,7 +985,7 @@ Item_case_expr::this_item_addr(THD *thd, Item **)
void Item_case_expr::print(String *str) void Item_case_expr::print(String *str)
{ {
str->append(STRING_WITH_LEN("case_expr@")); VOID(str->append(STRING_WITH_LEN("case_expr@")));
str->qs_append(m_case_expr_id); str->qs_append(m_case_expr_id);
} }
@ -3868,7 +3868,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
name); name);
break; break;
case MYSQL_TYPE_BIT: case MYSQL_TYPE_BIT:
field= new Field_bit_as_char(NULL, max_length, null_ptr, 0, NULL, 0, field= new Field_bit_as_char(NULL, max_length, null_ptr, 0,
Field::NONE, name); Field::NONE, name);
break; break;
default: default:

View File

@ -3342,6 +3342,10 @@ void Intvar_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
case INSERT_ID_EVENT: case INSERT_ID_EVENT:
msg="INSERT_ID"; msg="INSERT_ID";
break; break;
case INVALID_INT_EVENT:
default: // cannot happen
msg="INVALID_INT";
break;
} }
fprintf(file, "%s=%s;\n", msg, llstr(val,llbuff)); fprintf(file, "%s=%s;\n", msg, llstr(val,llbuff));
fflush(file); fflush(file);

View File

@ -753,7 +753,6 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
table_map read_tables, COND *conds, table_map read_tables, COND *conds,
bool allow_null_cond, bool allow_null_cond,
int *error) int *error)
{ {
SQL_SELECT *select; SQL_SELECT *select;
DBUG_ENTER("make_select"); DBUG_ENTER("make_select");
@ -7059,10 +7058,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
if (!quick) if (!quick)
return 0; /* no ranges found */ return 0; /* no ranges found */
if (quick->init()) if (quick->init())
{
delete quick;
goto err; goto err;
}
quick->records= records; quick->records= records;
if (cp_buffer_from_ref(thd,ref) && thd->is_fatal_error || if (cp_buffer_from_ref(thd,ref) && thd->is_fatal_error ||
@ -8404,7 +8400,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
ha_rows cur_records; ha_rows cur_records;
SEL_ARG *cur_index_tree= NULL; SEL_ARG *cur_index_tree= NULL;
ha_rows cur_quick_prefix_records= 0; ha_rows cur_quick_prefix_records= 0;
uint cur_param_idx; uint cur_param_idx=MAX_KEY;
key_map cur_used_key_parts; key_map cur_used_key_parts;
uint pk= param->table->s->primary_key; uint pk= param->table->s->primary_key;
@ -8620,6 +8616,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
*/ */
if (cur_read_cost < best_read_cost - (DBL_EPSILON * cur_read_cost)) 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_info= cur_index_info;
index= cur_index; index= cur_index;
best_read_cost= cur_read_cost; best_read_cost= cur_read_cost;

View File

@ -706,7 +706,7 @@ class SQL_SELECT :public Sql_alloc {
class FT_SELECT: public QUICK_RANGE_SELECT { class FT_SELECT: public QUICK_RANGE_SELECT {
public: public:
FT_SELECT(THD *thd, TABLE *table, uint key) : 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(); } ~FT_SELECT() { file->ft_end(); }
int init() { return error=file->ft_init(); } int init() { return error=file->ft_init(); }
int reset() { return 0; } int reset() { return 0; }

View File

@ -930,7 +930,8 @@ bool load_master_data(THD* thd)
host was specified; there could have been a problem when replication host was specified; there could have been a problem when replication
started, which led to relay log's IO_CACHE to not be inited. 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); mysql_free_result(master_status_res);
} }

View File

@ -2495,7 +2495,6 @@ bool sys_var_slave_skip_counter::update(THD *thd, set_var *var)
bool sys_var_sync_binlog_period::update(THD *thd, set_var *var) 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; sync_binlog_period= (ulong) var->save_result.ulonglong_value;
return 0; return 0;
} }

View File

@ -1742,7 +1742,8 @@ static void write_ignored_events_info_to_relay_log(THD *thd, MASTER_INFO *mi)
" to the relay log, " " to the relay log, "
"SHOW SLAVE STATUS may be inaccurate"); "SHOW SLAVE STATUS may be inaccurate");
rli->relay_log.harvest_bytes_written(&rli->log_space_total); 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; delete ev;
} }
else else
@ -2241,8 +2242,13 @@ bool show_master_info(THD* thd, MASTER_INFO* mi)
DBUG_RETURN(FALSE); 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; IO_CACHE* file = &mi->file;
char lbuf[22]; char lbuf[22];
@ -2261,8 +2267,9 @@ bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache)
When we come to this place in code, relay log may or not be initialized; 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. the caller is responsible for setting 'flush_relay_log_cache' accordingly.
*/ */
if (flush_relay_log_cache) if (flush_relay_log_cache &&
flush_io_cache(mi->rli.relay_log.get_log_file()); 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 We flushed the relay log BEFORE the master.info file, because if we crash
@ -2289,8 +2296,7 @@ bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache)
mi->password, mi->port, mi->connect_retry, mi->password, mi->port, mi->connect_retry,
(int)(mi->ssl), mi->ssl_ca, mi->ssl_capath, mi->ssl_cert, (int)(mi->ssl), mi->ssl_ca, mi->ssl_capath, mi->ssl_cert,
mi->ssl_cipher, mi->ssl_key); mi->ssl_cipher, mi->ssl_key);
flush_io_cache(file); DBUG_RETURN(-flush_io_cache(file));
DBUG_RETURN(0);
} }
@ -3355,7 +3361,11 @@ reconnect done to recover from failed read");
sql_print_error("Slave I/O thread could not queue event from master"); sql_print_error("Slave I/O thread could not queue event from master");
goto err; 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. See if the relay logs take too much space.
We don't lock mi->rli.log_space_lock here; this dirty read saves time We don't lock mi->rli.log_space_lock here; this dirty read saves time

View File

@ -231,7 +231,7 @@ int queue_event(MASTER_INFO* mi,const char* buf,ulong event_len);
int init_slave(); int init_slave();
void init_slave_skip_errors(const char* arg); 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); bool flush_relay_log_info(RELAY_LOG_INFO* rli);
int register_slave_on_master(MYSQL* mysql); int register_slave_on_master(MYSQL* mysql);
int terminate_slave_threads(MASTER_INFO* mi, int thread_mask, int terminate_slave_threads(MASTER_INFO* mi, int thread_mask,

View File

@ -951,7 +951,7 @@ bool acl_getroot_no_password(Security_context *sctx, char *user, char *host,
DBUG_PRINT("enter", ("Host: '%s', Ip: '%s', User: '%s', db: '%s'", DBUG_PRINT("enter", ("Host: '%s', Ip: '%s', User: '%s', db: '%s'",
(host ? host : "(NULL)"), (ip ? ip : "(NULL)"), (host ? host : "(NULL)"), (ip ? ip : "(NULL)"),
(user ? user : "(NULL)"), (db ? db : "(NULL)"))); user, (db ? db : "(NULL)")));
sctx->user= user; sctx->user= user;
sctx->host= host; sctx->host= host;
sctx->ip= ip; sctx->ip= ip;
@ -980,7 +980,7 @@ bool acl_getroot_no_password(Security_context *sctx, char *user, char *host,
for (i=0 ; i < acl_users.elements ; i++) for (i=0 ; i < acl_users.elements ; i++)
{ {
acl_user= dynamic_element(&acl_users,i,ACL_USER*); 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)) (acl_user->user && strcmp(user, acl_user->user) == 0))
{ {
if (compare_hostname(&acl_user->host, host, ip)) if (compare_hostname(&acl_user->host, host, ip))
@ -4980,8 +4980,6 @@ static int handle_grant_struct(uint struct_no, bool drop,
} }
if (! user) if (! user)
user= ""; user= "";
if (! host)
host= "";
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
DBUG_PRINT("loop",("scan struct: %u index: %u user: '%s' host: '%s'", DBUG_PRINT("loop",("scan struct: %u index: %u user: '%s' host: '%s'",
struct_no, idx, user, host)); struct_no, idx, user, host));

View File

@ -319,10 +319,12 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
DBUG_RETURN(0); DBUG_RETURN(0);
/* Otherwise, load options from the .opt file */ /* Otherwise, load options from the .opt file */
if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0) if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) < 0)
{ goto err1;
IO_CACHE cache; IO_CACHE cache;
init_io_cache(&cache, file, IO_SIZE, READ_CACHE, 0, 0, MYF(0)); 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)
{ {
@ -364,8 +366,6 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
} }
} }
} }
end_io_cache(&cache);
my_close(file,MYF(0));
/* /*
Put the loaded value into the hash. Put the loaded value into the hash.
Note that another thread could've added the same Note that another thread could've added the same
@ -374,7 +374,11 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
possibility into account. possibility into account.
*/ */
error= put_dbopt(path, create); error= put_dbopt(path, create);
}
end_io_cache(&cache);
err2:
my_close(file,MYF(0));
err1:
DBUG_RETURN(error); DBUG_RETURN(error);
} }

View File

@ -567,7 +567,7 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond,
SQL_SELECT *res= make_select(table, 0, 0, cond, 0, error); SQL_SELECT *res= make_select(table, 0, 0, cond, 0, error);
if (*error || (res && res->check_quick(thd, 0, HA_POS_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; delete res;
res=0; res=0;

View File

@ -686,7 +686,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
DBUG_ASSERT(view->table != 0 && view->field_translation != 0); DBUG_ASSERT(view->table != 0 && view->field_translation != 0);
bitmap_init(&used_fields, used_fields_buff, table->s->fields, 0); VOID(bitmap_init(&used_fields, used_fields_buff, table->s->fields, 0));
bitmap_clear_all(&used_fields); bitmap_clear_all(&used_fields);
view->contain_auto_increment= 0; view->contain_auto_increment= 0;

View File

@ -1615,6 +1615,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
statistic_increment(thd->status_var.com_other, &LOCK_status); statistic_increment(thd->status_var.com_other, &LOCK_status);
thd->enable_slow_log= opt_log_slow_admin_statements; thd->enable_slow_log= opt_log_slow_admin_statements;
db= thd->alloc(db_len + tbl_len + 2); 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; tbl_name= strmake(db, packet + 1, db_len)+1;
strmake(tbl_name, packet + db_len + 2, tbl_len); strmake(tbl_name, packet + db_len + 2, tbl_len);
mysql_table_dump(thd, db, tbl_name, -1); mysql_table_dump(thd, db, tbl_name, -1);
@ -6631,6 +6636,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
if (options & REFRESH_MASTER) if (options & REFRESH_MASTER)
{ {
DBUG_ASSERT(thd);
tmp_write_to_binlog= 0; tmp_write_to_binlog= 0;
if (reset_master(thd)) if (reset_master(thd))
{ {

View File

@ -1201,7 +1201,12 @@ bool change_master(THD* thd, MASTER_INFO* mi)
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
a slave before). 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) if (need_relay_log_purge)
{ {
relay_log_purge= 1; relay_log_purge= 1;
@ -1311,14 +1316,15 @@ bool mysql_show_binlog_events(THD* thd)
bool ret = TRUE; bool ret = TRUE;
IO_CACHE log; IO_CACHE log;
File file = -1; 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); Log_event::init_show_field_list(&field_list);
if (protocol->send_fields(&field_list, if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
Format_description_log_event *description_event= new
Format_description_log_event(3); /* MySQL 4.0 by default */
/* /*
Wait for handlers to insert any pending information Wait for handlers to insert any pending information
into the binlog. For e.g. ndb which updates the binlog asynchronously into the binlog. For e.g. ndb which updates the binlog asynchronously

View File

@ -781,7 +781,7 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
it's a keyword it's a keyword
*/ */
packet->reserve(length*2 + 2); VOID(packet->reserve(length*2 + 2));
quote_char= (char) q; quote_char= (char) q;
packet->append(&quote_char, 1, system_charset_info); packet->append(&quote_char, 1, system_charset_info);
@ -1097,7 +1097,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
if (key_part->field) if (key_part->field)
append_identifier(thd,packet,key_part->field->field_name, append_identifier(thd,packet,key_part->field->field_name,
strlen(key_part->field->field_name)); strlen(key_part->field->field_name));
if (!key_part->field || if (key_part->field &&
(key_part->length != (key_part->length !=
table->field[key_part->fieldnr-1]->key_length() && table->field[key_part->fieldnr-1]->key_length() &&
!(key_info->flags & HA_FULLTEXT))) !(key_info->flags & HA_FULLTEXT)))
@ -1856,7 +1856,8 @@ LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str,
{ {
MEM_ROOT *mem= thd->mem_root; MEM_ROOT *mem= thd->mem_root;
if (allocate_lex_string) 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->str= strmake_root(mem, str, length);
lex_str->length= length; lex_str->length= length;
return lex_str; return lex_str;
@ -3164,7 +3165,7 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
table->field[9]->set_notnull(); table->field[9]->set_notnull();
} }
if (!(key_info->flags & HA_FULLTEXT) && if (!(key_info->flags & HA_FULLTEXT) &&
(!key_part->field || (key_part->field &&
key_part->length != key_part->length !=
show_table->field[key_part->fieldnr-1]->key_length())) show_table->field[key_part->fieldnr-1]->key_length()))
{ {

View File

@ -450,7 +450,7 @@ void mysql_print_status()
calc_sum_of_all_status(&tmp); calc_sum_of_all_status(&tmp);
printf("\nStatus information:\n\n"); 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("Current dir: %s\n", current_dir);
printf("Running threads: %d Stack size: %ld\n", thread_count, printf("Running threads: %d Stack size: %ld\n", thread_count,
(long) thread_stack); (long) thread_stack);

View File

@ -1640,7 +1640,10 @@ ulong get_form_pos(File file, uchar *head, TYPELIB *save_names)
ret_value=uint4korr(pos); ret_value=uint4korr(pos);
} }
if (! save_names) if (! save_names)
{
if (names)
my_free((gptr) buf,MYF(0)); my_free((gptr) buf,MYF(0));
}
else if (!names) else if (!names)
bzero((char*) save_names,sizeof(save_names)); bzero((char*) save_names,sizeof(save_names));
else else

View File

@ -67,8 +67,8 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
If you change the following, change it in get_max_elements function, too. 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); max_elements= max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+size);
open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, VOID(open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE,
MYF(MY_WME)); MYF(MY_WME)));
} }

View File

@ -276,7 +276,8 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
if (subkeys == -1) if (subkeys == -1)
{ {
/* the last entry in sub-tree */ /* 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 */ /* fall through to normal delete */
} }
else else

View File

@ -1159,7 +1159,7 @@ static int compare_huff_elements(void *not_used __attribute__((unused)),
static void check_counts(HUFF_COUNTS *huff_counts, uint trees, static void check_counts(HUFF_COUNTS *huff_counts, uint trees,
my_off_t records) 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; my_off_t old_length,new_length,length;
DBUG_ENTER("check_counts"); DBUG_ENTER("check_counts");

View File

@ -376,7 +376,10 @@ pthread_handler_t thr_find_all_keys(void *arg)
{ {
if (my_init_dynamic_array(&info->buffpek, sizeof(BUFFPEK), if (my_init_dynamic_array(&info->buffpek, sizeof(BUFFPEK),
maxbuffer, maxbuffer/2)) maxbuffer, maxbuffer/2))
{
my_free((gptr) sort_keys,MYF(0)); my_free((gptr) sort_keys,MYF(0));
sort_keys= (uchar **) NULL; /* for err: label */
}
else else
break; break;
} }