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
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:126
mythbaseexp.h
mythdbcon.h
kDB_Backup_Empty_DB
@ kDB_Backup_Empty_DB
Definition: dbutil.h:14
DBUtil::~DBUtil
~DBUtil()=default
hardwareprofile.distros.mythtv_data.data_mythtv.prefix
string prefix
Definition: data_mythtv.py:40
DBUtil::m_versionString
QString m_versionString
Definition: dbutil.h:78
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
minor
#define minor(X)
Definition: compat.h:138
kDB_Backup_Disabled
@ kDB_Backup_Disabled
Definition: dbutil.h:15
DBUtil::DBUtil
DBUtil()=default
Constructs the DBUtil object.
kDB_Backup_Completed
@ kDB_Backup_Completed
Definition: dbutil.h:13
DBUtil
Aggregates database and DBMS utility functions.
Definition: dbutil.h:31
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:640
kDB_Backup_Failed
@ kDB_Backup_Failed
Definition: dbutil.h:12
uint
unsigned int uint
Definition: compat.h:140
MythDBBackupStatus
MythDBBackupStatus
Definition: dbutil.h:10
DBUtil::kUnknownVersionNumber
static const int kUnknownVersionNumber
Definition: dbutil.h:57
kDB_Backup_Unknown
@ kDB_Backup_Unknown
Definition: dbutil.h:11
query
MSqlQuery query(MSqlQuery::InitCon())
build_compdb.options
options
Definition: build_compdb.py:11