Skip to Content.
Sympa Menu

freetds - RE: [freetds] placeholders and messages

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: <ml AT freetds.org>
  • Cc:
  • Subject: RE: [freetds] placeholders and messages
  • Date: Fri, 8 Apr 2005 17:38:49 -0400

> From: ZIGLIO, Frediano, VF-IT
> Sent: Friday, April 08, 2005 3:21 AM
>
> Well, if you read my mail you will discover 4 bugs:
> - 1 MS odbc driver
> - 2 FreeTDS
> - 1 DBD::ODBC

I didn't quite understand your analysis. I think I do now.

> However the issue came from DBD::ODBC that do not handle
> SQLMoreResults if it returns SQL_ERROR. It works on MS odbc
> driver only because MS odbc driver discard error... I'm updating
> raiserror.c test to catch this case (and do some fix)

Two choices: make FreeTDS emulate Microsoft's driver, or make DBD::ODBC
do the right thing. I think #2 is better, if only because being
bug-compatible is hard: Sybase's driver will have different bugs.

It would be cool to add FreeTDS to the (short) list of "known
compatible" drivers. From .cpan/build/DBD-ODBC-1.13/README:

KNOWN COMPATIBLE Drivers (w/level 2 calls):
Driver Version Platform
Microsoft SQL Server v 2.65.0240 NT 4.0
Intersolv Oracle7 Driver* v 3.00.0000 NT 4.0

We could be #3! ;-)

It looks like the code in .cpan/build/DBD-ODBC-1.13/dbdimp.c::imp_sth_t
(line 2195 or so) is where SQLMoreResults is handled. I wouldn't mind
trying to patch it, but I have to understand the problem better. AIUI,
SQLMoreResults may return SQL_SUCCESS_WITH_INFO or SQL_ERROR, depending
on the severity argument to RAISERROR.

My test used severity 16. I tried severity 9. Get this: when I use
severity 9 AND I install an error handler ($dbh->{odbc_err_handler} =
\&err_handler;)), THEN odbc_rpc.pl prints the message: (!)

Executing: "{? = call t }" with parameters ''
execute returned: '-1'
Result #1:
[FirstResult]
'Here is the first row'
===> state: msg: This is an example error message.
Result #2:
[LastResult]
'Here is the last row'

This using 0.63. 0.62.3 still ignores the message.

More data
---------

I called the same test procedure, using severities 9 and 16, using
ActiveState Perl on a Windows box (using Microsoft's driver). The
result: severity 9 was not printed, and 16 led to a sequence error. It
did not matter whether odbc_err_handler was installed or not.

Microsoft, Severity 9:
$ perl odbc_rpc.pl [...] t
odbc_async_exec is: 1
Binding parameter #1, the return code

Executing: "{? = call t }" with parameters ''
execute returned: '-1'
Result #1:
[FirstResult]
'Here is the first row'
Result #2:
[LastResult]
'Here is the last row'

No message.

Microsoft, Severity 16:
$ perl odbc_rpc.pl [...] t
odbc_async_exec is: 1
Binding parameter #1, the return code

Executing: "{? = call t }" with parameters ''
execute returned: '-1'
Result #1:
[FirstResult]
'Here is the first row'
===> state: 42000 msg: This is an example error message.
^^^^^ not set by RAISERROR
DBD::ODBC::st fetchrow failed: (DBD: st_fetch/SQLMoreResults err=-1) at
odbc_rpc.pl line 98.
'Here is the first row' <== First row again!
===> state: HY010 msg: Function sequence error
DBD::ODBC::st fetchrow failed: (DBD: st_fetch/SQLFetch err=-1) at
odbc_rpc.pl line 98.

It looks like $sth->fetchrow returned the first row twice.

Conclusions
-----------

1. 0.63 + odbc_err_handler + (severity < 11) is OK
2. odbc_err_handler requires odbc_async_exec. One of these affects
DBD::ODBC's ability to recognize RAISERROR messages.
3. DBD::ODBC does not cope with higher severities.

Calling all Perlheads! Is the fetch loop in odbc_rpc.pl right and good?
Should it be doing something else? If the test is valid, it looks like
it's time to send a problem report to dbi-users AT perl.org.

--jkl




-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named
above. If you are not the intended recipient, or an employee or agent
responsible
for delivering this message to the intended recipient, any review,
dissemination,
distribution or duplication of this communication is strictly prohibited. If
you are
not the intended recipient, please contact the sender immediately by reply
e-mail
and destroy all copies of the original message. Please note that we do not
accept
account orders and/or instructions by e-mail, and therefore will not be
responsible
for carrying out such orders and/or instructions. If you, as the intended
recipient
of this message, the purpose of which is to inform and update our clients,
prospects
and consultants of developments relating to our services and products, would
not
like to receive further e-mail correspondence from the sender, please "reply"
to the
sender indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New
York,
NY 10105.




Archive powered by MHonArc 2.6.24.

Top of Page