Skip to Content.
Sympa Menu

freetds - Re: Troubles with getting datetime field

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: "'TDS Development Group'" <freetds AT franklin.metalab.unc.edu>
  • Subject: Re: Troubles with getting datetime field
  • Date: Mon, 13 May 2002 12:18:25 -0400


> From: Vladimir Maximenko [mailto:mvu AT wplus.net]
> Sent: May 13, 2002 11:03 AM
>
> Yes! I solve this trouble by adding next string into
> TDS_INT tds_convert_datetime(int srctype,unsigned char *src,int
> desttype,unsigned char *dest,TDS_INT destlen)
>
> instead
> if (destlen<0) {
> memset(dest,' ',30);
> } else {
> memset(dest,' ',destlen);
> }
> I wrote
> if (destlen<0) {
> memset(dest,' ',30);
> destlen=30;
> } else {
> memset(dest,' ',destlen);
> }
> and it's working!
> Am I right?

Vladimir,

Yes, looks good. I checked the calling hierarchy back to dblib/dblib.c.
tds_convert basically supports dbconvert(), where a -1 destination length is
an assurance from the calling application that sufficient space is
available.

I did not check ctlib or odbc; I'm not as familiar with those APIs.

A simpler version would be:

if (destlen < 0)
destlen = 30;

memset(dest,' ',destlen);

That's what I'll check in unless someone hollers.

There's a big unapplied datetime patch out there, so this solution might not
last for long.

Thanks for the patch, Vladimir.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page