Author: timbo
Date: Mon Nov  2 15:13:51 2009
New Revision: 13466

Modified:
   dbi/trunk/Changes
   dbi/trunk/DBI.xs
   dbi/trunk/dbixs_rev.h
   dbi/trunk/t/70callbacks.t

Log:
Added ChildCallbacks => { ... } to Callbacks as a way to
specify Callbacks for child handles.


Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes   (original)
+++ dbi/trunk/Changes   Mon Nov  2 15:13:51 2009
@@ -9,12 +9,20 @@
 =head2 Changes in DBI 1.611 (svn rXXX)
 
 XXX needs to be redone to convert ReadOnly to an internal flag:
-  Fixes DBI->trace (0, *STDERR); (H.Merijn Brand)
-    tried to open a file named "*main::STDERR" in perl-5.10.x
+
+  Fixes DBI->trace(0, *STDERR); (H.Merijn Brand)
+    which tried to open a file named "*main::STDERR" in perl-5.10.x
+
+  Bumped required perl version to 5.8.1 (as announced in DBI 1.607)
+
   Changed "Issuing rollback() due to DESTROY without explicit disconnect"
     warning to not be issued if ReadOnly set for that dbh.
   Updated dbipport.h to Devel::PPPort 3.19 (H.Merijn Brand)
-  Bumped required perl version to 5.8.1 (as announced in DBI 1.607)
+
+  Added ChildCallbacks => { ... } to Callbacks as a way to
+    specify Callbacks for child handles.
+    With tests and docs thanks to David E. Wheeler.
+XXX awaiting docs
 
 =head2 Changes in DBI 1.609 (svn r12816) 8th June 2009
 

Modified: dbi/trunk/DBI.xs
==============================================================================
--- dbi/trunk/DBI.xs    (original)
+++ dbi/trunk/DBI.xs    Mon Nov  2 15:13:51 2009
@@ -1263,6 +1263,19 @@
             dbih_setup_attrib(aTHX_ h,imp,"HandleError",parent,0,1);
             dbih_setup_attrib(aTHX_ h,imp,"ReadOnly",parent,0,1);
             dbih_setup_attrib(aTHX_ h,imp,"Profile",parent,0,1);
+
+            /* setup Callbacks from parents' ChildCallbacks */
+            if (DBIc_has(parent_imp, DBIcf_Callbacks)
+            && (tmp_svp = hv_fetch((HV*)SvRV(parent), "Callbacks", 9, 0))
+            && SvROK(*tmp_svp) && SvTYPE(SvRV(*tmp_svp)) == SVt_PVHV
+            && (tmp_svp = hv_fetch((HV*)SvRV(*tmp_svp), "ChildCallbacks", 14, 
0))
+            && SvROK(*tmp_svp) && SvTYPE(SvRV(*tmp_svp)) == SVt_PVHV
+            ) {
+                /* XXX mirrors behaviour of dbih_set_attr_k() of Callbacks */
+                hv_store((HV*)SvRV(h), "Callbacks", 9, 
newRV_inc(SvRV(*tmp_svp)), 0);
+                DBIc_set(imp, DBIcf_Callbacks, 1);
+            }
+
             DBIc_LongReadLen(imp) = DBIc_LongReadLen(parent_imp);
 #ifdef sv_rvweaken
             if (1) {
@@ -1868,6 +1881,7 @@
     else if (keylen==9 && strEQ(key, "Callbacks")) {
         if ( on && (!SvROK(valuesv) || (SvTYPE(SvRV(valuesv)) != SVt_PVHV)) )
             croak("Can't set Callbacks to '%s'",neatsvpv(valuesv,0));
+        /* see also dbih_setup_handle for ChildCallbacks handling */
         DBIc_set(imp_xxh, DBIcf_Callbacks, on);
         cacheit = 1;
     }

Modified: dbi/trunk/dbixs_rev.h
==============================================================================
--- dbi/trunk/dbixs_rev.h       (original)
+++ dbi/trunk/dbixs_rev.h       Mon Nov  2 15:13:51 2009
@@ -1,3 +1,4 @@
-/* Thu Oct 29 22:58:37 2009 */
+/* Mon Nov  2 22:44:58 2009 */
+/* Mixed revision working copy (13455M:13465) */
 /* Code modified since last checkin */
-#define DBIXS_REVISION 13337
+#define DBIXS_REVISION 13455

Modified: dbi/trunk/t/70callbacks.t
==============================================================================
--- dbi/trunk/t/70callbacks.t   (original)
+++ dbi/trunk/t/70callbacks.t   Mon Nov  2 15:13:51 2009
@@ -9,7 +9,7 @@
 BEGIN {
         plan skip_all => '$h->{Callbacks} attribute not supported for 
DBI::PurePerl'
                 if $DBI::PurePerl && $DBI::PurePerl; # doubled to avoid typo 
warning
-        plan tests => 61;
+        plan tests => 63;
 }
 
 $| = 1;

Reply via email to