# HG changeset patch # User Alain Mazy # Date 1713875831 -7200 # Node ID 8b507b1514ebe17e697180a6c910660a1d84c43d # Parent def06a42e5efd98a77a5c8f4c08b6c739f5f85bc cache dynamic SQLite statements (imported from large-queries branch) diff -r def06a42e5ef -r 8b507b1514eb OrthancFramework/Sources/SQLite/Connection.h --- a/OrthancFramework/Sources/SQLite/Connection.h Tue Apr 23 13:07:38 2024 +0200 +++ b/OrthancFramework/Sources/SQLite/Connection.h Tue Apr 23 14:37:11 2024 +0200 @@ -56,6 +56,7 @@ #endif #define SQLITE_FROM_HERE ::Orthanc::SQLite::StatementId(__ORTHANC_FILE__, __LINE__) +#define SQLITE_FROM_HERE_DYNAMIC(sql) ::Orthanc::SQLite::StatementId(__ORTHANC_FILE__, __LINE__, sql) namespace Orthanc { diff -r def06a42e5ef -r 8b507b1514eb OrthancFramework/Sources/SQLite/StatementId.cpp --- a/OrthancFramework/Sources/SQLite/StatementId.cpp Tue Apr 23 13:07:38 2024 +0200 +++ b/OrthancFramework/Sources/SQLite/StatementId.cpp Tue Apr 23 14:37:11 2024 +0200 @@ -56,12 +56,24 @@ { } + Orthanc::SQLite::StatementId::StatementId(const char *file, + int line, + const std::string& statement) : + file_(file), + line_(line), + statement_(statement) + { + } + bool StatementId::operator< (const StatementId& other) const { if (line_ != other.line_) return line_ < other.line_; - return strcmp(file_, other.file_) < 0; + if (strcmp(file_, other.file_) < 0) + return true; + + return statement_ < other.statement_; } } } diff -r def06a42e5ef -r 8b507b1514eb OrthancFramework/Sources/SQLite/StatementId.h --- a/OrthancFramework/Sources/SQLite/StatementId.h Tue Apr 23 13:07:38 2024 +0200 +++ b/OrthancFramework/Sources/SQLite/StatementId.h Tue Apr 23 14:37:11 2024 +0200 @@ -54,6 +54,7 @@ private: const char* file_; int line_; + std::string statement_; StatementId(); // Forbidden @@ -61,6 +62,10 @@ StatementId(const char* file, int line); + StatementId(const char* file, + int line, + const std::string& statement); + bool operator< (const StatementId& other) const; }; }