[PATCH] Transaction problems with large objects in PgSQL.py
"Pinchart, Laurent" <[email protected]>
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, Here's a patch that fixes two transaction problems in PgSQL.py. The first problem is in Connection.binary, which commits a transaction if it has started one, but doesn't reset the "inTransaction" flag to 0. The Connection object thus thinks that we are still in a transaction when we are not, and fails to begin a new transaction on the next cursor open operation. The second problem is in Connection.unlink which should raise a NotSupportedError exception when a called from within a transaction in PostgreSQL < 7.1.0. The version check actually raise an exception when the PostgreSQL version is >= 7.1.0 OR when a transaction is NOT in progress, instead of when the PostgreSQL version is NOT >= 7.1.0 AND a transaction is in progress. The attached patch is against the latest CVS version. Laurent Pinchart
PgSQL.py.diff
(application/octet-stream, 648 B)
--- PgSQL.py 2003-06-12 11:11:11.000000000 +0200
+++ PgSQL.py 2003-06-12 11:13:04.000000000 +0200
@@ -2557,6 +2557,7 @@
if self.inTransaction:
if _ct: # Only commit the transaction if we started it.
self.conn.query("COMMIT WORK")
+ self.__dict__["inTransaction"] = 0
return _lo
@@ -2569,7 +2570,7 @@
raise InterfaceError, \
"Unlink of large object failed - Connection is not open."
- if self.version.post70 or not self.inTransaction:
+ if not self.version.post70 and self.inTransaction:
raise NotSupportedError, \
"unlink of a PostgreSQL Large Object in a transaction"