Skip to content

Commit ef32140

Browse files
committed
PBCKP-2705: Adjust signal handling and compatibility for PostgreSQL 18
This patch adds compatibility changes for PostgreSQL 18: - Updated signal handler initialization in pgut.c to use sigaction() instead of pqsignal(), as pqsignal() now returns void. - Updated process_block_change() in backup.c to handle the new RelPathStr structure returned by relpathperm() in v18. - Updated CreateReplicationSlot_compat() in stream.c to support the new CreateReplicationSlot() signature introduced in v18. These changes ensure successful build and runtime behavior with PostgreSQL 18 while preserving backward compatibility with earlier versions.
1 parent 721d5d2 commit ef32140

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/backup.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2518,11 +2518,16 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
25182518
int segno;
25192519
pgFile **file_item;
25202520
pgFile f;
2521+
#if PG_VERSION_NUM >= 180000
2522+
RelPathStr rel_path_str = relpathperm(rnode, forknum);
2523+
rel_path = rel_path_str.str;
2524+
#else
2525+
rel_path = relpathperm(rnode, forknum);
2526+
#endif
25212527

25222528
segno = blkno / RELSEG_SIZE;
25232529
blkno_inseg = blkno % RELSEG_SIZE;
25242530

2525-
rel_path = relpathperm(rnode, forknum);
25262531
if (segno > 0)
25272532
f.rel_path = psprintf("%s.%u", rel_path, segno);
25282533
else

src/stream.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ CreateReplicationSlot_compat(PGconn *conn, const char *slot_name, const char *pl
188188
bool is_temporary, bool is_physical,
189189
bool slot_exists_ok)
190190
{
191-
#if PG_VERSION_NUM >= 150000
191+
#if PG_VERSION_NUM >= 180000
192+
return CreateReplicationSlot(conn, slot_name, plugin, is_temporary, is_physical,
193+
/* reserve_wal = */ true, slot_exists_ok, /* two_phase = */ false, /* failover = */ false);
194+
#elif PG_VERSION_NUM >= 150000
192195
return CreateReplicationSlot(conn, slot_name, plugin, is_temporary, is_physical,
193196
/* reserve_wal = */ true, slot_exists_ok, /* two_phase = */ false);
194197
#elif PG_VERSION_NUM >= 110000

0 commit comments

Comments
 (0)