On Thu Dec 10 11:51:03 2009, nomorsad wrote:
Show quoted text> Hi,
>
> The DBD::ODBC Perl module don't seems to work with the ODBC Sqlite
> driver from
http://www.ch-werner.de/sqliteodbc/ (last version 0.84)
>
> However, this SQlite driver works great with other non-Perl applications.
>
> I think the message come from :
>
http://www.ch-werner.de/sqliteodbc/html/sqlite3odbc_8c-source.html#l08995
>
> Regards,
> Vincent
>
>
>
> * Versions :
> ActivePerl 5.8.9
> DBD::ODBC 1.23
> DBI 1.609
>
> * Example of script :
>
> use DBD::ODBC;
> DBI->connect("dbi:ODBC:DSN=SCF1");
>
> output with stack trace:
>
> DBI connect('DSN=SCF1','',...) failed: invalid length or pointer
> (SQL-HY009) at C:/Perl/lib/DBI.pm line 652
> DBI::__ANON__(undef, undef) called at C:/Perl/lib/DBI.pm line 706
> DBI::connect('DBI', 'dbi:ODBC:DSN=SCF1') called at C:\Documents and
> Settings\Administrateur\Bureau\test.pl line 3
DBD::ODBC uses SQLSetConnectOption (the older API) not
SQLSetConnectAttr. The driver manager is supposed to translate
SQLSetCOnnectOption calls to SQLSetConnectAttr calls and I'd guess it
does not set len to SQL_IS_INTEGER (it probably passed 0). If you look
at the ODBC API docs sqllite should not be looking at the len for
SQL_AUTO_COMMIT as they say:
"If Attribute is an ODBC-defined attribute and ValuePtr is an integer,
StringLength is ignored."
You can find the docs here:
http://msdn.microsoft.com/en-us/library/ms713605%28VS.85%29.aspx
I think sqllite is wrong in this case, it should not require the len to
be SQL_IS_INTEGER or SQL_IS_UINTEGER or SQL_IS_POINTER as
SQL_AUTO_COMMIT is an ODBC defined attribute. Also, the remainder of the
code is absolutely wrong here:
if (val && len >= sizeof (SQLINTEGER)) {
09019 getit:
09020 d->autocommit = *((SQLINTEGER *) val) ==
SQL_AUTOCOMMIT_ON;
I len was > sizeof(SQLINTEGER) and val was 0 or 1 (for on or off) then
the code above would attempt to dereference 0 or 1 which would seg fault.
You need to go back to the sqllite people and tell then this code is
wrong. If the attribute is SQL_AUTO_COMMIT they can simply treat val as
an SQL_INTEGER which contains SQL_AUTOCOMMIT_ON or OFF.
I'll leave this report open for a while in case you or someone at
sqllite want to comment but it is not a bug in DBD::ODBC.
Martin
--
Martin J. Evans
Wetherby, UK