private Object runWriteTransaction(final ISqlJetTableRun op) throws SqlJetException { return db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { final ISqlJetBtreeDataTable table = new SqlJetBtreeDataTable(btree, tableName, write); try { return op.run(table); } finally { table.close(); } } }); }
public long updateWithRowIdOr(final SqlJetConflictAction onConflict, final long rowId, final Object... values) throws SqlJetException { return (Long) db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { final ISqlJetBtreeDataTable table = getBtreeDataTable(); if (table.eof()) { throw new SqlJetException(SqlJetErrorCode.MISUSE, "Table is empty or current record doesn't't point to data row"); } return table.updateCurrentWithRowId(onConflict, rowId, values); } }); }
public void updateOr(final SqlJetConflictAction onConflict, final Object... values) throws SqlJetException { db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { final ISqlJetBtreeDataTable table = getBtreeDataTable(); if (table.eof()) { throw new SqlJetException(SqlJetErrorCode.MISUSE, "Table is empty or current record doesn't't point to data row"); } table.updateCurrent(onConflict, values); return null; } }); }
public void updateByFieldNamesOr(final SqlJetConflictAction onConflict, final Map<String, Object> values) throws SqlJetException { db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { final ISqlJetBtreeDataTable table = getBtreeDataTable(); if (table.eof()) { throw new SqlJetException(SqlJetErrorCode.MISUSE, "Table is empty or current record doesn't point to data row"); } table.update(onConflict, values); return null; } }); }
/** * Creates trigger from SQL clause. * * @param sql * CREATE TRIGGER ... sentence. * @return definition of the trigger being created. */ public ISqlJetTriggerDef createTrigger(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetTriggerDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createTrigger(sql); } }); }
/** * Drop table. * * @param tableName name of table to drop. */ public void dropTable(final String tableName) throws SqlJetException { checkOpen(); runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { getSchemaInternal().dropTable(tableName); return null; } }); }
/** * Drop index. * * @param indexName name of the index to drop. */ public void dropIndex(final String indexName) throws SqlJetException { checkOpen(); runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { getSchemaInternal().dropIndex(indexName); return null; } }); }
/** * Drop view. * * @param viewName name of the view to drop. */ public void dropView(final String viewName) throws SqlJetException { checkOpen(); runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { getSchemaInternal().dropView(viewName); return null; } }); }
/** * Create index from SQL clause. * * @param sql * CREATE INDEX ... sentence. * @return definition of created index. */ public ISqlJetIndexDef createIndex(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetIndexDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createIndex(sql); } }); }
/** * Creates virtual table from SQL clause. * * @param sql * CREATE VIRTUAL TABLE ... sentence. * @return definition of create virtual table. */ public ISqlJetVirtualTableDef createVirtualTable(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetVirtualTableDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createVirtualTable(sql, 0); } }); }
/** * Drop trigger. * * @param triggerName name of the trigger to drop. */ public void dropTrigger(final String triggerName) throws SqlJetException { checkOpen(); runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { getSchemaInternal().dropTrigger(triggerName); return null; } }); }
public void delete() throws SqlJetException { db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { final ISqlJetBtreeDataTable table = getBtreeDataTable(); if (table.eof()) { throw new SqlJetException(SqlJetErrorCode.MISUSE, "Table is empty or current record doesn't point to data row"); } table.delete(); return null; } }); super.delete(); }
/** * Alters table. * * @param sql * ALTER TABLE ... sentence. * @return altered table schema definition. */ public ISqlJetTableDef alterTable(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetTableDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().alterTable(sql); } }); }
/** * Creates view from SQL clause. * * @param sql * CREATE VIEW X AS SELECT ... sentence. * @return definition of the view being created. */ public ISqlJetViewDef createView(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetViewDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createView(sql); } }); }
/** * Create table from SQL clause. * * @param sql * CREATE TABLE ... sentence. * @return definition of create table. */ public ISqlJetTableDef createTable(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetTableDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createTable(sql); } }); }
public void runWriteTransaction(final IFSSqlJetTransaction transaction) throws SVNException { if (myRepCacheDB != null) { try { myRepCacheDB.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { try { transaction.run(); } catch (SVNException e) { throw new SqlJetException(e); } return null; } }); } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } } }
public Object runWithLock(SqlJetDb db) throws SqlJetException { int version = db.getOptions().getUserVersion(); if (version < REP_CACHE_DB_FORMAT) { db.getOptions().setAutovacuum(true); db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { db.getOptions().setUserVersion(REP_CACHE_DB_FORMAT); db.createTable(FSRepresentationCacheManager.REP_CACHE_DB_SQL); return null; } }); } else if (version > REP_CACHE_DB_FORMAT) { throw new SqlJetException("Schema format " + version + " not recognized"); } return null; } });
public Object runWithLock(SqlJetDb db) throws SqlJetException { int version = db.getOptions().getUserVersion(); if (version < REP_CACHE_DB_FORMAT) { db.getOptions().setAutovacuum(true); db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { db.getOptions().setUserVersion(REP_CACHE_DB_FORMAT); db.createTable(FSRepresentationCacheManager.REP_CACHE_DB_SQL); return null; } }); } else if (version > REP_CACHE_DB_FORMAT) { throw new SqlJetException("Schema format " + version + " not recognized"); } return null; } });
public Object runWithLock(SqlJetDb db) throws SqlJetException { int version = db.getOptions().getUserVersion(); if (version < REP_CACHE_DB_FORMAT) { db.getOptions().setAutovacuum(true); db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { db.getOptions().setUserVersion(REP_CACHE_DB_FORMAT); db.createTable(FSRepresentationCacheManager.REP_CACHE_DB_SQL); return null; } }); } else if (version > REP_CACHE_DB_FORMAT) { throw new SqlJetException("Schema format " + version + " not recognized"); } return null; } });
public long exec() throws SVNException { try { sDb.getDb().getOptions().setAutovacuum(true); sDb.getDb().runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { db.createTable("create table revprop (revision integer UNIQUE not null, " + "properties BLOB not null);"); db.createIndex("create index i_revision on revprop (revision);"); db.getOptions().setUserVersion(1); return null; } }); } catch (SqlJetException e) { SVNErrorMessage err = SVNErrorMessage.create( SVNErrorCode.SQLITE_ERROR,e); SVNErrorManager.error(err, SVNLogType.FSFS); } return 0; }