#include <dbutil.h>
This class allows retrieving or comparing the DBMS server version, and backing up the database.
The backup functionality currently requires mysqldump to be installed on the system. This may change in the future to allow backups even when there is no DB client installation on the system.
Definition at line 20 of file dbutil.h.
Public Member Functions | |
| DBUtil () | |
| Constructs the DBUtil object. | |
| ~DBUtil () | |
| QString | GetDBMSVersion (void) |
| Returns the QString version name of the DBMS or QString::null in the event of an error. | |
| int | CompareDBMSVersion (int major, int minor=0, int point=0) |
| Compares the version of the active DBMS with the provided version. | |
| bool | BackupDB (QString &filename) |
Static Public Member Functions | |
| static bool | IsBackupInProgress (void) |
Static Public Attributes | |
| static const int | kUnknownVersionNumber = INT_MIN |
Private Member Functions | |
| bool | QueryDBMSVersion (void) |
| Reads and returns the QString version name from the DBMS or returns QString::null in the event of an error. | |
| bool | ParseDBMSVersion (void) |
| Parses m_versionString to find the major, minor, and point version. | |
| QStringList | GetTables (void) |
| Retrieves a list of tables from the database. | |
| QString | CreateBackupFilename (QString prefix="mythconverg", QString extension=".sql") |
| Creates a filename to use for the filename. | |
| QString | GetBackupDirectory () |
| Determines the appropriate path for the database backup. | |
| bool | DoBackup (QString &filename) |
Private Attributes | |
| QString | m_versionString |
| int | m_versionMajor |
| int | m_versionMinor |
| int | m_versionPoint |
| DBUtil::DBUtil | ( | void | ) |
| QString DBUtil::GetDBMSVersion | ( | void | ) |
Returns the QString version name of the DBMS or QString::null in the event of an error.
Definition at line 36 of file dbutil.cpp.
Referenced by UpgradeTVDatabaseSchema().
| int DBUtil::CompareDBMSVersion | ( | int | major, | |
| int | minor = 0, |
|||
| int | point = 0 | |||
| ) |
Compares the version of the active DBMS with the provided version.
Returns negative, 0, or positive if the active DBMS version is less than, equal to, or greater than the provided version or returns DBUtil::kUnknownVersionNumber if the version cannot be determined.
| major | The major version number (i.e. 5 in "5.0.22") | |
| minor | The minor version number (i.e. 0 in "5.0.22") | |
| point | The point version number (i.e. 22 in "5.0.22") |
Definition at line 55 of file dbutil.cpp.
Referenced by GetTables(), and UpgradeTVDatabaseSchema().
| bool DBUtil::BackupDB | ( | QString & | filename | ) |
| bool DBUtil::IsBackupInProgress | ( | void | ) | [static] |
| bool DBUtil::QueryDBMSVersion | ( | void | ) | [private] |
Reads and returns the QString version name from the DBMS or returns QString::null in the event of an error.
Definition at line 398 of file dbutil.cpp.
Referenced by GetDBMSVersion(), and ParseDBMSVersion().
| bool DBUtil::ParseDBMSVersion | ( | void | ) | [private] |
Parses m_versionString to find the major, minor, and point version.
Definition at line 427 of file dbutil.cpp.
Referenced by CompareDBMSVersion().
| QStringList DBUtil::GetTables | ( | void | ) | [private] |
Retrieves a list of tables from the database.
The function tries to ensure that the list contains only tables and no views. However, for MySQL 5.0.1, the list will also contain any views defined in the database.
Definition at line 203 of file dbutil.cpp.
| QString DBUtil::CreateBackupFilename | ( | QString | prefix = "mythconverg", |
|
| QString | extension = ".sql" | |||
| ) | [private] |
Creates a filename to use for the filename.
The filename is a concatenation of the given prefix, a hyphen, the current date/time, and the extension.
| prefix | The prefix (i.e. a database name) which should appear before the date/time | |
| extension | The extension to use for the file, including a dot, if desired |
Definition at line 248 of file dbutil.cpp.
Referenced by DoBackup().
| QString DBUtil::GetBackupDirectory | ( | void | ) | [private] |
Determines the appropriate path for the database backup.
The function requests the special "DB Backups" storage group. In the event the group is not defined, the StorageGroup will fall back to using the "Default" group. For users upgrading from version 0.20 or before (which do not support Storage Groups), the StorageGroup will fall back to using the old RecordFilePrefix.
Definition at line 264 of file dbutil.cpp.
Referenced by DoBackup().
| bool DBUtil::DoBackup | ( | QString & | filename | ) | [private] |
const int DBUtil::kUnknownVersionNumber = INT_MIN [static] |
Definition at line 33 of file dbutil.h.
Referenced by CompareDBMSVersion(), and UpgradeTVDatabaseSchema().
QString DBUtil::m_versionString [private] |
Definition at line 47 of file dbutil.h.
Referenced by GetDBMSVersion(), ParseDBMSVersion(), and QueryDBMSVersion().
int DBUtil::m_versionMajor [private] |
int DBUtil::m_versionMinor [private] |
int DBUtil::m_versionPoint [private] |
1.5.5