On Tue, Apr 30, 2002 at 03:34:26PM -0400, Geoffrey Young wrote: > hi Tim and all - it's been a long time :) > > Stas and I just ran across something interesting concerning Apache::DBI and $dbh > attributes. I think it involves a both a bug and a place for enhancements. > > we all know how Apache::DBI works - it stashes away $dbh based on connect string >info. > however, connect string info is limiting, so nice thing to do is strip down your >connect() > call to the bare minimum and add attributes to $dbh after the fact: > > my $dbh = DBI->connect($dbase, $user, $pass); > $dbh->{AutoCommit} = 0;
Don't do that. It (connect_cached) stashes away $dbh based on connect string info *and* all the attributes. You should set all the atributes you require in the connect() and then not change them later. That way connections that require different attributes are sure to get different handles. > to take this a step further, what would be really DWIMy is for DBI to clear all of >the > $dbh attributes not specified in the connect() call (including stuff like >LongReadLen) if > dbi_connect_method = 'Apache'. that seems like the right thing, since with >Apache::DBI > wat we want a "new" $dbh, just without the connect overhead. and DBI seems like a > reasonable place to do it, especially since DBI->connect is kinda >action-at-a-distance > anyway wrt Apache::DBI. > > maybe I'm missing something design-wise, though? I think the Apache::DBI subclass can override the STORE method and track attribute changes itself. Tim.