Navigation Menu

Skip to content

Commit

Permalink
[mysql56][mariadb] support store_timestamp(). refs #1266
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 31, 2012
1 parent ee9094a commit 429a7c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 13 additions & 3 deletions ha_mroonga.cc
Expand Up @@ -6930,15 +6930,15 @@ long long int ha_mroonga::get_grn_time_from_timestamp_field(Field_timestamp *fie
{
MRN_DBUG_ENTER_METHOD();
long long int grn_time = 0;
#ifdef MRN_FIELD_TIMESTAMP_GET_TIMESTAMP_USE_TIMEVAL
#ifdef MRN_TIMESTAMP_USE_TIMEVAL
int warnings = 0;
struct timeval time_value;
if (field->get_timestamp(&time_value, &warnings)) {
// XXX: Should we report warnings or MySQL does?
} else {
grn_time = GRN_TIME_PACK(time_value.tv_sec, time_value.tv_usec);
}
#elif defined(MRN_FIELD_TIMESTAMP_GET_TIMESTAMP_USE_MY_TIME_T)
#elif defined(MRN_TIMESTAMP_USE_MY_TIME_T)
unsigned long int micro_seconds;
my_time_t seconds = field->get_timestamp(&micro_seconds);
grn_time = GRN_TIME_PACK(seconds, micro_seconds);
Expand Down Expand Up @@ -7250,10 +7250,20 @@ void ha_mroonga::storage_store_field_timestamp(Field *field,
uint value_length)
{
long long int time = *((long long int *)value);
Field_timestamp *timestamp_field = (Field_timestamp *)field;
#ifdef MRN_TIMESTAMP_USE_TIMEVAL
struct timeval time_value;
GRN_TIME_UNPACK(time, time_value.tv_sec, time_value.tv_usec);
timestamp_field->store_timestamp(&time_value);
#elif defined(MRN_TIMESTAMP_USE_MY_TIME_T)
int32 sec, usec;
GRN_TIME_UNPACK(time, sec, usec);
timestamp_field->store_TIME(sec, usec);
#else
int32 sec, usec __attribute__((unused));
GRN_TIME_UNPACK(time, sec, usec);
Field_timestamp *timestamp_field = (Field_timestamp *)field;
timestamp_field->store_timestamp(sec);
#endif
}

void ha_mroonga::storage_store_field_date(Field *field,
Expand Down
6 changes: 3 additions & 3 deletions ha_mroonga.h
Expand Up @@ -107,11 +107,11 @@ extern "C" {
#endif

#if MYSQL_VERSION_ID >= 50604
# define MRN_FIELD_TIMESTAMP_GET_TIMESTAMP_USE_TIMEVAL
# define MRN_TIMESTAMP_USE_TIMEVAL
#elif defined(MRN_MARIADB_P)
# define MRN_FIELD_TIMESTAMP_GET_TIMESTAMP_USE_MY_TIME_T
# define MRN_TIMESTAMP_USE_MY_TIME_T
#else
# define MRN_FIELD_TIMESTAMP_GET_TIMESTAMP_USE_LONG
# define MRN_TIMESTAMP_USE_LONG
#endif

class ha_mroonga;
Expand Down

0 comments on commit 429a7c9

Please sign in to comment.