List:MySQL ODBC« Previous MessageNext Message »
From:Peter Harvey Date:October 13 2004 4:28pm
Subject:Re: Fix for retrieving "time" fields
View as plain text  
Can you please submit this as a bug report so that it will get more closely 
looked at and so that you will be informed of the resolution (as the bug 
submitter).

Thanks


On Tuesday 12 October 2004 14:21, Bill Dargel wrote:
> 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

-- 
Peter Harvey, Software Developer
MySQL AB, www.mysql.com
Office: +1 619 251-6923

Are you MySQL certified?  www.mysql.com/certification

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