On Mon, Feb 17, 2003 at 09:16:17PM +1100, Bradley Baetz wrote:
> On Mon, Feb 17, 2003 at 09:25:33AM +0000, Tim Bunce wrote:
> > Did you try moving these two lines:
> >
> > SV *ka_rv = *hv_fetch((HV*)DBIc_MY_H(imp_sth),
>keyattrib,strlen(keyattrib), TRUE);
> > ka_rv = newSVsv(ka_rv); /* copy to invoke FETCH magic */
> >
> > to the top of the function, specifically before the perl_call_method("fetch",)
> >
> > Tim.
> >
>
> Hmm. I thought I had, but it turned out that I didn't move the keyattrib
> test too, so stuff got tainted from there.
>
> Patch attached, passes 5.6.1 and 5.8.0. 5.005_03 passes if I comment out
> the Time::HiRes use, and ignore some Test.pm undefined var warnings.
Great! Thanks.
Tim.
> Bradley
> --- DBI-1.32.orig/DBI.xs Sun Dec 1 14:36:44 2002
> +++ DBI-1.32/DBI.xs Mon Feb 17 01:49:35 2003
> @@ -3455,13 +3455,12 @@
> char * keyattrib
> PREINIT:
> SV *rowavr;
> + SV *ka_rv;
> D_imp_sth(sth);
> CODE:
> PUSHMARK(sp);
> XPUSHs(sth);
> PUTBACK;
> - if (perl_call_method("fetch", G_SCALAR) != 1)
> - croak("panic: DBI fetch"); /* should never happen */
> if (!keyattrib || !*keyattrib) {
> SV *kn = DBIc_FetchHashKeyName(imp_sth);
> if (kn && SvOK(kn))
> @@ -3469,6 +3468,10 @@
> else
> keyattrib = "NAME";
> }
> + ka_rv = *hv_fetch((HV*)DBIc_MY_H(imp_sth), keyattrib,strlen(keyattrib), TRUE);
> + ka_rv = newSVsv(ka_rv); /* copy to invoke FETCH magic */
> + if (perl_call_method("fetch", G_SCALAR) != 1)
> + croak("panic: DBI fetch"); /* should never happen */
> SPAGAIN;
> rowavr = POPs;
> PUTBACK;
> @@ -3479,8 +3482,6 @@
> int num_fields = AvFILL(rowav)+1;
> HV *hv;
> AV *ka_av;
> - SV *ka_rv = *hv_fetch((HV*)DBIc_MY_H(imp_sth), keyattrib,strlen(keyattrib),
>TRUE);
> - ka_rv = newSVsv(ka_rv); /* copy to invoke FETCH magic */
> if (!(SvROK(ka_rv) && SvTYPE(SvRV(ka_rv))==SVt_PVAV)) {
> sv_setiv(DBIc_ERR(imp_sth), 1);
> sv_setpvf(DBIc_ERRSTR(imp_sth),