diff options
author | Davi Arnaut <davi.arnaut@oracle.com> | 2010-07-20 16:30:10 -0300 |
---|---|---|
committer | Davi Arnaut <davi.arnaut@oracle.com> | 2010-07-20 16:30:10 -0300 |
commit | 182599dd13f280ce4d51333bca98dbd5e4816bba (patch) | |
tree | c02d7fe89f0e9d9cbd05e83dd77ceeed812eb293 /sql | |
parent | 774194634297aebf6ecbbda7c5601c796f43e5fc (diff) | |
parent | 9a5fa17fd3c4885262e31bf14cf495d02e5f6b27 (diff) | |
download | mariadb-git-182599dd13f280ce4d51333bca98dbd5e4816bba.tar.gz |
Merge of mysql-5.1-bugteam into mysql-trunk-merge.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/item.cc | 5 | ||||
-rw-r--r-- | sql/log.cc | 73 | ||||
-rw-r--r-- | sql/mysqld.cc | 7 | ||||
-rw-r--r-- | sql/partition_info.cc | 2 | ||||
-rw-r--r-- | sql/slave.cc | 7 | ||||
-rw-r--r-- | sql/spatial.cc | 3 | ||||
-rw-r--r-- | sql/sql_acl.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 14 | ||||
-rw-r--r-- | sql/sql_load.cc | 15 | ||||
-rw-r--r-- | sql/sql_parse.cc | 8 | ||||
-rw-r--r-- | sql/sql_partition.cc | 2 | ||||
-rw-r--r-- | sql/sql_repl.cc | 7 | ||||
-rw-r--r-- | sql/sql_show.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 3 | ||||
-rw-r--r-- | sql/udf_example.c | 2 |
17 files changed, 67 insertions, 91 deletions
diff --git a/sql/field.cc b/sql/field.cc index 56d60ff5b28..287698f5652 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5501,7 +5501,6 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) int Field_date::store(double nr) { longlong tmp; - int error= 0; if (nr >= 19000000000000.0 && nr <= 99991231235959.0) nr=floor(nr/1000000.0); // Timestamp to date if (nr < 0.0 || nr > 99991231.0) @@ -5510,7 +5509,6 @@ int Field_date::store(double nr) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_DATE); - error= 1; } else tmp= (longlong) rint(nr); diff --git a/sql/item.cc b/sql/item.cc index 92cf2df8a4c..8210f4e6caf 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -301,11 +301,10 @@ my_decimal *Item::val_decimal_from_int(my_decimal *decimal_value) my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value) { String *res; - char *end_ptr; + if (!(res= val_str(&str_value))) - return 0; // NULL or EOM + return NULL; - end_ptr= (char*) res->ptr()+ res->length(); if (str2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_BAD_NUM, res->ptr(), res->length(), res->charset(), decimal_value) & E_DEC_BAD_NUM) diff --git a/sql/log.cc b/sql/log.cc index b398cb1e73f..427057a7783 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -5447,6 +5447,22 @@ void sql_perror(const char *message) } +/* + Unfortunately, there seems to be no good way + to restore the original streams upon failure. +*/ +static bool redirect_std_streams(const char *file) +{ + if (freopen(file, "a+", stdout) && freopen(file, "a+", stderr)) + { + setbuf(stderr, NULL); + return FALSE; + } + + return TRUE; +} + + bool flush_error_log() { bool result=0; @@ -5474,11 +5490,7 @@ bool flush_error_log() setbuf(stderr, NULL); my_delete(err_renamed, MYF(0)); my_rename(log_error_file, err_renamed, MYF(0)); - if (freopen(log_error_file,"a+",stdout)) - { - freopen(log_error_file,"a+",stderr); - setbuf(stderr, NULL); - } + redirect_std_streams(log_error_file); if ((fd= my_open(err_temp, O_RDONLY, MYF(0))) >= 0) { @@ -5493,13 +5505,7 @@ bool flush_error_log() result= 1; #else my_rename(log_error_file, err_renamed, MYF(0)); - if (freopen(log_error_file,"a+",stdout)) - { - FILE *reopen; - reopen= freopen(log_error_file,"a+",stderr); - setbuf(stderr, NULL); - } - else + if (redirect_std_streams(log_error_file)) result= 1; #endif mysql_mutex_unlock(&LOCK_error_log); @@ -5551,25 +5557,9 @@ static void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, #endif /* _WIN32 */ -/** - Prints a printf style message to the error log and, under NT, to the - Windows event log. - - This function prints the message into a buffer and then sends that buffer - to other functions to write that message to other logging sources. - - @param event_type Type of event to write (Error, Warning, or Info) - @param format Printf style format of message - @param args va_list list of arguments for the message - - @returns - The function always returns 0. The return value is present in the - signature to be compatible with other logging routines, which could - return an error (e.g. logging to the log tables) -*/ - #ifndef EMBEDDED_LIBRARY -static void print_buffer_to_file(enum loglevel level, const char *buffer) +static void print_buffer_to_file(enum loglevel level, const char *buffer, + size_t length) { time_t skr; struct tm tm_tmp; @@ -5583,7 +5573,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) localtime_r(&skr, &tm_tmp); start=&tm_tmp; - fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n", + fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %.*s\n", start->tm_year % 100, start->tm_mon+1, start->tm_mday, @@ -5592,7 +5582,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) start->tm_sec, (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? "Warning" : "Note"), - buffer); + (int) length, buffer); fflush(stderr); @@ -5600,7 +5590,22 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) DBUG_VOID_RETURN; } +/** + Prints a printf style message to the error log and, under NT, to the + Windows event log. + This function prints the message into a buffer and then sends that buffer + to other functions to write that message to other logging sources. + + @param level The level of the msg significance + @param format Printf style format of message + @param args va_list list of arguments for the message + + @returns + The function always returns 0. The return value is present in the + signature to be compatible with other logging routines, which could + return an error (e.g. logging to the log tables) +*/ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) { char buff[1024]; @@ -5608,7 +5613,7 @@ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) DBUG_ENTER("vprint_msg_to_log"); length= my_vsnprintf(buff, sizeof(buff), format, args); - print_buffer_to_file(level, buff); + print_buffer_to_file(level, buff, length); #ifdef _WIN32 print_buffer_to_nt_eventlog(level, buff, length, sizeof(buff)); @@ -5616,7 +5621,7 @@ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) DBUG_RETURN(0); } -#endif /*EMBEDDED_LIBRARY*/ +#endif /* EMBEDDED_LIBRARY */ void sql_print_error(const char *format, ...) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1a44115d893..ba78687523b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3720,7 +3720,6 @@ static void end_ssl() static int init_server_components() { - FILE *reopen; DBUG_ENTER("init_server_components"); /* We need to call each of these following functions to ensure that @@ -3768,8 +3767,8 @@ static int init_server_components() if (freopen(log_error_file, "a+", stdout)) #endif { - reopen= freopen(log_error_file, "a+", stderr); - setbuf(stderr, NULL); + if (freopen(log_error_file, "a+", stderr)) + setbuf(stderr, NULL); } } } @@ -6984,7 +6983,7 @@ mysqld_get_one_option(int optid, *val= 0; val+= 2; while (*val && my_isspace(mysqld_charset, *val)) - *val++; + val++; if (!*val) { sql_print_error("Bad syntax in replicate-rewrite-db - empty TO db!\n"); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 43934551016..caf28fdd83e 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1535,13 +1535,11 @@ bool partition_info::set_up_charset_field_preps() i= 0; while ((field= *(ptr++))) { - CHARSET_INFO *cs; uchar *field_buf; LINT_INIT(field_buf); if (!field_is_partition_charset(field)) continue; - cs= ((Field_str*)field)->charset(); size= field->pack_length(); if (!(field_buf= (uchar*) sql_calloc(size))) goto error; diff --git a/sql/slave.cc b/sql/slave.cc index d41d0479dde..6caa04359a8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3275,11 +3275,8 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, mysql_mutex_lock(&rli->data_lock); if (rli->slave_skip_counter) { - char *pos; - pos= strmake(saved_log_name, rli->group_relay_log_name, FN_REFLEN - 1); - pos= '\0'; - pos= strmake(saved_master_log_name, rli->group_master_log_name, FN_REFLEN - 1); - pos= '\0'; + strmake(saved_log_name, rli->group_relay_log_name, FN_REFLEN - 1); + strmake(saved_master_log_name, rli->group_master_log_name, FN_REFLEN - 1); saved_log_pos= rli->group_relay_log_pos; saved_master_log_pos= rli->group_master_log_pos; saved_skip= rli->slave_skip_counter; diff --git a/sql/spatial.cc b/sql/spatial.cc index f96196cb836..f1dd0e6cebd 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -142,11 +142,10 @@ Geometry *Geometry::construct(Geometry_buffer *buffer, { uint32 geom_type; Geometry *result; - char byte_order; if (data_len < SRID_SIZE + WKB_HEADER_SIZE) // < 4 + (1 + 4) return NULL; - byte_order= data[SRID_SIZE]; + /* + 1 to skip the byte order (stored in position SRID_SIZE). */ geom_type= uint4korr(data + SRID_SIZE + 1); if (!(result= create_by_typeid(buffer, (int) geom_type))) return NULL; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 074f1047d67..7e004c05f8e 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5831,7 +5831,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list) { int result; String wrong_users; - ulong sql_mode; LEX_USER *user_name, *tmp_user_name; List_iterator <LEX_USER> user_list(list); TABLE_LIST tables[GRANT_TABLES]; @@ -5880,7 +5879,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list) } some_users_created= TRUE; - sql_mode= thd->variables.sql_mode; if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0)) { append_user(&wrong_users, user_name); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index f746edef83f..2b1ce66e509 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5820,7 +5820,7 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) DBUG_ENTER("update_field_dependencies"); if (thd->mark_used_columns != MARK_COLUMNS_NONE) { - MY_BITMAP *current_bitmap, *other_bitmap; + MY_BITMAP *bitmap; /* We always want to register the used keys, as the column bitmap may have @@ -5831,15 +5831,9 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) table->merge_keys.merge(field->part_of_key); if (thd->mark_used_columns == MARK_COLUMNS_READ) - { - current_bitmap= table->read_set; - other_bitmap= table->write_set; - } + bitmap= table->read_set; else - { - current_bitmap= table->write_set; - other_bitmap= table->read_set; - } + bitmap= table->write_set; /* The test-and-set mechanism in the bitmap is not reliable during @@ -5848,7 +5842,7 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) only those columns that are used in the SET clause. I.e they are being set here. See multi_update::prepare() */ - if (bitmap_fast_test_and_set(current_bitmap, field->field_index)) + if (bitmap_fast_test_and_set(bitmap, field->field_index)) { if (thd->mark_used_columns == MARK_COLUMNS_WRITE) { diff --git a/sql/sql_load.cc b/sql/sql_load.cc index b2a816a69dd..d367c1c4fde 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -175,6 +175,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool is_fifo=0; #ifndef EMBEDDED_LIBRARY LOAD_FILE_INFO lf_info; + THD::killed_state killed_status= THD::NOT_KILLED; #endif char *db = table_list->db; // This is never null /* @@ -186,7 +187,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ulong skip_lines= ex->skip_lines; bool transactional_table; bool is_concurrent; - THD::killed_state killed_status= THD::NOT_KILLED; DBUG_ENTER("mysql_load"); #ifdef EMBEDDED_LIBRARY @@ -510,7 +510,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, error=1; thd->killed= THD::KILL_QUERY; };); - killed_status= (error == 0)? THD::NOT_KILLED : thd->killed; + +#ifndef EMBEDDED_LIBRARY + killed_status= (error == 0) ? THD::NOT_KILLED : thd->killed; +#endif + /* We must invalidate the table in query cache before binlog writing and ha_autocommit_... @@ -553,7 +557,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if (lf_info.wrote_create_file) { int errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); - + /* since there is already an error, the possible error of writing binary log will be ignored */ if (thd->transaction.stmt.modified_non_trans_table) @@ -767,12 +771,9 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, List_iterator_fast<Item> it(fields_vars); Item_field *sql_field; TABLE *table= table_list->table; - ulonglong id; bool err; DBUG_ENTER("read_fixed_length"); - id= 0; - while (!read_info.read_fixed_length()) { if (thd->killed) @@ -901,12 +902,10 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, Item *item; TABLE *table= table_list->table; uint enclosed_length; - ulonglong id; bool err; DBUG_ENTER("read_sep_field"); enclosed_length=enclosed.length(); - id= 0; for (;;it.rewind()) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 28a867cfcd8..d31723c36e3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1387,7 +1387,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { STATUS_VAR current_global_status_var; ulong uptime; - uint length; + uint length __attribute__((unused)); ulonglong queries_per_second1000; char buff[250]; uint buff_len= sizeof(buff); @@ -1400,7 +1400,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, else queries_per_second1000= thd->query_id * LL(1000) / uptime; - length= my_snprintf((char*) buff, buff_len - 1, + length= my_snprintf(buff, buff_len - 1, "Uptime: %lu Threads: %d Questions: %lu " "Slow queries: %lu Opens: %lu Flush tables: %lu " "Open tables: %u Queries per second avg: %u.%u", @@ -1525,7 +1525,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, #endif if (MYSQL_QUERY_DONE_ENABLED() || MYSQL_COMMAND_DONE_ENABLED()) { - int res; + int res __attribute__((unused)); res= (int) thd->is_error(); if (command == COM_QUERY) { @@ -5826,7 +5826,7 @@ void mysql_init_multi_delete(LEX *lex) void mysql_parse(THD *thd, const char *inBuf, uint length, Parser_state *parser_state) { - int error; + int error __attribute__((unused)); DBUG_ENTER("mysql_parse"); DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on();); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index d7ff753dfd0..49f972f35ca 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1071,7 +1071,6 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, partition_info *part_info= table->part_info; bool result= TRUE; int error; - const char *save_where; LEX *old_lex= thd->lex; LEX lex; uint8 saved_full_group_by_flag; @@ -1083,7 +1082,6 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, func_expr->walk(&Item::change_context_processor, 0, (uchar*) &lex.select_lex.context); - save_where= thd->where; thd->where= "partition function"; /* In execution we must avoid the use of thd->change_item_tree since diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 5f994c09d6d..d528dc64b5e 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1394,12 +1394,9 @@ bool change_master(THD* thd, Master_info* mi) /* Before processing the command, save the previous state. */ - char *pos; - pos= strmake(saved_host, mi->host, HOSTNAME_LENGTH); - pos= '\0'; + strmake(saved_host, mi->host, HOSTNAME_LENGTH); saved_port= mi->port; - pos= strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1); - pos= '\0'; + strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1); saved_log_pos= mi->master_log_pos; /* diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a8ae5832a2a..c13d05377e0 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4112,7 +4112,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, uchar *pos; char tmp[MAX_FIELD_WIDTH]; String type(tmp,sizeof(tmp), system_charset_info); - char *end; DEBUG_SYNC(thd, "get_schema_column"); @@ -4133,7 +4132,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, field->field_name) & COL_ACLS; if (!tables->schema_table && !col_access) continue; - end= tmp; + char *end= tmp; for (uint bitnr=0; col_access ; col_access>>=1,bitnr++) { if (col_access & 1) @@ -4169,7 +4168,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, table->field[15]->store((const char*) pos, strlen((const char*) pos), cs); - end= tmp; if (field->unireg_check == Field::NEXT_NUMBER) table->field[16]->store(STRING_WITH_LEN("auto_increment"), cs); if (timestamp_field == field && diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d28b4859ab5..4471c336188 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6499,7 +6499,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, uint index_add_count= 0; uint *index_add_buffer= NULL; uint candidate_key_count= 0; - bool committed= 0; bool no_pk; DBUG_ENTER("mysql_alter_table"); @@ -7329,7 +7328,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, DBUG_PRINT("info", ("Committing before unlocking table")); if (trans_commit_stmt(thd) || trans_commit_implicit(thd)) goto err_new_table_cleanup; - committed= 1; } /*end of if (! new_table) for add/drop index*/ diff --git a/sql/table.cc b/sql/table.cc index a58623f0036..df94e70b558 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -541,7 +541,7 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) int error, table_type; bool error_given; File file; - uchar head[64], *disk_buff; + uchar head[64]; char path[FN_REFLEN]; MEM_ROOT **root_ptr, *old_root; DBUG_ENTER("open_table_def"); @@ -550,7 +550,6 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) error= 1; error_given= 0; - disk_buff= NULL; strxmov(path, share->normalized_path.str, reg_ext, NullS); if ((file= mysql_file_open(key_file_frm, diff --git a/sql/udf_example.c b/sql/udf_example.c index 284689d329f..c1dbdd069a9 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -1072,7 +1072,7 @@ char *myfunc_argument_name(UDF_INIT *initid __attribute__((unused)), { if (!args->attributes[0]) { - null_value= 0; + *null_value= 1; return 0; } (*length)--; /* space for ending \0 (for debugging purposes) */ |