Ticket #2538: mythtv-recorded_tables_cleanup_mysql3_compat.patch
File mythtv-recorded_tables_cleanup_mysql3_compat.patch, 3.9 KB (added by , 19 years ago) |
---|
-
programs/mythbackend/housekeeper.h
34 34 void runFillDatabase(); 35 35 void CleanupMyOldRecordings(void); 36 36 void CleanupAllOldInUsePrograms(void); 37 void CleanupRecordedTables(void); 37 38 bool threadrunning; 38 39 bool filldbRunning; 39 40 bool isMaster; -
programs/mythbackend/housekeeper.cpp
221 221 } 222 222 } 223 223 224 if (wantToRun("JobQueueCleanup", 1, 0, 24)) 225 { 224 if (wantToRun("DailyCleanup", 1, 0, 24)) { 226 225 JobQueue::CleanupOldJobsInQueue(); 227 updateLastrun("JobQueueCleanup");228 }229 230 if (wantToRun("InUseProgramsCleanup", 1, 0, 24))231 {232 226 CleanupAllOldInUsePrograms(); 233 updateLastrun("InUseProgramsCleanup"); 227 CleanupRecordedTables(); 228 updateLastrun("DailyCleanup"); 234 229 } 235 230 } 236 231 … … 331 326 query.exec(); 332 327 } 333 328 329 void HouseKeeper::CleanupRecordedTables(void) 330 { 331 QString table[] = { "recordedprogram", "recordedrating", 332 "recordedcredits" }; 333 MSqlQuery query(MSqlQuery::InitCon()); 334 MSqlQuery deleteQuery(MSqlQuery::InitCon()); 335 336 for (int tableIndex = 0; tableIndex < 3; tableIndex++) 337 { 338 query.prepare(QString("SELECT DISTINCT p.chanid, p.starttime " 339 "FROM %1 p LEFT JOIN recorded r " 340 "ON p.chanid = r.chanid " 341 "AND p.starttime = r.progstart " 342 "WHERE r.chanid IS NULL;") 343 .arg(table[tableIndex])); 344 if (!query.exec() || !query.isActive()) 345 { 346 MythContext::DBError("HouseKeeper Cleaning Recorded Tables", query); 347 return; 348 } 349 deleteQuery.prepare(QString("DELETE FROM %1 " 350 "WHERE chanid = :CHANID " 351 "AND starttime = :STARTTIME;") 352 .arg(table[tableIndex])); 353 while (query.next()) 354 { 355 deleteQuery.bindValue(":CHANID", query.value(0).toString()); 356 deleteQuery.bindValue(":STARTTIME", query.value(1).toString()); 357 deleteQuery.exec(); 358 } 359 } 360 } 361 334 362 void *HouseKeeper::doHouseKeepingThread(void *param) 335 363 { 336 364 HouseKeeper *hkeeper = (HouseKeeper*)param; -
programs/mythfilldatabase/filldata.cpp
2782 2782 query.bindValue(":OFFSET", offset); 2783 2783 query.exec(); 2784 2784 2785 query.prepare("DELETE p FROM recordedprogram p "2786 "LEFT JOIN recorded r ON "2787 " p.chanid = r.chanid AND p.starttime = r.progstart "2788 "WHERE r.chanid IS NULL;");2789 query.exec();2790 2791 query.prepare("DELETE p FROM recordedrating p "2792 "LEFT JOIN recorded r ON "2793 " p.chanid = r.chanid AND p.starttime = r.progstart "2794 "WHERE r.chanid IS NULL;");2795 query.exec();2796 2797 query.prepare("DELETE p FROM recordedcredits p "2798 "LEFT JOIN recorded r ON "2799 " p.chanid = r.chanid AND p.starttime = r.progstart "2800 "WHERE r.chanid IS NULL;");2801 query.exec();2802 2803 2785 query.prepare("DELETE FROM record WHERE (type = :SINGLE " 2804 2786 "OR type = :OVERRIDE OR type = :DONTRECORD) " 2805 2787 "AND enddate < NOW();");