Skip to Content.
Sympa Menu

freetds - Re: [freetds] dbdatecrack producing erroneous results

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: crunsus <crunsus AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] dbdatecrack producing erroneous results
  • Date: Tue, 24 Apr 2012 16:44:35 -0400

I solved the problem finally, after investigating deeper into the guts of dbdatecrack inside dblib.c line 5529
if (dbproc->msdblib) {
++di->month;
++di->weekday;
}
and stepping through this code I realized that dbproc->msdblib is never set to 1 so no adjustment is performed hence the difference in the results. I did more digging and found that MSDBLIB had to be defined for that to happen.
I rebuilt the FreeTDS with MSDBLIB defined which broke some other stuff because DBDATEREC has now different members but I managed to correct those errors and voila, now it works perfectly and I no longer need my lousy replacement function.
It is just that no one told me that I needed to define MSDBLIB, it is not very evident but it kind of makes sense since I run against SQL Server and not against Sybase, it never occured to me that they would be that much different.
Anyways big thanks to Frediano for pointing me into the right direction, he is right, his code works,it is just that dbproc->msdblib was never set in my case and I didn't realize that MS had implemented the encoding of the datetime differently than Sybase and it needed to be re-adjusted after tds_datecrack was applied for cracking. I always assumed FreeTDS would work out of the box for SQL Server but apparently it comes preconfigured for Sybase DBLIB,
I had to change #define SYBDBLIB 1 into #define MSDBLIB 1 and things started to work out for me.
So many thanks for the help given to a newbie and again congrats for your product, it absolutely kicks ass.

Best Regards,
Crunsus


Message: 1
Date: Mon, 23 Apr 2012 17:45:36 +0100
From: Frediano Ziglio<freddy77 AT gmail.com>
Subject: Re: [freetds] dbdatecrack producing erroneous results
To: FreeTDS Development Group<freetds AT lists.ibiblio.org>
Message-ID:
<CAHt6W4e4Hg4Nc2f0EbyCMK-jBo3Ei+=45eKfsFSifoXtk_6-hQ AT mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

I compared your function with tds_datecrack looping with a program
from 1753/1/1 to 4000/1/1 (not taking into account time) and I got
same results.

There should be something in the detection of msdblib flag that is wrong.

Frediano








Archive powered by MHonArc 2.6.24.

Top of Page