Navigation Menu

Skip to content

Commit

Permalink
[mysql56] support Field_timestamp::get_timestamp().
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 31, 2012
1 parent 0a0e2c5 commit 98f8bd5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
28 changes: 25 additions & 3 deletions ha_mroonga.cc
Expand Up @@ -6926,14 +6926,36 @@ int ha_mroonga::generic_store_bulk_float(Field *field, grn_obj *buf)
DBUG_RETURN(error);
}

long long int ha_mroonga::get_grn_time_from_timestamp_field(Field_timestamp *field)
{
MRN_DBUG_ENTER_METHOD();
long long int grn_time = 0;
#ifdef MRN_FIELD_TIMESTAMP_GET_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)
unsigned long long int micro_seconds;
my_time_t seconds = field->get_timestamp(&micro_seconds);
grn_time = GRN_TIME_PACK(seconds, micro_seconds);
#else
my_bool is_null_value;
long seconds = field->get_timestamp(&is_null_value);
grn_time = GRN_TIME_PACK(seconds, 0);
#endif
DBUG_RETURN(grn_time);
}

int ha_mroonga::generic_store_bulk_timestamp(Field *field, grn_obj *buf)
{
MRN_DBUG_ENTER_METHOD();
int error = 0;
my_bool is_null_value;
Field_timestamp *timestamp_field = (Field_timestamp *)field;
long seconds = timestamp_field->get_timestamp(&is_null_value);
long long int time = GRN_TIME_PACK(seconds, 0);
long long int time = get_grn_time_from_timestamp_field(timestamp_field);
grn_obj_reinit(ctx, buf, GRN_DB_TIME, 0);
GRN_TIME_SET(ctx, buf, time);
DBUG_RETURN(error);
Expand Down
10 changes: 10 additions & 0 deletions ha_mroonga.h
Expand Up @@ -106,6 +106,14 @@ extern "C" {
# define MRN_HAVE_HA_EXTRA_PREPARE_FOR_FORCED_CLOSE
#endif

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

class ha_mroonga;

/* structs */
Expand Down Expand Up @@ -402,6 +410,8 @@ class ha_mroonga: public handler
longlong *limit,
grn_obj *target_table, grn_obj *score_column);

long long int get_grn_time_from_timestamp_field(Field_timestamp *field);

int generic_store_bulk_string(Field *field, grn_obj *buf);
int generic_store_bulk_integer(Field *field, grn_obj *buf);
int generic_store_bulk_float(Field *field, grn_obj *buf);
Expand Down

0 comments on commit 98f8bd5

Please sign in to comment.