MythTV  master
dbutil.h
Go to the documentation of this file.
1 #ifndef DBUTIL_H_
2 #define DBUTIL_H_
3 
4 #include <QStringList>
5 
6 #include "mythbaseexp.h"
7 #include "mythdbcon.h"
8 
10 {
16 };
17 
31 {
32  public:
36  DBUtil() = default;
37  ~DBUtil() = default;
38 
39  QString GetDBMSVersion(void);
40  int CompareDBMSVersion(int major, int minor=0, int point=0);
41 
42  static MythDBBackupStatus BackupDB(QString &filename,
43  bool disableRotation = false);
44  static bool CheckTables(bool repair = false,
45  const QString &options = "QUICK");
46  static bool RepairTables(const QStringList &tables);
47 
48  static bool IsNewDatabase(void);
49  static bool IsBackupInProgress(void);
50  static int CountClients(void);
51 
52  static bool TryLockSchema(MSqlQuery &query, uint timeout_secs);
53  static void UnlockSchema(MSqlQuery &query);
54 
55  static bool CheckTimeZoneSupport(void);
56 
57  static const int kUnknownVersionNumber;
58 
59  protected:
60  static bool CreateTemporaryDBConf(
61  const QString &privateinfo, QString &filename);
62 
63  private:
64  bool QueryDBMSVersion(void);
65  bool ParseDBMSVersion(void);
66 
67  static QStringList GetTables(const QStringList &engines = QStringList());
68  static QStringList CheckRepairStatus(MSqlQuery &query);
69 
70  static QString CreateBackupFilename(const QString& prefix = "mythconverg",
71  const QString& extension = ".sql");
72  static QString GetBackupDirectory();
73 
74  static bool DoBackup(const QString &backupScript, QString &filename,
75  bool disableRotation = false);
76  static bool DoBackup(QString &filename);
77 
78  QString m_versionString;
79 
80  int m_versionMajor { -1 };
81  int m_versionMinor { -1 };
82  int m_versionPoint { -1 };
83 
84 };
85 
86 #endif
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
static const int kUnknownVersionNumber
Definition: dbutil.h:57
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
#define minor(X)
Definition: compat.h:138
QString m_versionString
Definition: dbutil.h:78
unsigned int uint
Definition: compat.h:140
MythDBBackupStatus
Definition: dbutil.h:9
Aggregates database and DBMS utility functions.
Definition: dbutil.h:30