public void close() throws SqlJetException { if (table != null) { table = null; } if (cursor != null) { cursor.close(); cursor = null; } }
public void close() throws SqlJetException { cursor.close(); }
static void close(ISqlJetCursor cursor) { try { cursor.close(); } catch (SqlJetException e) { logger.log(Level.WARN, e); } }
public void reset() throws SVNException { binds.clear(); if (isNeedsReset()) { try { getCursor().close(); } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); } finally { setCursor(null); sDb.commit(); } } }
private void resetCursor() throws SVNException { try { getCursor().close(); } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); } setCursor(openCursor()); }
private void resetCursor() throws SVNException { try { getCursor().close(); } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); } setCursor(openCursor()); }
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 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(); } } }
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); }
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; } }
private String getNodeReposRelpath(long wcId, String path) throws SVNException { ISqlJetCursor cursor = null; try { cursor = getTable().lookup(null, wcId, path); if (!cursor.eof()) { return cursor.getString(NODES__Fields.repos_path.toString()); } } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); } finally { if (cursor != null) { try { cursor.close(); } catch (SqlJetException e) { } } } return null; }
@Override public void delete(String fullname) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); ISqlJetCursor cursor = table.lookup(StateTable.NDX_FULL_NAME, fullname); while (!cursor.eof()) { cursor.delete(); } cursor.close(); } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to delete: " + fullname, e); } }
public Long getMaxOpDepth(Long wcId, String localRelpath) throws SVNException { ISqlJetCursor c = null; try { c = getTable().lookup(null, wcId, localRelpath); c = c.reverse(); if (!c.eof()) { long rowDepth = c.getInteger(SVNWCDbSchema.NODES__Fields.op_depth.toString()); if (rowDepth >= minDepth) { return rowDepth; } } } catch (SqlJetException e) { SVNSqlJetDb.createSqlJetError(e); } finally { try { c.close(); } catch (SqlJetException e) { } } return null; }
public void transaction(SVNSqlJetDb db) throws SqlJetException, SVNException { try { db.beginTransaction(SqlJetTransactionMode.WRITE); final ISqlJetTable table = db.getDb().getTable(SVNWCDbSchema.NODES.name()); ISqlJetCursor c = table.lookup(null, wcRoot.getWcId(), SVNFileUtil.getFilePath(localRelpath)); c = c.reverse(); if (!c.eof()) { final Map<String, Object> updateValues = new HashMap<String, Object>(); updateValues.put(SVNWCDbSchema.NODES__Fields.translated_size.toString(), translatedSize); updateValues.put(SVNWCDbSchema.NODES__Fields.last_mod_time.toString(), lastModTime); c.updateByFieldNames(updateValues); } c.close(); db.commit(); } catch (SqlJetException e) { db.rollback(); throw e; } catch (SVNException e) { db.rollback(); throw e; } } }
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; }
@Override public State get(String fullname) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); ISqlJetCursor cursor = table.lookup(StateTable.NDX_FULL_NAME, fullname); if (!cursor.eof()) { State state = read(cursor); cursor.close(); return state; } } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to get " + fullname, e); } return null; }
private FSRepresentationCacheRecord getByHash(final String hash) throws SVNException { ISqlJetCursor lookup = null; try { lookup = myTable.lookup(myTable.getPrimaryKeyIndexName(), new Object[] { hash }); if (!lookup.eof()) { return new FSRepresentationCacheRecord(lookup); } } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } finally { if (lookup != null) { try { lookup.close(); } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } } } return null; }
private FSRepresentationCacheRecord getByHash(final String hash) throws SVNException { ISqlJetCursor lookup = null; try { lookup = myTable.lookup(myTable.getPrimaryKeyIndexName(), new Object[] { hash }); if (!lookup.eof()) { return new FSRepresentationCacheRecord(lookup); } } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } finally { if (lookup != null) { try { lookup.close(); } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } } } return null; }
private FSRepresentationCacheRecord getByHash(final String hash) throws SVNException { ISqlJetCursor lookup = null; try { lookup = myTable.lookup(myTable.getPrimaryKeyIndexName(), new Object[] { hash }); if (!lookup.eof()) { return new FSRepresentationCacheRecord(lookup); } } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } finally { if (lookup != null) { try { lookup.close(); } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } } } return null; }
@Override public void update(State state) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); ISqlJetCursor cursor = table.lookup(StateTable.NDX_FULL_NAME, state.fullname); while (!cursor.eof()) { cursor.update(getData(state)); cursor.next(); } cursor.close(); } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to update: " + state, e); } }