~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal.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:
1349
1349
 * This is pretty much a hack for usability, but keeps us compatible
1350
1350
 * with MySQL.
1351
1351
 */
1352
 
bool DateTime::from_int64_t(const int64_t from)
 
1352
bool DateTime::from_int64_t(const int64_t from, bool convert)
1353
1353
{
1354
1354
  int64_t copy_from= from;
1355
1355
  int64_t part1;
1358
1358
  if (copy_from == 0LL)
1359
1359
    return false;
1360
1360
 
1361
 
  if (copy_from < 10000101000000LL)
 
1361
  if (convert && copy_from < 10000101000000LL)
1362
1362
  {
1363
1363
    if (copy_from < 101)
1364
1364
      return false;