Index: t/12quote.t
===================================================================
--- t/12quote.t	(revision 15342)
+++ t/12quote.t	(working copy)
@@ -13,6 +13,7 @@
 $| = 1;
 
 my $dbh = DBI->connect('dbi:ExampleP:', '', '');
+# $dbh->debug(4);
 
 sub check_quote {
 	# checking quote
Index: dbixs_rev.h
===================================================================
--- dbixs_rev.h	(revision 15342)
+++ dbixs_rev.h	(working copy)
@@ -1,4 +1,3 @@
-/* Wed Apr 18 12:37:44 2012 */
-/* Mixed revision working copy (15267M:15268) */
+/* Mon Jul  9 12:45:07 2012 */
 /* Code modified since last checkin */
-#define DBIXS_REVISION 15267
+#define DBIXS_REVISION 15342
Index: DBI.xs
===================================================================
--- DBI.xs	(revision 15342)
+++ DBI.xs	(working copy)
@@ -1497,7 +1497,8 @@
     /* also store a direct pointer to imp, aka PVX(dbih_imp_sv),        */
     /* in mg_ptr (with mg_len set to null, so it wont be freed)         */
     sv_magic(SvRV(h), dbih_imp_sv, DBI_MAGIC, (char*)imp, 0);
-    SvREFCNT_dec(dbih_imp_sv);  /* since sv_magic() incremented it      */
+    if (SvREFCNT(dbih_imp_sv) > 1)
+        SvREFCNT_dec(dbih_imp_sv);  /* if sv_magic() incremented it     */
     SvRMAGICAL_on(SvRV(h));     /* so DBI magic gets sv_clear'd ok      */
 
     {
@@ -3336,7 +3337,8 @@
             }
             if (ima_flags & IMA_KEEP_ERR)
                 keep_error = TRUE;
-            if (ima_flags & IMA_KEEP_ERR_SUB
+            if ((ima_flags & IMA_KEEP_ERR_SUB)
+		&& !PL_dirty
                 && DBIc_PARENT_COM(imp_xxh) && DBIc_CALL_DEPTH(DBIc_PARENT_COM(imp_xxh)) > 0)
                 keep_error = TRUE;
             if (ima_flags & IMA_CLEAR_STMT) {
@@ -3410,6 +3412,7 @@
             DBIc_ACTIVE_off(imp_xxh);
         }
         call_depth = 0;
+        is_nested_call = 0;
     }
     else {
         DBI_SET_LAST_HANDLE(h);
@@ -3422,11 +3425,13 @@
             /* XXX sv_copy() if Profiling? */
             (void)hv_store((HV*)SvRV(parent), "Statement", 9, SvREFCNT_inc(tmp_sv), 0);
         }
+        is_nested_call = 
+          (call_depth > 1 ||
+           (!PL_dirty && /* not in global destruction [CPAN #75614] */
+            DBIc_PARENT_COM(imp_xxh) &&
+            DBIc_CALL_DEPTH(DBIc_PARENT_COM(imp_xxh))) >= 1);
     }
 
-    is_nested_call = ( call_depth > 1 || (DBIc_PARENT_COM(imp_xxh) && (DBIc_CALL_DEPTH(DBIc_PARENT_COM(imp_xxh)) >= 1)) );
-
-
     /* --- dispatch --- */
 
     if (!keep_error && meth_type != methtype_set_err) {