Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure fixed_schedule field is populated #6181

Merged
merged 1 commit into from
Oct 13, 2023
Merged
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
20 changes: 10 additions & 10 deletions src/bgw/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ ts_bgw_job_get_scheduled(size_t alloc_size, MemoryContext mctx)
* handle them below. We can only use memcpy for the non-nullable fixed
* width starting part of the BgwJob struct.
*/
memcpy(job, GETSTRUCT(tuple), offsetof(FormData_bgw_job, fixed_schedule));
memcpy(job, GETSTRUCT(tuple), offsetof(FormData_bgw_job, initial_start));
Copy link
Contributor Author

@jnidzwetzki jnidzwetzki Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixed_schedule field is now included and all fields starting from initial_start are initialized below.


if (should_free)
heap_freetuple(tuple);
Expand All @@ -390,28 +390,28 @@ ts_bgw_job_get_scheduled(size_t alloc_size, MemoryContext mctx)
continue;
}
#endif

/* handle NULL columns */
value = slot_getattr(ti->slot, Anum_bgw_job_hypertable_id, &isnull);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reordered the initialization order to match the order of the FormData_bgw_job struct.

job->fd.hypertable_id = isnull ? 0 : DatumGetInt32(value);

initial_start = slot_getattr(ti->slot, Anum_bgw_job_initial_start, &initial_start_isnull);
if (!initial_start_isnull)
job->fd.initial_start = DatumGetTimestampTz(initial_start);
else
job->fd.initial_start = DT_NOBEGIN;
timezone = slot_getattr(ti->slot, Anum_bgw_job_timezone, &timezone_isnull);
if (!timezone_isnull)
job->fd.timezone = DatumGetTextPP(timezone);
else
job->fd.timezone = NULL;

value = slot_getattr(ti->slot, Anum_bgw_job_hypertable_id, &isnull);
job->fd.hypertable_id = isnull ? 0 : DatumGetInt32(value);

/* We skip config, check_name, and check_schema since the scheduler
* doesn't need these, it saves us from detoasting, and simplifies
* freeing job lists in the scheduler as otherwise the config field
* would have to be freed separately when freeing a job. */
job->fd.config = NULL;

timezone = slot_getattr(ti->slot, Anum_bgw_job_timezone, &timezone_isnull);
if (!timezone_isnull)
job->fd.timezone = DatumGetTextPP(timezone);
else
job->fd.timezone = NULL;

old_ctx = MemoryContextSwitchTo(mctx);
jobs = lappend(jobs, job);
MemoryContextSwitchTo(old_ctx);
Expand Down