[Groonga-mysql-commit] mroonga/mroonga [master] [mysql56] support Field_timestamp::get_timestamp().

Back to archive index

null+****@clear***** null+****@clear*****
2012年 1月 31日 (火) 17:39:52 JST


Kouhei Sutou	2012-01-31 17:39:52 +0900 (Tue, 31 Jan 2012)

  New Revision: 98f8bd50400d6bf7ead69fa79ab9d1d202ec0dc4

  Log:
    [mysql56] support Field_timestamp::get_timestamp().

  Modified files:
    ha_mroonga.cc
    ha_mroonga.h

  Modified: ha_mroonga.cc (+25 -3)
===================================================================
--- ha_mroonga.cc    2012-01-31 17:03:20 +0900 (3ea0e50)
+++ ha_mroonga.cc    2012-01-31 17:39:52 +0900 (b1ef7b0)
@@ -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);

  Modified: ha_mroonga.h (+10 -0)
===================================================================
--- ha_mroonga.h    2012-01-31 17:03:20 +0900 (4e6c8ff)
+++ ha_mroonga.h    2012-01-31 17:39:52 +0900 (8266976)
@@ -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 */
@@ -402,6 +410,8 @@ private:
                               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);




Groonga-mysql-commit メーリングリストの案内
Back to archive index