Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions include/cron.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,43 @@

/* reorder these #include's at your peril */

#ifndef WIN32_COMPAT_H
#define WIN32_COMPAT_H

#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>



/* Fix missing POSIX types */
#ifndef uid_t
typedef int uid_t;
typedef int gid_t;
#endif

#ifndef uint
typedef unsigned int uint;
#endif

/* Fix poll mapping */
#define poll WSAPoll

/* Stub out rlimit to satisfy the compiler without using port.h */
struct rlimit {
uint rlim_cur;
uint rlim_max;
};
#define RLIMIT_NOFILE 0
static inline int getrlimit(int resource, struct rlimit *rlp) { return 0; }

#endif /* _WIN32 */
#endif /* WIN32_COMPAT_H */


#include <sys/types.h>


#include <sys/param.h>

#include <stdio.h>
Expand Down
17 changes: 14 additions & 3 deletions src/pg_cron.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@
*
*-------------------------------------------------------------------------
*/

/** move this first so windows gets the winsock early */
#include "cron.h"

#if defined(_WIN32) && (PG_VERSION_NUM < 160000)
/*
* Skip sys/resource.h for PG15 and lower on Windows
* this is only an issue with PG < 16 for windows cause of the changes in 16 and above for windows
*/
#else
#include <sys/resource.h>
#endif


#include "postgres.h"
#include "fmgr.h"
Expand All @@ -30,7 +42,6 @@
/* these headers are used by this particular worker's code */

#define MAIN_PROGRAM
#include "cron.h"

#include "pg_cron.h"
#include "task_states.h"
Expand Down Expand Up @@ -1508,7 +1519,7 @@ ManageCronTask(CronTask *task, TimestampTz currentTime)
task->lastStartTime = GetCurrentTimestamp();

if (CronLogRun)
UpdateJobRunDetail(task->runId, &pid, GetCronStatus(CRON_STATUS_RUNNING), NULL, &task->lastStartTime, NULL);
UpdateJobRunDetail(task->runId, (int32 *) &pid, GetCronStatus(CRON_STATUS_RUNNING), NULL, &task->lastStartTime, NULL);

task->state = CRON_TASK_BGW_RUNNING;
break;
Expand Down Expand Up @@ -1556,7 +1567,7 @@ ManageCronTask(CronTask *task, TimestampTz currentTime)

pid = (pid_t) PQbackendPID(connection);
if (CronLogRun)
UpdateJobRunDetail(task->runId, &pid, GetCronStatus(CRON_STATUS_SENDING), NULL, NULL, NULL);
UpdateJobRunDetail(task->runId, (int32 *) &pid, GetCronStatus(CRON_STATUS_SENDING), NULL, NULL, NULL);
}
else if (pollingStatus == PGRES_POLLING_FAILED)
{
Expand Down