dbcheck.cpp File Reference

Go to the source code of this file.

Functions

static bool UpdateDBVersionNumber (const QString &newnumber)
 Updates the schema version stored in the database.
static bool performActualUpdate (const QString updates[], QString version, QString &dbver)
 Runs a number of SQL commands, and updates the schema version.
static bool InitializeDatabase (void)
static bool doUpgradeTVDatabaseSchema (void)
 This is called by UpgradeTVDatabaseSchema() to actually upgrade the schema to what MythTV expects.
bool convert_diseqc_db (void)
bool lockSchema (MSqlQuery &query)
 Get a lock on the schemalock table.
void unlockSchema (MSqlQuery &query)
 Release the lock on the schemalock table.
int CompareTVDatabaseSchemaVersion (void)
 Called from outside dbcheck.cpp to compare the database schema version with the expected version.
bool UpgradeTVDatabaseSchema (void)
 Called from outside dbcheck.cpp to update the schema.

Variables

const QString currentDatabaseVersion = "1214"
 This is the DB schema version expected by the running MythTV instance.


Function Documentation

static bool UpdateDBVersionNumber ( const QString &  newnumber  )  [static]

Updates the schema version stored in the database.

Updates "DBSchemaVer" property in the settings table.

Parameters:
newnumber New schema version.

Definition at line 351 of file mythtv/libs/libmythtv/dbcheck.cpp.

Referenced by doUpgradeTVDatabaseSchema(), and performActualUpdate().

static bool performActualUpdate ( const QString  updates[],
QString  version,
QString &  dbver 
) [static]

Runs a number of SQL commands, and updates the schema version.

Parameters:
updates array of SQL commands to issue, terminated by a "" string.
version version we are updating db to.
dbver the database version at the end of the function is returned in this parameter, if things go well this will be 'version'.
Returns:
true on success, false on failure

Definition at line 402 of file mythtv/libs/libmythtv/dbcheck.cpp.

Referenced by DoOldDVDDatabaseSchemaUpgrage(), DoOldVideoDatabaseSchemaUpgrade(), doUpgradeTVDatabaseSchema(), DoVideoDatabaseSchemaUpgrade(), InitializeDatabase(), InitializeDVDDatabase(), InitializeVideoDatabase(), performActualUpdate(), UpgradeArchiveDatabaseSchema(), UpgradeFlixDatabaseSchema(), UpgradeGalleryDatabaseSchema(), UpgradeGameDatabaseSchema(), UpgradeMusicDatabaseSchema(), and UpgradePhoneDatabaseSchema().

bool InitializeDatabase ( void   )  [static]

static bool doUpgradeTVDatabaseSchema ( void   )  [static]

This is called by UpgradeTVDatabaseSchema() to actually upgrade the schema to what MythTV expects.

This function Initializes the database if the "DBSchemaVer" property does not exist in the database. Otherwise it upgrades the schema from the one in that property to the currentDatabaseVersion, by running the SQL commands needed for each upgrade between the two versions. This will only upgrade the schema, so bad things may happen if you upgrade and then downgrade MythTV across DB Schema versions.

Definition at line 611 of file mythtv/libs/libmythtv/dbcheck.cpp.

Referenced by UpgradeTVDatabaseSchema().

bool convert_diseqc_db ( void   ) 

Definition at line 1353 of file diseqcsettings.cpp.

Referenced by doUpgradeTVDatabaseSchema().

lockSchema ( MSqlQuery query  ) 

Get a lock on the schemalock table.

Definition at line 444 of file mythtv/libs/libmythtv/dbcheck.cpp.

Referenced by CompareTVDatabaseSchemaVersion(), and UpgradeTVDatabaseSchema().

unlockSchema ( MSqlQuery query  ) 

Release the lock on the schemalock table.

Definition at line 472 of file mythtv/libs/libmythtv/dbcheck.cpp.

Referenced by CompareTVDatabaseSchemaVersion(), and UpgradeTVDatabaseSchema().

CompareTVDatabaseSchemaVersion ( void   ) 

Called from outside dbcheck.cpp to compare the database schema version with the expected version.

If the "DBSchemaVer" property is not found (i.e. the schema has not been initialized, the function returns negative, as if the schema simply needed upgrading, so InitializeDatabase() can do its job.

We lock the schemalock table for write so that we block if there are any DB schema updates in progress. This will make sure that we get the correct schema version number after the updates are completed and the update process unlocks the schemalock table.

Returns:
negative, 0, or positive if the schema version is less than, equal to, or greater than the expected version

Definition at line 494 of file mythtv/libs/libmythtv/dbcheck.cpp.

Referenced by CheckSchemaVersion(), and main().

UpgradeTVDatabaseSchema ( void   ) 

Called from outside dbcheck.cpp to update the schema.

If the "DBSchemaVer" property equals the currentDatabase version this returns true immediately. If not we lock the schemalock table. If this fails we return false. If it succeeds we call doUpgradeTVDatabaseSchema() to do the actual update, and then we unlock the schemalock table.

If the program running this function is killed while this is running then the schema may be corrupted.

Returns:
true on success, false on failure.

Definition at line 526 of file mythtv/libs/libmythtv/dbcheck.cpp.

Referenced by CheckSchemaVersion(), and main().


Variable Documentation

const QString currentDatabaseVersion = "1214"


Generated on Sat Dec 18 05:15:51 2010 for MythTV by  doxygen 1.5.5