Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/AbstractDBAPI2AdaptorLayer
In directory sc8-pr-cvs1:/tmp/cvs-serv31031/DatabaseAdaptors/AbstractDBAPI2AdaptorLayer
Modified Files:
AbstractDBAPI2Adaptor.py
Log Message:
Fixed AbstractDBAPI2Adaptor.create/dropDatabaseWithAdmin.Conn.Dict.():
under some circumstances it was possible that createDB() fails when
called just after the drop, fails (see comments in the code for
details)
Index: AbstractDBAPI2Adaptor.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/AbstractDBAPI2AdaptorLayer/AbstractDBAPI2Adaptor.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AbstractDBAPI2Adaptor.py 10 Jan 2003 10:45:45 -0000 1.1
--- AbstractDBAPI2Adaptor.py 22 Apr 2003 17:05:26 -0000 1.2
***************
*** 132,137 ****
cur.execute(sqlExpr.statement())
finally:
cnx.close()
!
def defaultExpressionClass(self):
"See Modeling.interfaces.Adaptor for details"
--- 132,153 ----
cur.execute(sqlExpr.statement())
finally:
+ # Note: it can be that, when drop/createDBWithAdminConnDict() are called
+ # just one after the other (such as in mdl_generate_DB_schema.py)
+ # it is not sufficient to close the cnx, or, e.g. postgresql
+ # raises the following error:
+ # ERROR: CREATE DATABASE: source database "template1" is being
+ # accessed by other users
+ # (this happens particularly often when creating the DB after dropping
+ # the database initially failed --because the database does not exist
+ # yet, e.g.)
+ # Since I remember having seen possibly-related strange things on
+ # drop/createDB w/ mysql I've changed the code here: explicit closing
+ # followed by explicit destruction. As far as I can tell it solves the
+ # problem, I suspect a delayed destruction of the cnx in dropDB()
+ # causing the connection to persist when createDB begins.
+ cur.rollback() ; cur.close()
cnx.close()
! del cur, cnx
!
def defaultExpressionClass(self):
"See Modeling.interfaces.Adaptor for details"
***************
*** 152,156 ****
--- 168,176 ----
cur.execute(sqlExpr.statement())
finally:
+ # See comments in createDatabaseWithAdministrativeConnectionDictionary()
+ # --> explicit closing and destruction of cnx and cur are intended here
+ cur.rollback() ; cur.close()
cnx.close()
+ del cur; del cnx
def expressionFactory(self):
|