~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/numhybrid.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
 
#include <math.h>
 
20
#include <drizzled/server_includes.h>
22
21
#include <drizzled/function/numhybrid.h>
23
22
 
24
 
namespace drizzled
25
 
{
26
 
 
27
23
void Item_func_numhybrid::fix_num_length_and_dec()
28
24
{}
29
25
 
50
46
  {
51
47
    int64_t nr= int_op();
52
48
    if (null_value)
53
 
      return 0;
 
49
      return 0; /* purecov: inspected */
54
50
    str->set_int(nr, unsigned_flag, &my_charset_bin);
55
51
    break;
56
52
  }
58
54
  {
59
55
    double nr= real_op();
60
56
    if (null_value)
61
 
      return 0;
 
57
      return 0; /* purecov: inspected */
62
58
    str->set_real(nr,decimals,&my_charset_bin);
63
59
    break;
64
60
  }
177
173
  }
178
174
  return val;
179
175
}
180
 
 
181
 
} /* namespace drizzled */