Skip to content

Commit 1972eb4

Browse files
committed
compatibility fixes for backport to v11
1 parent 7097d1e commit 1972eb4

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

engine.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@
3333
#include "miscadmin.h"
3434
#include "port/pg_crc32c.h"
3535
#include "storage/copydir.h"
36+
#if PG_VERSION_NUM >= 120000
3637
#include "storage/md.h"
38+
#include "storage/sync.h"
39+
#endif
3740
#include "storage/reinit.h"
3841
#include "storage/smgr.h"
39-
#include "storage/sync.h"
4042
#include "utils/array.h"
4143
#include "utils/builtins.h"
4244
#include "utils/pg_lsn.h"

ptrack.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,19 @@
2929
#include <unistd.h>
3030
#include <sys/stat.h>
3131

32+
#if PG_VERSION_NUM < 120000
33+
#include "access/htup_details.h"
34+
#endif
3235
#include "catalog/pg_tablespace.h"
3336
#include "catalog/pg_type.h"
3437
#include "funcapi.h"
3538
#include "miscadmin.h"
3639
#include "nodes/pg_list.h"
3740
#include "storage/copydir.h"
3841
#include "storage/lmgr.h"
42+
#if PG_VERSION_NUM >= 120000
3943
#include "storage/md.h"
44+
#endif
4045
#include "storage/reinit.h"
4146
#include "utils/builtins.h"
4247
#include "utils/guc.h"
@@ -55,7 +60,9 @@ int ptrack_map_size_tmp;
5560
static copydir_hook_type prev_copydir_hook = NULL;
5661
static mdwrite_hook_type prev_mdwrite_hook = NULL;
5762
static mdextend_hook_type prev_mdextend_hook = NULL;
63+
#if PG_VERSION_NUM >= 120000
5864
static ProcessSyncRequests_hook_type prev_ProcessSyncRequests_hook = NULL;
65+
#endif
5966

6067
void _PG_init(void);
6168
void _PG_fini(void);
@@ -65,8 +72,9 @@ static void ptrack_mdwrite_hook(RelFileNodeBackend smgr_rnode,
6572
ForkNumber forkno, BlockNumber blkno);
6673
static void ptrack_mdextend_hook(RelFileNodeBackend smgr_rnode,
6774
ForkNumber forkno, BlockNumber blkno);
75+
#if PG_VERSION_NUM >= 120000
6876
static void ptrack_ProcessSyncRequests_hook(void);
69-
77+
#endif
7078
static void ptrack_gather_filelist(List **filelist, char *path, Oid spcOid, Oid dbOid);
7179
static int ptrack_filelist_getnext(PtScanCtx * ctx);
7280

@@ -108,8 +116,10 @@ _PG_init(void)
108116
mdwrite_hook = ptrack_mdwrite_hook;
109117
prev_mdextend_hook = mdextend_hook;
110118
mdextend_hook = ptrack_mdextend_hook;
119+
#if PG_VERSION_NUM >= 120000
111120
prev_ProcessSyncRequests_hook = ProcessSyncRequests_hook;
112121
ProcessSyncRequests_hook = ptrack_ProcessSyncRequests_hook;
122+
#endif
113123
}
114124

115125
/*
@@ -122,7 +132,9 @@ _PG_fini(void)
122132
copydir_hook = prev_copydir_hook;
123133
mdwrite_hook = prev_mdwrite_hook;
124134
mdextend_hook = prev_mdextend_hook;
135+
#if PG_VERSION_NUM >= 120000
125136
ProcessSyncRequests_hook = prev_ProcessSyncRequests_hook;
137+
#endif
126138
}
127139

128140
/*
@@ -194,6 +206,7 @@ ptrack_mdextend_hook(RelFileNodeBackend smgr_rnode,
194206
prev_mdextend_hook(smgr_rnode, forknum, blocknum);
195207
}
196208

209+
#if PG_VERSION_NUM >= 120000
197210
static void
198211
ptrack_ProcessSyncRequests_hook()
199212
{
@@ -202,6 +215,7 @@ ptrack_ProcessSyncRequests_hook()
202215
if (prev_ProcessSyncRequests_hook)
203216
prev_ProcessSyncRequests_hook();
204217
}
218+
#endif
205219

206220
/*
207221
* Recursively walk through the path and add all data files to filelist.
@@ -426,7 +440,11 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
426440
ctx->filelist = NIL;
427441

428442
/* Make tuple descriptor */
443+
#if PG_VERSION_NUM >= 120000
429444
tupdesc = CreateTemplateTupleDesc(2);
445+
#else
446+
tupdesc = CreateTemplateTupleDesc(2, false);
447+
#endif
430448
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "path", TEXTOID, -1, 0);
431449
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "pagemap", BYTEAOID, -1, 0);
432450
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
@@ -475,6 +493,7 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
475493
char pathname[MAXPGPATH];
476494
bytea *result = NULL;
477495
Size result_sz = pagemap.bitmapsize + VARHDRSZ;
496+
HeapTuple htup = NULL;
478497

479498
/* Create a bytea copy of our bitmap */
480499
result = (bytea *) palloc(result_sz);
@@ -490,7 +509,9 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
490509
pagemap.bitmap = NULL;
491510
pagemap.bitmapsize = 0;
492511

493-
SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(heap_form_tuple(funcctx->tuple_desc, values, nulls)));
512+
htup = heap_form_tuple(funcctx->tuple_desc, values, nulls);
513+
if (htup)
514+
SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(htup));
494515
}
495516
else
496517
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy