From 0ec5b19a9fd4f96981ab73b494e0c867cee9c52c Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Sat, 21 Jun 2008 05:15:40 +0000 Subject: Fix writing of large memo/ole fields. Apparently Access does not like long value fields longer than 4076 bytes. git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@352 f203690c-595d-4dc9-a70b-905162fa7fd2 --- src/changes/changes.xml | 6 ++++++ src/java/com/healthmarketscience/jackcess/Column.java | 6 ++---- src/java/com/healthmarketscience/jackcess/JetFormat.java | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index bff2c96..7f3d746 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -5,6 +5,12 @@ James Ahlborn + + + Fix writing of large memo/ole fields. Apparently Access does not like + long value fields longer than 4076 bytes. + + Need to store auto-number values back into row so that indexes can be diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java index dde0985..5987ae3 100644 --- a/src/java/com/healthmarketscience/jackcess/Column.java +++ b/src/java/com/healthmarketscience/jackcess/Column.java @@ -754,9 +754,7 @@ public class Column implements Comparable { && (value.length <= getFormat().MAX_INLINE_LONG_VALUE_SIZE)) { type = LONG_VALUE_TYPE_THIS_PAGE; lvalDefLen += value.length; - } else if(Table.getRowSpaceUsage(value.length, getFormat()) <= - getFormat().MAX_ROW_SIZE) - { + } else if(value.length <= getFormat().MAX_LONG_VALUE_ROW_SIZE) { type = LONG_VALUE_TYPE_OTHER_PAGE; } else { type = LONG_VALUE_TYPE_OTHER_PAGES; @@ -802,7 +800,7 @@ public class Column implements Comparable { writeLongValueHeader(lvalPage); // figure out how much we will put in this page - int chunkLength = Math.min(getFormat().MAX_ROW_SIZE - 4, + int chunkLength = Math.min(getFormat().MAX_LONG_VALUE_ROW_SIZE - 4, remainingLen); nextLvalPageNum = ((chunkLength < remainingLen) ? getPageChannel().allocateNewPage() : 0); diff --git a/src/java/com/healthmarketscience/jackcess/JetFormat.java b/src/java/com/healthmarketscience/jackcess/JetFormat.java index b8b7fea..0b2b994 100644 --- a/src/java/com/healthmarketscience/jackcess/JetFormat.java +++ b/src/java/com/healthmarketscience/jackcess/JetFormat.java @@ -115,6 +115,7 @@ public abstract class JetFormat { public final int SIZE_ROW_LOCATION; public final int SIZE_LONG_VALUE_DEF; public final int MAX_INLINE_LONG_VALUE_SIZE; + public final int MAX_LONG_VALUE_ROW_SIZE; public final int SIZE_TDEF_HEADER; public final int SIZE_TDEF_TRAILER; public final int SIZE_COLUMN_DEF_BLOCK; @@ -200,6 +201,7 @@ public abstract class JetFormat { SIZE_ROW_LOCATION = defineSizeRowLocation(); SIZE_LONG_VALUE_DEF = defineSizeLongValueDef(); MAX_INLINE_LONG_VALUE_SIZE = defineMaxInlineLongValueSize(); + MAX_LONG_VALUE_ROW_SIZE = defineMaxLongValueRowSize(); SIZE_TDEF_HEADER = defineSizeTdefHeader(); SIZE_TDEF_TRAILER = defineSizeTdefTrailer(); SIZE_COLUMN_DEF_BLOCK = defineSizeColumnDefBlock(); @@ -264,6 +266,7 @@ public abstract class JetFormat { protected abstract int defineSizeRowLocation(); protected abstract int defineSizeLongValueDef(); protected abstract int defineMaxInlineLongValueSize(); + protected abstract int defineMaxLongValueRowSize(); protected abstract int defineSizeTdefHeader(); protected abstract int defineSizeTdefTrailer(); protected abstract int defineSizeColumnDefBlock(); @@ -385,6 +388,8 @@ public abstract class JetFormat { @Override protected int defineMaxInlineLongValueSize() { return 64; } @Override + protected int defineMaxLongValueRowSize() { return 4076; } + @Override protected int defineSizeTdefHeader() { return 63; } @Override protected int defineSizeTdefTrailer() { return 2; } -- cgit v1.2.3