On Thu, Feb 19, 2004 at 02:09:16PM +0100, Steffen Goeldner wrote:
> Tim Bunce wrote:
> >
> > I'd also like driver authors to consider/try-out the new
> > [...]
> > - Recording 'success with info' (incl db messages etc) and 'warnings'
>
> Calling perl -Mblib set_err.pl, the sequence
>
> $dbh->set_err( '','E1');
> $dbh->set_err( 0 ,'E2'); # nok
>
> (in DBD::NullP::db::nullp_test) doesn't escalate from info to warning:
> However
> $dbh->set_err( '','E1');
> $dbh->set_err('0','E2'); # ok
> works:
Well spotted. I can replicate that with this change to the tests:
--- t/08keeperr.t (revision 56)
+++ t/08keeperr.t (working copy)
@@ -88,7 +88,7 @@
is($warn, 0);
is("@handlewarn", "1 0 0");
-$dbh->set_err("0", "(got warn)", "AA001");
+$dbh->set_err(0, "(got warn)", "AA001");
ok(defined $DBI::err);
is($DBI::err, "0");
is($DBI::errstr, "(got info)\n(got warn)");
> Is there a problem with SvCUR and numeric 0 (at least in perl v5.6.1)?
A literal integer in the source probably generates an SV that SvNIOK
but not SvPOK.
This seems to fix it:
--- DBI.xs (revision 64)
+++ DBI.xs (working copy)
@@ -488,7 +488,8 @@
if (SvTRUE(err) /* new error: so assign */
|| !SvOK(h_err) /* no existing warn/info: so assign */
/* new warn ("0" len 1) > info ("" len 0): so assign */
- || (SvOK(err) && SvCUR(err) > SvCUR(h_err)) ) {
+ || (SvOK(err) && strlen(SvPV_nolen(err)) > strlen(SvPV_nolen(h_err)))
+ ) {
sv_setsv(h_err, err);
err_changed = 1;
}
> --- DBI-1.41-RC1-orig/DBI.pm Tue Feb 17 13:18:08 2004
> +++ DBI-1.41-RC1/DBI.pm Thu Feb 19 12:22:39 2004
> @@ -316,6 +316,7 @@
> ix_ => { class => 'DBD::Informix', },
> msql_ => { class => 'DBD::mSQL', },
> mysql_ => { class => 'DBD::mysql', },
> + nullp_ => { class => 'DBD::NullP', },
> odbc_ => { class => 'DBD::ODBC', },
Applied.
Thanks Steffen.
Have you tried using the new set_err semantics for warnings DBD::ADO?
Tim.