Bug 183268 - mythfilldatabase erroneously deletes record schedules for the current day
Bug#: 183268 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: cardoe@gentoo.org Reported By: digitalaudiorock@hotmail.com
Component: Applications
URL: 
Summary: mythfilldatabase erroneously deletes record schedules for the current day
Keywords:  
Status Whiteboard: 
Opened: 2007-06-26 14:10 0000
Description:   Opened: 2007-06-26 14:10 0000
mythfilldata always deletes records from the record table with types of single,
override, or dontrecord whose enddate is the current day.

The problem is in the clearOldDBEntries in the file filldata.cpp:

query.prepare("DELETE FROM record WHERE (type = :SINGLE "
                  "OR type = :OVERRIDE OR type = :DONTRECORD) "
                  "AND enddate < NOW();");
    query.bindValue(":SINGLE", kSingleRecord);
    query.bindValue(":OVERRIDE", kOverrideRecord);
    query.bindValue(":DONTRECORD", kDontRecord);
    query.exec();

Since enddate is a date column (not datetime) it's getting compared to NOW() as
a datetime at 12:00AM, thus always less than NOW().  Using either CURDATE(),
CURRENT_DATE, or CAST(NOW() AS DATE) in place of NOW() would work correctly.


Reproducible: Always

Steps to Reproduce:
1. Schedule a "record only this showing" type for the current day.
2. Run mythfilldatabase.


Actual Results:  
The schedule gets deleted.

------- Comment #1 From Jakub Moc (RETIRED) 2007-06-26 14:14:36 0000 -------
Always provide ebuild name and version in bug summary, please.

------- Comment #2 From Tom Dexter 2007-06-26 14:30:20 0000 -------
Sorry...I forgot to include that this is occuring in:

media-tv/mythtv-0.20.1_p13344
dev-db/mysql-5.0.42

...though it appears to be the same in media-tv/mythtv-0.20_p12325.

------- Comment #3 From Doug Goldstein 2007-06-28 18:23:35 0000 -------
Have you filed this upstream?

------- Comment #4 From Tom Dexter 2007-06-29 16:24:09 0000 -------
At the time I entered this, I thought it might be something that had already
been resolved upstream.  As far as I can see I don't think it has been, so I
will file a bug today.

------- Comment #5 From Tom Dexter 2007-06-29 17:14:52 0000 -------
I filed this mythtv bug:

http://svn.mythtv.org/trac/ticket/3681

I found that this doesn't appear to have been corrected in 0.21 either, though
the code is now in /libs/libmythtv/programdata.cpp rather than
/programs/mythfilldatabase/filldata.cpp.

------- Comment #6 From Tom Dexter 2007-07-02 17:26:59 0000 -------
It appears that this has been resolved upstream for both 0.20 and 0.21.

------- Comment #7 From Doug Goldstein 2007-07-02 17:50:26 0000 -------
This will be fixed in a mythtv ebuild newer then 13794. So
>=media-tv/mythtv-0.21_p13794

------- Comment #8 From Doug Goldstein 2007-08-06 21:42:01 0000 -------
Fixed in mythtv-0.20.1_p14146

------- Comment #9 From Doug Goldstein 2007-08-06 21:43:28 0000 -------
*** Bug 187445 has been marked as a duplicate of this bug. ***