~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/time/date_add_interval.cc

  • Committer: Brian Aker
  • Date: 2011-01-08 10:35:13 UTC
  • mfrom: (2057.2.9 timestamp)
  • Revision ID: brian@tangent.org-20110108103513-3wuo8tsyajjcxjrg
Merge in fractional seconds to timestamp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
  */
67
67
  cached_field_type= DRIZZLE_TYPE_VARCHAR;
68
68
  arg0_field_type= args[0]->field_type();
69
 
  if (arg0_field_type == DRIZZLE_TYPE_DATETIME ||
70
 
      arg0_field_type == DRIZZLE_TYPE_TIMESTAMP)
 
69
  if (arg0_field_type == DRIZZLE_TYPE_DATETIME or arg0_field_type == DRIZZLE_TYPE_TIMESTAMP or arg0_field_type == DRIZZLE_TYPE_MICROTIME)
 
70
  {
71
71
    cached_field_type= DRIZZLE_TYPE_DATETIME;
 
72
  }
72
73
  else if (arg0_field_type == DRIZZLE_TYPE_DATE)
73
74
  {
74
75
    if (int_type <= INTERVAL_DAY || int_type == INTERVAL_YEAR_MONTH)
 
76
    {
75
77
      cached_field_type= arg0_field_type;
 
78
    }
76
79
    else
 
80
    {
77
81
      cached_field_type= DRIZZLE_TYPE_DATETIME;
 
82
    }
78
83
  }
79
84
}
80
85
 
115
120
  else if (ltime.second_part)
116
121
  {
117
122
    /* Ensure we've got enough room for our timestamp string. */
118
 
    str->length(DateTime::MAX_STRING_LENGTH);
119
 
    size_t length= snprintf(str->c_ptr(), DateTime::MAX_STRING_LENGTH,
 
123
    str->alloc(MicroTimestamp::MAX_STRING_LENGTH);
 
124
    size_t length= snprintf(str->ptr(), MicroTimestamp::MAX_STRING_LENGTH,
120
125
                            "%04u-%02u-%02u %02u:%02u:%02u.%06u",
121
126
                            ltime.year,
122
127
                            ltime.month,
124
129
                            ltime.hour,
125
130
                            ltime.minute,
126
131
                            ltime.second,
127
 
                            (uint32_t) ltime.second_part);
 
132
                            ltime.second_part);
128
133
    str->length(length);
129
134
    str->set_charset(&my_charset_bin);
130
135
  }