freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Frediano Ziglio <freddyz77 AT tin.it>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: RE: [freetds] Re: SQL_C_BINARY type issue
- Date: Sun, 22 Feb 2004 10:03:02 +0100
> >
> > On Feb 18, 2004, at 2:51 PM, Jonathan Monroe wrote:
> >
> > > I think I have found an issue with the way the SQL_C_BINARY
> > data type
> > > is handled in the ODBC code.
> > [snip]
> >
> > It just occurred to me that the patch I provided for
> > convert_tds2sql.c
> > only fixed the problem for varchar columns - other column types will
> > still have some sort of conversion performed. The better way of
> > handling it is probably to treat SQL_C_BINARY as a special
> > case and not
> > call tds_convert() at all.
> >
> > So, the new patch would look like this:
> >
> > convert_tds2sql.c: v1.37:
> > 81,84c81,102
> > < nRetVal = tds_convert(context, srctype, src, srclen,
> > nDestSybType, &ores);
> > < if (nRetVal < 0)
> > < return nRetVal;
> > <
> > ---
> > > if (desttype == SQL_C_BINARY)
> > > {
> > > /* just copy the raw bytes */
> > > if (destlen > 0) {
> > > cplen = (destlen > srclen) ? srclen
> > : destlen;
> > > assert(cplen >= 0);
> > > /* do not NULL terminate binary buffer */
> > > memcpy(dest, src, cplen);
> > > ret = cplen;
> > > } else {
> > > /* if destlen == 0 we return only length */
> > > if (destlen != 0)
> > > ret = TDS_FAIL;
> > > }
> > > }
> > > else
> > > {
> > > nRetVal = tds_convert(context, srctype, src, srclen,
> > nDestSybType, &ores);
> > > if (nRetVal < 0)
> > > return nRetVal;
> > > }
> > >
> > 236,250c254
> > < tdsdump_log(TDS_DBG_FUNC, "convert_tds2sql:
> > outputting
> > binary data destlen = %d \n", destlen);
> > <
> > < ret = nRetVal;
> > < if (destlen > 0) {
> > < cplen = (destlen > nRetVal) ? nRetVal
> > : destlen;
> > < assert(cplen >= 0);
> > < /* do not NULL terminate binary buffer */
> > < memcpy(dest, ores.ib, cplen);
> > < } else {
> > < /* if destlen == 0 we return only length */
> > < if (destlen != 0)
> > < ret = TDS_FAIL;
> > < }
> > <
> > < free(ores.ib);
> > ---
> > > /* handled as special case above */
> >
> >
> > Anybody see any problems with doing it this way?
> >
> > Jonathan Monroe
> >
>
> You spot a real problem. I don't know if is correct to handle varchar as
> a binary string (ie: '012345') however I don't know the real behaviour
> for other types. For instance how MS ODBC return a datetime?? Same
> format of wire (as FreeTDS does now) or converting to TIMESTAMP before
> ?? Some tests are needed to handle this type...
>
SQL_C_BINARY behavior is correct and reflect MS ODBC one. I don't know
why but all library (dblib, CTLib and ODBC) have the same behavior.
I'm doing some tests for DATETIME and others type.
freddy77
-
RE: [freetds] Re: SQL_C_BINARY type issue,
ZIGLIO, Frediano, VF-IT, 02/20/2004
- RE: [freetds] Re: SQL_C_BINARY type issue, Frediano Ziglio, 02/22/2004
- <Possible follow-up(s)>
- [freetds] Re: SQL_C_BINARY type issue, Jonathan Monroe, 02/22/2004
- RE: [freetds] Re: SQL_C_BINARY type issue, ZIGLIO, Frediano, VF-IT, 02/23/2004
- [freetds] Re: SQL_C_BINARY type issue, Jonathan Monroe, 02/23/2004
- RE: [freetds] Re: SQL_C_BINARY type issue, ZIGLIO, Frediano, VF-IT, 02/23/2004
- RE: [freetds] Re: SQL_C_BINARY type issue, Lowden, James K, 02/23/2004
Archive powered by MHonArc 2.6.24.