[Dbix-class] Storage::DBI::ODBC cause DBI->connect() to becalled twice

Oystein.Torget at dnv.com Oystein.Torget at dnv.com
Mon Aug 11 18:43:05 BST 2008


> -----Original Message-----
> From: Marc Mims [mailto:marc at questright.com] 
> Sent: 11. august 2008 18:10
> To: dbix-class at lists.scsys.co.uk
> Subject: Re: [Dbix-class] Storage::DBI::ODBC cause 
> DBI->connect() to becalled twice
> 
> * Oystein.Torget at dnv.com <Oystein.Torget at dnv.com> [080811 08:40]:
> > It seems that the Storage::DBI::ODBC module causes DBI->connect() to
> > be called twice when you connect to the database.
> >  
> > I have posted this as a possible bug in CPAN RT. The bug report with
> > more information can be found here:
> > http://rt.cpan.org/Public/Bug/Display.html?id=38186
> >  
> > The bug *seems* to be easy to fix, but feedback from others using the
> > Storage::DBI::ODBC module would be useful.
> 
> Looks we're recursing and $self->_dbh, rather than $self->dbh would,
> indeed, solve the problem.  However, I wonder if we should be 
> using the
> newer $self->dbh_do, instead?
> 
> 	-Marc

I am not sure if I understand what you suggest, but I tried replacing the two following lines

my $dbh = $self->dbh;
my $dbtype = eval { $dbh->get_info(17) };

with

my $dbtype = $self->dbh_do( sub { my ( $storage, $dbh ) = @_; $dbh->get_info(17) } );

Doing so still causes two calls to DBI->connect() and gives the same problem with database locks not being released. The reason that connect() gets called two times is that _conn_pid has not been set when _rebless() calls dbh_do() so _verify_pid() clears _dbh and _populate_dbh gets called a second time.

Setting $self->_conn_pid before the call to _rebless() will make using dbh_do() work correctly in _rebless(), but I don't know if that is something that is ok to do.

- oyse


**************************************************************
The contents of this e-mail message and any attachments are confidential and are intended solely for the addressee. If you have received this transmission in error, please immediately notify the sender by return e-mail and delete this message and its attachments. Any unauthorized use, copying or dissemination of this transmission is prohibited. Neither the confidentiality nor the integrity of this message can be vouched for following transmission on the Internet. 
**************************************************************



More information about the DBIx-Class mailing list