Re: Email notification pgAgent - Mailing list pgadmin-hackers

From Dave Page
Subject Re: Email notification pgAgent
Date
Msg-id AANLkTi=yLSGYTXCdjAWXW_XWYVvYOAoxam5YugU-pUwC@mail.gmail.com
Whole thread Raw
In response to Re: Email notification pgAgent  (Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>)
Responses Re: Email notification pgAgent  (Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>)
List pgadmin-hackers
Hi

On Mon, Dec 27, 2010 at 9:46 AM, Jasmin Dizdarevic
<jasmin.dizdarevic@gmail.com> wrote:
> Hi Dave,
> P3 is a good idea.
> I think the best way to configure notifications is on a per job level. So I
> need two fields in the pga_job table:
> alter table pgagent.pga_job add column jobmailnotkind varchar(7) check
> (jobmailnotkind in ('Success','Failure','Both'));

That should probably be:

alter table pgagent.pga_job add column jobmailnotkind char check
(jobmailnotkind in ('s','f','b'));

which more closely matches the existing style - eg. pga_jobstep.jstonerror.

> alter table pgagent.pga_job add column jobmailnotrecp varchar(320);

LOL - where did you get 320 from? :-). Just make that one a "text"
column. It's actually marginally more efficient in PostgreSQL anyway,
because it eliminates the length check that is required by a
varchar(n).

> The SMTP server address is going to be an optional cl-argument (-s).
> If this is going into a release.

Seems reasonable.

> Can I assume that the fields are present,
> even if pgagent is compiled without mail notification?

You can handle that by bumping the schema version number in
pgagent.pgagent_schema_version, and the pgAgent major version number
to match. pgAgent should then refuse to run on the older, non-upgraded
schema. Of course, you should also update the two SQL scripts
accordingly.

> Background: I think, it would be inefficient to perform an extra select
> between #ifdef MAIL_NOTIFICATION and #endif,

I don't think you'd do it that way - you'd put the 2 versions of the query in an

#ifdef MAIL_NOTIFICATION

#else

#endif

block. But... don't bother :-). Just update the schema as noted above.
The reason for making the mail feature optional, is that we don't want
to force a dependency on the wxSMTP package, but that doesn't mean we
need to remove all traces of the mail feature in builds where it's
disabled.

> Maybe, my questions seems to be silly, sorry for that. It's my first try to
> contribute to an open source project.

No problem at all - we were all first timers once.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

pgadmin-hackers by date:

Previous
From: Jasmin Dizdarevic
Date:
Subject: Re: Email notification pgAgent
Next
From: Jasmin Dizdarevic
Date:
Subject: Re: Email notification pgAgent