perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Vanasco <...@2xlp.com>
Subject Re: DBD:Pg (Postgres) + Apache::DBI
Date Mon, 20 Mar 2006 23:36:24 GMT

On Mar 20, 2006, at 5:48 PM, Perrin Harkins wrote:
> Here's my guess -- are you calling you DBI->connect() on every  
> request?
yep.

> If this is all making you annoyed with Apache::DBI, just make your own
> cleanup handler that does a rollback.  It's easy to do, as long as you
> have a simple way to get the database handle.

well, i already have a cleanup handler that does some stuff with my  
db handle , so i'll just stuck a rollback in there.  problem solved.

and in solving it, I also found the issue. and ( of course )  it was  
entirely my fault .

	i connect as AutoCommit = 0 so I get the rollback

	then i have a db abstraction level that flips AutoCommit to 1 (shown  
below) and replaces the begin_work / rollback / commit -- because I  
need to explicitly declare those commands
	i *think* a bad  error trap missed the rollback, which would have  
flipped my autocommit.

anyways, thanks a ton.  this was killing me.  i've been porting 160+  
tables of a mysql-centric db layout to postgres, and having to redo a  
significant amount of sql statements to standard sql language.  so my  
db handles were corrupting nonstop.


	eval
	{
		$db->{'dbh'}->do($SQL) or die "Can not insert";
	};
	if ( $@ )
	{	
		$self->set_error( "Error: $@" )
		$db-> _dbwriter_endwork_rollback();
	}



sub _dbwriter_beginwork
{
	eval
	{
		$_[0]->{'DBH'}{AutoCommit} = 1;
		$_[0]->{'DBH'}->begin_work;
	};
	if ( $@ )
	{
		return 0;
	}
	return 1;
}

sub _dbwriter_endwork_rollback
{
	$_[0]->{'DBH'}->rollback;
	$_[0]->{'DBH'}{AutoCommit} = 0;
}

sub _dbwriter_endwork_commit
{
	$_[0]->{'DBH'}->commit;
	$_[0]->{'DBH'}{AutoCommit} = 0;
}

Mime
View raw message