[freetds] BUG?: incorrect struct tds_microsoft_dbdaterec

LacaK lacak at zoznam.sk
Fri Aug 20 04:03:53 EDT 2010


Hi,
I am not sure if this is right place to report bug or not, but I do not 
know if bug-tracker on sourceforge.net is active.
(if there is active bug tracke, let me know please)

There is in sybdb.h defined:

struct tds_microsoft_dbdaterec
{
    DBINT year;        /* 1753 - 9999         */
    DBINT quarter;        /* 1 - 4            */
    DBINT month;        /* 1 - 12            */
    DBINT day;        /* 1 - 31            */
    DBINT dayofyear;    /* 1 - 366            */
    DBINT week;                /* 1 - 54 (for leap years) */
    DBINT weekday;        /* 1 - 7 (Mon. - Sun.)     */
    DBINT hour;        /* 0 - 23            */
    DBINT minute;        /* 0 - 59            */
    DBINT second;        /* 0 - 59            */
    DBINT millisecond;    /* 0 - 999            */
    DBINT tzone;        /* 0 - 127  (Sybase only)  */   
};   

But Microsoft uses slightly different format, see: 
http://msdn.microsoft.com/en-us/library/aa937027(v=SQL.80).aspx

|typedef struct dbdaterec
{
    int year;            // 1753 - 9999 
    int quarter;         // 1 - 4 
    int month;           // 1 - 12 
    int dayofyear;       // 1 - 366 
    int day;             // 1 - 31 
    int week;            // 1 - 54 (for leap years) 
    int weekday;         // 1 - 7 (Mon. - Sun.) 
    int hour;            // 0 - 23 
    int minute;          // 0 - 59 
    int second;          // 0 - 59 
    int millisecond;     // 0 - 999 
} DBDATEREC;|

*
"day" and "dayofyear" are exchanged !!!*
So I think, that struct tds_microsoft_dbdaterec and function dbdatecrack 
(which only uses dbdaterec) must be adjusted:
(to keep "binnary" compatibilty with Microsoft implementation in 
ntwdblib.dll)
...
    if (dbproc ? dbproc->msdblib : msdblib) {
        ++di->quarter;
        ++di->datemonth;
        ++di->datedweek;
//add these two lines:
        di->datedmonth = dr.dayofyear;
        di->datedyear = dr.day;
    }

...

-Laco.



More information about the FreeTDS mailing list