0005-Adjust-code-to-PG13-list-sort-changes.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 4a149cb833dbb45507cd52e63707311e9642587c Mon Sep 17 00:00:00 2001
  2. From: Sven Klemm <sven@timescale.com>
  3. Date: Sat, 19 Sep 2020 23:20:37 +0200
  4. Subject: [PATCH] Adjust code to PG13 list sort changes
  5. PG13 changes the name of the list sorting function from list_qsort
  6. to list_sort. Additionally PG13 does in-place sort.
  7. https://github.com/postgres/postgres/commit/569ed7f483
  8. Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
  9. Fetch from: https://github.com/timescale/timescaledb/commit/13d8aac33b6fc5104c8ad1da816dc0d009fc13a7.patch
  10. ---
  11. src/bgw/scheduler.c | 15 ++++++++++++++-
  12. 1 file changed, 14 insertions(+), 1 deletion(-)
  13. diff --git a/src/bgw/scheduler.c b/src/bgw/scheduler.c
  14. index 2630ff9f..b9d1aa38 100644
  15. --- a/src/bgw/scheduler.c
  16. +++ b/src/bgw/scheduler.c
  17. @@ -530,10 +530,15 @@ ts_populate_scheduled_job_tuple(ScheduledBgwJob *sjob, Datum *values)
  18. #endif
  19. static int
  20. +#if PG13_LT
  21. cmp_next_start(const void *left, const void *right)
  22. {
  23. const ListCell *left_cell = *((ListCell **) left);
  24. const ListCell *right_cell = *((ListCell **) right);
  25. +#else
  26. +cmp_next_start(const ListCell *left_cell, const ListCell *right_cell)
  27. +{
  28. +#endif
  29. ScheduledBgwJob *left_sjob = lfirst(left_cell);
  30. ScheduledBgwJob *right_sjob = lfirst(right_cell);
  31. @@ -549,10 +554,18 @@ cmp_next_start(const void *left, const void *right)
  32. static void
  33. start_scheduled_jobs(register_background_worker_callback_type bgw_register)
  34. {
  35. + List *ordered_scheduled_jobs;
  36. ListCell *lc;
  37. Assert(CurrentMemoryContext == scratch_mctx);
  38. +
  39. /* Order jobs by increasing next_start */
  40. - List *ordered_scheduled_jobs = list_qsort(scheduled_jobs, cmp_next_start);
  41. +#if PG13_LT
  42. + ordered_scheduled_jobs = list_qsort(scheduled_jobs, cmp_next_start);
  43. +#else
  44. + /* PG13 does in-place sort */
  45. + ordered_scheduled_jobs = scheduled_jobs;
  46. + list_sort(ordered_scheduled_jobs, cmp_next_start);
  47. +#endif
  48. foreach (lc, ordered_scheduled_jobs)
  49. {
  50. --
  51. 2.29.2