summaryrefslogtreecommitdiff
path: root/tests/test_lobject.py
diff options
context:
space:
mode:
authorBlake Rouse <blake.rouse@canonical.com>2014-09-05 11:55:14 -0400
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2014-12-25 15:06:18 +0100
commite13ec67da393480e7cec408f94f21a8e9d266bc3 (patch)
treed0df10d7ce93d0fce594f6467a283e35934447b8 /tests/test_lobject.py
parent85ba098cd84a983b816d2dbdf7ec741c4f93ec75 (diff)
downloadpsycopg2-e13ec67da393480e7cec408f94f21a8e9d266bc3.tar.gz
Use lseek64 and ltell64 to support large object greater than 2gb in size.
Diffstat (limited to 'tests/test_lobject.py')
-rwxr-xr-xtests/test_lobject.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_lobject.py b/tests/test_lobject.py
index 66a3d8a..36b2427 100755
--- a/tests/test_lobject.py
+++ b/tests/test_lobject.py
@@ -225,6 +225,24 @@ class LargeObjectTests(LargeObjectTestCase):
self.assertEqual(lo.seek(-2, 2), length - 2)
self.assertEqual(lo.read(), "ta")
+ def test_seek_tell_greater_than_2gb(self):
+ lo = self.conn.lobject()
+
+ # write chunks until its 3gb
+ length = 0
+ for _ in range(24):
+ # each chunk is written with 128mb
+ length += lo.write("data" * (1 << 25))
+ self.assertEqual(lo.tell(), length)
+ lo.close()
+ lo = self.conn.lobject(lo.oid)
+
+ # seek to 3gb - 4, last written text should be data
+ offset = (1 << 31) + (1 << 30) - 4 # 2gb + 1gb - 4
+ self.assertEqual(lo.seek(offset, 0), offset)
+ self.assertEqual(lo.tell(), offset)
+ self.assertEqual(lo.read(), "data")
+
def test_unlink(self):
lo = self.conn.lobject()
lo.unlink()