Re: [Dbi-interbase-devel] How to close open transactions with AutoCommit = 1 in case of a failed pre
Status: Beta
Brought to you by:
edpratomo
From: Daniel R. <dan...@gm...> - 2001-07-31 11:58:10
|
hello peter yep, it's a bug! a failed prepare does no rollback or commit in AutoCommit mode and disconnect doesn't too, but they should... i'll fix this asap. for now there's a little workaround: set AutoCommit to 0 right before the disconnect: (this makes disconnect to do a commit) $_db->{AutoCommit} = 0; with this added to line 87 in the test script -> the tables are created and altered. rgds -daniel ----- Original Message ----- From: "Peter Köller" <pko...@me...> To: <dbi...@li...> Sent: Tuesday, July 31, 2001 10:58 AM Subject: Re: [Dbi-interbase-devel] How to close open transactions with AutoCommit = 1 in case of a failed prepare? Hello Daniel, now I have isolated a test script which can reproduce the problem I mentioned yesterday. The problem seems to be the following: - prepare fails because of non-existing table - disconnect (because the user can select another database) - connect again to the same database because the user wants the same one - create tables - ERROR!!! If the disconnect and connect are left out, then no ERROR occurs. I attached a test script derived from my perl program. Is this a bug? Peter > -----Ursprüngliche Nachricht----- > Von: dbi...@li... > [mailto:dbi...@li...]Im Auftrag von > Daniel Ritz > Gesendet am: Montag, 30. Juli 2001 19:11 > An: dbi...@li... > Betreff: Re: [Dbi-interbase-devel] How to close open transactions with > AutoCommit = 1 in case of a failed prepare? > > hello > > i've created two scripts doing what you described. the first is with > AutoCommit = 0, the second with AutoCommit = 1. > > first: create an empty db with ib console. > - when you first run the script you see the error message for the > failed prepare, > the table is cerated and some data is inserted into it. > - second run: display content of the table created before. > > you can find the scripts at http://ritz.dnsart.com/interbase > > one question: what version of dbd-interbase are you using? > > > rgds > -daniel > > ps: if you problem still exists and you're using an up to date > version of the dbd > then it's probaly a bug (a missing commit or something). in this > case please send me > a code example that causes the error. i then try to fix it... > > ----- Original Message ----- > From: "Peter Köller" <pko...@me...> > To: <dbi...@li...> > Sent: Monday, July 30, 2001 11:32 AM > Subject: [Dbi-interbase-devel] How to close open transactions > with AutoCommit = 1 in case of a failed prepare? > > > > Hello! > > > > Is there a good portable solution for doing the following: > > > > 1. select something > > 2. if prepare failed (e. g. the database tables don't exist) > then goto 3. > > else goto 4. > > 3. create database tables > > 4. execute statement > > > > I run into the problem, that create tables fails because of open > > transactions. Even disconnect fails in Step 3. > > > > "DBD::InterBase::db disconnect failed: Unsuccessful execution caused by > > system er > > ror that does not preclude successful execution of subsequent statements > > -cannot disconnect database with open transactions (1 active)" > > > > I use connect with AutoCommit set to true. > > > > Would the following be a good portable solution for > DBD::InterBase and other > > database drivers, too??? > > > > $db->{AutoCommit} = 0; > > $st = $db->prepare($sql); > > if (!$st) { > > print "error ..."; > > $db->rollback(); > > return; > > } > > $st->execute(); > > if (!$st) { > > print "error ..."; > > $db->rollback(); > > return; > > } > > ... > > $db->commit(); > > > > With other DBD drivers, e. g. ODBC I had no problem with > creating database > > tables after a prepare failed, even if AutoCommit was set to > true. There was > > no error message about open transactions. I worry about database drivers > > which don't support transactions. > > > > Any suggestions? > > > > Regards, > > > > Peter > > > > > > _______________________________________________ > > Dbi-interbase-devel mailing list > > Dbi...@li... > > http://lists.sourceforge.net/lists/listinfo/dbi-interbase-devel > > > > > _______________________________________________ > Dbi-interbase-devel mailing list > Dbi...@li... > http://lists.sourceforge.net/lists/listinfo/dbi-interbase-devel > |