show processlist;
to see how many connections you have to your database server. My guess is that you will see one. If thats the case, then whats happening is probably the following: Because Apache::DBI uses the DSN/username/password combination to uniquely identify a connection within its connection pool, the second connect() is getting returned the first handle, _and_ you are resetting AutoCommit on the fly. Because $db2 and $db1 are references to the same connection in the pool, $db1 will get the attributes you set on $db2.
Peace, Jamie
Christophe Musielak wrote:
Le jeu 13/11/2003 à 20:08, Perrin Harkins a écrit :
On Thu, 2003-11-13 at 10:32, Christophe Musielak wrote:
My question is : is it safe to use transactions of multiple objects,Yes. Database handles are not shared between interpreters.
doing a commit or rollback at the end as i'm sure i will stay in the
same interpreter space and that no other user can ask for the same
database handle to do some stuff while i'm working?
Ok
btw, ApacheDBI is always returning me a handle with the defaultHmmm... Was I talking to you about this on Perlmonks?
parameters i used when issuing the connection ( {AutoCommit => 1} for
example), even if i changed the parameters with
local->{dbh}->{AutoCommit} = 0.
Yes
It sounds like maybe you don't understand what local() does, which is
not surprising since hardly anyone does. Any change you make with
local() only lasts for the current scope. If you change things without
local(), it will change the cached handle permanently.
Thanks for your answer Perrin. I tried without local() too and i see exactly the same result, ie each time i ask DBI via ApacheDBI for a database handle, i get the handle with the same parameters i created the handle with, not the ones i just modified, although i can see while login it's the same handle.
To be clear, as my english not so good :
-----------------------------
my $db = DBI->connect($dsn,$user, $password, { AutoCommit => 1, RaiseError => 1 } )|| die "ERROR NO_CONNECTION_TO_POSTMASTER\n";
print "$db"."\n";
print "".$db->{AutoCommit}."\n";
$db->{AutoCommit} = 0;
print "".$db->{AutoCommit}."\n";
my $db2 = DBI->connect($dsn,$user, $password, { AutoCommit => 1, RaiseError => 1 } )|| die "ERROR NO_CONNECTION_TO_POSTMASTER\n";
print "$db"."\n"; print "".$db->{AutoCommit}."\n";
-----------------------------
And here is the result :
Database::Dbh = Apache::DBI::db=HASH(0x8f95d28) Database::Dbh =1 Database::Dbh = # ok AutoCommit Off Database::Dbh = Apache::DBI::db=HASH(0x8f95d28) # ok same handler Database::Dbh =1 <<<<<<< AutoCommit back On !!
Is this a normal behave of Apache::DBI or am i missing something?
Thanks a lot for your help.
Christophe.
- Perrin
-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html