Loading ...
Sorry, an error occurred while loading the content.
 

[PATCH] Fix Apache::DBI cleanup when multiple database handles are used

Expand Messages
  • Joe Thomas
    This patch should make the cleanup handlers roll back all database handles that have been used in a script, rather than just the last one connected. Currently,
    Message 1 of 1 , Aug 31, 2004
      This patch should make the cleanup handlers roll back all database handles
      that have been used in a script, rather than just the last one connected.
      Currently, $Idx is a file-scoped variable, and gets overwritten with each
      call to Apache::DBI::connect.

      I've made $Idx a lexical variable scoped to connect(), and pass it as a
      parameter to cleanup(). This necessitated pushing a closure ("sub {
      cleanup($Idx) }") onto the cleanup handlers.

      The real reason I wrote this was that I have a DBD driver that aggregates
      several database handles into one virtual handle. It was calling
      DBI->connect from inside its own connect method, and strange bugs started
      popping up when it was run under Apache::DBI. It turns out that the inner
      connect() calls were causing $Idx to be overwritten, so the handle got
      stored in the wrong slot in %Connected.

      This patch makes Apache::DBI::connect reentrant, and my problem goes away.

      Joe
    Your message has been successfully submitted and would be delivered to recipients shortly.