Skip to content

Commit a8aa44c

Browse files
authored
Add pg_logging_init for PG version 12 and above (#612)
1 parent d0a4f1c commit a8aa44c

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/bin/pg_autoctl/main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "keeper_config.h"
1919
#include "lock_utils.h"
2020
#include "string_utils.h"
21+
#if (PG_VERSION_NUM >= 120000)
22+
#include "common/logging.h"
23+
#endif
2124

2225
char pg_autoctl_argv0[MAXPGPATH];
2326
char pg_autoctl_program[MAXPGPATH];
@@ -48,6 +51,16 @@ main(int argc, char **argv)
4851
/* set our logging infrastructure */
4952
(void) set_logger();
5053

54+
/*
55+
* Since PG 12, we need to call pg_logging_init before any calls to pg_log_*
56+
* otherwise, we get a segfault. Although we don't use pg_log_* directly,
57+
* functions from the common library such as rmtree do use them.
58+
* Logging change introduced in PG 12: https://git.postgresql.org/cgit/postgresql.git/commit/?id=cc8d41511721d25d557fc02a46c053c0a602fed0
59+
*/
60+
#if (PG_VERSION_NUM >= 120000)
61+
pg_logging_init(argv[0]);
62+
#endif
63+
5164
/* register our logging clean-up atexit */
5265
atexit(log_semaphore_unlink_atexit);
5366

0 commit comments

Comments
 (0)