1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge from 5.0-bugteam for 43414

This commit is contained in:
Staale Smedseng
2009-06-09 18:44:26 +02:00
13 changed files with 61 additions and 60 deletions

View File

@@ -1165,7 +1165,7 @@ bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len,
if (unsigned_flag) if (unsigned_flag)
{ {
if (((ulonglong) *rnd > unsigned_max) && (*rnd= (longlong) unsigned_max) || if ((((ulonglong) *rnd > unsigned_max) && (*rnd= (longlong) unsigned_max)) ||
error == MY_ERRNO_ERANGE) error == MY_ERRNO_ERANGE)
{ {
goto out_of_range; goto out_of_range;
@@ -1350,7 +1350,7 @@ void Field::copy_from_tmp(int row_offset)
if (null_ptr) if (null_ptr)
{ {
*null_ptr= (uchar) ((null_ptr[0] & (uchar) ~(uint) null_bit) | *null_ptr= (uchar) ((null_ptr[0] & (uchar) ~(uint) null_bit) |
null_ptr[row_offset] & (uchar) null_bit); (null_ptr[row_offset] & (uchar) null_bit));
} }
} }
@@ -4081,8 +4081,8 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
int error; int error;
char *end; char *end;
double nr= my_strntod(cs,(char*) from,len,&end,&error); double nr= my_strntod(cs,(char*) from,len,&end,&error);
if (error || (!len || (uint) (end-from) != len && if (error || (!len || ((uint) (end-from) != len &&
table->in_use->count_cuted_fields)) table->in_use->count_cuted_fields)))
{ {
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
(error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1);
@@ -4343,8 +4343,8 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
int error; int error;
char *end; char *end;
double nr= my_strntod(cs,(char*) from, len, &end, &error); double nr= my_strntod(cs,(char*) from, len, &end, &error);
if (error || (!len || (uint) (end-from) != len && if (error || (!len || ((uint) (end-from) != len &&
table->in_use->count_cuted_fields)) table->in_use->count_cuted_fields)))
{ {
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
(error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1);
@@ -5196,7 +5196,7 @@ int Field_time::store(longlong nr, bool unsigned_val)
MYSQL_TIMESTAMP_TIME, 1); MYSQL_TIMESTAMP_TIME, 1);
error= 1; error= 1;
} }
else if (nr > (longlong) TIME_MAX_VALUE || nr < 0 && unsigned_val) else if (nr > (longlong) TIME_MAX_VALUE || (nr < 0 && unsigned_val))
{ {
tmp= TIME_MAX_VALUE; tmp= TIME_MAX_VALUE;
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -5361,7 +5361,7 @@ int Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
int error; int error;
longlong nr= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error); longlong nr= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error);
if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155 || if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155 ||
error == MY_ERRNO_ERANGE) error == MY_ERRNO_ERANGE)
{ {
*ptr=0; *ptr=0;
@@ -5405,7 +5405,7 @@ int Field_year::store(double nr)
int Field_year::store(longlong nr, bool unsigned_val) int Field_year::store(longlong nr, bool unsigned_val)
{ {
ASSERT_COLUMN_MARKED_FOR_WRITE; ASSERT_COLUMN_MARKED_FOR_WRITE;
if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155) if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155)
{ {
*ptr= 0; *ptr= 0;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
@@ -8833,7 +8833,7 @@ bool Field_num::eq_def(Field *field)
Field_num *from_num= (Field_num*) field; Field_num *from_num= (Field_num*) field;
if (unsigned_flag != from_num->unsigned_flag || if (unsigned_flag != from_num->unsigned_flag ||
zerofill && !from_num->zerofill && !zero_pack() || (zerofill && !from_num->zerofill && !zero_pack()) ||
dec != from_num->dec) dec != from_num->dec)
return 0; return 0;
return 1; return 1;
@@ -9306,7 +9306,7 @@ Field_bit::unpack(uchar *to, const uchar *from, uint param_data,
and slave have the same sizes, then use the old unpack() method. and slave have the same sizes, then use the old unpack() method.
*/ */
if (param_data == 0 || if (param_data == 0 ||
(from_bit_len == bit_len) && (from_len == bytes_in_rec)) ((from_bit_len == bit_len) && (from_len == bytes_in_rec)))
{ {
if (bit_len > 0) if (bit_len > 0)
{ {

View File

@@ -99,7 +99,7 @@ static void do_field_to_null_str(Copy_field *copy)
static void do_outer_field_to_null_str(Copy_field *copy) static void do_outer_field_to_null_str(Copy_field *copy)
{ {
if (*copy->null_row || if (*copy->null_row ||
copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)) (copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)))
{ {
bzero(copy->to_ptr,copy->from_length); bzero(copy->to_ptr,copy->from_length);
copy->to_null_ptr[0]=1; // Always bit 1 copy->to_null_ptr[0]=1; // Always bit 1
@@ -212,7 +212,7 @@ static void do_copy_null(Copy_field *copy)
static void do_outer_field_null(Copy_field *copy) static void do_outer_field_null(Copy_field *copy)
{ {
if (*copy->null_row || if (*copy->null_row ||
copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)) (copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)))
{ {
*copy->to_null_ptr|=copy->to_bit; *copy->to_null_ptr|=copy->to_bit;
copy->to_field->reset(); copy->to_field->reset();
@@ -665,9 +665,9 @@ Copy_field::get_copy_func(Field *to,Field *from)
*/ */
if (to->real_type() != from->real_type() || if (to->real_type() != from->real_type() ||
!compatible_db_low_byte_first || !compatible_db_low_byte_first ||
((to->table->in_use->variables.sql_mode & (((to->table->in_use->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) && (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) &&
to->type() == MYSQL_TYPE_DATE || to->type() == MYSQL_TYPE_DATE) ||
to->type() == MYSQL_TYPE_DATETIME)) to->type() == MYSQL_TYPE_DATETIME))
{ {
if (from->real_type() == MYSQL_TYPE_ENUM || if (from->real_type() == MYSQL_TYPE_ENUM ||
@@ -770,8 +770,8 @@ int field_conv(Field *to,Field *from)
to->table->s->db_low_byte_first == from->table->s->db_low_byte_first && to->table->s->db_low_byte_first == from->table->s->db_low_byte_first &&
(!(to->table->in_use->variables.sql_mode & (!(to->table->in_use->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) || (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) ||
to->type() != MYSQL_TYPE_DATE && (to->type() != MYSQL_TYPE_DATE &&
to->type() != MYSQL_TYPE_DATETIME) && to->type() != MYSQL_TYPE_DATETIME)) &&
(from->real_type() != MYSQL_TYPE_VARCHAR || (from->real_type() != MYSQL_TYPE_VARCHAR ||
((Field_varstring*)from)->length_bytes == ((Field_varstring*)from)->length_bytes ==
((Field_varstring*)to)->length_bytes)) ((Field_varstring*)to)->length_bytes))

View File

@@ -75,7 +75,7 @@ bool Gis_read_stream::get_next_number(double *d)
skip_space(); skip_space();
if ((m_cur >= m_limit) || if ((m_cur >= m_limit) ||
(*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+') ((*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+'))
{ {
set_error_msg("Numeric constant expected"); set_error_msg("Numeric constant expected");
return 1; return 1;

View File

@@ -2291,8 +2291,8 @@ int handler::update_auto_increment()
DBUG_ASSERT(next_insert_id >= auto_inc_interval_for_cur_row.minimum()); DBUG_ASSERT(next_insert_id >= auto_inc_interval_for_cur_row.minimum());
if ((nr= table->next_number_field->val_int()) != 0 || if ((nr= table->next_number_field->val_int()) != 0 ||
table->auto_increment_field_not_null && (table->auto_increment_field_not_null &&
thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO))
{ {
/* /*
Update next_insert_id if we had already generated a value in this Update next_insert_id if we had already generated a value in this

View File

@@ -1484,8 +1484,8 @@ longlong Item_func_truth::val_int()
bool Item_in_optimizer::fix_left(THD *thd, Item **ref) bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
{ {
if (!args[0]->fixed && args[0]->fix_fields(thd, args) || if ((!args[0]->fixed && args[0]->fix_fields(thd, args)) ||
!cache && !(cache= Item_cache::get_cache(args[0]))) (!cache && !(cache= Item_cache::get_cache(args[0]))))
return 1; return 1;
cache->setup(args[0]); cache->setup(args[0]);
@@ -2996,8 +2996,8 @@ int cmp_longlong(void *cmp_arg,
One of the args is unsigned and is too big to fit into the One of the args is unsigned and is too big to fit into the
positive signed range. Report no match. positive signed range. Report no match.
*/ */
if (a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX || if ((a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX) ||
b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX) (b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX))
return a->unsigned_flag ? 1 : -1; return a->unsigned_flag ? 1 : -1;
/* /*
Although the signedness differs both args can fit into the signed Although the signedness differs both args can fit into the signed

View File

@@ -4463,8 +4463,8 @@ int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions,
update(); update();
if (result_type() == STRING_RESULT || if (result_type() == STRING_RESULT ||
result_type() == REAL_RESULT && (result_type() == REAL_RESULT &&
field->result_type() == STRING_RESULT) field->result_type() == STRING_RESULT))
{ {
String *result; String *result;
CHARSET_INFO *cs= collation.collation; CHARSET_INFO *cs= collation.collation;

View File

@@ -1314,8 +1314,8 @@ Item_in_subselect::row_value_transformer(JOIN *join)
Item *item_having_part2= 0; Item *item_having_part2= 0;
for (uint i= 0; i < cols_num; i++) for (uint i= 0; i < cols_num; i++)
{ {
DBUG_ASSERT(left_expr->fixed && DBUG_ASSERT((left_expr->fixed &&
select_lex->ref_pointer_array[i]->fixed || select_lex->ref_pointer_array[i]->fixed) ||
(select_lex->ref_pointer_array[i]->type() == REF_ITEM && (select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() == ((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
Item_ref::OUTER_REF)); Item_ref::OUTER_REF));
@@ -1392,8 +1392,8 @@ Item_in_subselect::row_value_transformer(JOIN *join)
for (uint i= 0; i < cols_num; i++) for (uint i= 0; i < cols_num; i++)
{ {
Item *item, *item_isnull; Item *item, *item_isnull;
DBUG_ASSERT(left_expr->fixed && DBUG_ASSERT((left_expr->fixed &&
select_lex->ref_pointer_array[i]->fixed || select_lex->ref_pointer_array[i]->fixed) ||
(select_lex->ref_pointer_array[i]->type() == REF_ITEM && (select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() == ((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
Item_ref::OUTER_REF)); Item_ref::OUTER_REF));

View File

@@ -2640,8 +2640,8 @@ bool Item_sum_count_distinct::setup(THD *thd)
enum enum_field_types f_type= f->type(); enum enum_field_types f_type= f->type();
tree_key_length+= f->pack_length(); tree_key_length+= f->pack_length();
if ((f_type == MYSQL_TYPE_VARCHAR) || if ((f_type == MYSQL_TYPE_VARCHAR) ||
!f->binary() && (f_type == MYSQL_TYPE_STRING || (!f->binary() && (f_type == MYSQL_TYPE_STRING ||
f_type == MYSQL_TYPE_VAR_STRING)) f_type == MYSQL_TYPE_VAR_STRING)))
{ {
all_binary= FALSE; all_binary= FALSE;
break; break;

View File

@@ -446,7 +446,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
strict_week_number= (*ptr=='V' || *ptr=='v'); strict_week_number= (*ptr=='V' || *ptr=='v');
tmp= (char*) val + min(val_len, 2); tmp= (char*) val + min(val_len, 2);
if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 || if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
strict_week_number && !week_number || (strict_week_number && !week_number) ||
week_number > 53) week_number > 53)
goto err; goto err;
val= tmp; val= tmp;
@@ -542,10 +542,10 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
%V,%v require %X,%x resprectively, %V,%v require %X,%x resprectively,
%U,%u should be used with %Y and not %X or %x %U,%u should be used with %Y and not %X or %x
*/ */
if (strict_week_number && if ((strict_week_number &&
(strict_week_number_year < 0 || (strict_week_number_year < 0 ||
strict_week_number_year_type != sunday_first_n_first_week_non_iso) || strict_week_number_year_type != sunday_first_n_first_week_non_iso)) ||
!strict_week_number && strict_week_number_year >= 0) (!strict_week_number && strict_week_number_year >= 0))
goto err; goto err;
/* Number of days since year 0 till 1st Jan of this year */ /* Number of days since year 0 till 1st Jan of this year */

View File

@@ -791,8 +791,8 @@ Log_event::do_shall_skip(Relay_log_info *rli)
(ulong) server_id, (ulong) ::server_id, (ulong) server_id, (ulong) ::server_id,
rli->replicate_same_server_id, rli->replicate_same_server_id,
rli->slave_skip_counter)); rli->slave_skip_counter));
if (server_id == ::server_id && !rli->replicate_same_server_id || if ((server_id == ::server_id && !rli->replicate_same_server_id) ||
rli->slave_skip_counter == 1 && rli->is_in_group()) (rli->slave_skip_counter == 1 && rli->is_in_group()))
return EVENT_SKIP_IGNORE; return EVENT_SKIP_IGNORE;
else if (rli->slave_skip_counter > 0) else if (rli->slave_skip_counter > 0)
return EVENT_SKIP_COUNT; return EVENT_SKIP_COUNT;
@@ -2733,7 +2733,8 @@ void Query_log_event::print_query_header(IO_CACHE* file,
if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db) if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db)
{ {
if ((different_db= memcmp(print_event_info->db, db, db_len + 1))) different_db= memcmp(print_event_info->db, db, db_len + 1);
if (different_db)
memcpy(print_event_info->db, db, db_len + 1); memcpy(print_event_info->db, db, db_len + 1);
if (db[0] && different_db) if (db[0] && different_db)
my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter); my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
@@ -6897,8 +6898,8 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid,
solution, to be able to terminate a started statement in the solution, to be able to terminate a started statement in the
binary log: the extraneous events will be removed in the future. binary log: the extraneous events will be removed in the future.
*/ */
DBUG_ASSERT(tbl_arg && tbl_arg->s && tid != ~0UL || DBUG_ASSERT((tbl_arg && tbl_arg->s && tid != ~0UL) ||
!tbl_arg && !cols && tid == ~0UL); (!tbl_arg && !cols && tid == ~0UL));
if (thd_arg->options & OPTION_NO_FOREIGN_KEY_CHECKS) if (thd_arg->options & OPTION_NO_FOREIGN_KEY_CHECKS)
set_flags(NO_FOREIGN_KEY_CHECKS_F); set_flags(NO_FOREIGN_KEY_CHECKS_F);
@@ -7090,7 +7091,7 @@ int Rows_log_event::do_add_row_data(uchar *row_data, size_t length)
#endif #endif
DBUG_ASSERT(m_rows_buf <= m_rows_cur); DBUG_ASSERT(m_rows_buf <= m_rows_cur);
DBUG_ASSERT(!m_rows_buf || m_rows_end && m_rows_buf < m_rows_end); DBUG_ASSERT(!m_rows_buf || (m_rows_end && m_rows_buf < m_rows_end));
DBUG_ASSERT(m_rows_cur <= m_rows_end); DBUG_ASSERT(m_rows_cur <= m_rows_end);
/* The cast will always work since m_rows_cur <= m_rows_end */ /* The cast will always work since m_rows_cur <= m_rows_end */

View File

@@ -3760,8 +3760,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
DBUG_PRINT("info", ("index_merge scans cost %g", imerge_cost)); DBUG_PRINT("info", ("index_merge scans cost %g", imerge_cost));
if (imerge_too_expensive || (imerge_cost > read_time) || if (imerge_too_expensive || (imerge_cost > read_time) ||
(non_cpk_scan_records+cpk_scan_records >= param->table->file->stats.records) && ((non_cpk_scan_records+cpk_scan_records >= param->table->file->stats.records) &&
read_time != DBL_MAX) read_time != DBL_MAX))
{ {
/* /*
Bail out if it is obvious that both index_merge and ROR-union will be Bail out if it is obvious that both index_merge and ROR-union will be
@@ -7950,7 +7950,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
goto err; goto err;
quick->records= records; quick->records= records;
if (cp_buffer_from_ref(thd, table, ref) && thd->is_fatal_error || if ((cp_buffer_from_ref(thd, table, ref) && thd->is_fatal_error) ||
!(range= new(alloc) QUICK_RANGE())) !(range= new(alloc) QUICK_RANGE()))
goto err; // out of memory goto err; // out of memory
@@ -8826,7 +8826,7 @@ int QUICK_RANGE_SELECT::cmp_prev(QUICK_RANGE *range_arg)
cmp= key_cmp(key_part_info, range_arg->min_key, cmp= key_cmp(key_part_info, range_arg->min_key,
range_arg->min_length); range_arg->min_length);
if (cmp > 0 || cmp == 0 && !(range_arg->flag & NEAR_MIN)) if (cmp > 0 || (cmp == 0 && !(range_arg->flag & NEAR_MIN)))
return 0; return 0;
return 1; // outside of range return 1; // outside of range
} }
@@ -10886,7 +10886,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range()
/* Compare the found key with max_key. */ /* Compare the found key with max_key. */
int cmp_res= key_cmp(index_info->key_part, max_key, int cmp_res= key_cmp(index_info->key_part, max_key,
real_prefix_len + min_max_arg_len); real_prefix_len + min_max_arg_len);
if (!((cur_range->flag & NEAR_MAX) && (cmp_res == -1) || if (!(((cur_range->flag & NEAR_MAX) && (cmp_res == -1)) ||
(cmp_res <= 0))) (cmp_res <= 0)))
{ {
result= HA_ERR_KEY_NOT_FOUND; result= HA_ERR_KEY_NOT_FOUND;
@@ -11004,7 +11004,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
/* Compare the found key with min_key. */ /* Compare the found key with min_key. */
int cmp_res= key_cmp(index_info->key_part, min_key, int cmp_res= key_cmp(index_info->key_part, min_key,
real_prefix_len + min_max_arg_len); real_prefix_len + min_max_arg_len);
if (!((cur_range->flag & NEAR_MIN) && (cmp_res == 1) || if (!(((cur_range->flag & NEAR_MIN) && (cmp_res == 1)) ||
(cmp_res >= 0))) (cmp_res >= 0)))
continue; continue;
} }

View File

@@ -744,8 +744,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
} }
else if (eq_type) else if (eq_type)
{ {
if (!is_null && !cond->val_int() || if ((!is_null && !cond->val_int()) ||
is_null && !test(part->field->is_null())) (is_null && !test(part->field->is_null())))
return 0; // Impossible test return 0; // Impossible test
} }
else if (is_field_part) else if (is_field_part)

View File

@@ -2235,7 +2235,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli)
"the slave_transaction_retries variable.", "the slave_transaction_retries variable.",
slave_trans_retries); slave_trans_retries);
} }
else if (exec_res && !temp_err || else if ((exec_res && !temp_err) ||
(opt_using_transactions && (opt_using_transactions &&
rli->group_relay_log_pos == rli->event_relay_log_pos)) rli->group_relay_log_pos == rli->event_relay_log_pos))
{ {