From 955c6654b77ed12de7ee126fad60ee9f294dd8b5 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Sat, 16 Apr 2011 13:45:32 +0000 Subject: [PATCH] better handling of read-only indexes git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@552 f203690c-595d-4dc9-a70b-905162fa7fd2 --- src/java/com/healthmarketscience/jackcess/Database.java | 3 --- src/java/com/healthmarketscience/jackcess/IndexCursor.java | 5 +++++ src/java/com/healthmarketscience/jackcess/IndexData.java | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java index 9156a46..3691e22 100644 --- a/src/java/com/healthmarketscience/jackcess/Database.java +++ b/src/java/com/healthmarketscience/jackcess/Database.java @@ -2003,9 +2003,6 @@ public class Database private DefaultTableFinder(IndexCursor systemCatalogCursor) { _systemCatalogCursor = systemCatalogCursor; - if(_systemCatalogCursor.getIndex().getIndexData().isReadOnly()) { - throw new IllegalArgumentException("Unusable index"); - } } @Override diff --git a/src/java/com/healthmarketscience/jackcess/IndexCursor.java b/src/java/com/healthmarketscience/jackcess/IndexCursor.java index df31a09..2529c40 100644 --- a/src/java/com/healthmarketscience/jackcess/IndexCursor.java +++ b/src/java/com/healthmarketscience/jackcess/IndexCursor.java @@ -137,6 +137,11 @@ public class IndexCursor extends Cursor "JetFormat " + table.getFormat() + " does not currently support index lookups"); } + if(index.getIndexData().isReadOnly()) { + throw new IllegalArgumentException( + "Given index " + index + + " is not usable for indexed lookups because it is read-only"); + } IndexCursor cursor = new IndexCursor(table, index, index.cursor(startRow, startInclusive, endRow, endInclusive)); diff --git a/src/java/com/healthmarketscience/jackcess/IndexData.java b/src/java/com/healthmarketscience/jackcess/IndexData.java index 87e23a7..93f4ad5 100644 --- a/src/java/com/healthmarketscience/jackcess/IndexData.java +++ b/src/java/com/healthmarketscience/jackcess/IndexData.java @@ -1191,6 +1191,8 @@ public abstract class IndexData { return new GenTextColumnDescriptor(col, flags); } // unsupported sort order + LOG.warn("Unsupported collating sort order " + sortOrder + + " for text index, making read-only"); setReadOnly(); return new ReadOnlyColumnDescriptor(col, flags); case INT: @@ -1214,6 +1216,8 @@ public abstract class IndexData { default: // FIXME we can't modify this index at this point in time + LOG.warn("Unsupported data type " + col.getType() + + " for index, making read-only"); setReadOnly(); return new ReadOnlyColumnDescriptor(col, flags); } -- 2.39.5