[Checkins] SVN: relstorage/trunk/ In Oracle, don't trip over transaction descriptions longer than 2000 bytes.

Shane Hathaway shane at hathawaymix.org
Mon Aug 24 11:25:56 EDT 2009


Log message for revision 103157:
  In Oracle, don't trip over transaction descriptions longer than 2000 bytes.
  

Changed:
  U   relstorage/trunk/CHANGES.txt
  U   relstorage/trunk/relstorage/adapters/oracle.py
  U   relstorage/trunk/relstorage/tests/reltestbase.py

-=-
Modified: relstorage/trunk/CHANGES.txt
===================================================================
--- relstorage/trunk/CHANGES.txt	2009-08-24 15:05:44 UTC (rev 103156)
+++ relstorage/trunk/CHANGES.txt	2009-08-24 15:25:56 UTC (rev 103157)
@@ -9,6 +9,13 @@
 - [TODO: add the blob_dir parameter to component.xml and README]
 
 
+Next Bug Fix Release
+--------------------
+
+- In Oracle, don't trip over transaction descriptions longer than 2000
+  bytes.
+
+
 Version 1.2.0b2 (2009-05-05)
 ----------------------------
 

Modified: relstorage/trunk/relstorage/adapters/oracle.py
===================================================================
--- relstorage/trunk/relstorage/adapters/oracle.py	2009-08-24 15:05:44 UTC (rev 103156)
+++ relstorage/trunk/relstorage/adapters/oracle.py	2009-08-24 15:25:56 UTC (rev 103157)
@@ -629,7 +629,11 @@
             (tid, packed, username, description, extension)
         VALUES (:1, :2, :3, :4, :5)
         """
-        encoding = cursor.connection.encoding
+        max_desc_len = 2000
+        if len(description) > max_desc_len:
+            log.warning('Trimming description of transaction %s '
+                'to %d characters', tid, max_desc_len)
+            description = description[:max_desc_len]
         cursor.execute(stmt, (
             tid, packed and 'Y' or 'N', cx_Oracle.Binary(username),
             cx_Oracle.Binary(description), cx_Oracle.Binary(extension)))

Modified: relstorage/trunk/relstorage/tests/reltestbase.py
===================================================================
--- relstorage/trunk/relstorage/tests/reltestbase.py	2009-08-24 15:05:44 UTC (rev 103156)
+++ relstorage/trunk/relstorage/tests/reltestbase.py	2009-08-24 15:25:56 UTC (rev 103157)
@@ -277,6 +277,18 @@
         finally:
             db.close()
 
+    def checkLongTransactionDescription(self):
+        # Don't trip over long transaction descriptions
+        db = DB(self._storage)
+        try:
+            c = db.open()
+            r = c.root()
+            r['key'] = 1
+            transaction.get().note('A long description. ' * 1000)
+            transaction.commit()
+        finally:
+            db.close()
+
     def checkAutoReconnect(self):
         # Verify auto-reconnect
         db = DB(self._storage)



More information about the Checkins mailing list