Skip to Content.
Sympa Menu

freetds - RE: DBLIB Unit Tests failing again

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Bill Thompson" <thompbil AT exchange.uk.ml.com>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: RE: DBLIB Unit Tests failing again
  • Date: Mon, 16 Sep 2002 08:34:02 -0400


> Hi Guys,
>

Hi again! I must stop answering my own messages :-)

> 2) The third column (which is *numeric* not float ) has clearly become
> corrupted somewhere along the line. I am sure this is an endian issue. I
> don't have the capability to test a little endian client, so I'll need
> some help. It would be really useful to know if the column became
> corrupted on the bcp "in" or bcp "out". I think the dblib0016 table
> persists after the test program has been run. David, perhaps you could
> tell me if the data in the database is corrupt ?
>

I think I've tracked this down. The problem is that internally to freetds
we store numeric data in a byte array in big-endian format. If we're
talking to SQL Server this needs to be byteswapped regardless of whether
the client is big or little endian. The code in question is in bcp.c,
function _bcp_exec_in().

I think we need to replace :

#ifdef WORDS_BIGENDIAN

tds_swap_datatype(tds_get_conversion_type(bcpcol->db_type,
bcpcol->db_length),
bcpcol->data);
#endif

with:

#ifdef WORDS_BIGENDIAN

tds_swap_datatype(tds_get_conversion_type(bcpcol->db_type,
bcpcol->db_length),
bcpcol->data);
#else
if (is_numeric_type(bcpcol->db_type)) {

tds_swap_datatype(tds_get_conversion_type(bcpcol->db_type,
bcpcol->db_length),
bcpcol->data);
}
#endif

could someone check that out on a little-endian client and see if it works
( and if so , do the patch ) ? Thankyou.

> 3) The date formats are different - the output format excludes the seconds
> and milliseconds, which is not acceptable. This issue goes back a *long*
> way :-). I think you must have defined a date format in your freetds.conf
> , which the dblib convert function picks up. I think I'm going to have to
> hardwire the bcp functions so that they always output dates in the
> "complete" format.
>

I'm in two minds about how to do this. I think the neatest way would be to
temporarily override the date output format while in function
_bcp_exec_out().
I can see how to do this from the code in dbinit(), but the trouble is
that the context is declared static in dblib.c :

static DBLIBCONTEXT *g_dblib_ctx = NULL;

and I need to reference it from bcp.c ....

Would it be safe to increase the scope of this declaration ?


> Bill

Bill :-)




Archive powered by MHonArc 2.6.24.

Top of Page