Tim Bunce wrote, on 12/08/2005 22:21:
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.

 [ details snipped ]


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.

That looks exactly like what is needed.

> (The existing ora_st_prepare function can wrap the
statement param in a mortal SV then call ora_st_prepare_sv).

This is the compatibility bridge I could not see for myself.
Thank you Tim. I will proceed on this basis.

BTW. Can you help me with two related queries to do with
$dbh->do()

 1. Why is it that, in DBD::Oracle, dbd_db_do is #defined in
    dbdimp.h and provided with a prototype in Oracle.h when
    there is no implementation? Is this a historical vestige?
    I ask because the prototype suggests the same problem
    with the utf8 flag.

 2. Should you make a similar change to the code after
    '#ifdef dbd_db_do4' in Driver.xst? I know that DBD::Oracle
   does not use this code, but any driver which does will have
   the same problem.

--
Charles Jardine - Computing Service, University of Cambridge
[EMAIL PROTECTED]    Tel: +44 1223 334506, Fax: +44 1223 334679

Reply via email to