diff options
author | Tim McCune <javajedi@users.sf.net> | 2005-08-12 05:28:37 +0000 |
---|---|---|
committer | Tim McCune <javajedi@users.sf.net> | 2005-08-12 05:28:37 +0000 |
commit | cd4c2188725dec869749adb490ef24bebc720813 (patch) | |
tree | 23d6a2f3fc28fc007e3235df79370f28d3eab803 | |
parent | 468b7748b3df1870bd477d5e46b2f310859534b6 (diff) | |
download | jackcess-cd4c2188725dec869749adb490ef24bebc720813.tar.gz jackcess-cd4c2188725dec869749adb490ef24bebc720813.zip |
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
-rw-r--r-- | project.xml | 4 | ||||
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/Table.java | 25 | ||||
-rw-r--r-- | test/data/delTest.mdb | bin | 0 -> 135168 bytes | |||
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java | 9 |
4 files changed, 26 insertions, 12 deletions
diff --git a/project.xml b/project.xml index fa8da63..2e26fe5 100644 --- a/project.xml +++ b/project.xml @@ -3,7 +3,7 @@ <pomVersion>1</pomVersion> <id>jackcess</id> <name>Jackcess</name> - <currentVersion>1.0</currentVersion> + <currentVersion>1.1</currentVersion> <organization> <name>Health Market Science, Inc.</name> <url>http://www.healthmarketscience.com</url> @@ -18,7 +18,7 @@ <siteDirectory>/home/groups/j/ja/jackcess/htdocs</siteDirectory> <repository> <connection>scm:cvs:pserver:anonymous@cvs.sf.net:/cvsroot/jackcess:jackcess</connection> - <url>http://cvs.sf.net/viewcvs.py/jackcess/</url> + <url>http://cvs.sf.net/viewcvs.py/</url> </repository> <mailingLists> <mailingList> 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 Binary files differnew file mode 100644 index 0000000..915caa2 --- /dev/null +++ b/test/data/delTest.mdb 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(); |