60 lines
1.9 KiB
Diff
60 lines
1.9 KiB
Diff
|
From 4a149cb833dbb45507cd52e63707311e9642587c Mon Sep 17 00:00:00 2001
|
||
|
From: Sven Klemm <sven@timescale.com>
|
||
|
Date: Sat, 19 Sep 2020 23:20:37 +0200
|
||
|
Subject: [PATCH] Adjust code to PG13 list sort changes
|
||
|
|
||
|
PG13 changes the name of the list sorting function from list_qsort
|
||
|
to list_sort. Additionally PG13 does in-place sort.
|
||
|
|
||
|
https://github.com/postgres/postgres/commit/569ed7f483
|
||
|
|
||
|
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
|
||
|
Fetch from: https://github.com/timescale/timescaledb/commit/13d8aac33b6fc5104c8ad1da816dc0d009fc13a7.patch
|
||
|
---
|
||
|
src/bgw/scheduler.c | 15 ++++++++++++++-
|
||
|
1 file changed, 14 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/src/bgw/scheduler.c b/src/bgw/scheduler.c
|
||
|
index 2630ff9f..b9d1aa38 100644
|
||
|
--- a/src/bgw/scheduler.c
|
||
|
+++ b/src/bgw/scheduler.c
|
||
|
@@ -530,10 +530,15 @@ ts_populate_scheduled_job_tuple(ScheduledBgwJob *sjob, Datum *values)
|
||
|
#endif
|
||
|
|
||
|
static int
|
||
|
+#if PG13_LT
|
||
|
cmp_next_start(const void *left, const void *right)
|
||
|
{
|
||
|
const ListCell *left_cell = *((ListCell **) left);
|
||
|
const ListCell *right_cell = *((ListCell **) right);
|
||
|
+#else
|
||
|
+cmp_next_start(const ListCell *left_cell, const ListCell *right_cell)
|
||
|
+{
|
||
|
+#endif
|
||
|
ScheduledBgwJob *left_sjob = lfirst(left_cell);
|
||
|
ScheduledBgwJob *right_sjob = lfirst(right_cell);
|
||
|
|
||
|
@@ -549,10 +554,18 @@ cmp_next_start(const void *left, const void *right)
|
||
|
static void
|
||
|
start_scheduled_jobs(register_background_worker_callback_type bgw_register)
|
||
|
{
|
||
|
+ List *ordered_scheduled_jobs;
|
||
|
ListCell *lc;
|
||
|
Assert(CurrentMemoryContext == scratch_mctx);
|
||
|
+
|
||
|
/* Order jobs by increasing next_start */
|
||
|
- List *ordered_scheduled_jobs = list_qsort(scheduled_jobs, cmp_next_start);
|
||
|
+#if PG13_LT
|
||
|
+ ordered_scheduled_jobs = list_qsort(scheduled_jobs, cmp_next_start);
|
||
|
+#else
|
||
|
+ /* PG13 does in-place sort */
|
||
|
+ ordered_scheduled_jobs = scheduled_jobs;
|
||
|
+ list_sort(ordered_scheduled_jobs, cmp_next_start);
|
||
|
+#endif
|
||
|
|
||
|
foreach (lc, ordered_scheduled_jobs)
|
||
|
{
|
||
|
--
|
||
|
2.29.2
|
||
|
|