From cd4c2188725dec869749adb490ef24bebc720813 Mon Sep 17 00:00:00 2001 From: Tim McCune Date: Fri, 12 Aug 2005 05:28:37 +0000 Subject: [PATCH] Added handling of deleted rows. Fixed a couple bugs introduced by the 1.5 upgrade. git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@19 f203690c-595d-4dc9-a70b-905162fa7fd2 --- project.xml | 4 +-- .../healthmarketscience/jackcess/Table.java | 25 +++++++++++------- test/data/delTest.mdb | Bin 0 -> 135168 bytes .../jackcess/DatabaseTest.java | 9 +++++++ 4 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 test/data/delTest.mdb diff --git a/project.xml b/project.xml index fa8da63..2e26fe5 100644 --- a/project.xml +++ b/project.xml @@ -3,7 +3,7 @@ 1 jackcess Jackcess - 1.0 + 1.1 Health Market Science, Inc. http://www.healthmarketscience.com @@ -18,7 +18,7 @@ /home/groups/j/ja/jackcess/htdocs scm:cvs:pserver:anonymous@cvs.sf.net:/cvsroot/jackcess:jackcess - http://cvs.sf.net/viewcvs.py/jackcess/ + http://cvs.sf.net/viewcvs.py/ diff --git a/src/java/com/healthmarketscience/jackcess/Table.java b/src/java/com/healthmarketscience/jackcess/Table.java index 4714eb1..f9f7f1f 100644 --- a/src/java/com/healthmarketscience/jackcess/Table.java +++ b/src/java/com/healthmarketscience/jackcess/Table.java @@ -202,9 +202,9 @@ public class Table { if (column.getType() == DataType.BOOLEAN) { value = new Boolean(!isNull); //Boolean values are stored in the null mask } else if (!isNull) { - if (!column.getType().isVariableLength()) { + if (!column.isVariableLength()) { //Read in fixed length column data - columnData = new byte[column.getType().getSize()]; + columnData = new byte[column.size()]; _buffer.get(columnData); } else { //Refer to already-read-in variable length data @@ -238,13 +238,18 @@ public class Table { } _rowStart = _buffer.getShort(_format.OFFSET_DATA_ROW_LOCATION_BLOCK + _currentRowInPage * _format.SIZE_ROW_LOCATION); - // XXX - Handle overflow pages and deleted rows. - _buffer.position(_rowStart); - _buffer.limit(_lastRowStart); - _rowsLeftOnPage--; _currentRowInPage++; - _lastRowStart = _rowStart; - return true; + _rowsLeftOnPage--; + if (_rowStart < 0) { + // Deleted row. Skip. + return positionAtNextRow(); + } else { + // XXX - Handle overflow pages. + _buffer.position(_rowStart); + _buffer.limit(_lastRowStart); + _lastRowStart = _rowStart; + return true; + } } /** @@ -439,7 +444,7 @@ public class Table { for (iter = _columns.iterator(); iter.hasNext() && index < row.size(); index++) { col = (Column) iter.next(); - if (!col.getType().isVariableLength()) { + if (!col.isVariableLength()) { //Fixed length column data comes first if (row.get(index) != null) { buffer.put(col.write(row.get(index))); @@ -464,7 +469,7 @@ public class Table { for (iter = _columns.iterator(); iter.hasNext() && index < row.size(); index++) { col = (Column) iter.next(); short offset = (short) buffer.position(); - if (col.getType().isVariableLength()) { + if (col.isVariableLength()) { if (row.get(index) != null) { buffer.put(col.write(row.get(index))); } diff --git a/test/data/delTest.mdb b/test/data/delTest.mdb new file mode 100644 index 0000000000000000000000000000000000000000..915caa2a35fef5ae7a83627acab3efc3ffbbb68a GIT binary patch literal 135168 zcmeI53vgT2na9t)l4VJjbrr{X5JDp203pRjmYv{0LoHi2N$?}VAvEBH$d;T4Kjhj< zNC*%UN(*!bm}Pbrxa@ueY0&o0li zSO4lWyGI&7ARfN$6ZdEC{CMp*4}9f#=$W6s@JR2EUi-!;TK{~{GaVNW{`QjJAAR^w z$#1Rs?`MMd?E15QaQ(Hf{q)Hn_AG4Pwc*LSzkBPzbsMX0SsOii%R}y!5B|l|<39Aj zZw~j}@HhYW(%q}?-2ERbFNhv}{Yc_?ru4bi$M!Gw9sgBz&-b^xgs86xK@&DifC(@G zCcp%k025#WOn?b60VXgT1Quy%?(yf0C7@|>gWCIKbn&#Y&oE{FW&%ur2`~XBzyz28 z6JP>NfC(@GCcp$vF9Ihr(>J>IlQPQ9GN%wbG3H)rWli-7sGN2!5M^Qkx(KM700v$) z9As1wyX>R5Ji-Ax4`Qw$H)*7UTgH*^;HD5xIro4Z7E0e<;TF=Nq`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xu_JyWT7)L$!6>r6!(WXr(PinSobFRu4o$JMV zaVvJEuE%cEA)GhhXcpK@)Y_-}3hY}R5w~Ig>2BC}igtWDMTce6jujG{<<90^mW{c~ zcel0M_j-gPn--)}gZ(|*@Tr1LQjB8dL|RiZ2-g^{l2}hMh&-gQQeqG(4&yT*ZDUwD zF$w!2__CV{O>wA)|5kjOp?w6os21yRwE>@M=pDk*1d03*CzC@&`V3(|?N<1p;}XeX zgT;YZC=Me?eK+)?RUJvkBs5Dvn{Kcmy~%wPM;|l|f=(YkWS@YKPWW$?lvOoddBfJT&^C>n4}xqMHgsj}X^ZO`Tn#|qDw*>Z_lg2i#EYH{<4MsyQ7szqO`rVxVLdbsgKz}* z3OyI7%xZC-+WjywDSOT6M(j~ZWf1ivChJESspM)$vHObd2dW|aP`f?|E>T%yVg-cg zUNLo^?B2j)rb5R*AE&Mf7tU^+{kr+wr`kvBiJCh#+y56#N7n3>*^(cB#avWX)7(gV zI2Uzk6=?8QNYG;M+%+^sCy_#g8Sk`8ua`55y%4F0%=VM(I{MK2!FS{+6O5i zZlZwm#!z>dXWryyrWujjd(JeHc@v&#*o%^BFbz8ayUcZ?7>yOMqyh31c(Y2_-md7s gF@~ literal 0 HcmV?d00001 diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java index 6b1fc0e..c4dac93 100644 --- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -29,6 +29,15 @@ public class DatabaseTest extends TestCase { //tmp.deleteOnExit(); return Database.create(tmp); } + + public void testReadDeletedRows() throws Exception { + Table table = Database.open(new File("test/data/delTest.mdb")).getTable("Table"); + int rows = 0; + while (table.getNextRow() != null) { + rows++; + } + assertEquals(2, rows); + } public void testGetColumns() throws Exception { List columns = open().getTable("Table1").getColumns(); -- 2.39.5