~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types.

This fixes the buffer overflow in https://bugs.launchpad.net/drizzle/+bug/373468

It also removes a handwritten snprintf in field/datetime.cc
However... this caused us to have to change Temporal to have a way to not
"convert" the int64_t value (so 20090101 becomes 20090101000000 etc) as it
has already been converted and we just want the Temporal type to do the
to_string conversion.

This still causes a failure in 'metadata' test due to size of timestamp type. I need feedback from Jay on when the usecond code comes into play to know the correct fix for this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
 
20
#include "drizzled/server_includes.h"
 
21
#include CSTDINT_H
22
22
#include "drizzled/temporal.h"
23
23
#include "drizzled/error.h"
24
24
#include "drizzled/function/time/microsecond.h"
25
25
 
26
 
namespace drizzled
27
 
{
28
 
 
29
26
int64_t Item_func_microsecond::val_int()
30
27
{
31
28
  assert(fixed);
52
49
   *
53
50
   * Oh, and Brian Aker MADE me do this. :) --JRP
54
51
   */
55
 
  Time temporal_time;
 
52
  drizzled::Time temporal_time;
56
53
  
57
54
  char time_buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
58
55
  String tmp_time(time_buff,sizeof(time_buff), &my_charset_utf8_bin);
64
61
     * representing a time value, so we grab the first argument 
65
62
     * as a DateTime object and try that for a match...
66
63
     */
67
 
    DateTime temporal_datetime;
 
64
    drizzled::DateTime temporal_datetime;
68
65
    Item_result arg0_result_type= args[0]->result_type();
69
66
    
70
67
    switch (arg0_result_type)
119
116
  }
120
117
  return (int64_t) temporal_time.useconds();
121
118
}
122
 
 
123
 
} /* namespace drizzled */