public ISqlJetSchema getSchema(String databaseName) throws SqlJetException { return db.getSchema(); } }
public boolean hasTable(String tableName) throws SVNException { try { return tableName != null && db.getSchema().getTableNames().contains(tableName); } catch (SqlJetException e) { SVNErrorMessage err1 = SVNErrorMessage.create(SVNErrorCode.SQLITE_ERROR, e); SVNErrorManager.error(err1, SVNLogType.DEFAULT); } return false; }
@Override public void execute(SqlJetDb database) throws SqlJetException { ISqlJetSchema schema = database.getSchema(); if (schema.getTable(STATE_TABLE) == null) { database.createTable(CREATE_STATE_SQL); } else if (Boolean.getBoolean(StateManager.CLEAR_LOCAL_STATE)) { database.getTable(STATE_TABLE).clear(); } } };
@Override public void execute(SqlJetDb database) throws SqlJetException { ISqlJetSchema schema = database.getSchema(); if (schema.getTable(INVOCATION_TABLE) == null) { database.createTable(CREATE_INVOCATION_SQL); } if (schema.getTable(INVOKER_TABLE) == null) { database.createTable(CREATE_INVOKER_SQL); database.createIndex(CREATE_INVOKER_INDEX); } } };
private void handleDropIndex() throws SqlJetException { CommonTree options = (CommonTree) ast.getChild(0); boolean ifExists = options.getChildCount() > 0 && "exists".equalsIgnoreCase(options.getChild(0).getText()); String indexName = ast.getChild(1).getText(); if (db.getSchema().getIndex(indexName) != null) { db.dropIndex(indexName); } else if (!ifExists) { throw new SqlJetException(SqlJetErrorCode.ERROR, "Index does not exists."); } }
private void handleDropTable() throws SqlJetException { CommonTree options = (CommonTree) ast.getChild(0); boolean ifExists = options.getChildCount() > 0 && "exists".equalsIgnoreCase(options.getChild(0).getText()); String tableName = ast.getChild(1).getText(); if (db.getSchema().getTable(tableName) != null) { db.dropTable(tableName); } else if (!ifExists) { throw new SqlJetException(SqlJetErrorCode.ERROR, "Table does not exists."); } }
public void bumpTo(SVNWCDb db, SVNSqlJetDb sDb, File wcRootAbsPath) throws SVNException { /*-- STMT_UPGRADE_TO_26 * DROP VIEW IF EXISTS NODES_BASE; * CREATE VIEW NODES_BASE AS * SELECT * FROM nodes * WHERE op_depth = 0; */ try { if (sDb.getDb().getSchema().getViewNames().contains("NODES_BASE")) { sDb.getDb().dropView("NODES_BASE"); } sDb.getDb().createView("CREATE VIEW NODES_BASE AS SELECT * FROM nodes WHERE op_depth = 0;"); } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); } setVersion(sDb, (int)26); } }
private void ensureNodesMovedToIndex(SVNSqlJetDb sDb) throws SVNException { try { sDb.beginTransaction(SqlJetTransactionMode.WRITE); if (sDb.getDb().getSchema().getIndex("I_NODES_MOVED") == null) { sDb.getDb().createIndex("CREATE UNIQUE INDEX I_NODES_MOVED ON NODES (wc_id, moved_to, op_depth);"); } sDb.commit(); } catch (SqlJetException e) { sDb.rollback(); SVNSqlJetDb.createSqlJetError(e); } }
case TABLE: if (stmt.isDrop()) { if (db.getSchema().getTableNames().contains(stmt.getName())) { db.dropTable(stmt.getSql()); if (db.getSchema().getTableNames().contains(stmt.getName())) { db.dropTable(stmt.getName()); case INDEX: if (stmt.isDrop()) { if (db.getSchema().getIndexNames().contains(stmt.getName())) { db.dropIndex(stmt.getSql()); if (db.getSchema().getIndexNames().contains(stmt.getName())) { db.dropIndex(stmt.getName()); case VIEW: if (stmt.isDrop()) { if (db.getSchema().getViewNames().contains(stmt.getName())) { db.dropView(stmt.getSql()); if (db.getSchema().getViewNames().contains(stmt.getName())) { db.dropView(stmt.getName()); case TRIGGER: if (stmt.isDrop()) { if (db.getSchema().getTriggerNames().contains(stmt.getName())) { db.dropTrigger(stmt.getSql());
if (sDb.getDb().getSchema().getTriggerNames().contains("nodes_update_checksum_trigger")) { sDb.getDb().dropTrigger("nodes_update_checksum_trigger"); if (sDb.getDb().getSchema().getTriggerNames().contains("nodes_insert_trigger")) { sDb.getDb().dropTrigger("nodes_insert_trigger"); if (sDb.getDb().getSchema().getTriggerNames().contains("nodes_delete_trigger")) { sDb.getDb().dropTrigger("nodes_delete_trigger");
public void bumpTo(SVNWCDb db, SVNSqlJetDb sDb, File wcRootAbsPath) throws SVNException { try { if (sDb.getDb().getSchema().getTable("NODES").getColumn("inherited_props") == null) { sDb.getDb().createIndex("CREATE UNIQUE INDEX IF NOT EXISTS I_NODES_MOVED ON NODES (wc_id, moved_to, op_depth);"); sDb.getDb().createIndex("CREATE INDEX IF NOT EXISTS I_PRISTINE_MD5 ON PRISTINE (md5_checksum);");
public void bumpTo(SVNWCDb db, SVNSqlJetDb sDb, File wcRootAbsPath) throws SVNException { try { if (sDb.getDb().getSchema().getTable("NODES").getColumn("inherited_props") != null) { setVersion(sDb, 31); return; } else { if (sDb.getDb().getSchema().getIndex("I_ACTUAL_CHANGELIST") != null) { sDb.getDb().dropIndex("I_ACTUAL_CHANGELIST"); if (sDb.getDb().getSchema().getIndex("I_EXTERNALS_PARENT") != null) { sDb.getDb().dropIndex("I_EXTERNALS_PARENT");