diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2018-12-17 23:21:35 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2018-12-17 23:21:35 +0000 |
commit | 84e162f6e2ccdd40f5b962fa1bb44aaab79dfa66 (patch) | |
tree | 66caa4ff1781b61fc0d8cdc6dc015ee3bba0fa28 /src/main/java/com/healthmarketscience/jackcess/impl | |
parent | c1aa151cd41d0b8da5f16ac2b40bdc7f084f7d70 (diff) | |
parent | 112cb827e960be047f38cd7c60b27b4202f02596 (diff) | |
download | jackcess-84e162f6e2ccdd40f5b962fa1bb44aaab79dfa66.tar.gz jackcess-84e162f6e2ccdd40f5b962fa1bb44aaab79dfa66.zip |
merge trunk changes through r1241
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jdk8@1242 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java/com/healthmarketscience/jackcess/impl')
3 files changed, 20 insertions, 4 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java index 8e67d60..6ab88ab 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java @@ -546,6 +546,12 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, ZoneContext } void initColumnValidator() throws IOException { + + if(getDatabase().isReadOnly()) { + // validators are irrelevant for read-only databases + return; + } + // first initialize any "external" (user-defined) validator setColumnValidator(null); diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java index c5f5481..dcd4e18 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java @@ -262,6 +262,8 @@ public class DatabaseImpl implements Database, ZoneContext private final Path _file; /** the simple name of the database */ private final String _name; + /** whether or not this db is read-only */ + private final boolean _readOnly; /** Buffer to hold database pages */ private ByteBuffer _buffer; /** ID of the Tables system object */ @@ -409,7 +411,8 @@ public class DatabaseImpl implements Database, ZoneContext } DatabaseImpl db = new DatabaseImpl(mdbFile, channel, closeChannel, autoSync, - null, charset, timeZone, provider); + null, charset, timeZone, provider, + readOnly); success = true; return db; @@ -468,7 +471,8 @@ public class DatabaseImpl implements Database, ZoneContext transferDbFrom(channel, getResourceAsStream(details.getEmptyFilePath())); channel.force(true); DatabaseImpl db = new DatabaseImpl(mdbFile, channel, closeChannel, autoSync, - fileFormat, charset, timeZone, null); + fileFormat, charset, timeZone, null, + false); success = true; return db; } finally { @@ -520,11 +524,13 @@ public class DatabaseImpl implements Database, ZoneContext */ protected DatabaseImpl(Path file, FileChannel channel, boolean closeChannel, boolean autoSync, FileFormat fileFormat, Charset charset, - TimeZone timeZone, CodecProvider provider) + TimeZone timeZone, CodecProvider provider, + boolean readOnly) throws IOException { _file = file; _name = getName(file); + _readOnly = readOnly; _format = JetFormat.getFormat(channel); _charset = ((charset == null) ? getDefaultCharset(_format) : charset); _columnOrder = getDefaultColumnOrder(); @@ -557,6 +563,10 @@ public class DatabaseImpl implements Database, ZoneContext return _name; } + public boolean isReadOnly() { + return _readOnly; + } + /** * @usage _advanced_method_ */ diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java index fcc9cb5..77edf80 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java @@ -425,7 +425,7 @@ public class DefaultTextFunctions } }); - public static final Function FORMAT = registerFunc(new FuncVar("Format", 1, 4) { + public static final Function FORMAT = registerStringFunc(new FuncVar("Format", 1, 4) { @Override protected Value evalVar(EvalContext ctx, Value[] params) { |