List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:May 5 2008 3:47pm
Subject:re: Inconsistent store implementation for field_year. (one checks >=
2155.0 other checks > 2155)
View as plain text  
Hi!

>>>>> "Krunal" == Krunal Bauskar <krunalbauskar@stripped> writes:

Krunal> Hi,
Krunal> For datatype YEAR:

Krunal> In field.cc: 5161, year value 2155 is considered invalid:

Krunal> int Field_year::store(double nr)
Krunal> {
Krunal>   if (nr < 0.0 || nr >= 2155.0)
Krunal>   {
Krunal>     (void) Field_year::store((longlong) -1, FALSE);
Krunal>     return 1;
Krunal>   }
Krunal>   return Field_year::store((longlong) nr, FALSE);
Krunal> }

Krunal> But in field.cc:5172, year value 2155 is valid:

Krunal> int Field_year::store(longlong nr, bool unsigned_val)
Krunal> {
Krunal>   ASSERT_COLUMN_MARKED_FOR_WRITE;
Krunal>   if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155)
Krunal>   {
Krunal>     *ptr= 0;
Krunal>     set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
Krunal>     return 1;
Krunal>   }
Krunal>   ...
Krunal> }

Krunal> How come different store functions have different behavior?

The above is a bug. The right test should be > 2155.0.  I have now
fixed this in my copy of the 5.1 tree.

Regards,
Monty

PS: Sorry for late the late reply
Thread
Inconsistent store implementation for field_year. (one checks >= 2155.0 other checks > 2155)Krunal Bauskar3 Apr
  • re: Inconsistent store implementation for field_year. (one checks >=2155.0 other checks > 2155)Michael Widenius5 May