Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3689d50

Browse files
dlepikhovaoleg gurev
authored and
oleg gurev
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 parenta2b03fb commit3689d50

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

‎src/backup.c‎

Lines changed: 8 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
intsegno;
25192519
pgFile**file_item;
25202520
pgFilef;
2521+
#ifPG_VERSION_NUM >=180000
2522+
RelPathStrrel_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
@@ -2554,7 +2559,9 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
25542559

25552560
if (segno>0)
25562561
pg_free(f.rel_path);
2562+
#ifPG_VERSION_NUM<180000
25572563
pg_free(rel_path);
2564+
#endif
25582565

25592566
}
25602567

‎src/stream.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ CreateReplicationSlot_compat(PGconn *conn, const char *slot_name, const char *pl
188188
boolis_temporary,boolis_physical,
189189
boolslot_exists_ok)
190190
{
191-
#ifPG_VERSION_NUM >=150000
191+
#ifPG_VERSION_NUM >=180000
192+
returnCreateReplicationSlot(conn,slot_name,plugin,is_temporary,is_physical,
193+
/* reserve_wal = */ true,slot_exists_ok,/* two_phase = */ false,/* failover = */ false);
194+
#elifPG_VERSION_NUM >=150000
195+
192196
returnCreateReplicationSlot(conn,slot_name,plugin,is_temporary,is_physical,
193197
/* reserve_wal = */ true,slot_exists_ok,/* two_phase = */ false);
194198
#elifPG_VERSION_NUM >=110000

‎src/utils/pgut.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,23 @@ handle_interrupt(SIGNAL_ARGS)
10621062
staticvoid
10631063
init_cancel_handler(void)
10641064
{
1065+
#ifPG_VERSION_NUM<180000
10651066
oldhandler=pqsignal(SIGINT,handle_interrupt);
1067+
#else
1068+
{
1069+
structsigactionact,oldact;
1070+
1071+
act.sa_handler=handle_interrupt;
1072+
sigemptyset(&act.sa_mask);
1073+
act.sa_flags=SA_RESTART;
1074+
1075+
/* Get the previous handler and set the new one */
1076+
if (sigaction(SIGINT,&act,&oldact)<0)
1077+
elog(ERROR,"sigaction(SIGINT) failed: %m");
1078+
1079+
oldhandler=oldact.sa_handler;
1080+
}
1081+
#endif
10661082
pqsignal(SIGQUIT,handle_interrupt);
10671083
pqsignal(SIGTERM,handle_interrupt);
10681084
pqsignal(SIGPIPE,handle_interrupt);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp