summaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/schemaresolver.h
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2015-04-19 22:30:21 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2015-04-19 22:30:21 -0400
commita308f430f694423064ebc86fd0506c8c6fdb3d93 (patch)
treeceacd24fecf92f40980f8d8f3fd169e317c886af /SQLiteStudio3/coreSQLiteStudio/schemaresolver.h
parenta5b034d4a9c44f9bc1e83b01de82530f8fc63013 (diff)
Imported Upstream version 3.0.5upstream/3.0.5
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/schemaresolver.h')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/schemaresolver.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/schemaresolver.h b/SQLiteStudio3/coreSQLiteStudio/schemaresolver.h
index 5316f5a..5d325d8 100644
--- a/SQLiteStudio3/coreSQLiteStudio/schemaresolver.h
+++ b/SQLiteStudio3/coreSQLiteStudio/schemaresolver.h
@@ -14,6 +14,7 @@
#include "db/sqlquery.h"
#include "db/db.h"
#include "common/strhash.h"
+#include "common/expiringcache.h"
#include <QStringList>
class SqliteCreateTable;
@@ -38,6 +39,24 @@ class API_EXPORT SchemaResolver
QString ddl;
};
+ struct ObjectCacheKey
+ {
+ enum Type
+ {
+ OBJECT_NAMES,
+ OBJECT_DETAILS,
+ OBJECT_DDL
+ };
+
+ ObjectCacheKey(Type type, Db* db, const QString& value1 = QString(), const QString& value2 = QString(), const QString& value3 = QString());
+
+ Type type;
+ Db* db;
+ QString value1;
+ QString value2;
+ QString value3;
+ };
+
explicit SchemaResolver(Db* db);
virtual ~SchemaResolver();
@@ -164,8 +183,12 @@ class API_EXPORT SchemaResolver
static QString objectTypeToString(ObjectType type);
static ObjectType stringToObjectType(const QString& type);
+ static void staticInit();
+
+ static_char* USE_SCHEMA_CACHING = "useSchemaCaching";
private:
+ bool usesCache();
SqliteQueryPtr getParsedDdl(const QString& ddl);
SqliteCreateTablePtr virtualTableAsRegularTable(const QString& database, const QString& table);
StrHash< QStringList> getGroupedObjects(const QString &database, const QStringList& inputList, SqliteQueryType type);
@@ -180,8 +203,13 @@ class API_EXPORT SchemaResolver
Parser* parser = nullptr;
bool ignoreSystemObjects = false;
Db::Flags dbFlags;
+
+ static ExpiringCache<ObjectCacheKey,QVariant> cache;
};
+int qHash(const SchemaResolver::ObjectCacheKey& key);
+int operator==(const SchemaResolver::ObjectCacheKey& k1, const SchemaResolver::ObjectCacheKey& k2);
+
template <class T>
StrHash<QSharedPointer<T>> SchemaResolver::getAllParsedObjectsForType(const QString& database, const QString& type)
{