~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/item_timefunc.cc

  • Committer: Brian Aker
  • Date: 2008-07-03 00:50:29 UTC
  • Revision ID: brian@tangent.org-20080703005029-ox3ecpt3oldhmvb0
Basic first step removal of timezone support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2006
2006
}
2007
2007
 
2008
2008
 
2009
 
void Item_func_convert_tz::fix_length_and_dec()
2010
 
{
2011
 
  collation.set(&my_charset_bin);
2012
 
  decimals= 0;
2013
 
  max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
2014
 
  maybe_null= 1;
2015
 
}
2016
 
 
2017
 
 
2018
 
String *Item_func_convert_tz::val_str(String *str)
2019
 
{
2020
 
  MYSQL_TIME time_tmp;
2021
 
 
2022
 
  if (get_date(&time_tmp, 0))
2023
 
    return 0;
2024
 
 
2025
 
  if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
2026
 
  {
2027
 
    null_value= 1;
2028
 
    return 0;
2029
 
  }
2030
 
 
2031
 
  make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
2032
 
 
2033
 
  return str;
2034
 
}
2035
 
 
2036
 
 
2037
 
longlong Item_func_convert_tz::val_int()
2038
 
{
2039
 
  MYSQL_TIME time_tmp;
2040
 
 
2041
 
  if (get_date(&time_tmp, 0))
2042
 
    return 0;
2043
 
  
2044
 
  return (longlong)TIME_to_ulonglong_datetime(&time_tmp);
2045
 
}
2046
 
 
2047
 
 
2048
 
bool Item_func_convert_tz::get_date(MYSQL_TIME *ltime,
2049
 
                                    uint fuzzy_date __attribute__((unused)))
2050
 
{
2051
 
  my_time_t my_time_tmp;
2052
 
  String str;
2053
 
  THD *thd= current_thd;
2054
 
 
2055
 
  if (!from_tz_cached)
2056
 
  {
2057
 
    from_tz= my_tz_find(thd, args[1]->val_str(&str));
2058
 
    from_tz_cached= args[1]->const_item();
2059
 
  }
2060
 
 
2061
 
  if (!to_tz_cached)
2062
 
  {
2063
 
    to_tz= my_tz_find(thd, args[2]->val_str(&str));
2064
 
    to_tz_cached= args[2]->const_item();
2065
 
  }
2066
 
 
2067
 
  if (from_tz==0 || to_tz==0 || get_arg0_date(ltime, TIME_NO_ZERO_DATE))
2068
 
  {
2069
 
    null_value= 1;
2070
 
    return 1;
2071
 
  }
2072
 
 
2073
 
  {
2074
 
    my_bool not_used;
2075
 
    my_time_tmp= from_tz->TIME_to_gmt_sec(ltime, &not_used);
2076
 
    /* my_time_tmp is guranteed to be in the allowed range */
2077
 
    if (my_time_tmp)
2078
 
      to_tz->gmt_sec_to_TIME(ltime, my_time_tmp);
2079
 
  }
2080
 
 
2081
 
  null_value= 0;
2082
 
  return 0;
2083
 
}
2084
 
 
2085
 
 
2086
 
void Item_func_convert_tz::cleanup()
2087
 
{
2088
 
  from_tz_cached= to_tz_cached= 0;
2089
 
  Item_date_func::cleanup();
2090
 
}
2091
 
 
2092
 
 
2093
2009
void Item_date_add_interval::fix_length_and_dec()
2094
2010
{
2095
2011
  enum_field_types arg0_field_type;