[Zodb-checkins] SVN: ZODB/branches/bug1734/src/BTrees/ Beefed up
the test case; rewrote the C a little.
Tim Peters
tim.one at comcast.net
Wed Mar 23 11:53:36 EST 2005
Log message for revision 29654:
Beefed up the test case; rewrote the C a little.
Changed:
U ZODB/branches/bug1734/src/BTrees/MergeTemplate.c
U ZODB/branches/bug1734/src/BTrees/tests/testConflict.py
-=-
Modified: ZODB/branches/bug1734/src/BTrees/MergeTemplate.c
===================================================================
--- ZODB/branches/bug1734/src/BTrees/MergeTemplate.c 2005-03-23 14:01:10 UTC (rev 29653)
+++ ZODB/branches/bug1734/src/BTrees/MergeTemplate.c 2005-03-23 16:53:36 UTC (rev 29654)
@@ -93,6 +93,13 @@
SetIteration i1 = {0,0,0}, i2 = {0,0,0}, i3 = {0,0,0};
int cmp12, cmp13, cmp23, mapping, set;
+ /* If either "after" bucket is empty, punt. */
+ if (s2->len == 0 || s3->len == 0)
+ {
+ merge_error(-1, -1, -1, 12);
+ goto err;
+ }
+
if (initSetIteration(&i1, OBJECT(s1), 1) < 0)
goto err;
if (initSetIteration(&i2, OBJECT(s2), 1) < 0)
@@ -117,13 +124,6 @@
if (i3.next(&i3) < 0)
goto err;
- /* If either "after" bucket was empty, punt. */
- if (i2.position < 0 || i3.position < 0)
- {
- merge_error(i1.position, i2.position, i3.position, 12);
- goto err;
- }
-
/* Consult zodb/btrees/interfaces.py for the meaning of the last
* argument passed to merge_error().
*/
Modified: ZODB/branches/bug1734/src/BTrees/tests/testConflict.py
===================================================================
--- ZODB/branches/bug1734/src/BTrees/tests/testConflict.py 2005-03-23 14:01:10 UTC (rev 29653)
+++ ZODB/branches/bug1734/src/BTrees/tests/testConflict.py 2005-03-23 16:53:36 UTC (rev 29654)
@@ -812,7 +812,38 @@
else:
self.fail("expected ConflictError")
+ # Same thing, except commit the transactions in the opposite order.
+ b = OOBTree()
+ for i in range(0, 200, 4):
+ b[i] = i
+ r1 = self.db.open().root()
+ r1["t"] = b
+ transaction.commit()
+
+ r2 = self.db.open(synch=False).root()
+ copy = r2["t"]
+ # Make sure all of copy is loaded.
+ list(copy.values())
+
+ self.assertEqual(b._p_serial, copy._p_serial)
+
+ # Now one transaction empties the first bucket, and another adds a
+ # key to the first bucket.
+ b[1] = 1
+ transaction.commit()
+
+ for k in range(0, 60, 4):
+ del copy[k]
+ try:
+ transaction.commit()
+ except ConflictError, detail:
+ self.assert_(str(detail).startswith('database conflict error'))
+ transaction.abort()
+ else:
+ self.fail("expected ConflictError")
+
+
def test_suite():
suite = TestSuite()
for k in (
More information about the Zodb-checkins
mailing list