X-Git-Url: http://git.megacz.com/?p=org.ibex.mail.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fmail%2FSqliteMailbox.java;h=0d8053294af772a9514996a44ac09c21ed7a92fb;hp=c423fef8a730c99f9aecc061b73f28378dd13f7c;hb=eb54d55cb9ae403a6824687b44b2ee2fafb8e7c5;hpb=2e7880f610fe822ac54cc312aff0997c578bc858 diff --git a/src/org/ibex/mail/SqliteMailbox.java b/src/org/ibex/mail/SqliteMailbox.java index c423fef..0d80532 100644 --- a/src/org/ibex/mail/SqliteMailbox.java +++ b/src/org/ibex/mail/SqliteMailbox.java @@ -22,7 +22,18 @@ public class SqliteMailbox extends Mailbox.Default implements MailTree { private Connection conn; private static final String columns = " messageid_, from_,to_,date_,subject_,headers_,body_,flags_"; - + private static final String[] indexedColumns = new String[] { + "uid_", + "messageid_", + "flags_", + /* + "from_", + "to_", + "subject_", + "date_" + */ + }; + /** * from http://www.sqlite.org/autoinc.html * "If a column has the type INTEGER PRIMARY KEY AUTOINCREMENT @@ -35,6 +46,7 @@ public class SqliteMailbox extends Mailbox.Default implements MailTree { * allowed and any attempt to insert a new row will fail with an * SQLITE_FULL error. */ + // FIXME: should messageid_ be decared unique? private static final String columns_ = "uid_ INTEGER PRIMARY KEY AUTOINCREMENT, messageid_ unique,from_,to_,date_,subject_,headers_,body_,flags_"; @@ -57,13 +69,9 @@ public class SqliteMailbox extends Mailbox.Default implements MailTree { } else { this.uidValidity = rs.getInt(1); } - try { - //conn.prepareStatement("create virtual table 'mail' using FTS2("+columns_+")").executeUpdate(); - conn.prepareStatement("create table 'mail' ("+columns_+")").executeUpdate(); - } catch (SQLException e) { - /* FIXME */ - } - conn.prepareStatement("create index if not exists uid_index on mail(uid_);").executeUpdate(); + conn.prepareStatement("create table if not exists 'mail' ("+columns_+")").executeUpdate(); + for(String name : indexedColumns) + conn.prepareStatement("create index if not exists "+name+"index on mail("+name+");").executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); }