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: Frediano Ziglio <freddyz77 AT tin.it>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] placeholders and messages
  • Date: Sat, 09 Apr 2005 10:36:56 +0200

Il giorno ven, 08-04-2005 alle 17:38 -0400, Lowden, James K ha scritto:
> > 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.
>

I don't like to fill our driver of workaround for others package bugs.
If I remember there are already 2/3 of these in code (I remember one for
PHP and one for DBD::ODBC witch do not pass NULLs correctly binding
parameters...). However this workaround can lead to different problem so
I would avoid it. DBD::ODBC should be fixed...

> 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 would be very fine...

> 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.
>

Yes.

> 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.
>

Also CC me and Jeff Urlwin (DBD::ODBC author).

I would proceed in this way (not in order)
- (opt) provide a patch for DBD::ODBC 1.13 to fix this issue (on our ML
too)
- (opt) updated 20SqlServer.t (see http://svn.perl.org/modules/dbd-
odbc/trunk/t/20SqlServer.t) to test this issue
- post a detailed message to DBI and Jeff to let he know
- update FreeTDS tests to catch all these problems (and fix them), it
would be fine in 0.64 to read data like MS odbc do (I remember a post on
ML that state for example that after all rows are retrieved (sqlfetch
returned success but never no data) it can issue another query (perhaps
this require some change in token handling...).

freddy77






Archive powered by MHonArc 2.6.24.

Top of Page