[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: back-sql writes binding improperly



Brad Midgley wrote:

Pierangelo

I note that it appears that your RDBMS requires the column size to
be set when values of SQL_CHAR type are used.


FYI, freetds also wants the column size set for SQL_VARCHAR.

It would be easier to find these things if openldap examined the output from SQLBindParameter. Freetds was returning a failure code with the 0-length column.

Would you accept patches along these lines for the bindparameter calls?


Definitely. I'm happy to receive feedback about other RDBMS than those I can test personally,
and I'm fine with patches that improve the portability and usability, provided they don't break
things that work (at least for me ;).




rc = SQLBindParameter( sth, pno + 2 - po,
SQL_PARAM_INPUT,
SQL_C_CHAR, SQL_CHAR,
0, 0, at_val->bv_val,
at_val->bv_len, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
" backsql_modify_internal(): "
"add_proc param bind failed\n",
0, 0, 0 );
backsql_PrintErrors( bi->db_env,
dbh, sth, rc );


                    if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
                        rs->sr_err = LDAP_OTHER;
                        rs->sr_text = "SQL-backend error";
                        goto done;
                    }
                }

I have very little reliable documentation about ODBC, and, from what I could find,
the column size should be set for most if not all types, including integers. However,
nobody ever complained. SQL_CHAR types are used only in add.c, while
SQL_VARCHAR are used in other operations as well, so I assumed you could do
fine with them. I'll update all SQLBindParameter calls.


p.



   SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497