Subject: PgAgent leap year problem

From: Mehmet Emin KARAKAŞ <[email-masked]>
Date: Mon, 2 Mar 2020 14:56:30 +0300

Hi,

Scheduled tasks set as the last day of February this year did not work. In
your schedule function have a small bug.  Leap year function get year
parameter, but your code is sending day as a parameter.  Fixing patch
attached in this mail.

Best Regards...

-- 
MEHMET EMİN KARAKAŞ
PostgreSQL DBA

Turksat Satellite Communication and Cable TV Operations
Konya Yolu 40. Km. 06839 Golbasi / ANKARA - TÜRKİYE
Tel     :  +90 312 615 32 73
Faks  :  +90 312 615 32 77
diff --git a/sql/pgagent.sql b/sql/pgagent.sql
index 7eb42ba..7ff552b 100644
--- a/sql/pgagent.sql
+++ b/sql/pgagent.sql
@@ -476,7 +476,7 @@ BEGIN
             (jscmonthdays = ''{f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,t}'' AND
              ((date_part(''MONTH'', nextrun) IN (1,3,5,7,8,10,12) AND date_part(''DAY'', nextrun) = 31) OR
               (date_part(''MONTH'', nextrun) IN (4,6,9,11) AND date_part(''DAY'', nextrun) = 30) OR
-              (date_part(''MONTH'', nextrun) = 2 AND ((pgagent.pga_is_leap_year(date_part(''DAY'', nextrun)::int2) AND date_part(''DAY'', nextrun) = 29) OR date_part(''DAY'', nextrun) = 28))))) AND
+              (date_part(''MONTH'', nextrun) = 2 AND ((pgagent.pga_is_leap_year(date_part(''YEAR'', nextrun)::int2) AND date_part(''DAY'', nextrun) = 29) OR date_part(''DAY'', nextrun) = 28))))) AND
             (jscmonths = ''{f,f,f,f,f,f,f,f,f,f,f,f}'' OR jscmonths[date_part(''MONTH'', nextrun)] = TRUE)) THEN

---

From: Neel Patel <[email-masked]>
Date: Wed, 4 Mar 2020 10:53:36 +0530

Hi Mehmet,

It was a bug in pgAgent. Thank you for sharing the patch. I have reviewed
and tested, it is working fine.

Dave/Ashesh:-  Can we commit this patch ?

Thanks,
Neel Patel

---

From: Ashesh Vashi <[email-masked]>
Date: Wed, 4 Mar 2020 12:22:46 +0530

> Dave/Ashesh:-  Can we commit this patch ?
Mehmet,

Thanks for your patch.
Changes look good except it does not take care of the upgrade scenarios.

Hence - updated the patch for the same.

Neel,

Would you please review the updated patch with the upgrade scenarios?

-- Thanks, Ashesh

>> Scheduled tasks set as the last day of February this year did not work.
>> In your schedule function have a small bug.  Leap year function get year

---

From: Neel Patel <[email-masked]>
Date: Wed, 4 Mar 2020 12:36:20 +0530

Hi Ashesh,

I have reviewed it and looks good.  I have updated the sql version in
header of each sql file.

Thanks,
Neel Patel

---

From: Ashesh Vashi <[email-masked]>
Date: Wed, 4 Mar 2020 13:22:31 +0530

> I have reviewed it and looks good.  I have updated the sql version in
Thanks Neel.
Committed the patch with the change suggested offline regarding the updated
version in the windows resource (.rc) files.

-- Thanks, Ashesh

>
> Thanks,
> Neel Patel
>
> On Wed, Mar 4, 2020 at 12:22 PM Ashesh Vashi <
> [email-masked]> wrote:
>
>>> It was a bug in pgAgent. Thank you for sharing the patch. I have
>>> reviewed and tested, it is working fine.
>>>