Commit 58613a85 authored by unknown's avatar unknown

Support of warnings for all DML statements (Insert, Update and Alter)

Fix LOAD DATA INFILE warnings to have a better meanigful messages
Fix to make the mysql command line to automatically show the warnings count for all basic commands
parent 1f4309fa
......@@ -277,7 +277,8 @@
#define ER_CUT_VALUE_GROUP_CONCAT 1258
#define ER_WARN_TOO_FEW_RECORDS 1259
#define ER_WARN_TOO_MANY_RECORDS 1260
#define ER_WARN_DATA_TRUNCATED 1261
#define ER_WARN_NULL_TO_NOTNULL 1262
#define ER_ERROR_MESSAGES 263
#define ER_WARN_NULL_TO_NOTNULL 1261
#define ER_WARN_DATA_OUT_OF_RANGE 1262
#define ER_WARN_DATA_TRUNCATED 1263
#define ER_ERROR_MESSAGES 264
......@@ -367,7 +367,7 @@ void Field_decimal::overflow(bool negative)
uint len=field_length;
char *to=ptr, filler= '9';
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
if (negative)
{
if (!unsigned_flag)
......@@ -477,7 +477,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
from++;
if (from == end)
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
is_cuted_fields_incr=1;
}
else if (*from == '+' || *from == '-') // Found some sign ?
......@@ -553,7 +553,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
for (;from != end && my_isspace(&my_charset_bin, *from); from++) ;
if (from != end) // If still something left, warn
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
is_cuted_fields_incr=1;
}
}
......@@ -731,7 +731,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
if (tmp_char != '0') // Losing a non zero digit ?
{
if (!is_cuted_fields_incr)
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
return 0;
}
continue;
......@@ -748,7 +748,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
if (tmp_char != '0') // Losing a non zero digit ?
{
if (!is_cuted_fields_incr)
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
return 0;
}
continue;
......@@ -966,18 +966,18 @@ int Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
if (tmp < 0)
{
tmp=0; /* purecov: inspected */
current_thd->cuted_fields++; /* purecov: inspected */
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (tmp > 255)
{
tmp= 255;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len,end,cs))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error= 1;
}
}
......@@ -986,18 +986,18 @@ int Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
if (tmp < -128)
{
tmp= -128;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (tmp >= 128)
{
tmp= 127;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len,end,cs))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error= 1;
}
}
......@@ -1015,13 +1015,13 @@ int Field_tiny::store(double nr)
if (nr < 0.0)
{
*ptr=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > 255.0)
{
*ptr=(char) 255;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1032,13 +1032,13 @@ int Field_tiny::store(double nr)
if (nr < -128.0)
{
*ptr= (char) -128;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > 127.0)
{
*ptr=127;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1055,13 +1055,13 @@ int Field_tiny::store(longlong nr)
if (nr < 0L)
{
*ptr=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > 255L)
{
*ptr= (char) 255;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1072,13 +1072,13 @@ int Field_tiny::store(longlong nr)
if (nr < -128L)
{
*ptr= (char) -128;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > 127L)
{
*ptr=127;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1168,18 +1168,18 @@ int Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
if (tmp < 0)
{
tmp=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (tmp > (uint16) ~0)
{
tmp=(uint16) ~0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len,end,cs))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error= 1;
}
}
......@@ -1188,18 +1188,18 @@ int Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
if (tmp < INT_MIN16)
{
tmp= INT_MIN16;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (tmp > INT_MAX16)
{
tmp=INT_MAX16;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len,end,cs))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error= 1;
}
}
......@@ -1225,13 +1225,13 @@ int Field_short::store(double nr)
if (nr < 0)
{
res=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > (double) (uint16) ~0)
{
res=(int16) (uint16) ~0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1242,13 +1242,13 @@ int Field_short::store(double nr)
if (nr < (double) INT_MIN16)
{
res=INT_MIN16;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > (double) INT_MAX16)
{
res=INT_MAX16;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1274,13 +1274,13 @@ int Field_short::store(longlong nr)
if (nr < 0L)
{
res=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > (longlong) (uint16) ~0)
{
res=(int16) (uint16) ~0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1291,13 +1291,13 @@ int Field_short::store(longlong nr)
if (nr < INT_MIN16)
{
res=INT_MIN16;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > INT_MAX16)
{
res=INT_MAX16;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1442,18 +1442,18 @@ int Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
if (tmp < 0)
{
tmp=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (tmp >= (long) (1L << 24))
{
tmp=(long) (1L << 24)-1L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len,end,cs))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error= 1;
}
}
......@@ -1462,18 +1462,18 @@ int Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
if (tmp < INT_MIN24)
{
tmp= INT_MIN24;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (tmp > INT_MAX24)
{
tmp=INT_MAX24;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len,end,cs))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error= 1;
}
}
......@@ -1492,14 +1492,14 @@ int Field_medium::store(double nr)
if (nr < 0)
{
int3store(ptr,0);
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr >= (double) (long) (1L << 24))
{
uint32 tmp=(uint32) (1L << 24)-1L;
int3store(ptr,tmp);
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1511,14 +1511,14 @@ int Field_medium::store(double nr)
{
long tmp=(long) INT_MIN24;
int3store(ptr,tmp);
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > (double) INT_MAX24)
{
long tmp=(long) INT_MAX24;
int3store(ptr,tmp);
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1535,14 +1535,14 @@ int Field_medium::store(longlong nr)
if (nr < 0L)
{
int3store(ptr,0);
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr >= (longlong) (long) (1L << 24))
{
long tmp=(long) (1L << 24)-1L;;
int3store(ptr,tmp);
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1554,14 +1554,14 @@ int Field_medium::store(longlong nr)
{
long tmp=(long) INT_MIN24;
int3store(ptr,tmp);
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > (longlong) INT_MAX24)
{
long tmp=(long) INT_MAX24;
int3store(ptr,tmp);
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1676,7 +1676,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
(from+len != end && current_thd->count_cuted_fields &&
!test_if_int(from,len,end,cs)))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error= 1;
}
#ifdef WORDS_BIGENDIAN
......@@ -1701,13 +1701,13 @@ int Field_long::store(double nr)
if (nr < 0)
{
res=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > (double) (ulong) ~0L)
{
res=(int32) (uint32) ~0L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1718,13 +1718,13 @@ int Field_long::store(double nr)
if (nr < (double) INT_MIN32)
{
res=(int32) INT_MIN32;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > (double) INT_MAX32)
{
res=(int32) INT_MAX32;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1751,13 +1751,13 @@ int Field_long::store(longlong nr)
if (nr < 0)
{
res=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr >= (LL(1) << 32))
{
res=(int32) (uint32) ~0L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1768,13 +1768,13 @@ int Field_long::store(longlong nr)
if (nr < (longlong) INT_MIN32)
{
res=(int32) INT_MIN32;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > (longlong) INT_MAX32)
{
res=(int32) INT_MAX32;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1934,7 +1934,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
(from+len != end && current_thd->count_cuted_fields &&
!test_if_int(from,len,end,cs)))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error= 1;
}
#ifdef WORDS_BIGENDIAN
......@@ -1959,13 +1959,13 @@ int Field_longlong::store(double nr)
if (nr < 0)
{
res=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr >= (double) ~ (ulonglong) 0)
{
res= ~(longlong) 0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -1976,13 +1976,13 @@ int Field_longlong::store(double nr)
if (nr <= (double) LONGLONG_MIN)
{
res=(longlong) LONGLONG_MIN;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr >= (double) LONGLONG_MAX)
{
res=(longlong) LONGLONG_MAX;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -2146,7 +2146,7 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
Field_float::store(my_strntod(cs,(char*) from,len,(char**)NULL,&err));
if (err || current_thd->count_cuted_fields && !test_if_real(from,len,cs))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
return 1;
}
return (err) ? 1 : 0;
......@@ -2161,20 +2161,20 @@ int Field_float::store(double nr)
nr=floor(nr*log_10[dec]+0.5)/log_10[dec]; // To fixed point
if (unsigned_flag && nr < 0)
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
nr=0;
error= 1;
}
if (nr < -FLT_MAX)
{
j= -FLT_MAX;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr > FLT_MAX)
{
j=FLT_MAX;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -2197,7 +2197,7 @@ int Field_float::store(longlong nr)
float j= (float) nr;
if (unsigned_flag && j < 0)
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
j=0;
error= 1;
}
......@@ -2419,12 +2419,12 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
double j= my_strntod(cs,(char*) from,len,(char**)0,&err);
if (err || current_thd->count_cuted_fields && !test_if_real(from,len,cs))
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
err= 1;
}
if (unsigned_flag && j < 0)
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
j=0;
err= 1;
}
......@@ -2447,7 +2447,7 @@ int Field_double::store(double nr)
nr=floor(nr*log_10[dec]+0.5)/log_10[dec]; // To fixed point
if (unsigned_flag && nr < 0)
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
nr=0;
error= 1;
}
......@@ -2469,7 +2469,7 @@ int Field_double::store(longlong nr)
int error= 0;
if (unsigned_flag && j < 0)
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
j=0;
}
......@@ -2710,7 +2710,7 @@ int Field_timestamp::store(double nr)
if (nr < 0 || nr > 99991231235959.0)
{
nr= 0; // Avoid overflow on buff
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
error|= Field_timestamp::store((longlong) rint(nr));
......@@ -2726,6 +2726,7 @@ int Field_timestamp::store(double nr)
static longlong fix_datetime(longlong nr)
{
current_thd->last_cuted_field= 0;
if (nr == LL(0) || nr >= LL(10000101000000))
return nr; // Normal datetime >= Year 1000
if (nr < 101)
......@@ -2750,7 +2751,7 @@ static longlong fix_datetime(longlong nr)
return nr+LL(19000000000000); // YYMMDDHHMMSS, 1970-1999
err:
current_thd->cuted_fields++;
current_thd->last_cuted_field= 1;
return LL(0);
}
......@@ -2783,6 +2784,8 @@ int Field_timestamp::store(longlong nr)
else
#endif
longstore(ptr,(uint32) timestamp);
if (current_thd->last_cuted_field)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
return 0;
}
......@@ -3026,6 +3029,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp=0L;
error= 1;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
else
{
......@@ -3035,7 +3039,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
if (tmp > 8385959)
{
tmp=8385959;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
}
......@@ -3053,13 +3057,13 @@ int Field_time::store(double nr)
if (nr > 8385959.0)
{
tmp=8385959L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr < -8385959.0)
{
tmp= -8385959L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -3070,7 +3074,7 @@ int Field_time::store(double nr)
if (tmp % 100 > 59 || tmp/100 % 100 > 59)
{
tmp=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
}
......@@ -3086,13 +3090,13 @@ int Field_time::store(longlong nr)
if (nr > (longlong) 8385959L)
{
tmp=8385959L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (nr < (longlong) -8385959L)
{
tmp= -8385959L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -3101,7 +3105,7 @@ int Field_time::store(longlong nr)
if (tmp % 100 > 59 || tmp/100 % 100 > 59)
{
tmp=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
}
......@@ -3209,11 +3213,11 @@ int Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155)
{
*ptr=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
return 1;
}
else if (current_thd->count_cuted_fields && !test_if_int(from,len,end,cs))
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
if (nr != 0 || len != 4)
{
if (nr < YY_PART_YEAR)
......@@ -3241,7 +3245,7 @@ int Field_year::store(longlong nr)
if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155)
{
*ptr=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
return 1;
}
if (nr != 0 || field_length != 4) // 0000 -> 0; 00 -> 2000
......@@ -3310,6 +3314,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
{
tmp=0;
error= 1;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
else
tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day);
......@@ -3334,7 +3339,7 @@ int Field_date::store(double nr)
if (nr < 0.0 || nr > 99991231.0)
{
tmp=0L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -3360,7 +3365,7 @@ int Field_date::store(longlong nr)
if (nr < 0 || nr > LL(99991231))
{
tmp=0L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -3489,6 +3494,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
{
tmp=0L;
error= 1;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
else
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
......@@ -3501,6 +3507,7 @@ int Field_newdate::store(double nr)
if (nr < 0.0 || nr > 99991231235959.0)
{
(void) Field_newdate::store((longlong) -1);
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
return 1;
}
else
......@@ -3517,7 +3524,7 @@ int Field_newdate::store(longlong nr)
if (nr < 0L || nr > 99991231L)
{
tmp=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -3535,7 +3542,7 @@ int Field_newdate::store(longlong nr)
if (month > 12 || day > 31)
{
tmp=0L; // Don't allow date to change
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -3553,7 +3560,7 @@ void Field_newdate::store_time(TIME *ltime,timestamp_type type)
else
{
tmp=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
int3store(ptr,tmp);
}
......@@ -3671,7 +3678,7 @@ int Field_datetime::store(double nr)
if (nr < 0.0 || nr > 99991231235959.0)
{
nr=0.0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
error |= Field_datetime::store((longlong) rint(nr));
......@@ -3685,7 +3692,7 @@ int Field_datetime::store(longlong nr)
if (nr < 0 || nr > LL(99991231235959))
{
nr=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else
......@@ -3698,6 +3705,8 @@ int Field_datetime::store(longlong nr)
else
#endif
longlongstore(ptr,nr);
if (current_thd->last_cuted_field)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
return error;
}
......@@ -3710,7 +3719,7 @@ void Field_datetime::store_time(TIME *ltime,timestamp_type type)
else
{
tmp=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
......@@ -3913,7 +3922,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
from+= field_charset->scan(field_charset, from, end, MY_SEQ_SPACES);
if (from != end)
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error=1;
}
}
......@@ -4082,7 +4091,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
if (length > field_length)
{
length=field_length;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error= 1;
}
memcpy(ptr+2,from,length);
......@@ -4305,7 +4314,7 @@ void Field_blob::store_length(uint32 number)
if (number > 255)
{
number=255;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
ptr[0]= (uchar) number;
break;
......@@ -4313,7 +4322,7 @@ void Field_blob::store_length(uint32 number)
if (number > (uint16) ~0)
{
number= (uint16) ~0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
......@@ -4328,7 +4337,7 @@ void Field_blob::store_length(uint32 number)
if (number > (uint32) (1L << 24))
{
number= (uint32) (1L << 24)-1L;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
int3store(ptr,number);
break;
......@@ -4939,11 +4948,11 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
if (err || end != from+length || tmp > typelib->count)
{
tmp=0;
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
}
else
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
}
store_type((ulonglong) tmp);
return err;
......@@ -4961,7 +4970,7 @@ int Field_enum::store(longlong nr)
int error= 0;
if ((uint) nr > typelib->count || nr == 0)
{
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
nr=0;
error=1;
}
......@@ -5089,7 +5098,7 @@ void Field_enum::sql_type(String &res) const
*/
ulonglong find_set(TYPELIB *lib, const char *x, uint length, char **err_pos,
uint *err_len)
uint *err_len, bool *set_warning)
{
const char *end= x + length;
*err_pos= 0; // No error yet
......@@ -5101,7 +5110,6 @@ ulonglong find_set(TYPELIB *lib, const char *x, uint length, char **err_pos,
if (x != end)
{
const char *start= x;
bool error= 0;
for (;;)
{
const char *pos= start;
......@@ -5114,7 +5122,7 @@ ulonglong find_set(TYPELIB *lib, const char *x, uint length, char **err_pos,
{
*err_pos= (char*) start;
*err_len= var_len;
error= 1;
*set_warning= 1;
}
else
found|= ((longlong) 1 << (find - 1));
......@@ -5122,8 +5130,6 @@ ulonglong find_set(TYPELIB *lib, const char *x, uint length, char **err_pos,
break;
start= pos + 1;
}
if (error)
current_thd->cuted_fields++;
}
return found;
}
......@@ -5131,6 +5137,7 @@ ulonglong find_set(TYPELIB *lib, const char *x, uint length, char **err_pos,
int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
{
bool set_warning= 0;
int err= 0;
char *not_used;
uint not_used2;
......@@ -5143,7 +5150,7 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
from= tmpstr.ptr();
length= tmpstr.length();
}
ulonglong tmp= find_set(typelib, from, length, &not_used, &not_used2);
ulonglong tmp= find_set(typelib, from, length, &not_used, &not_used2, &set_warning);
if (!tmp && length && length < 22)
{
/* This is for reading numbers with LOAD DATA INFILE */
......@@ -5153,9 +5160,11 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
tmp > (ulonglong) (((longlong) 1 << typelib->count) - (longlong) 1))
{
tmp=0;
current_thd->cuted_fields++;
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_TRUNCATED, ER(ER_WARN_DATA_TRUNCATED),
field_name, 0);
}
else
current_thd->cuted_fields--; // Remove warning from find_set
}
store_type(tmp);
return err;
......@@ -5169,7 +5178,7 @@ int Field_set::store(longlong nr)
(longlong) 1))
{
nr&= (longlong) (((longlong) 1 << typelib->count) - (longlong) 1);
current_thd->cuted_fields++;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED);
error=1;
}
store_type((ulonglong) nr);
......@@ -5485,3 +5494,13 @@ create_field::create_field(Field *old_field,Field *orig_field)
geom_type= ((Field_geom*)old_field)->geom_type;
}
}
/* Warning handling */
void Field::set_warning(const uint level, const uint code)
{
THD *thd= current_thd;
thd->cuted_fields++;
push_warning_printf(thd, (MYSQL_ERROR::enum_warning_level)level,
code, ER(code), field_name, thd->row_count);
}
......@@ -210,6 +210,8 @@ class Field
virtual bool get_time(TIME *ltime);
virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; }
virtual void set_charset(CHARSET_INFO *charset) { }
virtual void set_warning(const unsigned int level,
const unsigned int code);
friend bool reopen_table(THD *,struct st_table *,bool);
friend int cre_myisam(my_string name, register TABLE *form, uint options,
ulonglong auto_increment_value);
......@@ -1108,7 +1110,7 @@ bool set_field_to_null(Field *field);
bool set_field_to_null_with_conversions(Field *field, bool no_conversions);
uint find_enum(TYPELIB *typelib,const char *x, uint length);
ulonglong find_set(TYPELIB *typelib,const char *x, uint length,
char **err_pos, uint *err_len);
char **err_pos, uint *err_len, bool *set_warning);
bool test_if_int(const char *str, int length, const char *int_end,
CHARSET_INFO *cs);
......
......@@ -121,7 +121,7 @@ set_field_to_null(Field *field)
field->reset();
if (current_thd->count_cuted_fields)
{
current_thd->cuted_fields++; // Increment error counter
field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,ER_WARN_DATA_TRUNCATED);
return 0;
}
if (!current_thd->no_errors)
......@@ -175,7 +175,7 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
return 0; // field is set in handler.cc
if (current_thd->count_cuted_fields)
{
current_thd->cuted_fields++; // Increment error counter
field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,ER_WARN_NULL_TO_NOTNULL);
return 0;
}
if (!current_thd->no_errors)
......@@ -225,7 +225,8 @@ static void do_copy_not_null(Copy_field *copy)
{
if (*copy->from_null_ptr & copy->from_bit)
{
current_thd->cuted_fields++;
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_TRUNCATED);
copy->to_field->reset();
}
else
......@@ -324,7 +325,8 @@ static void do_cut_string(Copy_field *copy)
{
if (!my_isspace(system_charset_info, *ptr)) // QQ: ucs incompatible
{
current_thd->cuted_fields++; // Give a warning
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_TRUNCATED);
break;
}
}
......@@ -344,7 +346,8 @@ static void do_varstring(Copy_field *copy)
{
length=copy->to_length-2;
if (current_thd->count_cuted_fields)
current_thd->cuted_fields++; // Increment error counter
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_TRUNCATED);
}
int2store(copy->to_ptr,length);
memcpy(copy->to_ptr+2, copy->from_ptr,length);
......
......@@ -1010,6 +1010,7 @@ bool sys_var::check_enum(THD *thd, set_var *var, TYPELIB *enum_names)
bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
{
bool not_used;
char buff[80], *error= 0;
uint error_len= 0;
String str(buff, sizeof(buff), system_charset_info), *res;
......@@ -1019,7 +1020,7 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
if (!(res= var->value->val_str(&str)))
goto err;
var->save_result.ulong_value= (ulong)
find_set(enum_names, res->c_ptr(), res->length(), &error, &error_len);
find_set(enum_names, res->c_ptr(), res->length(), &error, &error_len, &not_used);
if (error_len)
{
strmake(buff, error, min(sizeof(buff), error_len));
......
......@@ -260,8 +260,10 @@
"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)"
"Z_DATA_ERROR: Input data was corrupted for zlib"
"%d line(s) was(were) cut by group_concat()";
"Value count is fewer than the column count at row %ld";
"Value count is more than the column count at row %ld";
"Data truncated for column '%s' at row %ld";
"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"
"Record count is fewer than the column count at row %ld";
"Record count is more than the column count at row %ld";
"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld";
"Data truncated, out of range for column '%s' at row %ld";
"Data truncated for column '%s' at row %ld"
......@@ -512,6 +512,7 @@ class THD :public ilink
ulong query_id, warn_id, version, options, thread_id, col_access;
ulong current_stmt_id;
ulong rand_saved_seed1, rand_saved_seed2;
ulong row_count; // Row counter, mainly for errors and warnings
long dbug_thread_id;
pthread_t real_id;
uint current_tablenr,tmp_table,cond_count;
......@@ -530,6 +531,7 @@ class THD :public ilink
uint8 query_cache_type; // type of query cache processing
bool slave_thread;
bool set_query_id,locked,count_cuted_fields,some_tables_deleted;
bool last_cuted_field;
bool no_errors, allow_sum_func, password, is_fatal_error;
bool query_start_used,last_insert_id_used,insert_id_used,rand_used;
bool system_thread,in_lock_tables,global_read_lock;
......
......@@ -79,6 +79,7 @@ void mysql_reset_errors(THD *thd)
free_root(&thd->warn_root,MYF(0));
bzero((char*) thd->warn_count, sizeof(thd->warn_count));
thd->warn_list.empty();
thd->row_count= 1; // by default point to row 1
}
DBUG_VOID_RETURN;
}
......
......@@ -297,6 +297,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
{ // Get auto increment value
id= thd->last_insert_id;
}
thd->row_count++;
}
if (lock_type == TL_WRITE_DELAYED)
{
......
......@@ -368,11 +368,10 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
List_iterator_fast<Item> it(fields);
Item_field *sql_field;
ulonglong id;
ulong row_pos;
DBUG_ENTER("read_fixed_length");
id= 0;
row_pos= 1;
/* No fields can be null in this format. mark all fields as not null */
while ((sql_field= (Item_field*) it++))
sql_field->field->set_notnull();
......@@ -391,13 +390,13 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
#endif
while ((sql_field= (Item_field*) it++))
{
Field *field=sql_field->field;
Field *field= sql_field->field;
if (pos == read_info.row_end)
{
thd->cuted_fields++; /* Not enough fields */
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_TOO_FEW_RECORDS,
ER(ER_WARN_TOO_FEW_RECORDS), row_pos);
ER(ER_WARN_TOO_FEW_RECORDS), thd->row_count);
field->reset();
}
else
......@@ -408,13 +407,7 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
field->field_length)
length=field->field_length;
save_chr=pos[length]; pos[length]='\0'; // Safeguard aganst malloc
if (field->store((char*) pos,length,read_info.read_charset))
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_TRUNCATED,
ER(ER_WARN_DATA_TRUNCATED),
field->field_name, row_pos);
}
field->store((char*) pos,length,read_info.read_charset);
pos[length]=save_chr;
if ((pos+=length) > read_info.row_end)
pos= read_info.row_end; /* Fills rest with space */
......@@ -425,7 +418,7 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
thd->cuted_fields++; /* To long row */
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_TOO_MANY_RECORDS,
ER(ER_WARN_TOO_MANY_RECORDS), row_pos);
ER(ER_WARN_TOO_MANY_RECORDS), thd->row_count);
}
if (write_record(table,&info))
DBUG_RETURN(1);
......@@ -446,9 +439,9 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
thd->cuted_fields++; /* To long row */
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_TOO_MANY_RECORDS,
ER(ER_WARN_TOO_MANY_RECORDS), row_pos);
ER(ER_WARN_TOO_MANY_RECORDS), thd->row_count);
}
row_pos++;
thd->row_count++;
}
if (id && !read_info.error)
thd->insert_id(id); // For binary/update log
......@@ -466,12 +459,10 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
Item_field *sql_field;
uint enclosed_length;
ulonglong id;
ulong row_pos;
DBUG_ENTER("read_sep_field");
enclosed_length=enclosed.length();
id= 0;
row_pos= 1;
for (;;it.rewind())
{
......@@ -502,26 +493,14 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
if (field->type() == FIELD_TYPE_TIMESTAMP)
((Field_timestamp*) field)->set_time();
else if (field != table->next_number_field)
{
thd->cuted_fields++;
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_NULL_TO_NOTNULL,
ER(ER_WARN_NULL_TO_NOTNULL),
field->field_name, row_pos);
}
field->set_warning((uint)MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_NULL_TO_NOTNULL);
}
continue;
}
field->set_notnull();
read_info.row_end[0]=0; // Safe to change end marker
if (field->store((char*) read_info.row_start,length,read_info.read_charset))
{
// Data truncated or out of bounds
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_TRUNCATED,
ER(ER_WARN_DATA_TRUNCATED),
field->field_name, row_pos);
}
field->store((char*) read_info.row_start,length,read_info.read_charset);
}
if (read_info.error)
break;
......@@ -536,7 +515,7 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
thd->cuted_fields++;
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_TOO_FEW_RECORDS,
ER(ER_WARN_TOO_FEW_RECORDS), row_pos);
ER(ER_WARN_TOO_FEW_RECORDS), thd->row_count);
}
}
if (write_record(table,&info))
......@@ -557,10 +536,10 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
{
thd->cuted_fields++; /* To long row */
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_TOO_MANY_RECORDS,
ER(ER_WARN_TOO_MANY_RECORDS), row_pos);
ER_WARN_TOO_MANY_RECORDS, ER(ER_WARN_TOO_MANY_RECORDS),
thd->row_count);
}
row_pos++;
thd->row_count++;
}
if (id && !read_info.error)
thd->insert_id(id); // For binary/update log
......
......@@ -3653,12 +3653,13 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
{
char *not_used;
uint not_used2;
bool not_used3;
thd->cuted_fields=0;
String str,*res;
res=default_value->val_str(&str);
(void) find_set(interval, res->ptr(), res->length(), &not_used,
&not_used2);
&not_used2, &not_used3);
if (thd->cuted_fields)
{
net_printf(thd,ER_INVALID_DEFAULT,field_name);
......
......@@ -5018,6 +5018,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
ha_rows found_records=join->found_records;
READ_RECORD *info= &join_tab->read_record;
join->thd->row_count= 0;
do
{
if (join->thd->killed) // Aborted by user
......@@ -5026,6 +5027,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
return -2; /* purecov: inspected */
}
join->examined_rows++;
join->thd->row_count++;
if (!on_expr || on_expr->val_int())
{
found=1;
......
......@@ -2383,6 +2383,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
handle_duplicates == DUP_REPLACE)
to->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
next_field=to->next_number_field;
thd->row_count= 0;
while (!(error=info.read_record(&info)))
{
if (thd->killed)
......@@ -2391,6 +2392,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
error= 1;
break;
}
thd->row_count++;
if (next_field)
next_field->reset();
for (Copy_field *copy_ptr=copy ; copy_ptr != copy_end ; copy_ptr++)
......
......@@ -315,6 +315,7 @@ int mysql_update(THD *thd,
}
else
table->file->unlock_row();
thd->row_count++;
}
end_read_record(&info);
thd->proc_info="end";
......
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