1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2026-06-21 01:34:15 +02:00

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.
This commit is contained in:
Daria
2025-11-06 22:28:19 +01:00
committed by oleg gurev
parent a2b03fb633
commit 3689d50d58
3 changed files with 29 additions and 2 deletions
+8 -1
View File
@@ -2518,11 +2518,16 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
int segno;
pgFile **file_item;
pgFile f;
#if PG_VERSION_NUM >= 180000
RelPathStr rel_path_str = relpathperm(rnode, forknum);
rel_path = rel_path_str.str;
#else
rel_path = relpathperm(rnode, forknum);
#endif
segno = blkno / RELSEG_SIZE;
blkno_inseg = blkno % RELSEG_SIZE;
rel_path = relpathperm(rnode, forknum);
if (segno > 0)
f.rel_path = psprintf("%s.%u", rel_path, segno);
else
@@ -2554,7 +2559,9 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
if (segno > 0)
pg_free(f.rel_path);
#if PG_VERSION_NUM < 180000
pg_free(rel_path);
#endif
}
+5 -1
View File
@@ -188,7 +188,11 @@ CreateReplicationSlot_compat(PGconn *conn, const char *slot_name, const char *pl
bool is_temporary, bool is_physical,
bool slot_exists_ok)
{
#if PG_VERSION_NUM >= 150000
#if PG_VERSION_NUM >= 180000
return CreateReplicationSlot(conn, slot_name, plugin, is_temporary, is_physical,
/* reserve_wal = */ true, slot_exists_ok, /* two_phase = */ false, /* failover = */ false);
#elif PG_VERSION_NUM >= 150000
return CreateReplicationSlot(conn, slot_name, plugin, is_temporary, is_physical,
/* reserve_wal = */ true, slot_exists_ok, /* two_phase = */ false);
#elif PG_VERSION_NUM >= 110000
+16
View File
@@ -1062,7 +1062,23 @@ handle_interrupt(SIGNAL_ARGS)
static void
init_cancel_handler(void)
{
#if PG_VERSION_NUM < 180000
oldhandler = pqsignal(SIGINT, handle_interrupt);
#else
{
struct sigaction act, oldact;
act.sa_handler = handle_interrupt;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_RESTART;
/* Get the previous handler and set the new one */
if (sigaction(SIGINT, &act, &oldact) < 0)
elog(ERROR, "sigaction(SIGINT) failed: %m");
oldhandler = oldact.sa_handler;
}
#endif
pqsignal(SIGQUIT, handle_interrupt);
pqsignal(SIGTERM, handle_interrupt);
pqsignal(SIGPIPE, handle_interrupt);