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