Skip to Content.
Sympa Menu

freetds - Re: Big Endian Patches

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: David Ramsey <dramsey AT neosoft.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Big Endian Patches
  • Date: Tue, 13 Feb 2001 13:56:33 -0600


Ok, now I am seeing some weird behavior. With the patch in place, I can
use SQSH 1.7 and access the SQL Server database and get proper date
outputs. But using the same libraries to link DBD::Sybase against and
running the same query, I am getting the dates in gibberish now. I am
quite certain this is a byte ordering issue but is there anywhere else
to look inside Free TDS or do I need to dig into the DBD::Sybase code?

Thanks for any assistance.

David Ramsey wrote:
>
> I just started using Free TDS to pull data from a MS SQL Server 6.5
> database into Oracle 8i but I had similar problems with formatting of
> the dates. What I found was that a similar change needed to be applied
> to the tds_convert_datetime function as had originally been applied to
> the tds_convert_datetime4 function. The sole difference was that the
> "word" size in this case was 4 bytes so in the loop all references to 2
> were changed to 4.
>
> Here's my diff of my working convert.c versus what I got when I did a
> cvs diff today. Hopefully this will help other people who have to suck
> data out of MS SQL Server machines over to Sparcs (and other big endian
> machines).
>
> cvs diff -w convert.c
> Index: convert.c
> ===================================================================
> RCS file: /Repository/freetds/src/tds/convert.c,v
> retrieving revision 1.46
> diff -w -r1.46 convert.c
> 494a495,497
> > #ifdef WORDS_BIGENDIAN
> > int i, n;
> > #endif
> 522a526,532
> > #ifdef WORDS_BIGENDIAN /* We need to swap the words */
> > n = sizeof(TDS_DATETIME) ;
> > memset(dest, '\0', n ) ;
> > for ( i = 0; i < sizeof(TDS_DATETIME) ; i += 4)
> > memcpy(dest + i, src + (n - 4) - i, 4) ;
> >
> > #else
> 523a534,535
> > #endif
> > // memcpy(dest,src,sizeof(TDS_DATETIME));
> 537a550,552
> > #ifdef WORDS_BIGENDIAN
> > int i, n;
> > #endif
> 567a583,589
> > #ifdef WORDS_BIGENDIAN /* We need to swap the words */
> > n = sizeof(TDS_DATETIME4) ;
> > memset(dest, '\0', n ) ;
> > for ( i = 0; i < sizeof(TDS_DATETIME4) ; i += 2)
> > memcpy(dest + i, src + (n - 2) - i, 2) ;
> >
> > #else
> 568a591
> > #endif
>

--
David Ramsey -- dramsey AT neosoft.com

-- There is an old Vulcan proverb: only Nixon could go to China.




Archive powered by MHonArc 2.6.24.

Top of Page