[mythtv] [PATCH] Stop complaints about duplicate keys on program insert

Stuart Auchterlonie stuarta at squashedfrog.net
Wed Apr 6 11:41:53 UTC 2005


Hi All,


The attached patch adds a few lines to siscan.cpp that delete a
program from the program table before inserting the new program
on the same channel at the same start time.

This is for those of us who get their program guide data over
the air from a DVB card, and it stops the logfile from filling
up with lots of messages complaining that the program information
couldn't be inserted because the key already exists. This is the
normal case as the same program information is sent over and over.

This mimics the same behaviour as found in programinfo.cpp


Stuart Auchterlonie

-------------- next part --------------
Index: libs/libmythtv/siscan.cpp
===================================================================
--- libs/libmythtv/siscan.cpp	(revision 4)
+++ libs/libmythtv/siscan.cpp	(working copy)
@@ -1015,6 +1015,15 @@
             {
                  counter++;
 
+                 query.prepare("DELETE FROM program"
+                               " WHERE chanid = :CHANID"
+                               " AND starttime = :STARTTIME ;");
+                 query.bindValue(":CHANID",ChanID);
+                 query.bindValue(":STARTTIME",(*e).StartTime.toString(QString("yyyy-MM-dd hh:mm:00")));
+                 if (!query.exec())
+                     MythContext::DBError("Adding Event", 
+                                          query);
+
                  query.prepare("INSERT INTO program (chanid,starttime,endtime,"
                           "title,description,subtitle,category,"
                           "stereo,closecaptioned,hdtv,airdate,originalairdate)"
@@ -1079,4 +1088,3 @@
     }
     pthread_mutex_unlock(&events_lock);
 }
-


More information about the mythtv-dev mailing list