@Override public void execute(SqlJetDb db) throws SqlJetException { db.getTable(INVOCATION_TABLE).insert(transactionId, phase, exceptionType); } };
@Override public void execute(SqlJetDb db) throws SqlJetException { ISqlJetTable table = db.getTable(INVOKER_TABLE); ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName(), transactionId, phase, databaseId); try { if (!cursor.eof()) { cursor.updateByFieldNames(Collections.<String, Object>singletonMap(RESULT_COLUMN, result)); } } finally { close(cursor); } } };
private boolean exists(SqlJetDb db, long wcId, String localRelPath) throws SqlJetException { ISqlJetTable table = db.getTable(SVNWCDbSchema.NODES.name()); ISqlJetCursor cursor = table.lookup(null, wcId, localRelPath); try { return !cursor.eof(); } finally { cursor.close(); } }
private static Map<SvnChecksum, Integer> calculateCorrectChecksumRefcounts(SVNWCDbRoot root) throws SVNException { Map<SvnChecksum, Integer> checksumToRefCount = new HashMap<SvnChecksum, Integer>(); final SqlJetDb db = root.getSDb().getDb(); try { final ISqlJetTable nodesTable = db.getTable(SVNWCDbSchema.NODES.name()); db.beginTransaction(SqlJetTransactionMode.READ_ONLY); final ISqlJetCursor cursor = nodesTable.open(); for (; !cursor.eof(); cursor.next()) { String sha1ChecksumString = cursor.getString(SVNWCDbSchema.NODES__Fields.checksum.name()); if (sha1ChecksumString == null) { continue; } SvnChecksum sha1Checksum = SvnChecksum.fromString(sha1ChecksumString); Integer refCount = checksumToRefCount.get(sha1Checksum); int incrementedRefCount = refCount == null ? 1 : refCount + 1; checksumToRefCount.put(sha1Checksum, incrementedRefCount); } cursor.close(); } catch (SqlJetException e) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.WC_DB_ERROR, e); SVNErrorManager.error(errorMessage, e, SVNLogType.WC); } finally { try { db.commit(); } catch (SqlJetException ignore) { } } return checksumToRefCount; }
protected ISqlJetCursor openCursor() throws SVNException { try { Object[] where = getWhere(); if (isPathScoped() && isPathScopeInIndex()) { where = new Object[] {where[0], getPathScope()}; return getTable().scope(getIndexName(), where, null); } return getTable().lookup(getIndexName(), where); } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); return null; } }
public Map<String, Object> getRowValues2(Map<String, Object> v) throws SVNException { v = v == null ? new HashMap<String, Object>() : v; try { final List<ISqlJetColumnDef> columns = getTable().getDefinition().getColumns(); final Object[] rValues = getCursor().getRowValues(); final Object[] values; if (rValues.length < columns.size()) { values = new Object[columns.size()]; System.arraycopy(rValues, 0, values, 0, rValues.length); } else { values = rValues; } for (int i = 0; i < values.length; i++) { v.put(columns.get(i).getName(), values[i]); } return v; } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); return null; } }
@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(); } } };
private boolean exists(SqlJetDb db, long wcId, String localRelPath) throws SqlJetException { ISqlJetTable table = db.getTable(SVNWCDbSchema.NODES.name()); ISqlJetCursor cursor = table.lookup(null, wcId, localRelPath); try { return !cursor.eof(); } finally { cursor.close(); } } }
begingWriteTransaction(wcRoot); final ISqlJetTable repositoryTable = wcRoot.getSDb().getDb().getTable(SVNWCDbSchema.REPOSITORY.toString()); ISqlJetCursor cursor = repositoryTable.open(); while(!cursor.eof()) { final String oldUrl = cursor.getString(SVNWCDbSchema.REPOSITORY__Fields.root.toString());
public Map<String, Object> getRowValues() throws SVNException { final HashMap<String, Object> v = new HashMap<String, Object>(); try { final List<ISqlJetColumnDef> columns = getTable().getDefinition().getColumns(); for (ISqlJetColumnDef column : columns) { final String colName = column.getName(); final SqlJetValueType fieldType = getCursor().getFieldType(colName); if (fieldType == SqlJetValueType.NULL) { v.put(colName, null); } else if (fieldType == SqlJetValueType.BLOB) { v.put(colName, getCursor().getBlobAsArray(colName)); } else { v.put(colName, getCursor().getValue(colName)); } } return v; } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); return null; } }
@Override public Set<String> execute(SqlJetDb database) throws SqlJetException { Set<String> set = new TreeSet<>(); ISqlJetTable table = database.getTable(STATE_TABLE); ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName()); try { if (!cursor.eof()) { do { set.add(cursor.getString(DATABASE_COLUMN)); } while (cursor.next()); } return set; } finally { close(cursor); } } };
public void beforeInsert(SqlJetConflictAction conflictAction, ISqlJetTable table, Map<String, Object> newValues) throws SqlJetException { if (conflictAction == SqlJetConflictAction.REPLACE) { Object o1 = newValues.get(NODES__Fields.wc_id.toString()); Object o2 = newValues.get(NODES__Fields.local_relpath.toString()); Object o3 = newValues.get(NODES__Fields.op_depth.toString()); ISqlJetCursor cursor = table.lookup(null, new Object[] {o1, o2, o3}); try { if (!cursor.eof()) { changeRefCount(cursor.getString(NODES__Fields.checksum.toString()), -1); } } finally { cursor.close(); } } String newChecksumValue = (String) newValues.get(NODES__Fields.checksum.toString()); changeRefCount(newChecksumValue, 1); }
@Override public void execute(SqlJetDb db) throws SqlJetException { db.getTable(INVOKER_TABLE).insert(transactionId, phase, databaseId); } };
cursor = table.open();
@Override public void execute(SqlJetDb db) throws SqlJetException { ISqlJetTable table = db.getTable(STATE_TABLE); ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName(), event.getSource()); try { if (!cursor.eof()) { cursor.delete(); } } finally { close(cursor); } } };
public void statementCompleted(SqlJetDb db, SqlJetException error) throws SqlJetException { try { if (error == null && !getTriggerValues().isEmpty()) { Map<String, Object> values = new HashMap<String, Object>(); ISqlJetTable pristineTable = db.getTable(SVNWCDbSchema.PRISTINE.toString()); for (String checksum : getTriggerValues().keySet()) { long delta = getTriggerValues().get(checksum); if (delta == 0) { continue; } ISqlJetCursor cursor = pristineTable.lookup(null, checksum); if (cursor != null && !cursor.eof()) { long refcount = cursor.getInteger(SVNWCDbSchema.PRISTINE__Fields.refcount.toString()); refcount += delta; if (refcount < 0) { refcount = 0; } values.put(SVNWCDbSchema.PRISTINE__Fields.refcount.toString(), refcount); cursor.updateByFieldNames(values); } cursor.close(); } } } finally { checksumTriggerValues = null; } }
@Override public void execute(SqlJetDb db) throws SqlJetException { db.getTable(STATE_TABLE).insert(event.getSource()); } };