[Groonga-mysql-commit] mroonga/mroonga [master] [mariadb] support no fractional second TIME.

Back to archive index

null+****@clear***** null+****@clear*****
2012年 2月 22日 (水) 22:55:01 JST


Kouhei Sutou	2012-02-22 22:55:01 +0900 (Wed, 22 Feb 2012)

  New Revision: 25d886815616bf6a2c8cc2f7898b9f64916b332d

  Log:
    [mariadb] support no fractional second TIME.

  Modified files:
    ha_mroonga.cc

  Modified: ha_mroonga.cc (+30 -12)
===================================================================
--- ha_mroonga.cc    2012-02-22 22:18:35 +0900 (7aa0798)
+++ ha_mroonga.cc    2012-02-22 22:55:01 +0900 (881c9f2)
@@ -8520,19 +8520,37 @@ int ha_mroonga::storage_encode_key_time(Field *field, const uchar *key,
   int error = 0;
   long long int time;
 #ifdef MRN_MARIADB_P
-  // TODO: remove me when MariaDB becomes based on MySQL 5.6.
-  // This implementation may be costful.
-  Field_time_hires *time_hires_field = (Field_time_hires *)field;
-  Field_time_hires unpacker((uchar *)key,
-                            (uchar *)(key - 1),
-                            time_hires_field->null_bit,
-                            time_hires_field->unireg_check,
-                            time_hires_field->field_name,
-                            time_hires_field->decimals(),
-                            time_hires_field->charset());
   MYSQL_TIME mysql_time;
-  uint fuzzy_date = 0;
-  unpacker.get_date(&mysql_time, fuzzy_date);
+  if (field->decimals() == 0) {
+    long long int packed_time = sint3korr(key);
+    mysql_time.neg = false;
+    if (packed_time < 0) {
+      mysql_time.neg = true;
+      packed_time = -packed_time;
+    }
+    mysql_time.year = 0;
+    mysql_time.month = 0;
+    mysql_time.day = 0;
+    mysql_time.hour = (int)(packed_time / 10000);
+    long long int minute_part = packed_time - mysql_time.hour * 10000;
+    mysql_time.minute = (int)(minute_part / 100);
+    mysql_time.second = (int)(minute_part % 100);
+    mysql_time.second_part = 0;
+    mysql_time.time_type = MYSQL_TIMESTAMP_TIME;
+  } else {
+    // TODO: remove me when MariaDB becomes based on MySQL 5.6.
+    // This implementation may be costful.
+    Field_time_hires *time_hires_field = (Field_time_hires *)field;
+    Field_time_hires unpacker((uchar *)key,
+                              (uchar *)(key - 1),
+                              time_hires_field->null_bit,
+                              time_hires_field->unireg_check,
+                              time_hires_field->field_name,
+                              time_hires_field->decimals(),
+                              time_hires_field->charset());
+    uint fuzzy_date = 0;
+    unpacker.get_date(&mysql_time, fuzzy_date);
+  }
   time = mrn_mysql_time_to_grn_time(&mysql_time);
 #else
   int mysql_time = (int)sint3korr(key);




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