summaryrefslogtreecommitdiffstats
path: root/whine.pl
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-03-03 16:19:09 +0100
committermkanat%kerio.com <>2005-03-03 16:19:09 +0100
commit7cb62ca9a2742e10334cba6bf965a5c0d8ad40ba (patch)
treee509aee1bc024c0d486e557cd3f7a2e9750f45e8 /whine.pl
parent0e8f16e1c64b07cf6d90264f8f754307d340b30e (diff)
downloadbugzilla-7cb62ca9a2742e10334cba6bf965a5c0d8ad40ba.tar.gz
bugzilla-7cb62ca9a2742e10334cba6bf965a5c0d8ad40ba.tar.xz
Bug: 284244: DATE_SUB and DATE_ADD are not ANSI SQL
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=wicked, a=justdave
Diffstat (limited to 'whine.pl')
-rwxr-xr-xwhine.pl39
1 files changed, 19 insertions, 20 deletions
diff --git a/whine.pl b/whine.pl
index 97378a178..a13a129b4 100755
--- a/whine.pl
+++ b/whine.pl
@@ -172,18 +172,18 @@ while (my ($schedule_id, $day, $time) = $sched_h->fetchrow_array) {
elsif ($time >= $now_hour) {
# set it to today + number of hours
$sth = $dbh->prepare( "UPDATE whine_schedules " .
- "SET run_next=DATE_ADD(CURRENT_DATE(), " .
- $dbh->sql_interval('? HOUR') . ") " .
- "WHERE id=?");
+ "SET run_next = CURRENT_DATE() + " .
+ $dbh->sql_interval('? HOUR') .
+ " WHERE id = ?");
$sth->execute($time, $schedule_id);
}
# the target time is less than the current time
else { # set it for the next applicable day
my $nextdate = &get_next_date($day);
$sth = $dbh->prepare( "UPDATE whine_schedules " .
- "SET run_next=" .
- "DATE_ADD(?, " . $dbh->sql_interval('? HOUR') . ") " .
- "WHERE id=?");
+ "SET run_next = ? + " .
+ $dbh->sql_interval('? HOUR') .
+ " WHERE id = ?");
$sth->execute($nextdate, $time, $schedule_id);
}
@@ -197,9 +197,9 @@ while (my ($schedule_id, $day, $time) = $sched_h->fetchrow_array) {
my $target_time = ($time =~ /^\d+$/) ? $time : 0;
$sth = $dbh->prepare( "UPDATE whine_schedules " .
- "SET run_next=DATE_ADD(?, " .
- $dbh->sql_interval('? HOUR') . ") " .
- "WHERE id=?");
+ "SET run_next = ? + " .
+ $dbh->sql_interval('? HOUR') .
+ " WHERE id = ?");
$sth->execute($target_date, $target_time, $schedule_id);
}
}
@@ -596,22 +596,21 @@ sub reset_timer {
my $nextdate = &get_next_date($run_day);
$sth = $dbh->prepare( "UPDATE whine_schedules " .
- "SET run_next=DATE_ADD(?, " .
- $dbh->sql_interval('? HOUR') . ") " .
- "WHERE id=?");
+ "SET run_next = ? + " .
+ $dbh->sql_interval('? HOUR') .
+ " WHERE id = ?");
$sth->execute($nextdate, $target_time, $schedule_id);
return;
}
- # Scheduling is done in terms of whole minutes, so we use DATE_SUB() to
+ # Scheduling is done in terms of whole minutes, so we use subtraction to
# drop the seconds from the time.
if ($minute_offset > 0) {
$sth = $dbh->prepare("UPDATE whine_schedules " .
- "SET run_next = " .
- "DATE_SUB(DATE_ADD(NOW(), " .
- $dbh->sql_interval('? MINUTE') . "), " .
- $dbh->sql_interval('SECOND(NOW()) SECOND') . ") " .
- "WHERE id=?");
+ "SET run_next = NOW() + " .
+ $dbh->sql_interval('? MINUTE') . " - " .
+ $dbh->sql_interval('SECOND(NOW()) SECOND') .
+ " WHERE id = ?");
$sth->execute($minute_offset, $schedule_id);
} else {
# The minute offset is zero or less, which is not supposed to happen.
@@ -691,8 +690,8 @@ sub get_next_date {
}
# Get a date in whatever format the database will accept
- $sth = $dbh->prepare("SELECT DATE_ADD(CURRENT_DATE(), " .
- $dbh->sql_interval('? DAY') . ")");
+ $sth = $dbh->prepare("SELECT CURRENT_DATE() + " .
+ $dbh->sql_interval('? DAY'));
$sth->execute($add_days);
return $sth->fetch->[0];
}