Excellent. Many thanks.
Tim.
On Fri, Aug 03, 2001 at 06:21:44PM -0500, Stephen Clouse wrote:
> Let me preface this by saying I know just enough C to be dangerous, and I know
> even less of Perl internals (although I'm trying, really :) But I think I've
> been able to deduce a patch through heuristic analysis of the code.
>
> This code is in dbd_rebind_ph_char, at dbdimp.c:742:
>
> if (!SvPOK(phs->sv)) { /* normalizations for special cases */
> if (SvOK(phs->sv)) { /* ie a number, convert to string ASAP */
> if (!(SvROK(phs->sv) && phs->is_inout))
> sv_2pv(phs->sv, &na);
> }
> else /* ensure we're at least an SVt_PV (so SvPVX etc work) */
> SvUPGRADE(phs->sv, SVt_PV);
> }
>
> I notice by the comments that the goal is to ensure that SvPVX will work later
> on. Well, I followed the code from dbd_bind_ph to the OCILobWrite call, and no
> such upgrading of the SV goes on when binding a LOB. Then you call SvPVX on
> it -- (several times, actually), one of them being in the OCILobWrite call
> itself:
>
> OCILobWrite_log_stat(imp_sth->svchp, errhp,
> fbh->desc_h, &amtp, 1, SvPVX(phs->sv), amtp, OCI_ONE_PIECE,
> 0,0, 0,SQLCS_IMPLICIT, status);
>
> So my deduction was, if the code above was necessary for character fields, it's
> probably necessary for LOBs too. So I spliced it into dbd_rebind_ph_lob. With
> that patch, test.pl runs flawlessly:
>
> $VAR1 = {
> '1' => '1',
> '2' => 'A',
> '3' => '3',
> '4' => 'B',
> '5' => '5'
> };
>
> So that seems to be it. I doubt this patch is production-quality, but hopefully
> it saves you some time in coming up with a real fix.
>
> --
> Stephen Clouse <[EMAIL PROTECTED]>
> Senior Programmer, IQ Coordinator Project Lead
> The IQ Group, Inc. <http://www.theiqgroup.com/>
> diff -ru DBD-Oracle-1.07.orig/oci8.c DBD-Oracle-1.07/oci8.c
> --- DBD-Oracle-1.07.orig/oci8.c Tue Jun 5 19:49:40 2001
> +++ DBD-Oracle-1.07/oci8.c Fri Aug 3 18:14:56 2001
> @@ -580,6 +580,15 @@
> sword status;
> ub4 lobEmpty = 0;
>
> + if (!SvPOK(phs->sv)) { /* normalizations for special cases */
> + if (SvOK(phs->sv)) { /* ie a number, convert to string ASAP */
> + if (!(SvROK(phs->sv) && phs->is_inout))
> + sv_2pv(phs->sv, &na);
> + }
> + else /* ensure we're at least an SVt_PV (so SvPVX etc work) */
> + SvUPGRADE(phs->sv, SVt_PV);
> + }
> +
> if (!phs->desc_h) {
> ++imp_sth->has_lobs;
> phs->desc_t = OCI_DTYPE_LOB;