Commit 4adab48b authored by unknown's avatar unknown

Things missing in last changset

After merge fixes
Don't give duplicate warnings for some ::store() functions


mysql-test/mysql-test-run.sh:
  Added back missing line
mysql-test/r/ps_2myisam.result:
  Update results after removing duplicate warnings from ::store()
mysql-test/r/ps_3innodb.result:
  Update results after removing duplicate warnings from ::store()
mysql-test/r/ps_4heap.result:
  Update results after removing duplicate warnings from ::store()
mysql-test/r/ps_5merge.result:
  Update results after removing duplicate warnings from ::store()
sql/field.cc:
  Don't give duplicate warnings for some ::store() functions
  Before we could get different number of warnings in the test suite for different platforms
sql/field.h:
  Update results after removing duplicate warnings from ::store()
sql/sql_class.h:
  Update results after removing duplicate warnings from ::store()
sql/sql_error.cc:
  Update results after removing duplicate warnings from ::store()
sql/sql_list.h:
  After merge fix
parent 2d435c8a
......@@ -692,6 +692,7 @@ then
fi
MYSQL_CLIENT_TEST="$MYSQL_CLIENT_TEST --no-defaults --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent"
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR --character-sets-dir=$CHARSETSDIR $EXTRA_MYSQLBINLOG_OPT"
MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
......
......@@ -2666,7 +2666,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 127
......@@ -2717,7 +2716,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 -128
......
......@@ -2649,7 +2649,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 127
......@@ -2700,7 +2699,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 -128
......
......@@ -2650,7 +2650,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 127
......@@ -2701,7 +2700,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 -128
......
......@@ -2586,7 +2586,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 127
......@@ -2637,7 +2636,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 -128
......@@ -5597,7 +5595,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 127
......@@ -5648,7 +5645,6 @@ Warning 1264 Out of range value adjusted for column 'c4' at row 1
Warning 1264 Out of range value adjusted for column 'c5' at row 1
Warning 1264 Out of range value adjusted for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 -128
......
......@@ -149,7 +149,7 @@ bool Field::check_int(const char *str, int length, const char *int_end,
truncation.
SYNOPSIS
Field::check_overflow()
Field::warn_if_overflow()
op_result decimal library return code (E_DEC_* see include/decimal.h)
RETURN
......@@ -157,19 +157,22 @@ bool Field::check_int(const char *str, int length, const char *int_end,
0 no error or some other errors except overflow
*/
int Field::check_overflow(int op_result)
int Field::warn_if_overflow(int op_result)
{
if (op_result == E_DEC_OVERFLOW)
{
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
return 1;
}
else if (op_result == E_DEC_TRUNCATED)
if (op_result == E_DEC_TRUNCATED)
{
set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
/* we return 1 only in case of EFL */
/* We return 0 here as this is not a critical issue */
}
return 0;
}
#ifdef NOT_USED
static bool test_if_real(const char *str,int length, CHARSET_INFO *cs)
{
......@@ -507,7 +510,7 @@ longlong Field::convert_decimal2longlong(const my_decimal *val,
i= 0;
*err= 1;
}
else if (check_overflow(my_decimal2int(E_DEC_ERROR &
else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR &
~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED,
val, TRUE, &i)))
{
......@@ -515,7 +518,7 @@ longlong Field::convert_decimal2longlong(const my_decimal *val,
*err= 1;
}
}
else if (check_overflow(my_decimal2int(E_DEC_ERROR &
else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR &
~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED,
val, FALSE, &i)))
{
......@@ -616,7 +619,7 @@ int Field_str::store_decimal(const my_decimal *d)
{
double val;
/* TODO: use decimal2string? */
int err= check_overflow(my_decimal2double(E_DEC_FATAL_ERROR &
int err= warn_if_overflow(my_decimal2double(E_DEC_FATAL_ERROR &
~E_DEC_OVERFLOW, d, &val));
return err | store(val);
}
......@@ -1552,12 +1555,17 @@ void Field_new_decimal::set_value_on_overflow(my_decimal *decimal_value,
checks if decimal_value fits into field size.
if it does, stores the decimal in the buffer using binary format.
Otherwise sets maximal number that can be stored in the field.
RETURN
0 ok
1 error
*/
bool Field_new_decimal::store_value(const my_decimal *decimal_value)
{
DBUG_ENTER("Field_new_decimal::store_value");
my_decimal *dec= (my_decimal*)decimal_value;
int error= 0;
DBUG_ENTER("Field_new_decimal::store_value");
DBUG_EXECUTE("enter", print_decimal(dec););
/* check that we do not try to write negative value in unsigned field */
......@@ -1565,13 +1573,15 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value)
{
DBUG_PRINT("info", ("unsigned overflow"));
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
error= 1;
dec= &decimal_zero;
}
DBUG_PRINT("info", ("saving with precision %d, scale: %d",
(int)field_length, (int)decimals()));
DBUG_EXECUTE("info", print_decimal(dec););
if (check_overflow(my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
if (warn_if_overflow(my_decimal2binary(E_DEC_FATAL_ERROR &
~E_DEC_OVERFLOW,
dec, ptr,
field_length,
decimals())))
......@@ -1584,20 +1594,20 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value)
DBUG_RETURN(1);
}
DBUG_EXECUTE("info", print_decimal_buff(dec, ptr, bin_size););
DBUG_RETURN(0);
DBUG_RETURN(error);
}
int Field_new_decimal::store(const char *from, uint length,
CHARSET_INFO *charset)
{
DBUG_ENTER("Field_new_decimal::store(char*)");
int err;
my_decimal decimal_value;
DBUG_ENTER("Field_new_decimal::store(char*)");
switch ((err= str2my_decimal(E_DEC_FATAL_ERROR &
~(E_DEC_OVERFLOW | E_DEC_BAD_NUM),
from, length, charset, &decimal_value)))
{
from, length, charset, &decimal_value))) {
case E_DEC_TRUNCATED:
set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
break;
......@@ -1624,8 +1634,10 @@ int Field_new_decimal::store(const char *from, uint length,
int Field_new_decimal::store(double nr)
{
my_decimal decimal_value;
int err= double2my_decimal(E_DEC_FATAL_ERROR &
~E_DEC_OVERFLOW, nr,
int err;
DBUG_ENTER("Field_new_decimal::store(double)");
err= double2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, nr,
&decimal_value);
/*
TODO: fix following when double2my_decimal when double2decimal
......@@ -1638,10 +1650,18 @@ int Field_new_decimal::store(double nr)
if (nr2 != nr)
err= E_DEC_TRUNCATED;
}
if (err)
{
if (check_overflow(err))
set_value_on_overflow(&decimal_value, decimal_value.sign());
store_value(&decimal_value);
return err;
/* Only issue a warning if store_value doesn't issue an warning */
table->in_use->got_warning= 0;
}
if (store_value(&decimal_value))
err= 1;
else if (err && !table->in_use->got_warning)
err= warn_if_overflow(err);
DBUG_RETURN(err);
}
......@@ -1649,10 +1669,19 @@ int Field_new_decimal::store(longlong nr)
{
my_decimal decimal_value;
int err;
if ((err= check_overflow(int2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
nr, unsigned_flag, &decimal_value))))
if ((err= int2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
nr, unsigned_flag, &decimal_value)))
{
if (check_overflow(err))
set_value_on_overflow(&decimal_value, decimal_value.sign());
store_value(&decimal_value);
/* Only issue a warning if store_value doesn't issue an warning */
table->in_use->got_warning= 0;
}
if (store_value(&decimal_value))
err= 1;
else if (err && !table->in_use->got_warning)
err= warn_if_overflow(err);
return err;
}
......@@ -1728,6 +1757,7 @@ void Field_new_decimal::sql_type(String &str) const
add_zerofill_and_unsigned(str);
}
/****************************************************************************
** tiny int
****************************************************************************/
......
......@@ -290,7 +290,11 @@ public:
int cuted_increment);
void set_datetime_warning(const uint level, const uint code,
double nr, timestamp_type ts_type);
int check_overflow(int op_result);
inline bool check_overflow(int op_result)
{
return (op_result == E_DEC_OVERFLOW);
}
int warn_if_overflow(int op_result);
virtual field_cast_enum field_cast_type()= 0;
bool field_cast_compatible(field_cast_enum type);
/* maximum possible display length */
......
......@@ -1027,6 +1027,7 @@ public:
bool charset_is_system_charset, charset_is_collation_connection;
bool slow_command;
bool no_trans_update, abort_on_warning;
bool got_warning; /* Set on call to push_warning() */
longlong row_count_func; /* For the ROW_COUNT() function */
sp_rcontext *spcont; // SP runtime context
sp_cache *sp_proc_cache;
......
......@@ -108,6 +108,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
if (thd->query_id != thd->warn_id)
mysql_reset_errors(thd);
thd->got_warning= 1;
if (thd->spcont &&
thd->spcont->find_handler(code,
((int) level >=
......
......@@ -158,15 +158,6 @@ public:
last= &first;
return tmp->info;
}
inline void concat(base_list *list)
{
if (!list->is_empty())
{
*last= list->first;
last= list->last;
elements+= list->elements;
}
}
inline void disjoin(base_list *list)
{
list_node **prev= &first;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment