On Fri, Aug 12, 2005 at 04:45:50PM +0100, Charles Jardine wrote:
> The method $dbh->prepare($stmt) of DBD::Oracle ignores the
> state of the utf8 flag in the SV for $stmt.

> At the C level, the following code, from the file Oracle.c,
> is implicated:
> 
> >XS(XS_DBD__Oracle__st__prepare)

> The problem is that the above code, which is the implementation
> of DBD::Oracle::st::_prepare, is not part of the DBD::Oracle
> distribution, nor is it derived from this distribution. It is
> actually derived from the file Driver.xst, which is part of the
> DBI distribution.
> 
> This has two consequences.
> 
>  1. The bug must be present in all drivers which use Driver.xst :=(
> 
>  2. I can't see at all how to fix it for DBD::Oracle. It seems that
>     a fix _requires_ an incompatible change to Driver.xst. The
>     bug cannot be fixed without change to the prototype for
>     dbd_st_prepare. However, such a change to the DBI seems
>     out of the question.
> 
> Can anyone suggest a way forward?

This change to Driver.xst enables drivers to define a dbd_st_prepare_sv
function (via a macro) that can then do what's required:

--- Driver.xst  (revision 1000)
+++ Driver.xst  (working copy)
@@ -411,13 +411,17 @@
 void
 _prepare(sth, statement, attribs=Nullsv)
     SV *       sth
-    char *     statement
+    SV *       statement
     SV *       attribs
     CODE:
     {
     D_imp_sth(sth);
     DBD_ATTRIBS_CHECK("_prepare", sth, attribs);
-    ST(0) = dbd_st_prepare(sth, imp_sth, statement, attribs) ? &sv_yes : 
&sv_no;
+#ifdef dbd_st_prepare_sv
+    ST(0) = dbd_st_prepare_sv(sth, imp_sth, statement, attribs) ? &sv_yes : 
&sv_no;
+#else
+    ST(0) = dbd_st_prepare(sth, imp_sth, SVPV_nolen(statement), attribs) ? 
&sv_yes : &sv_no;
+#endif
     }
 
If that seems okay to you then I'll include it in the next DBI release.
Then I'll happily accept a patch that adds an ora_st_prepare_sv function
to DBD::Oracle. (The existing ora_st_prepare function can wrap the
statement param in a mortal SV then call ora_st_prepare_sv).

Thanks Charles!

Tim.

Reply via email to