Example #1
0
void OsmApiDb::transaction()
{
  // Queries must be created from within the current transaction.
  _resetQueries();
  if (!_db.transaction())
  {
    throw HootException(_db.lastError().text());
  }
  _inTransaction = true;
}
Example #2
0
void OsmApiDb::rollback()
{
  _resetQueries();

  if (!_db.rollback())
  {
    LOG_WARN("Error rolling back transaction.");
    throw HootException("Error rolling back transaction: " + _db.lastError().text());
  }
  _inTransaction = false;
}
Example #3
0
void ServicesDb::commit()
{
  createPendingMapIndexes();
  _flushBulkInserts();
  _resetQueries();
  if (!_db.commit())
  {
    LOG_WARN("Error committing transaction.");
    throw HootException("Error committing transaction: " + _db.lastError().text());
  }
  _inTransaction = false;
}
Example #4
0
void ServicesDb::_checkLastMapId(long mapId)
{
  if (_lastMapId != mapId)
  {
    _flushBulkInserts();
    _resetQueries();
    _nodeIdReserver.reset();
    _wayIdReserver.reset();
    _relationIdReserver.reset();
    _lastMapId = mapId;
  }
}
Example #5
0
void OsmApiDb::close()
{
  _resetQueries();

  if (_inTransaction)
  {
    LOG_WARN("Closing database before transaction is committed. Rolling back transaction.");
    rollback();
  }

  // Seeing this? "Unable to free statement: connection pointer is NULL"
  // Make sure all queries are listed in _resetQueries.
  _db.close();
}
Example #6
0
void ServicesDb::close()
{
  createPendingMapIndexes();
  _flushBulkInserts();

  _resetQueries();

  if (_inTransaction)
  {
    LOG_WARN("Closing database before transaction is committed. Rolling back transaction.");
    rollback();
  }

  // Seeing this? "Unable to free statement: connection pointer is NULL"
  // Make sure all queries are listed in _resetQueries.
  _db.close();
}
Example #7
0
void OsmApiDb::commit()
{
  if ( _db.isOpen() == false )
  {
    throw HootException("Tried to commit a transaction on a closed database");
  }

  if ( _inTransaction == false )
  {
    throw HootException("Tried to commit but weren't in a transaction");
  }

  _resetQueries();
  if (!_db.commit())
  {
    LOG_WARN("Error committing transaction.");
    throw HootException("Error committing transaction: " + _db.lastError().text());
  }
  _inTransaction = false;
}
Example #8
0
void OsmApiDb::_init()
{
  _inTransaction = false;
  _resetQueries();
}