diff -u -r DBD-Oracle-1.80-ORIG/dbdimp.c DBD-Oracle-1.80/dbdimp.c --- DBD-Oracle-1.80-ORIG/dbdimp.c 2019-07-25 14:15:30.000000000 +0000 +++ DBD-Oracle-1.80/dbdimp.c 2020-08-06 12:47:30.193715144 +0000 @@ -51,6 +51,7 @@ ub2 al32utf8_csid = 873; ub2 al16utf16_csid = 2000; +static int dbd_dr_destroy_called = 0; typedef struct sql_fbh_st sql_fbh_t; struct sql_fbh_st { @@ -199,6 +200,7 @@ dTHX; DBIS = dbistate; dbd_init_oci(dbistate); + dbd_dr_destroy_called = 0; } @@ -208,6 +210,8 @@ dTHX; sword status; + dbd_dr_destroy_called = 1; + /* We rely on the DBI dispatcher to destroy all child handles before we get here (DBI >= 1.623). */ if (imp_drh->leak_state) { @@ -1167,6 +1171,11 @@ /* since most errors imply already disconnected. */ DBIc_ACTIVE_off(imp_dbh); + /* If dbd_dr_destroy has been called, it's completely */ + /* unsafe to do anything with the handle, so just return */ + if (dbd_dr_destroy_called) { + return 1; + } /* Oracle will commit on an orderly disconnect. */ /* See DBI Driver.xst file for the DBI approach. */