~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_timefunc.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
{
54
54
  char *buff;
55
55
  const CHARSET_INFO * const cs= &my_charset_bin;
56
 
  uint length= MAX_DATE_STRING_REP_LENGTH;
 
56
  uint32_t length= MAX_DATE_STRING_REP_LENGTH;
57
57
 
58
58
  if (str->alloc(length))
59
59
    return 1;
178
178
  
179
179
static bool sec_to_time(int64_t seconds, bool unsigned_flag, DRIZZLE_TIME *ltime)
180
180
{
181
 
  uint sec;
 
181
  uint32_t sec;
182
182
 
183
183
  memset(ltime, 0, sizeof(*ltime));
184
184
  
262
262
*/
263
263
 
264
264
static bool extract_date_time(DATE_TIME_FORMAT *format,
265
 
                              const char *val, uint length, DRIZZLE_TIME *l_time,
 
265
                              const char *val, uint32_t length, DRIZZLE_TIME *l_time,
266
266
                              enum enum_drizzle_timestamp_type cached_timestamp_type,
267
267
                              const char **sub_pattern_end,
268
268
                              const char *date_time_type)
515
515
 
516
516
  if (yearday > 0)
517
517
  {
518
 
    uint days;
 
518
    uint32_t days;
519
519
    days= calc_daynr(l_time->year,1,1) +  yearday - 1;
520
520
    if (days <= 0 || days > MAX_DAY_NUMBER)
521
521
      goto err;
525
525
  if (week_number >= 0 && weekday)
526
526
  {
527
527
    int days;
528
 
    uint weekday_b;
 
528
    uint32_t weekday_b;
529
529
 
530
530
    /*
531
531
      %V,%v require %X,%x resprectively,
606
606
                    enum enum_drizzle_timestamp_type type, String *str)
607
607
{
608
608
  char intbuff[15];
609
 
  uint hours_i;
610
 
  uint weekday;
 
609
  uint32_t hours_i;
 
610
  uint32_t weekday;
611
611
  ulong length;
612
612
  const char *ptr, *end;
613
613
  THD *thd= current_thd;
771
771
      case 'U':
772
772
      case 'u':
773
773
      {
774
 
        uint year;
 
774
        uint32_t year;
775
775
        if (type == DRIZZLE_TIMESTAMP_TIME)
776
776
          return 1;
777
777
        length= int10_to_str(calc_week(l_time,
785
785
      case 'v':
786
786
      case 'V':
787
787
      {
788
 
        uint year;
 
788
        uint32_t year;
789
789
        if (type == DRIZZLE_TIMESTAMP_TIME)
790
790
          return 1;
791
791
        length= int10_to_str(calc_week(l_time,
800
800
      case 'x':
801
801
      case 'X':
802
802
      {
803
 
        uint year;
 
803
        uint32_t year;
804
804
        if (type == DRIZZLE_TIMESTAMP_TIME)
805
805
          return 1;
806
806
        (void) calc_week(l_time,
850
850
                         For example, '1.1' -> '1.100000'
851
851
*/
852
852
 
853
 
static bool get_interval_info(const char *str,uint length, const CHARSET_INFO * const cs,
854
 
                              uint count, uint64_t *values,
 
853
static bool get_interval_info(const char *str,uint32_t length, const CHARSET_INFO * const cs,
 
854
                              uint32_t count, uint64_t *values,
855
855
                              bool transform_msec)
856
856
{
857
857
  const char *end=str+length;
858
 
  uint i;
 
858
  uint32_t i;
859
859
  while (str != end && !my_isdigit(cs,*str))
860
860
    str++;
861
861
 
1023
1023
{
1024
1024
  assert(fixed == 1);
1025
1025
  const char *month_name;
1026
 
  uint   month= (uint) val_int();
 
1026
  uint32_t   month= (uint) val_int();
1027
1027
  THD *thd= current_thd;
1028
1028
 
1029
1029
  if (null_value || !month)
1079
1079
}
1080
1080
 
1081
1081
 
1082
 
uint week_mode(uint mode)
 
1082
uint32_t week_mode(uint32_t mode)
1083
1083
{
1084
 
  uint week_format= (mode & 7);
 
1084
  uint32_t week_format= (mode & 7);
1085
1085
  if (!(week_format & WEEK_MONDAY_FIRST))
1086
1086
    week_format^= WEEK_FIRST_WEEKDAY;
1087
1087
  return week_format;
1121
1121
int64_t Item_func_week::val_int()
1122
1122
{
1123
1123
  assert(fixed == 1);
1124
 
  uint year;
 
1124
  uint32_t year;
1125
1125
  DRIZZLE_TIME ltime;
1126
1126
  if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
1127
1127
    return 0;
1134
1134
int64_t Item_func_yearweek::val_int()
1135
1135
{
1136
1136
  assert(fixed == 1);
1137
 
  uint year,week;
 
1137
  uint32_t year,week;
1138
1138
  DRIZZLE_TIME ltime;
1139
1139
  if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
1140
1140
    return 0;
1162
1162
String* Item_func_dayname::val_str(String* str)
1163
1163
{
1164
1164
  assert(fixed == 1);
1165
 
  uint weekday=(uint) val_int();                // Always Item_func_daynr()
 
1165
  uint32_t weekday=(uint) val_int();            // Always Item_func_daynr()
1166
1166
  const char *day_name;
1167
1167
  THD *thd= current_thd;
1168
1168
 
1463
1463
}
1464
1464
 
1465
1465
 
1466
 
bool Item_func_from_days::get_date(DRIZZLE_TIME *ltime, uint fuzzy_date __attribute__((unused)))
 
1466
bool Item_func_from_days::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date __attribute__((unused)))
1467
1467
{
1468
1468
  int64_t value=args[0]->val_int();
1469
1469
  if ((null_value=args[0]->null_value))
1530
1530
 
1531
1531
 
1532
1532
bool Item_func_curdate::get_date(DRIZZLE_TIME *res,
1533
 
                                 uint fuzzy_date __attribute__((unused)))
 
1533
                                 uint32_t fuzzy_date __attribute__((unused)))
1534
1534
{
1535
1535
  *res=ltime;
1536
1536
  return 0;
1636
1636
 
1637
1637
 
1638
1638
bool Item_func_now::get_date(DRIZZLE_TIME *res,
1639
 
                             uint fuzzy_date __attribute__((unused)))
 
1639
                             uint32_t fuzzy_date __attribute__((unused)))
1640
1640
{
1641
1641
  *res= ltime;
1642
1642
  return 0;
1697
1697
 
1698
1698
 
1699
1699
bool Item_func_sysdate_local::get_date(DRIZZLE_TIME *res,
1700
 
                                       uint fuzzy_date __attribute__((unused)))
 
1700
                                       uint32_t fuzzy_date __attribute__((unused)))
1701
1701
{
1702
1702
  store_now_in_TIME(&ltime);
1703
1703
  *res= ltime;
1807
1807
 
1808
1808
 
1809
1809
 
1810
 
uint Item_func_date_format::format_length(const String *format)
 
1810
uint32_t Item_func_date_format::format_length(const String *format)
1811
1811
{
1812
 
  uint size=0;
 
1812
  uint32_t size=0;
1813
1813
  const char *ptr=format->ptr();
1814
1814
  const char *end=ptr+format->length();
1815
1815
 
1884
1884
{
1885
1885
  String *format;
1886
1886
  DRIZZLE_TIME l_time;
1887
 
  uint size;
 
1887
  uint32_t size;
1888
1888
  assert(fixed == 1);
1889
1889
 
1890
1890
  if (!is_time_format)
1982
1982
}
1983
1983
 
1984
1984
bool Item_func_from_unixtime::get_date(DRIZZLE_TIME *ltime,
1985
 
                                       uint fuzzy_date __attribute__((unused)))
 
1985
                                       uint32_t fuzzy_date __attribute__((unused)))
1986
1986
{
1987
1987
  uint64_t tmp= (uint64_t)(args[0]->val_int());
1988
1988
  /*
2035
2035
 
2036
2036
/* Here arg[1] is a Item_interval object */
2037
2037
 
2038
 
bool Item_date_add_interval::get_date(DRIZZLE_TIME *ltime, uint fuzzy_date __attribute__((unused)))
 
2038
bool Item_date_add_interval::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date __attribute__((unused)))
2039
2039
{
2040
2040
  INTERVAL interval;
2041
2041
 
2170
2170
{
2171
2171
  assert(fixed == 1);
2172
2172
  DRIZZLE_TIME ltime;
2173
 
  uint year;
 
2173
  uint32_t year;
2174
2174
  ulong week_format;
2175
2175
  long neg;
2176
2176
  if (date_value)
2322
2322
  else
2323
2323
  {
2324
2324
    // Convert character set if differ
2325
 
    uint dummy_errors;
 
2325
    uint32_t dummy_errors;
2326
2326
    if (!(res= args[0]->val_str(&tmp_value)) ||
2327
2327
        str->copy(res->ptr(), res->length(), from_cs,
2328
2328
        cast_cs, &dummy_errors))
2486
2486
}
2487
2487
 
2488
2488
 
2489
 
bool Item_date_typecast::get_date(DRIZZLE_TIME *ltime, uint fuzzy_date __attribute__((unused)))
 
2489
bool Item_date_typecast::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date __attribute__((unused)))
2490
2490
{
2491
2491
  bool res= get_arg0_date(ltime, TIME_FUZZY_DATE);
2492
2492
  ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
2895
2895
      int_type == INTERVAL_QUARTER ||
2896
2896
      int_type == INTERVAL_MONTH)
2897
2897
  {
2898
 
    uint year_beg, year_end, month_beg, month_end, day_beg, day_end;
2899
 
    uint years= 0;
2900
 
    uint second_beg, second_end, microsecond_beg, microsecond_end;
 
2898
    uint32_t year_beg, year_end, month_beg, month_end, day_beg, day_end;
 
2899
    uint32_t years= 0;
 
2900
    uint32_t second_beg, second_end, microsecond_beg, microsecond_end;
2901
2901
 
2902
2902
    if (neg == -1)
2903
2903
    {
3016
3016
    break;
3017
3017
  }
3018
3018
 
3019
 
  for (uint i=0 ; i < 2 ; i++)
 
3019
  for (uint32_t i=0 ; i < 2 ; i++)
3020
3020
  {
3021
3021
    str->append(',');
3022
3022
    args[i]->print(str, query_type);
3041
3041
       (format_name= format->format_name);
3042
3042
       format++)
3043
3043
  {
3044
 
    uint format_name_len;
 
3044
    uint32_t format_name_len;
3045
3045
    format_name_len= strlen(format_name);
3046
3046
    if (val_len == format_name_len &&
3047
3047
        !my_strnncoll(&my_charset_utf8_general_ci, 
3107
3107
*/
3108
3108
 
3109
3109
static date_time_format_types
3110
 
get_date_time_result_type(const char *format, uint length)
 
3110
get_date_time_result_type(const char *format, uint32_t length)
3111
3111
{
3112
3112
  const char *time_part_frms= "HISThiklrs";
3113
3113
  const char *date_part_frms= "MVUXYWabcjmvuxyw";
3189
3189
}
3190
3190
 
3191
3191
 
3192
 
bool Item_func_str_to_date::get_date(DRIZZLE_TIME *ltime, uint fuzzy_date)
 
3192
bool Item_func_str_to_date::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date)
3193
3193
{
3194
3194
  DATE_TIME_FORMAT date_time_format;
3195
3195
  char val_buff[64], format_buff[64];
3243
3243
}
3244
3244
 
3245
3245
 
3246
 
bool Item_func_last_day::get_date(DRIZZLE_TIME *ltime, uint fuzzy_date)
 
3246
bool Item_func_last_day::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date)
3247
3247
{
3248
3248
  if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) ||
3249
3249
      (ltime->month == 0))
3252
3252
    return 1;
3253
3253
  }
3254
3254
  null_value= 0;
3255
 
  uint month_idx= ltime->month-1;
 
3255
  uint32_t month_idx= ltime->month-1;
3256
3256
  ltime->day= days_in_month[month_idx];
3257
3257
  if ( month_idx == 1 && calc_days_in_year(ltime->year) == 366)
3258
3258
    ltime->day= 29;