mirror of
https://github.com/uroni/urbackup_backend.git
synced 2025-10-26 11:36:50 +00:00
Reset database cursor upon re-use
(cherry picked from commit ca5af2d8907c6415c13ea710e76192b75909c7f1)
This commit is contained in:
parent
c985060379
commit
f3db7fdcc0
@ -28,6 +28,9 @@
|
||||
DatabaseCursor::DatabaseCursor(CQuery *query, int *timeoutms)
|
||||
: query(query), transaction_lock(false), tries(60), timeoutms(timeoutms),
|
||||
lastErr(SQLITE_OK), _has_error(false), is_shutdown(false)
|
||||
#ifdef LOG_READ_QUERIES
|
||||
, db(db)
|
||||
#endif
|
||||
{
|
||||
query->setupStepping(timeoutms, true);
|
||||
|
||||
@ -41,6 +44,22 @@ DatabaseCursor::~DatabaseCursor(void)
|
||||
shutdown();
|
||||
}
|
||||
|
||||
bool DatabaseCursor::reset()
|
||||
{
|
||||
tries = 60;
|
||||
lastErr = SQLITE_OK;
|
||||
_has_error = false;
|
||||
is_shutdown = false;
|
||||
transaction_lock = false;
|
||||
|
||||
query->setupStepping(timeoutms, false);
|
||||
|
||||
#ifdef LOG_READ_QUERIES
|
||||
active_query = new ScopedAddActiveQuery(query, db, false);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DatabaseCursor::next(db_single_result &res)
|
||||
{
|
||||
res.clear();
|
||||
|
||||
@ -15,6 +15,8 @@ public:
|
||||
|
||||
bool next(db_single_result &res);
|
||||
|
||||
bool reset();
|
||||
|
||||
bool has_error();
|
||||
|
||||
virtual void shutdown();
|
||||
@ -31,6 +33,7 @@ private:
|
||||
|
||||
#ifdef LOG_READ_QUERIES
|
||||
ScopedAddActiveQuery *active_query;
|
||||
CDatabase* db;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@ public:
|
||||
|
||||
virtual bool has_error()=0;
|
||||
|
||||
virtual bool reset() = 0;
|
||||
|
||||
virtual void shutdown() = 0;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user