~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal.cc

  • Committer: Brian Aker
  • Date: 2010-12-31 02:23:39 UTC
  • mto: (2054.1.1 clean)
  • mto: This revision was merged to the branch mainline in revision 2049.
  • Revision ID: brian@tangent.org-20101231022339-g07ztt32wdwqdz46
Make it so that tables are sent not as raw but actual drop table commands to
the replication system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "config.h"
38
38
 
39
39
#include "drizzled/charset_info.h"
40
 
#include "drizzled/decimal.h"
 
40
#include "drizzled/type/decimal.h"
41
41
#include "drizzled/calendar.h"
42
42
#include "drizzled/temporal.h"
43
43
#include "drizzled/temporal_format.h"
1025
1025
    current++;
1026
1026
  }
1027
1027
 
1028
 
  if (! matched)
 
1028
  if (not matched)
1029
1029
    return false;
1030
 
  else
1031
 
    return is_valid();
 
1030
 
 
1031
  return is_fuzzy_valid();
1032
1032
}
1033
1033
 
1034
1034
int Time::to_string(char *to, size_t to_len) const
1075
1075
                  _hours, _minutes, _seconds, _useconds);
1076
1076
}
1077
1077
 
1078
 
void Time::to_decimal(my_decimal *to) const
 
1078
void Time::to_decimal(type::Decimal *to) const
1079
1079
{
1080
1080
  int64_t time_portion= (((_hours * 100L) + _minutes) * 100L) + _seconds;
1081
 
  (void) int2my_decimal(E_DEC_FATAL_ERROR, time_portion, false, to);
 
1081
  (void) int2_class_decimal(E_DEC_FATAL_ERROR, time_portion, false, to);
1082
1082
  if (_useconds > 0)
1083
1083
  {
1084
1084
    to->buf[(to->intg-1) / 9 + 1]= _useconds * 1000;
1086
1086
  }
1087
1087
}
1088
1088
 
1089
 
void Date::to_decimal(my_decimal *to) const
 
1089
void Date::to_decimal(type::Decimal *to) const
1090
1090
{
1091
1091
  int64_t date_portion= (((_years * 100L) + _months) * 100L) + _days;
1092
 
  (void) int2my_decimal(E_DEC_FATAL_ERROR, date_portion, false, to);
 
1092
  (void) int2_class_decimal(E_DEC_FATAL_ERROR, date_portion, false, to);
1093
1093
}
1094
1094
 
1095
 
void DateTime::to_decimal(my_decimal *to) const
 
1095
void DateTime::to_decimal(type::Decimal *to) const
1096
1096
{
1097
1097
  int64_t date_portion= (((_years * 100L) + _months) * 100L) + _days;
1098
1098
  int64_t time_portion= (((((date_portion * 100L) + _hours) * 100L) + _minutes) * 100L) + _seconds;
1099
 
  (void) int2my_decimal(E_DEC_FATAL_ERROR, time_portion, false, to);
 
1099
  (void) int2_class_decimal(E_DEC_FATAL_ERROR, time_portion, false, to);
1100
1100
  if (_useconds > 0)
1101
1101
  {
1102
1102
    to->buf[(to->intg-1) / 9 + 1]= _useconds * 1000;
1125
1125
     + _seconds;
1126
1126
}
1127
1127
 
 
1128
// We fill the structure based on just int
 
1129
void Time::to_uint64_t(uint64_t &to) const
 
1130
{
 
1131
  to= _hours * 24
 
1132
     + _minutes * 60
 
1133
     + _seconds;
 
1134
}
 
1135
 
1128
1136
void DateTime::to_int64_t(int64_t *to) const
1129
1137
{
1130
1138
  *to= ((
1348
1356
    return false;
1349
1357
}
1350
1358
 
1351
 
void Date::to_time_t(time_t *to) const
 
1359
void Date::to_time_t(time_t &to) const
1352
1360
{
1353
1361
  if (in_unix_epoch())
1354
1362
  {
1355
 
    *to= _epoch_seconds;
 
1363
    to= _epoch_seconds;
1356
1364
  }
1357
1365
  else
1358
 
    *to= 0;
 
1366
  {
 
1367
    to= 0;
 
1368
  }
1359
1369
}
1360
1370
 
1361
 
void Timestamp::to_time_t(time_t *to) const
 
1371
void Timestamp::to_time_t(time_t &to) const
1362
1372
{
1363
 
  *to= _epoch_seconds;
 
1373
  to= _epoch_seconds;
1364
1374
}
1365
1375
 
1366
1376
void MicroTimestamp::to_timeval(struct timeval *to) const
1392
1402
      && (_seconds <= 59); /* No Leap second... TIME is for elapsed time... */
1393
1403
}
1394
1404
 
 
1405
bool Time::is_fuzzy_valid() const
 
1406
{
 
1407
  if (is_valid())
 
1408
    return true;
 
1409
 
 
1410
  return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)
 
1411
      && (_months >= 1 && _months <= 12)
 
1412
      && (_days >= 1 && _days <= days_in_gregorian_year_month(_years, _months))
 
1413
      && (_hours <= 23)
 
1414
      && (_minutes <= 59)
 
1415
      && (_seconds <= 59); /* No Leap second... TIME is for elapsed time... */
 
1416
}
 
1417
 
1395
1418
bool DateTime::is_valid() const
1396
1419
{
1397
1420
  return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)