PEAR::DB destructors and uncommitted transactions
| From: | Roman Neuhauser | Date: | Thu, 05 Jun 2003 12:58:46 +0000 |
| Subject: | PEAR::DB destructors and uncommitted transactions | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-17057@lists.php.net to get a copy of this message | ||
Hi there,
1 year ago, there was a post on this list about destructors not rolling
back outstanding transactions at the request shutdown phase.
http://marc.theaimsgroup.com/?l=pear-dev&m=102613967408061&w=2
It yielded zero replies AFAICT. I'd like to see PEAR::DB::* classes
rolling back uncommitted transactions as well, and see two... actually,
three, possible ways of implementing them. I'm listing them in order of
increasing preference:
1) "if you want destructors rolling back transactions, have a hierarchy
parallel to PEAR::DB, with your drivers implementing the feature"
(we're already doing this for other features, so no big deal, this
is OOP afterall)
2) add _DB_* to the individual drivers which implement transactions.
I don't think this would be such a good idea.
3) add _DB_common(), and expectError(DB_ERROR_NOT_CAPABLE)
the problem with 3) is that the PEAR::DB user would probably want to
have a chance to handle eventual error situations in rollback() (I know
I would). this could be done in various ways, the easiest being going
for 1), actually [:)], but I still think a simple, quiet, rollback() in
the shutdown phase is better than uncommitted transactions hanging in
the server for half an hour. This opens up a way to error situations
which are hard to debug.
--
If you cc me or remove the list(s) completely I'll most likely ignore
your message. see http://www.eyrie.org./~eagle/faqs/questions.html
Index: DB/DB/common.php =================================================================== RCS file: /repository/pear/DB/DB/common.php,v retrieving revision 1.16 diff -u -u -r1.16 common.php --- DB/DB/common.php 19 May 2003 20:45:31 -0000 1.16 +++ DB/DB/common.php 5 Jun 2003 12:50:36 -0000 @@ -143,6 +143,19 @@ } // }}} + // {{{ destructor + /** + * Destructor + */ + function _DB_common() + { + $this->expectError(DB_ERROR_NOT_CAPABLE); + $this->rollback(); + $this->popExpect(); + $this->_PEAR(); + } + + // }}} // {{{ quoteString() /**
Index: DB/DB/common.php =================================================================== RCS file: /repository/pear/DB/DB/common.php,v retrieving revision 1.16 diff -u -u -r1.16 common.php --- DB/DB/common.php 19 May 2003 20:45:31 -0000 1.16 +++ DB/DB/common.php 5 Jun 2003 12:50:36 -0000 @@ -143,6 +143,19 @@ } // }}} + // {{{ destructor + /** + * Destructor + */ + function _DB_common() + { + $this->expectError(DB_ERROR_NOT_CAPABLE); + $this->rollback(); + $this->popExpect(); + $this->_PEAR(); + } + + // }}} // {{{ quoteString() /**