]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
pg_createsubscriber: Remove separate logfile_open() function
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 13 Apr 2026 08:52:19 +0000 (10:52 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Mon, 13 Apr 2026 08:52:19 +0000 (10:52 +0200)
This seems like an excessive indirection.

Discussion: https://www.postgresql.org/message-id/flat/CAEqnbaUthOQARV1dscGvB_EsqC-YfxiM6rWkVDHc%2BG%2Bf4oSUHw%40mail.gmail.com

src/bin/pg_basebackup/pg_createsubscriber.c

index 5c5fa2a76336b56a7035fcdc6937c9904a408df2..e90fce0302e62f5e40573df1742b3930bd621b31 100644 (file)
@@ -975,22 +975,6 @@ server_is_in_recovery(PGconn *conn)
        return ret == 0;
 }
 
-/*
- * Open a new logfile with proper permissions.
- */
-static FILE *
-logfile_open(const char *filename, const char *mode)
-{
-       FILE       *fh;
-
-       fh = fopen(filename, mode);
-
-       if (!fh)
-               pg_fatal("could not open log file \"%s\": %m", filename);
-
-       return fh;
-}
-
 static void
 make_output_dirs(const char *log_basedir)
 {
@@ -2530,8 +2514,10 @@ main(int argc, char **argv)
                make_output_dirs(opt.log_dir);
                internal_log_file = psprintf("%s/%s", logdir, INTERNAL_LOG_FILE_NAME);
 
-               /* logfile_open() will exit if there is an error */
-               internal_log_file_fp = logfile_open(internal_log_file, "a");
+               internal_log_file_fp = fopen(internal_log_file, "a");
+               if (!internal_log_file_fp)
+                       pg_fatal("could not open log file \"%s\": %m", internal_log_file);
+
                pg_free(internal_log_file);
 
                pg_logging_set_logfile(internal_log_file_fp);