1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-31 17:08:45 +01:00

AUP3: Use persistent prepared statements

SqliteSampleBlock now uses already prepared SQL statements for
all DB usage. This means that the statements  won't have to be
compiled each time they are used.
This commit is contained in:
Leland Lucius
2020-07-21 09:04:50 -05:00
parent 73c6225906
commit 6c70cb86ee
3 changed files with 218 additions and 173 deletions

View File

@@ -24,6 +24,7 @@ Paul Licameli split from AudacityProject.h
struct sqlite3;
struct sqlite3_context;
struct sqlite3_stmt;
struct sqlite3_value;
class AudacityProject;
@@ -159,7 +160,18 @@ private:
sqlite3 *OpenDB(FilePath fileName = {});
bool CloseDB();
bool DeleteDB();
enum StatementID
{
GetSamples,
GetSummary256,
GetSummary64k,
LoadSampleBlock,
InsertSampleBlock,
DeleteSampleBlock
};
void Prepare(enum StatementID id, const char *sql);
sqlite3_stmt *GetStatement(enum StatementID id);
bool Query(const char *sql, const ExecCB &callback);
@@ -233,6 +245,8 @@ private:
std::atomic< std::uint64_t > mCheckpointWaitingPages{ 0 };
std::atomic< std::uint64_t > mCheckpointCurrentPages{ 0 };
std::map<enum StatementID, sqlite3_stmt *> mStatements;
friend SqliteSampleBlock;
friend AutoCommitTransaction;
};