From: James Ahlborn Date: Tue, 24 Jun 2008 00:01:25 +0000 (+0000) Subject: Reduce maximum row size to what Access considers valid. X-Git-Tag: rel_1_1_15~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f6d431d8d283c603e70c8ffac40f687718a4490c;p=jackcess.git Reduce maximum row size to what Access considers valid. git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@353 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7f3d746..05b2d62 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -10,6 +10,9 @@ Fix writing of large memo/ole fields. Apparently Access does not like long value fields longer than 4076 bytes. + + Reduce maximum row size to what Access considers valid. + diff --git a/src/java/com/healthmarketscience/jackcess/JetFormat.java b/src/java/com/healthmarketscience/jackcess/JetFormat.java index 0b2b994..d0900f1 100644 --- a/src/java/com/healthmarketscience/jackcess/JetFormat.java +++ b/src/java/com/healthmarketscience/jackcess/JetFormat.java @@ -65,6 +65,7 @@ public abstract class JetFormat { public final long MAX_DATABASE_SIZE; public final int MAX_ROW_SIZE; + public final int PAGE_INITIAL_FREE_SPACE; public final int OFFSET_NEXT_TABLE_DEF_PAGE; public final int OFFSET_NUM_ROWS; @@ -151,6 +152,7 @@ public abstract class JetFormat { MAX_DATABASE_SIZE = defineMaxDatabaseSize(); MAX_ROW_SIZE = defineMaxRowSize(); + PAGE_INITIAL_FREE_SPACE = definePageInitialFreeSpace(); OFFSET_NEXT_TABLE_DEF_PAGE = defineOffsetNextTableDefPage(); OFFSET_NUM_ROWS = defineOffsetNumRows(); @@ -216,6 +218,7 @@ public abstract class JetFormat { protected abstract long defineMaxDatabaseSize(); protected abstract int defineMaxRowSize(); + protected abstract int definePageInitialFreeSpace(); protected abstract int defineOffsetNextTableDefPage(); protected abstract int defineOffsetNumRows(); @@ -296,7 +299,9 @@ public abstract class JetFormat { } @Override - protected int defineMaxRowSize() { return PAGE_SIZE - 16; } + protected int defineMaxRowSize() { return 4060; } + @Override + protected int definePageInitialFreeSpace() { return PAGE_SIZE - 14; } @Override protected int defineOffsetNextTableDefPage() { return 4; } diff --git a/src/java/com/healthmarketscience/jackcess/Table.java b/src/java/com/healthmarketscience/jackcess/Table.java index ad6d9ad..c4976ba 100644 --- a/src/java/com/healthmarketscience/jackcess/Table.java +++ b/src/java/com/healthmarketscience/jackcess/Table.java @@ -904,10 +904,9 @@ public class Table PageChannel pageChannel, JetFormat format) throws IOException { - // USAGE_MAP_DEF_FREE_SPACE = 3940; int usageMapRowLength = format.OFFSET_USAGE_MAP_START + format.USAGE_MAP_TABLE_BYTE_LENGTH; - int freeSpace = getRowSpaceUsage(format.MAX_ROW_SIZE, format) + int freeSpace = format.PAGE_INITIAL_FREE_SPACE - (2 * getRowSpaceUsage(usageMapRowLength, format)); ByteBuffer rtn = pageChannel.createPageBuffer(); @@ -1290,8 +1289,7 @@ public class Table ByteBuffer dataPage = _addRowBufferH.setNewPage(getPageChannel()); dataPage.put(PageTypes.DATA); //Page type dataPage.put((byte) 1); //Unknown - dataPage.putShort((short)getRowSpaceUsage(getFormat().MAX_ROW_SIZE, - getFormat())); //Free space in this page + dataPage.putShort((short)getFormat().PAGE_INITIAL_FREE_SPACE); //Free space in this page dataPage.putInt(_tableDefPageNumber); //Page pointer to table definition dataPage.putInt(0); //Unknown dataPage.putShort((short)0); //Number of rows on this page