From: James Ahlborn Date: Mon, 14 Mar 2011 02:53:11 +0000 (+0000) Subject: increase max size of memo/ole columns X-Git-Tag: jackcess-1.2.4~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=64e9887133cc2a0996f3793bb3748023c215cdfc;p=jackcess.git increase max size of memo/ole columns git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@526 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java index f578f76..e4b7ecd 100644 --- a/src/java/com/healthmarketscience/jackcess/Column.java +++ b/src/java/com/healthmarketscience/jackcess/Column.java @@ -107,6 +107,11 @@ public class Column implements Comparable { * multiple other pages */ private static final byte LONG_VALUE_TYPE_OTHER_PAGES = (byte) 0x00; + /** + * Mask to apply the long length in order to get the flag bits (only the + * first 2 bits are type flags). + */ + private static final int LONG_VALUE_TYPE_MASK = 0xC0000000; /** mask for the fixed len bit */ public static final byte FIXED_LEN_FLAG_MASK = (byte)0x01; @@ -117,9 +122,13 @@ public class Column implements Comparable { /** mask for the auto number guid bit */ public static final byte AUTO_NUMBER_GUID_FLAG_MASK = (byte)0x40; - /** mask for the unknown bit */ + /** mask for the unknown bit (possible "can be null"?) */ public static final byte UNKNOWN_FLAG_MASK = (byte)0x02; + // some other flags? + // 0x10: replication related field (or hidden?) + // 0x80: hyperlink (some memo based thing) + /** the "general" text sort order */ public static final short GENERAL_SORT_ORDER = 1033; @@ -548,14 +557,11 @@ public class Column implements Comparable { { ByteBuffer def = ByteBuffer.wrap(lvalDefinition) .order(PageChannel.DEFAULT_BYTE_ORDER); - int length = ByteUtil.get3ByteInt(def); - // bail out gracefully here as we don't understand the format - if (length < 0) - { - return null; - } + int lengthWithFlags = def.getInt(); + int length = lengthWithFlags & (~LONG_VALUE_TYPE_MASK); + byte[] rtn = new byte[length]; - byte type = def.get(); + byte type = (byte)((lengthWithFlags & LONG_VALUE_TYPE_MASK) >>> 24); if(type == LONG_VALUE_TYPE_THIS_PAGE) { @@ -932,8 +938,9 @@ public class Column implements Comparable { } ByteBuffer def = getPageChannel().createBuffer(lvalDefLen); - ByteUtil.put3ByteInt(def, value.length); - def.put(type); + // take length and apply type to first byte + int lengthWithFlags = value.length | (type << 24); + def.putInt(lengthWithFlags); if(type == LONG_VALUE_TYPE_THIS_PAGE) { // write long value inline diff --git a/src/java/com/healthmarketscience/jackcess/DataType.java b/src/java/com/healthmarketscience/jackcess/DataType.java index 56330d9..079c1e7 100644 --- a/src/java/com/healthmarketscience/jackcess/DataType.java +++ b/src/java/com/healthmarketscience/jackcess/DataType.java @@ -112,14 +112,14 @@ public enum DataType { * Accepts a {@code byte[]}, or {@code null}. Equivalent to SQL * {@link Types#LONGVARBINARY}, {@link Types#BLOB}. */ - OLE((byte) 0x0B, Types.LONGVARBINARY, null, true, true, 0, null, 0xFFFFFF, + OLE((byte) 0x0B, Types.LONGVARBINARY, null, true, true, 0, null, 0x3FFFFFFF, 1), /** * Corresponds to a java String of max length 8388607 chars. Accepts any * CharSequence, any Object converted to a String , or {@code null}. * Equivalent to SQL {@link Types#LONGVARCHAR}, {@link Types#CLOB}. */ - MEMO((byte) 0x0C, Types.LONGVARCHAR, null, true, true, 0, null, 0xFFFFFF, + MEMO((byte) 0x0C, Types.LONGVARCHAR, null, true, true, 0, null, 0x3FFFFFFF, JetFormat.TEXT_FIELD_UNIT_SIZE), /** * Unknown data. Handled like BINARY.