Skip to Content.
Sympa Menu

freetds - Re: [freetds] Row-wise parameter array binding bug in 0.64

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Row-wise parameter array binding bug in 0.64
  • Date: Fri, 8 Sep 2006 10:57:03 +0200

>
> Dear All,
>
> I have found a bug concerning row-wise parameter array
> binding in the ODBC interface of freetds 0.64. When trying to
> insert multiple rows with row-wise binding (using the
> SQL_ATTR_PARAMSET_SIZE and SQL_ATTR_PARAM_BIND_TYPE statement
> attributes), I found that the first two rows are inserted
> correctly; however, instead of the rest of the rows in the
> batch, the second line is inserted over and over. Upon
> inspecting the problem, I have found that the error is in
> odbc/sql2tds.c, near line 207:
>
> <snip>
> src = drec_apd->sql_desc_data_ptr;
> if (src && stmt->curr_param_row) {
> if (stmt->apd->header.sql_desc_bind_type !=
> SQL_BIND_BY_COLUMN) {
> src += stmt->apd->header.sql_desc_bind_type;
> if (stmt->apd->header.sql_desc_bind_offset_ptr)
> src +=
> *stmt->apd->header.sql_desc_bind_offset_ptr;
> } else {
> </snip>
>
> It can be seen that the address of the parameter value is
> calculated by adding the row size to the start address for
> all rows except for the first one. Thus, the code gives the
> correct address for only the first two rows. Fix:
>
> <snip>
> src = drec_apd->sql_desc_data_ptr;
> if (src && stmt->curr_param_row) {
> if (stmt->apd->header.sql_desc_bind_type !=
> SQL_BIND_BY_COLUMN) {
> src += stmt->curr_param_row * stmt->apd->header.sql_desc_bind_type;
> if (stmt->apd->header.sql_desc_bind_offset_ptr)
> src +=
> *stmt->apd->header.sql_desc_bind_offset_ptr;
> } else {
> </snip>
>
> This calculates the correct address for all rows.
>
> Cheers,
> Levi
>

Hi Levi,
fixed in CVS (both 0.64 and HEAD). It was clearly a bug. As usual you
can find patch at http://freetds.sourceforge.net/

Regards,
Frediano Ziglio





Archive powered by MHonArc 2.6.24.

Top of Page