MySQL Lists are EOL. Please join:

List:MySQL ODBC« Previous MessageNext Message »
From:Bill Dargel Date:October 12 2004 9:21pm
Subject:Fix for retrieving "time" fields
View as plain text  
Using MyODBC 3.51.09 I was getting back NULL for a column of type "time" 
that should have been "14:00:00". This was connecting to MySQL 4.0.21.

I perused the code and came up with the following patch to 
driver/results.c. No guarantees that I know what I'm doing, ;-) but it does 
handle my tests that were failing.

Apparently on a time field, what's sent across the wire is some variation 
on "HHMMSS"? The str_to_ts() function is expecting a date though, and 
returns an error if what it thinks should be the month is "00".

Is this the result of some recent change causing this to break?

-Bill
---------------------------------------------

--- results.c.orig      Thu Aug 12 12:02 2004
+++ results.c   Tue Oct 12 01:07 2004
@@ -883,21 +883,16 @@
      }
      case SQL_C_TIME:
      case SQL_C_TYPE_TIME:
-    {
-      SQL_TIMESTAMP_STRUCT ts;
-
-      if (str_to_ts(&ts,value))
-        *pcbValue= SQL_NULL_DATA;
-
-      else
+    {
+      ulong time= str_to_time(value,length);
        {
          SQL_TIME_STRUCT *time_info= (SQL_TIME_STRUCT *)rgbValue;

          if (time_info)
          {
-          time_info->hour= ts.hour;
-          time_info->minute= ts.minute;
-          time_info->second= ts.second;
+          time_info->hour=   (int) time/10000;
+          time_info->minute= (int) time/100%100;
+          time_info->second= (int) time%100;
          }
          *pcbValue=sizeof(TIME_STRUCT);
        }


-------------------------------------------
Bill Dargel            wdargel@stripped
Shoshana Technologies
100 West Joy Road, Ann Arbor, MI 48105  USA

Thread
Fix for retrieving "time" fieldsBill Dargel12 Oct
  • Re: Fix for retrieving "time" fieldsPeter Harvey13 Oct