Forum OpenACS Q&A: Response to db_foreach in transactions

Posted by Andrew Piskorski on
Warnings might be nice. But using two database handles when you could just as easily use only one is usually a bad idea anyway, no? IMO, doing DML inside a db_foreach is almost always something to be avoided, anyway.

Of course, if you really really wanted to prevent any possibility of this bug, just configure your DB API to only use one pool of database handles. Then when you do something that forces the DB API to use a second handle (from a second pool...), it won't. ;)