From: David M. <mdb...@dm...> - 2005-02-06 20:26:35
|
Hi Brian, list, I've been using an in-house heavily patched version of 0.5 for a long time now, and finally decided to try to update to the latest CVS, because you guys have made a lot of great progress. Many things are greatly improved over the old 0.5 version. I found a small bug that actually traces back to a mis-merge of some patches I sent you a year ago! The issue is the the structure for a table, num_rows contains a total count of rows in the table (actually, only counts non-deleted rows). However, the method mdb_read_row takes a row number relative to the block only. The bug occurs when you have a table with a small number of rows, all in one block, but with a bunch of deleted rows. In my case there are 33 total non-deleted rows (table->num_rows == 33). There are 44 rows in the first block, and 3 in the second. Doing the math, there are 14 deleted rows. However, the check in mdb_read_row: if (table->num_rows <= row) return 0; in mdb_read_row causes the routine to skip row indexes 33 -> 44 in the first data block. Looking back at my source (0.5 plus patches) the code reads: if (table->num_rows == 0) return 0; which is what it had been for years before that, and I think is still valid as an optimization. Changing the code back makes it work for me again. This may be white-space mangled due to cut and paste. =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/libmdb/data.c,v retrieving revision 1.87 diff -u -r1.87 data.c --- src/libmdb/data.c 15 Jan 2005 05:02:08 -0000 1.87 +++ src/libmdb/data.c 6 Feb 2005 20:16:21 -0000 @@ -229,7 +229,7 @@ MdbField fields[256]; int num_fields; - if (table->num_rows <= row) + if (table->num_rows == 0) return 0; row_start = mdb_pg_get_int16(mdb, (fmt->row_count_offset + 2) + (row*2)); |