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

Ian Ashley iashley at picdar.com
Wed Sep 20 04:29:35 EDT 2006


Levi,

Thanks very much for the follow up message you sent. I have now got it to
work using Sequel Server. While not directly related to this mailing does
anyone know if there is a way to do the same thing using ODBC to talk to an
Oracle database? The call

SQLSetStmtAttr(hstmt, SQL_ATTR_PARAM_BIND_TYPE, (SQLPOINTER) sizeof(struct
row), 0);

fails with ³IM001 - [unixODBC][Driver Manager]Driver does not support this
function² on Oracle databases.


Cheers,


From: "Levente Tamási   (IJ/ETH)" <Levente.Tamasi at ericsson.com>
Reply-To: FreeTDS Development Group <freetds at lists.ibiblio.org>
Date: Thu, 7 Sep 2006 15:06:28 +0200
To: <freetds at lists.ibiblio.org>
Conversation: Row-wise parameter array binding bug in 0.64
Subject: [freetds] Row-wise parameter array binding bug in 0.64

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


_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________




More information about the FreeTDS mailing list