From: adam Date: Sun, 15 Jul 2007 23:09:10 +0000 (+0000) Subject: add uid_ to SqliteJdbcMailbox X-Git-Url: http://git.megacz.com/?p=org.ibex.mail.git;a=commitdiff_plain;h=87171b6a0b0d5c056f41c59d7ecd034aeacb1fbc add uid_ to SqliteJdbcMailbox darcs-hash:20070715230910-5007d-284b4323ef957190840e4c17d77615e6bf167b6c.gz --- diff --git a/src/org/ibex/mail/SqliteJdbcMailbox.java b/src/org/ibex/mail/SqliteJdbcMailbox.java index 5fc3621..3c558ee 100644 --- a/src/org/ibex/mail/SqliteJdbcMailbox.java +++ b/src/org/ibex/mail/SqliteJdbcMailbox.java @@ -14,14 +14,29 @@ import java.util.*; public class SqliteJdbcMailbox extends Mailbox.Default { private Connection conn; - private static final String columns = "messageid_,from_,to_,date_,subject_,headers_,body_,flags_"; + private static final String columns = + " messageid_, from_,to_,date_,subject_,headers_,body_,flags_"; + + /** + * from http://www.sqlite.org/autoinc.html + * "If a column has the type INTEGER PRIMARY KEY AUTOINCREMENT + * then a slightly different ROWID selection algorithm is + * used. The ROWID chosen for the new row is one larger than the + * largest ROWID that has ever before existed in that same + * table. If the table has never before contained any data, then + * a ROWID of 1 is used. If the table has previously held a row + * with the largest possible ROWID, then new INSERTs are not + * allowed and any attempt to insert a new row will fail with an + * SQLITE_FULL error. + */ + private static final String columns_ = + "uid_ INTEGER PRIMARY KEY AUTOINCREMENT, messageid_ unique,from_,to_,date_,subject_,headers_,body_,flags_"; public SqliteJdbcMailbox(String filename) { try { Class.forName("org.sqlite.JDBC"); conn = DriverManager.getConnection("jdbc:sqlite:"+filename); - conn.prepareStatement("create virtual table if not exists "+ - "'mail' using FTS2("+columns+",PRIMARY KEY(messageid_))").executeUpdate(); + conn.prepareStatement("create virtual table if not exists 'mail' using FTS2("+columns_+")").executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); }