Hey everyone,
We are running an older version of Rivendell here (2.1.1), but we had to
upgrade our MySQL install to version 5.5. As we are using Arch Linux, it
has been replaced by MariaDB. Upgrade was seamless except for one (major)
detail: dayparting would no longer work. The only cuts that would play were
EVERGREEN ones.
I have tracked down the bug to an incompatible SQL line, in lib/rdcart.cpp,
function RDCart::selectCut(QString *cut,const QTime &time) const (line 72
in v2.1.1, 86 in 2.6.0):
select CUT_NAME,WEIGHT,LOCAL_COUNTER
from CUTS where
(
(
(START_DATETIME<="$1") &&
(END_DATETIME>="$2")
) ||
(START_DATETIME is null)
) &&
(
(
(START_DAYPART<="$3") && (END_DAYPART>="$4")
|| START_DAYPART is null
)
) &&
($5="Y") &&
(CART_NUMBER=$6) &&
(EVERGREEN="N") &&
(LENGTH>0)
order by LOCAL_COUNTER
$1-4 are the current time (in format "yyyy-MM-dd hh:mm:ss"), $5 is the day
of the week in short format (e.g. "MON" for Monday) and $6 is the cart
number. The issue with this line is that MySQL would implicitly convert
e.g. "2013-12-31 19:00:00" to "19:00:00" for columns START_DAYPART and
END_DAYPART, because of their type (TIME). MariaDB, unless I am mistaken,
does not, and therefore the times in the database are interpreted as
offsets from the Unix epoch, that is comparing "17:01:00" (value in
database) to "2013-12-31 17:00:00" (current time) results in a conversion
to ( "1970-01-01 17:01:00" <> "2013-12-31 17:00:00" ), which means
END_DAYPART would always be smaller than the current time (thus, no
scheduling of that cut).
Using full timestamps as values for TIME types is undocumented, therefore I
have fixed it by casting the timestamp to a second string, time_str, with
format "hh:mm:ss", then using it for variables $3 and $4.
I have included a patch in this email. Apply with `patch -p1 < <filename>`,
when in rivendell source directory. This fix should not break compatibility
with MySQL, but I did not test it.
Is there a bug tracker for the Rivendell project?
--
Sébastien Leblanc
diff -aur rivendell-2.6.0/lib/rdcart.cpp rivendell-2.6.0-timestamp/lib/rdcart.cpp
--- rivendell-2.6.0/lib/rdcart.cpp 2013-12-11 13:51:47.000000000 -0500
+++ rivendell-2.6.0-timestamp/lib/rdcart.cpp 2013-12-30 19:26:30.000000000 -0500
@@ -109,6 +109,8 @@
QDate current_date=QDate::currentDate();
QString datetime_str=QDateTime(current_date,time).
toString("yyyy-MM-dd hh:mm:ss");
+ QString time_str=QDateTime(current_date,time).
+ toString("hh:mm:ss");
// if(type()==RDCart::Audio) {
switch(type()) {
@@ -123,8 +125,8 @@
(LENGTH>0) order by LOCAL_COUNTER",
(const char *)datetime_str,
(const char *)datetime_str,
- (const char *)datetime_str,
- (const char *)datetime_str,
+ (const char *)time_str,
+ (const char *)time_str,
(const char *)RDGetShortDayNameEN(current_date.dayOfWeek()).upper(),
cart_number);
q=new RDSqlQuery(sql);
_______________________________________________
Rivendell-dev mailing list
[email protected]
http://caspian.paravelsystems.com/mailman/listinfo/rivendell-dev