Merge with 5.1-microseconds

A lot of small fixes and new test cases.

client/mysqlbinlog.cc:
  Cast removed
client/mysqltest.cc:
  Added missing DBUG_RETURN
include/my_pthread.h:
  set_timespec_time_nsec() now only takes one argument
mysql-test/t/date_formats.test:
  Remove --disable_ps_protocl as now also ps supports microseconds
mysys/my_uuid.c:
  Changed to use my_interval_timer() instead of my_getsystime()
mysys/waiting_threads.c:
  Changed to use my_hrtime()
sql/field.h:
  Added bool special_const_compare() for fields that may convert values before compare (like year)
sql/field_conv.cc:
  Added test to get optimal copying of identical temporal values.
sql/item.cc:
  Return that item_int is equal if it's positive, even if unsigned flag is different.
  Fixed Item_cache_str::save_in_field() to have identical null check as other similar functions
  Added proper NULL check to Item_cache_int::save_in_field()
sql/item_cmpfunc.cc:
  Don't call convert_constant_item() if there is nothing that is worth converting.
  Simplified test when years should be converted
sql/item_sum.cc:
  Mark cache values in Item_sum_hybrid as not constants to ensure they are not replaced by other cache values in compare_datetime()
sql/item_timefunc.cc:
  Changed sec_to_time() to take a my_decimal argument to ensure we don't loose any sub seconds.
  Added Item_temporal_func::get_time() (This simplifies some things)
sql/mysql_priv.h:
  Added Lazy_string_decimal()
sql/mysqld.cc:
  Added my_decimal constants max_seconds_for_time_type, time_second_part_factor
sql/table.cc:
  Changed expr_arena to be of type CONVENTIONAL_EXECUTION to ensure that we don't loose any items that are created by fix_fields()
sql/tztime.cc:
  TIME_to_gmt_sec() now sets *in_dst_time_gap in case of errors
  This is needed to be able to detect if timestamp is 0
storage/maria/lockman.c:
  Changed from my_getsystime() to set_timespec_time_nsec()
storage/maria/ma_loghandler.c:
  Changed from my_getsystime() to my_hrtime()
storage/maria/ma_recovery.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/maria/unittest/trnman-t.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/xtradb/handler/ha_innodb.cc:
  Added support for new time,datetime and timestamp
unittest/mysys/thr_template.c:
  my_getsystime() -> my_interval_timer()
unittest/mysys/waiting_threads-t.c:
  my_getsystime() -> my_interval_timer()
This commit is contained in:
Michael Widenius 2011-05-28 05:11:32 +03:00
commit f197991f41
246 changed files with 11747 additions and 9889 deletions

View file

@ -214,7 +214,7 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage)
ALIGN_SIZE(sp->typecnt *
sizeof(TRAN_TYPE_INFO)) +
#ifdef ABBR_ARE_USED
ALIGN_SIZE(sp->charcnt) +
ALIGN_SIZE(sp->charcnt+1) +
#endif
sp->leapcnt * sizeof(LS_INFO))))
return 1;
@ -227,7 +227,7 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage)
tzinfo_buf+= ALIGN_SIZE(sp->typecnt * sizeof(TRAN_TYPE_INFO));
#ifdef ABBR_ARE_USED
sp->chars= tzinfo_buf;
tzinfo_buf+= ALIGN_SIZE(sp->charcnt);
tzinfo_buf+= ALIGN_SIZE(sp->charcnt+1);
#endif
sp->lsis= (LS_INFO *)tzinfo_buf;
@ -877,8 +877,9 @@ sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec)
RETURN VALUE
Seconds in UTC since Epoch.
0 in case of error.
0 in case of error. In this case *in_dst_time_gap is also set
*/
static my_time_t
TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
my_bool *in_dst_time_gap)
@ -887,12 +888,14 @@ TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
uint saved_seconds;
uint i;
int shift= 0;
DBUG_ENTER("TIME_to_gmt_sec");
*in_dst_time_gap= 0;
if (!validate_timestamp_range(t))
{
*in_dst_time_gap= 1; // Mark error
DBUG_RETURN(0);
}
/* We need this for correct leap seconds handling */
if (t->second < SECS_PER_MIN)
@ -936,6 +939,7 @@ TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
This means that source time can't be represented as my_time_t due to
limited my_time_t range.
*/
*in_dst_time_gap= 1; // Mark error
DBUG_RETURN(0);
}
@ -952,6 +956,7 @@ TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
if (local_t > (my_time_t) (TIMESTAMP_MAX_VALUE - shift * SECS_PER_DAY +
sp->revtis[i].rt_offset - saved_seconds))
{
*in_dst_time_gap= 1; // Mark error
DBUG_RETURN(0); /* my_time_t overflow */
}
local_t+= shift * SECS_PER_DAY;
@ -973,7 +978,10 @@ TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
/* check for TIMESTAMP_MAX_VALUE was already done above */
if (local_t < TIMESTAMP_MIN_VALUE)
{
local_t= 0;
*in_dst_time_gap= 1; // Mark error
}
DBUG_RETURN(local_t);
}
@ -1336,24 +1344,31 @@ Time_zone_offset::Time_zone_offset(long tz_offset_arg):
datetime value passed doesn't really exist
(i.e. falls into spring time-gap) and is not
touched otherwise.
It is not really used in this class.
It is not really used in this class, except
for indicating error
RETURN VALUE
Corresponding my_time_t value or 0 in case of error
Corresponding my_time_t value or 0 in case of error. In case of error
*in_dst_time_gap is also set.
*/
my_time_t
Time_zone_offset::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const
Time_zone_offset::TIME_to_gmt_sec(const MYSQL_TIME *t,
my_bool *in_dst_time_gap) const
{
my_time_t local_t;
int shift= 0;
*in_dst_time_gap= 0; // Reset
/*
Check timestamp range.we have to do this as calling function relies on
us to make all validation checks here.
*/
if (!validate_timestamp_range(t))
{
*in_dst_time_gap= 1; // Mark error
return 0;
}
/*
Do a temporary shift of the boundary dates to avoid
overflow of my_time_t if the time value is near it's
@ -1376,6 +1391,7 @@ Time_zone_offset::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap)
return local_t;
/* range error*/
*in_dst_time_gap= 1; // Mark error
return 0;
}