diff --git a/src/core/Indexer.cpp b/src/core/Indexer.cpp index a3767a6cc..387b8d821 100644 --- a/src/core/Indexer.cpp +++ b/src/core/Indexer.cpp @@ -407,7 +407,7 @@ void Indexer::ThreadLoop(){ while(!this->Exit()){ // Database should only be open when synchronizing - this->dbConnection.Open(this->database.c_str(),0,1024); + this->dbConnection.Open(this->database.c_str(),0,4096); this->RestartSync(false); this->Synchronize(); @@ -701,7 +701,8 @@ void Indexer::SyncOptimize(){ genre, artist, album, track number, path, filename ************************************/ - db::Statement stmt("SELECT t.id FROM tracks t LEFT OUTER JOIN genres g ON t.visual_genre_id=g.id LEFT OUTER JOIN albums al ON t.album_id=al.id LEFT OUTER JOIN artists ar ON t.visual_artist_id=ar.id LEFT OUTER JOIN folders f ON t.folder_id=f.id ORDER BY g.sort_order,ar.sort_order,al.sort_order,t.track,f.fullpath,t.filename",this->dbConnection); + db::Statement stmt("SELECT t.id FROM tracks t LEFT OUTER JOIN genres g ON g.id=t.visual_genre_id LEFT OUTER JOIN artists ar ON ar.id=t.visual_artist_id LEFT OUTER JOIN albums al ON al.id=t.album_id LEFT OUTER JOIN folders f ON f.id=t.folder_id ORDER BY g.sort_order,ar.sort_order,al.sort_order,t.track,f.fullpath,t.filename",this->dbConnection); + db::Statement stmtUpdate("UPDATE tracks SET sort_order1=? WHERE id=?",this->dbConnection); iCount = 0; while(stmt.Step()==db::ReturnCode::Row){ diff --git a/src/core/db/CachedStatement.cpp b/src/core/db/CachedStatement.cpp index 4e55764b1..bb779b2d9 100644 --- a/src/core/db/CachedStatement.cpp +++ b/src/core/db/CachedStatement.cpp @@ -48,10 +48,10 @@ CachedStatement::CachedStatement(const char* sql,Connection &connection) : State this->stmt = this->connection->GetCachedStatement(sql); } - -void CachedStatement::Finalize(){ +CachedStatement::~CachedStatement(){ sqlite3_reset(this->stmt); sqlite3_clear_bindings(this->stmt); this->connection->ReturnCachedStatement(this->sqlStatement.c_str(),this->stmt); + this->stmt=NULL; } diff --git a/src/core/db/CachedStatement.h b/src/core/db/CachedStatement.h index 3babe11ec..944071ee7 100644 --- a/src/core/db/CachedStatement.h +++ b/src/core/db/CachedStatement.h @@ -46,10 +46,9 @@ namespace musik{ namespace core{ namespace db{ class CachedStatement : public Statement{ public: CachedStatement(const char* sql,Connection &connection); + ~CachedStatement(); private: std::string sqlStatement; - protected: - void Finalize(); }; diff --git a/src/core/db/Statement.cpp b/src/core/db/Statement.cpp index c48912f59..da4934abe 100644 --- a/src/core/db/Statement.cpp +++ b/src/core/db/Statement.cpp @@ -57,11 +57,10 @@ Statement::Statement(Connection &connection) : connection(&connection),stmt(NULL Statement::~Statement(){ - this->Finalize(); + int err=sqlite3_finalize(this->stmt); } void Statement::Finalize(){ - int err=sqlite3_finalize(this->stmt); /* #ifdef _DEBUG if(err!=0){ const char *errorMsg = sqlite3_errmsg(this->connection->connection); diff --git a/src/core/db/Statement.h b/src/core/db/Statement.h index bf03d4a4e..8d9ab6aa2 100644 --- a/src/core/db/Statement.h +++ b/src/core/db/Statement.h @@ -51,7 +51,7 @@ namespace musik{ namespace core{ namespace db{ class Statement : boost::noncopyable{ public: Statement(const char* sql,Connection &connection); - ~Statement(); + virtual ~Statement(); void Reset(); int Step();