On Thu, Sep 12, 2002 at 07:47:10AM -0400, Steven N. Hirsch wrote:
> On Thu, 12 Sep 2002, Tim Bunce wrote:
>
> > > sub proxy_set_err {
> > > my ($h,$errmsg) = @_;
> > > my ($err,$state) =
> > > - ($errmsg =~ s/ \[err=(.*?),state=(.*?)\]//) ? ($1,$2) : (1,5 x ' ');
> > > + ($errmsg =~ s/ \[err=(.*?),state=(.*?)\]//) ? ($1,$2) : (1,' ');
> > > return DBI::set_err($h, $err, $errmsg, $state);
> > > }
> >
> > I think a better fix is to use ... : (1,'')
> > which is what I suggested originally. Was there a problem with that?
>
> Yes, it causes an exception from DBI::set_err(), which carps about
> expecting a five char string. My original use of a single space was a
> typo, but I did try it with '' - same problem.
>
> > If state is '' but err is non-zero then the DBI will return state
> > as 'S1000' (general error).
>
> I'll look into why this doesn't seem to be working for me.
Ah, I'd looked at the wrong set_err in DBI.xs (there are two).
Here's a patch:
***************
*** 3630,3636 ****
if (errstr==&sv_no || !SvOK(errstr))
errstr = errval;
sv_setsv(DBIc_ERRSTR(imp_xxh), errstr);
! if (SvOK(state)) {
STRLEN len;
if (SvPV(state, len) && len != 5)
croak("set_err: state must be 5 character string");
--- 3648,3654 ----
if (errstr==&sv_no || !SvOK(errstr))
errstr = errval;
sv_setsv(DBIc_ERRSTR(imp_xxh), errstr);
! if (SvTRUE(state)) {
STRLEN len;
if (SvPV(state, len) && len != 5)
croak("set_err: state must be 5 character string");
Tim.
> > > --- ProxyServer.pm 2002/09/10 01:37:40 1.5
> > > +++ ProxyServer.pm 2002/09/12 00:35:25 1.6
> > > @@ -195,7 +195,7 @@
> > > - my $state = $_[1]->state || '';
> > > + my $state = $_[1]->state || ' ';
> >
> > I don't think that needs changing.
>
> If the logic on the client is fixed per my patch, I agree. It's odd that
> we're seeing different behavior from DBI::set_err().
>
> Will advise...
>
>