On Wed, Aug 15, 2007 at 10:17:07PM -0400, John Siracusa wrote:
> On 8/15/07 10:08 PM, Graham Barr wrote:
> > On Aug 15, 2007, at 7:56 PM, John Siracusa wrote:
> >> The only dbh attributes that get set in init_dbh() after the
> >> DBI->connect() call are the ones that don't (apparently?) work if
> >> passed as connect options.
> > 
> > You are right, sorry.
> > 
> > It is DBI->connect that is setting all the attributes to the
> > requested values.
> 
> So how am I supposed to avoid setting those attributes if the only way I can
> tell if I've gotten a cached $dbh is to call connect() to get a $dbh!? :)
> 
> I suppose I could try to call connect() with no options, then set all the
> connect options after the connect...but IIRC some options can only be set on
> connect.  Maybe just special-case AutoCommit?

FYI, the relevant parts of DBI->connect are (effectively):

    $attr = {
        PrintError => 1,
        AutoCommit => 1,
        Username => $user,
        ref $attr ? %$attr : (),
    };

    $dbh = $drh->$connect_meth($dsn, $user, $pass, $attr);

    foreach $a (qw(Profile RaiseError PrintError AutoCommit)) { # do these first
        next unless  exists $apply->{$a};
        $dbh->{$a} = delete $apply->{$a};
    }
    while ( my ($a, $v) = each %$apply) {
        eval { $dbh->{$a} = $v } or $@ && warn $@;
    }

Tim.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to