PgAgent 3.3.0 batch scripts on windows always get status failed

From: Bastiaan Olij <bastiaan(at)basenlily(dot)me>
To: pgadmin-support(at)postgresql(dot)org
Subject: PgAgent 3.3.0 batch scripts on windows always get status failed
Date: 2013-01-31 02:03:12
Message-ID: 5109D0E0.5000500@basenlily.me
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

Hi All,

First post on this list so I hope I'm doing things right.
We've had a problem for awhile now that any batch script run by pgagent
on windows gets the status failed even if the batch file runs just fine.

I downloaded the latest copy of the source code to have a look and found
something strange in the code for Job::Execute in job.cpp

At the start of this method the variable succeeded gets set to false, in
the windows code it never gets set to true as apposed to the *nix code
where the variable rc is loaded with the return status of the batch
script and succeeded is assigned true if this status equals 0.

In the windows code (line 268) rc is set to 1, the return status of the
batch script is not returned. I do not know if this is done on purpose
and that as we can't detect if the script was successful succeeded is
left as failed or if not setting succeeded to true has simply been
overlooked?

I would suggest changing this code to:
268: // assume successful execution of script
269: rc = 0;
270: succeeded = true;

Alternatively, I'm assuming the code for CloseHandle is calling pclose,
the return value of pclose is the errorlevel returned by the batch
script and could be assigned to rc. I couldn't find the code for
CloseHandle so I'm not sure if it would be able to return this code but
if so the code could be turned into:
267: rc = CloseHandle(h_script);
268: if (rc == 0)
269: succeeded = true;

Cheers,

Bastiaan Olij

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Chris Bartlett 2013-02-01 00:01:33 Re: 1.16.1: many operations cause display tree to collapse
Previous Message John R Pierce 2013-01-30 17:18:50 Re: pg_Restore