LCOV - differential code coverage report
Current view: top level - src/bin/pg_upgrade - exec.c (source / functions) Coverage Total Hit LBC UBC GBC GNC CBC DUB DCB
Current: c38de3ae6098ccf1904109f2e550eb4777f66024 vs e352ac8c5c90ed6ce792f044c22145578542a330 Lines: 80.4 % 112 90 1 21 2 5 83 4 13
Current Date: 2026-11-05 14:14:01 +0100 Functions: 100.0 % 8 8 4 4 1
Baseline: lcov-20261105-baseline Branches: 51.9 % 54 28 1 25 3 25
Baseline Date: 2026-11-05 14:14:01 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(7,30] days: 100.0 % 1 1 1
(30,360] days: 100.0 % 4 4 4
(360..) days: 79.4 % 107 85 1 21 2 83
Function coverage date bins:
(7,30] days: 100.0 % 1 1 1
(360..) days: 100.0 % 7 7 3 4
Branch coverage date bins:
(360..) days: 51.9 % 54 28 1 25 3 25

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*
                                  2                 :                :  *  exec.c
                                  3                 :                :  *
                                  4                 :                :  *  execution functions
                                  5                 :                :  *
                                  6                 :                :  *  Copyright (c) 2010-2026, PostgreSQL Global Development Group
                                  7                 :                :  *  src/bin/pg_upgrade/exec.c
                                  8                 :                :  */
                                  9                 :                : 
                                 10                 :                : #include "postgres_fe.h"
                                 11                 :                : 
                                 12                 :                : #include <fcntl.h>
                                 13                 :                : 
                                 14                 :                : #include "common/string.h"
                                 15                 :                : #include "fe_utils/version.h"
                                 16                 :                : #include "pg_upgrade.h"
                                 17                 :                : 
                                 18                 :                : static void get_bin_version(ClusterInfo *cluster);
                                 19                 :                : static void check_exec(const char *dir, const char *program, bool check_version);
                                 20                 :                : 
                                 21                 :                : #ifdef WIN32
                                 22                 :                : static int  win32_check_directory_write_permissions(void);
                                 23                 :                : #endif
                                 24                 :                : 
                                 25                 :                : 
                                 26                 :                : /*
                                 27                 :                :  * get_bin_version
                                 28                 :                :  *
                                 29                 :                :  *  Fetch major version of binaries for cluster.
                                 30                 :                :  */
                                 31                 :                : static void
 3550 rhaas@postgresql.org       32                 :CBC          44 : get_bin_version(ClusterInfo *cluster)
                                 33                 :                : {
                                 34                 :                :     char        cmd[MAXPGPATH],
                                 35                 :                :                 cmd_output[MAX_STRING];
                                 36                 :                :     FILE       *output;
                                 37                 :                :     int         rc;
 3286 tgl@sss.pgh.pa.us          38                 :             44 :     int         v1 = 0,
                                 39                 :             44 :                 v2 = 0;
                                 40                 :                : 
 3550 rhaas@postgresql.org       41                 :             44 :     snprintf(cmd, sizeof(cmd), "\"%s/pg_ctl\" --version", cluster->bindir);
 1529 tgl@sss.pgh.pa.us          42                 :             44 :     fflush(NULL);
                                 43                 :                : 
 3550 rhaas@postgresql.org       44   [ +  -  -  + ]:             88 :     if ((output = popen(cmd, "r")) == NULL ||
                                 45                 :             44 :         fgets(cmd_output, sizeof(cmd_output), output) == NULL)
  968 michael@paquier.xyz        46                 :UBC           0 :         pg_fatal("could not get pg_ctl version data using %s: %m", cmd);
                                 47                 :                : 
 1451 peter@eisentraut.org       48                 :CBC          44 :     rc = pclose(output);
                                 49         [ -  + ]:             44 :     if (rc != 0)
 1451 peter@eisentraut.org       50                 :UBC           0 :         pg_fatal("could not get pg_ctl version data using %s: %s",
                                 51                 :                :                  cmd, wait_result_to_str(rc));
                                 52                 :                : 
 3286 tgl@sss.pgh.pa.us          53         [ -  + ]:CBC          44 :     if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
 1577 tgl@sss.pgh.pa.us          54                 :UBC           0 :         pg_fatal("could not get pg_ctl version output from %s", cmd);
                                 55                 :                : 
  126 nathan@postgresql.or       56                 :GNC          44 :     cluster->bin_version = v1 * 10000;
 3550 rhaas@postgresql.org       57                 :CBC          44 : }
                                 58                 :                : 
                                 59                 :                : 
                                 60                 :                : /*
                                 61                 :                :  * exec_prog()
                                 62                 :                :  *      Execute an external program with stdout/stderr redirected, and report
                                 63                 :                :  *      errors
                                 64                 :                :  *
                                 65                 :                :  * Formats a command from the given argument list, logs it to the log file,
                                 66                 :                :  * and attempts to execute that command.  If the command executes
                                 67                 :                :  * successfully, exec_prog() returns true.
                                 68                 :                :  *
                                 69                 :                :  * If the command fails, an error message is optionally written to the specified
                                 70                 :                :  * log_file, and the program optionally exits.
                                 71                 :                :  *
                                 72                 :                :  * The code requires it be called first from the primary thread on Windows.
                                 73                 :                :  */
                                 74                 :                : bool
 1733 michael@paquier.xyz        75                 :            334 : exec_prog(const char *log_filename, const char *opt_log_file,
                                 76                 :                :           bool report_error, bool exit_on_error, const char *fmt, ...)
                                 77                 :                : {
 4849 bruce@momjian.us           78                 :            334 :     int         result = 0;
                                 79                 :                :     int         written;
                                 80                 :                :     char        log_file[MAXPGPATH];
                                 81                 :                : 
                                 82                 :                : #define MAXCMDLEN (2 * MAXPGPATH)
                                 83                 :                :     char        cmd[MAXCMDLEN];
                                 84                 :                :     FILE       *log;
                                 85                 :                :     va_list     ap;
                                 86                 :                : 
                                 87                 :                : #ifdef WIN32
                                 88                 :                :     static DWORD mainThreadId = 0;
                                 89                 :                : 
                                 90                 :                :     /* We assume we are called from the primary thread first */
                                 91                 :                :     if (mainThreadId == 0)
                                 92                 :                :         mainThreadId = GetCurrentThreadId();
                                 93                 :                : #endif
                                 94                 :                : 
 1733 michael@paquier.xyz        95                 :            334 :     snprintf(log_file, MAXPGPATH, "%s/%s", log_opts.logdir, log_filename);
                                 96                 :                : 
 4567 heikki.linnakangas@i       97                 :            334 :     written = 0;
 5183 alvherre@alvh.no-ip.       98                 :            334 :     va_start(ap, fmt);
                                 99                 :            334 :     written += vsnprintf(cmd + written, MAXCMDLEN - written, fmt, ap);
                                100                 :            334 :     va_end(ap);
                                101         [ -  + ]:            334 :     if (written >= MAXCMDLEN)
 1577 tgl@sss.pgh.pa.us         102                 :UBC           0 :         pg_fatal("command too long");
 5183 alvherre@alvh.no-ip.      103                 :CBC         334 :     written += snprintf(cmd + written, MAXCMDLEN - written,
                                104                 :                :                         " >> \"%s\" 2>&1", log_file);
                                105         [ -  + ]:            334 :     if (written >= MAXCMDLEN)
 1577 tgl@sss.pgh.pa.us         106                 :UBC           0 :         pg_fatal("command too long");
                                107                 :                : 
 1577 tgl@sss.pgh.pa.us         108                 :CBC         334 :     pg_log(PG_VERBOSE, "%s", cmd);
                                109                 :                : 
                                110                 :                : #ifdef WIN32
                                111                 :                : 
                                112                 :                :     /*
                                113                 :                :      * For some reason, Windows issues a file-in-use error if we write data to
                                114                 :                :      * the log file from a non-primary thread just before we create a
                                115                 :                :      * subprocess that also writes to the same log file.  One fix is to sleep
                                116                 :                :      * for 100ms.  A cleaner fix is to write to the log file _after_ the
                                117                 :                :      * subprocess has completed, so we do this only when writing from a
                                118                 :                :      * non-primary thread.  fflush(), running system() twice, and pre-creating
                                119                 :                :      * the file do not see to help.
                                120                 :                :      */
                                121                 :                :     if (mainThreadId != GetCurrentThreadId())
                                122                 :                :     {
                                123                 :                :         fflush(NULL);
                                124                 :                :         result = system(cmd);
                                125                 :                :     }
                                126                 :                : #endif
                                127                 :                : 
 4851 bruce@momjian.us          128                 :            334 :     log = fopen(log_file, "a");
                                129                 :                : 
                                130                 :                : #ifdef WIN32
                                131                 :                :     {
                                132                 :                :         /*
                                133                 :                :          * "pg_ctl -w stop" might have reported that the server has stopped
                                134                 :                :          * because the postmaster.pid file has been removed, but "pg_ctl -w
                                135                 :                :          * start" might still be in the process of closing and might still be
                                136                 :                :          * holding its stdout and -l log file descriptors open.  Therefore,
                                137                 :                :          * try to open the log file a few more times.
                                138                 :                :          */
                                139                 :                :         int         iter;
                                140                 :                : 
                                141                 :                :         for (iter = 0; iter < 4 && log == NULL; iter++)
                                142                 :                :         {
                                143                 :                :             pg_usleep(1000000); /* 1 sec */
                                144                 :                :             log = fopen(log_file, "a");
                                145                 :                :         }
                                146                 :                :     }
                                147                 :                : #endif
                                148                 :                : 
 5174 andrew@dunslane.net       149         [ -  + ]:            334 :     if (log == NULL)
 1577 tgl@sss.pgh.pa.us         150                 :UBC           0 :         pg_fatal("could not open log file \"%s\": %m", log_file);
                                151                 :                : 
                                152                 :                : #ifdef WIN32
                                153                 :                :     /* Are we printing "command:" before its output? */
                                154                 :                :     if (mainThreadId == GetCurrentThreadId())
                                155                 :                :         fprintf(log, "\n\n");
                                156                 :                : #endif
 5243 alvherre@alvh.no-ip.      157                 :CBC         334 :     fprintf(log, "command: %s\n", cmd);
                                158                 :                : #ifdef WIN32
                                159                 :                :     /* Are we printing "command:" after its output? */
                                160                 :                :     if (mainThreadId != GetCurrentThreadId())
                                161                 :                :         fprintf(log, "\n\n");
                                162                 :                : #endif
                                163                 :                : 
                                164                 :                :     /*
                                165                 :                :      * In Windows, we must close the log file at this point so the file is not
                                166                 :                :      * open while the command is running, or we get a share violation.
                                167                 :                :      */
 5203 bruce@momjian.us          168                 :            334 :     fclose(log);
                                169                 :                : 
                                170                 :                : #ifdef WIN32
                                171                 :                :     /* see comment above */
                                172                 :                :     if (mainThreadId == GetCurrentThreadId())
                                173                 :                : #endif
                                174                 :                :     {
 1529 tgl@sss.pgh.pa.us         175                 :            334 :         fflush(NULL);
 4849 bruce@momjian.us          176                 :            334 :         result = system(cmd);
                                177                 :                :     }
                                178                 :                : 
 3223                           179   [ +  +  -  + ]:            334 :     if (result != 0 && report_error)
                                180                 :                :     {
                                181                 :                :         /* we might be in on a progress status line, so go to the next line */
 5088 bruce@momjian.us          182                 :UBC           0 :         report_status(PG_REPORT, "\n*failure*");
 5351                           183                 :              0 :         fflush(stdout);
                                184                 :                : 
 1577 tgl@sss.pgh.pa.us         185                 :              0 :         pg_log(PG_VERBOSE, "There were problems executing \"%s\"", cmd);
 5183 alvherre@alvh.no-ip.      186         [ #  # ]:              0 :         if (opt_log_file)
 3223 bruce@momjian.us          187         [ #  # ]:              0 :             pg_log(exit_on_error ? PG_FATAL : PG_REPORT,
                                188                 :                :                    "Consult the last few lines of \"%s\" or \"%s\" for\n"
                                189                 :                :                    "the probable cause of the failure.",
                                190                 :                :                    log_file, opt_log_file);
                                191                 :                :         else
                                192         [ #  # ]:              0 :             pg_log(exit_on_error ? PG_FATAL : PG_REPORT,
                                193                 :                :                    "Consult the last few lines of \"%s\" for\n"
                                194                 :                :                    "the probable cause of the failure.",
                                195                 :                :                    log_file);
                                196                 :                :     }
                                197                 :                : 
                                198                 :                : #ifndef WIN32
                                199                 :                : 
                                200                 :                :     /*
                                201                 :                :      * We can't do this on Windows because it will keep the "pg_ctl start"
                                202                 :                :      * output filename open until the server stops, so we do the \n\n above on
                                203                 :                :      * that platform.  We use a unique filename for "pg_ctl start" that is
                                204                 :                :      * never reused while the server is running, so it works fine.  We could
                                205                 :                :      * log these commands to a third file, but that just adds complexity.
                                206                 :                :      */
 4851 bruce@momjian.us          207         [ -  + ]:CBC         334 :     if ((log = fopen(log_file, "a")) == NULL)
 1577 tgl@sss.pgh.pa.us         208                 :UBC           0 :         pg_fatal("could not write to log file \"%s\": %m", log_file);
 5243 alvherre@alvh.no-ip.      209                 :CBC         334 :     fprintf(log, "\n\n");
                                210                 :            334 :     fclose(log);
                                211                 :                : #endif
                                212                 :                : 
 5183                           213                 :            334 :     return result == 0;
                                214                 :                : }
                                215                 :                : 
                                216                 :                : 
                                217                 :                : /*
                                218                 :                :  * pid_lock_file_exists()
                                219                 :                :  *
                                220                 :                :  * Checks whether the postmaster.pid file exists.
                                221                 :                :  */
                                222                 :                : bool
 5033 bruce@momjian.us          223                 :             44 : pid_lock_file_exists(const char *datadir)
                                224                 :                : {
                                225                 :                :     char        path[MAXPGPATH];
                                226                 :                :     int         fd;
                                227                 :                : 
 5959                           228                 :             44 :     snprintf(path, sizeof(path), "%s/postmaster.pid", datadir);
                                229                 :                : 
                                230         [ +  + ]:             44 :     if ((fd = open(path, O_RDONLY, 0)) < 0)
                                231                 :                :     {
                                232                 :                :         /* ENOTDIR means we will throw a more useful error later */
 5650                           233   [ -  +  -  - ]:             42 :         if (errno != ENOENT && errno != ENOTDIR)
  968 michael@paquier.xyz       234                 :UBC           0 :             pg_fatal("could not open file \"%s\" for reading: %m", path);
                                235                 :                : 
 5959 bruce@momjian.us          236                 :CBC          42 :         return false;
                                237                 :                :     }
                                238                 :                : 
 5959 bruce@momjian.us          239                 :GBC           2 :     close(fd);
                                240                 :              2 :     return true;
                                241                 :                : }
                                242                 :                : 
                                243                 :                : 
                                244                 :                : /*
                                245                 :                :  * Check that the current directory is writable
                                246                 :                :  */
                                247                 :                : void
   22 heikki.linnakangas@i      248                 :GNC          22 : check_current_dir_write_permissions(void)
                                249                 :                : {
                                250                 :                : #ifndef WIN32
 5583 bruce@momjian.us          251         [ -  + ]:CBC          22 :     if (access(".", R_OK | W_OK | X_OK) != 0)
                                252                 :                : #else
                                253                 :                :     if (win32_check_directory_write_permissions() != 0)
                                254                 :                : #endif
 1577 tgl@sss.pgh.pa.us         255                 :UBC           0 :         pg_fatal("You must have read and write access in the current directory.");
 6021 bruce@momjian.us          256                 :CBC          22 : }
                                257                 :                : 
                                258                 :                : #ifdef WIN32
                                259                 :                : /*
                                260                 :                :  * win32_check_directory_write_permissions()
                                261                 :                :  *
                                262                 :                :  *  access() on WIN32 can't check directory permissions, so we have to
                                263                 :                :  *  optionally create, then delete a file to check.
                                264                 :                :  *      http://msdn.microsoft.com/en-us/library/1w06ktdy%28v=vs.80%29.aspx
                                265                 :                :  */
                                266                 :                : static int
                                267                 :                : win32_check_directory_write_permissions(void)
                                268                 :                : {
                                269                 :                :     int         fd;
                                270                 :                : 
                                271                 :                :     /*
                                272                 :                :      * We open a file we would normally create anyway.  We do this even in
                                273                 :                :      * 'check' mode, which isn't ideal, but this is the best we can do.
                                274                 :                :      */
                                275                 :                :     if ((fd = open(GLOBALS_DUMP_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0)
                                276                 :                :         return -1;
                                277                 :                :     close(fd);
                                278                 :                : 
                                279                 :                :     return unlink(GLOBALS_DUMP_FILE);
                                280                 :                : }
                                281                 :                : #endif
                                282                 :                : 
                                283                 :                : 
                                284                 :                : /*
                                285                 :                :  * check_single_dir()
                                286                 :                :  *
                                287                 :                :  *  Check for the presence of a single directory in PGDATA, and fail if
                                288                 :                :  * is it missing or not accessible.
                                289                 :                :  */
                                290                 :                : static void
 3668 rhaas@postgresql.org      291                 :            396 : check_single_dir(const char *pg_data, const char *subdir)
                                292                 :                : {
                                293                 :                :     struct stat statBuf;
                                294                 :                :     char        subDirName[MAXPGPATH];
                                295                 :                : 
                                296                 :            396 :     snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data,
                                297                 :                :     /* Win32 can't stat() a directory with a trailing slash. */
                                298         [ +  + ]:            396 :              *subdir ? "/" : "",
                                299                 :                :              subdir);
                                300                 :                : 
                                301         [ -  + ]:            396 :     if (stat(subDirName, &statBuf) != 0)
  968 michael@paquier.xyz       302                 :UBC           0 :         report_status(PG_FATAL, "check for \"%s\" failed: %m",
                                303                 :                :                       subDirName);
 3668 rhaas@postgresql.org      304         [ -  + ]:CBC         396 :     else if (!S_ISDIR(statBuf.st_mode))
 1577 tgl@sss.pgh.pa.us         305                 :UBC           0 :         report_status(PG_FATAL, "\"%s\" is not a directory",
                                306                 :                :                       subDirName);
 3668 rhaas@postgresql.org      307                 :CBC         396 : }
                                308                 :                : 
                                309                 :                : 
                                310                 :                : /*
                                311                 :                :  * check_data_dir()
                                312                 :                :  *
                                313                 :                :  *  This function validates the given cluster directory - we search for a
                                314                 :                :  *  small set of subdirectories that we expect to find in a valid $PGDATA
                                315                 :                :  *  directory.  If any of the subdirectories are missing (or secured against
                                316                 :                :  *  us) we display an error message and exit()
                                317                 :                :  *
                                318                 :                :  */
                                319                 :                : void
                                320                 :             44 : check_data_dir(ClusterInfo *cluster)
                                321                 :                : {
                                322                 :             44 :     const char *pg_data = cluster->pgdata;
                                323                 :                : 
                                324                 :                :     /* get the cluster version */
  387 michael@paquier.xyz       325                 :             44 :     cluster->major_version = get_pg_version(cluster->pgdata,
                                326                 :                :                                             &cluster->major_version_str);
 3668 rhaas@postgresql.org      327                 :             44 :     check_single_dir(pg_data, "");
                                328                 :             44 :     check_single_dir(pg_data, "base");
                                329                 :             44 :     check_single_dir(pg_data, "global");
                                330                 :             44 :     check_single_dir(pg_data, "pg_multixact");
                                331                 :             44 :     check_single_dir(pg_data, "pg_subtrans");
  793 michael@paquier.xyz       332                 :             44 :     check_single_dir(pg_data, PG_TBLSPC_DIR);
 3668 rhaas@postgresql.org      333                 :             44 :     check_single_dir(pg_data, "pg_twophase");
  126 nathan@postgresql.or      334                 :GNC          44 :     check_single_dir(pg_data, "pg_wal");
                                335                 :             44 :     check_single_dir(pg_data, "pg_xact");
 5959 bruce@momjian.us          336                 :CBC          44 : }
                                337                 :                : 
                                338                 :                : 
                                339                 :                : /*
                                340                 :                :  * check_bin_dir()
                                341                 :                :  *
                                342                 :                :  *  This function searches for the executables that we expect to find
                                343                 :                :  *  in the binaries directory.  If we find that a required executable
                                344                 :                :  *  is missing (or secured against us), we display an error message and
                                345                 :                :  *  exit().
                                346                 :                :  *
                                347                 :                :  *  If check_versions is true, then the versions of the binaries are checked
                                348                 :                :  *  against the version of this pg_upgrade.  This is for checking the target
                                349                 :                :  *  bindir.
                                350                 :                :  */
                                351                 :                : void
 2072 peter@eisentraut.org      352                 :             44 : check_bin_dir(ClusterInfo *cluster, bool check_versions)
                                353                 :                : {
                                354                 :                :     struct stat statBuf;
                                355                 :                : 
                                356                 :                :     /* check bindir */
 5650 bruce@momjian.us          357         [ -  + ]:             44 :     if (stat(cluster->bindir, &statBuf) != 0)
  968 michael@paquier.xyz       358                 :LBC         (1) :         report_status(PG_FATAL, "check for \"%s\" failed: %m",
                                359                 :                :                       cluster->bindir);
 5650 bruce@momjian.us          360         [ -  + ]:CBC          44 :     else if (!S_ISDIR(statBuf.st_mode))
 1577 tgl@sss.pgh.pa.us         361                 :UBC           0 :         report_status(PG_FATAL, "\"%s\" is not a directory",
                                362                 :                :                       cluster->bindir);
                                363                 :                : 
 2072 peter@eisentraut.org      364                 :CBC          44 :     check_exec(cluster->bindir, "postgres", check_versions);
                                365                 :             44 :     check_exec(cluster->bindir, "pg_controldata", check_versions);
                                366                 :             44 :     check_exec(cluster->bindir, "pg_ctl", check_versions);
                                367                 :                : 
                                368                 :                :     /*
                                369                 :                :      * Fetch the binary version after checking for the existence of pg_ctl.
                                370                 :                :      * This way we report a useful error if the pg_ctl binary used for version
                                371                 :                :      * fetching is missing/broken.
                                372                 :                :      */
 3283 tgl@sss.pgh.pa.us         373                 :             44 :     get_bin_version(cluster);
                                374                 :                : 
  126 nathan@postgresql.or      375                 :GNC          44 :     check_exec(cluster->bindir, "pg_resetwal", check_versions);
                                376                 :                : 
 5787 bruce@momjian.us          377         [ +  + ]:CBC          44 :     if (cluster == &new_cluster)
                                378                 :                :     {
                                379                 :                :         /*
                                380                 :                :          * These binaries are only needed for the target version. pg_dump and
                                381                 :                :          * pg_dumpall are used to dump the old cluster, but must be of the
                                382                 :                :          * target version.
                                383                 :                :          */
 2072 peter@eisentraut.org      384                 :             22 :         check_exec(cluster->bindir, "initdb", check_versions);
                                385                 :             22 :         check_exec(cluster->bindir, "pg_dump", check_versions);
                                386                 :             22 :         check_exec(cluster->bindir, "pg_dumpall", check_versions);
                                387                 :             22 :         check_exec(cluster->bindir, "pg_restore", check_versions);
                                388                 :             22 :         check_exec(cluster->bindir, "psql", check_versions);
                                389                 :             22 :         check_exec(cluster->bindir, "vacuumdb", check_versions);
                                390                 :                :     }
 6021 bruce@momjian.us          391                 :             44 : }
                                392                 :                : 
                                393                 :                : static void
 2072 peter@eisentraut.org      394                 :            308 : check_exec(const char *dir, const char *program, bool check_version)
                                395                 :                : {
                                396                 :                :     char        path[MAXPGPATH];
                                397                 :                :     char       *line;
                                398                 :                :     char        cmd[MAXPGPATH];
                                399                 :                :     char        versionstr[128];
                                400                 :                : 
 2073                           401                 :            308 :     snprintf(path, sizeof(path), "%s/%s", dir, program);
                                402                 :                : 
 1577 tgl@sss.pgh.pa.us         403         [ -  + ]:            308 :     if (validate_exec(path) != 0)
 1577 tgl@sss.pgh.pa.us         404                 :UBC           0 :         pg_fatal("check for \"%s\" failed: %m", path);
                                405                 :                : 
 2073 peter@eisentraut.org      406                 :CBC         308 :     snprintf(cmd, sizeof(cmd), "\"%s\" -V", path);
                                407                 :                : 
 1000 dgustafsson@postgres      408         [ -  + ]:            308 :     if ((line = pipe_read_line(cmd)) == NULL)
 1577 tgl@sss.pgh.pa.us         409                 :UBC           0 :         pg_fatal("check for \"%s\" failed: cannot execute",
                                410                 :                :                  path);
                                411                 :                : 
 2072 peter@eisentraut.org      412         [ +  + ]:CBC         308 :     if (check_version)
                                413                 :                :     {
                                414                 :            220 :         pg_strip_crlf(line);
                                415                 :                : 
                                416                 :            220 :         snprintf(versionstr, sizeof(versionstr), "%s (PostgreSQL) " PG_VERSION, program);
                                417                 :                : 
                                418         [ -  + ]:            220 :         if (strcmp(line, versionstr) != 0)
 1577 tgl@sss.pgh.pa.us         419                 :UBC           0 :             pg_fatal("check for \"%s\" failed: incorrect version: found \"%s\", expected \"%s\"",
                                420                 :                :                      path, line, versionstr);
                                421                 :                :     }
                                422                 :                : 
 1000 dgustafsson@postgres      423                 :CBC         308 :     pg_free(line);
 6021 bruce@momjian.us          424                 :            308 : }
        

Generated by: LCOV version 2.0-1