if ((output = popen(cmd, "r")) == NULL ||
fgets(cmd_output, sizeof(cmd_output), output) == NULL)
pg_fatal("could not get pg_ctl version data using %s: %m", cmd);
rc = pclose(output); if (rc != 0)
pg_fatal("could not get pg_ctl version data using %s: %s",
cmd, wait_result_to_str(rc));
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
if (v1 < 10)
{ /* old style, e.g. 9.6.1 */
cluster->bin_version = v1 * 10000 + v2 * 100;
} else
{ /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
}
}
if (log == NULL)
pg_fatal("could not open log file \"%s\": %m", log_file);
#ifdef WIN32 /* Are we printing "command:" before its output? */ if (mainThreadId == GetCurrentThreadId())
fprintf(log, "\n\n"); #endif
fprintf(log, "command: %s\n", cmd); #ifdef WIN32 /* Are we printing "command:" after its output? */ if (mainThreadId != GetCurrentThreadId())
fprintf(log, "\n\n"); #endif
#ifdef WIN32 /* see comment above */ if (mainThreadId == GetCurrentThreadId()) #endif
{
fflush(NULL);
result = system(cmd);
}
if (result != 0 && report_error)
{ /* we might be in on a progress status line, so go to the next line */
report_status(PG_REPORT, "\n*failure*");
fflush(stdout);
pg_log(PG_VERBOSE, "There were problems executing \"%s\"", cmd); if (opt_log_file)
pg_log(exit_on_error ? PG_FATAL : PG_REPORT, "Consult the last few lines of \"%s\" or \"%s\" for\n" "the probable cause of the failure.",
log_file, opt_log_file); else
pg_log(exit_on_error ? PG_FATAL : PG_REPORT, "Consult the last few lines of \"%s\" for\n" "the probable cause of the failure.",
log_file);
}
#ifndef WIN32
/* *Wecan'tdothisonWindowsbecauseitwillkeepthe"pg_ctlstart" *outputfilenameopenuntiltheserverstops,sowedothe\n\naboveon *thatplatform.Weuseauniquefilenamefor"pg_ctlstart"thatis *neverreusedwhiletheserverisrunning,soitworksfine.Wecould *logthesecommandstoathirdfile,butthatjustaddscomplexity.
*/ if ((log = fopen(log_file, "a")) == NULL)
pg_fatal("could not write to log file \"%s\": %m", log_file);
fprintf(log, "\n\n");
fclose(log); #endif
if ((fd = open(path, O_RDONLY, 0)) < 0)
{ /* ENOTDIR means we will throw a more useful error later */ if (errno != ENOENT && errno != ENOTDIR)
pg_fatal("could not open file \"%s\" for reading: %m", path);
returnfalse;
}
close(fd); returntrue;
}
/* *verify_directories() * *doesallthehecticworkofverifyingdirectoriesandexecutables *ofoldandnewserver. * *NOTE:Mayupdatethevaluesofallparameters
*/ void
verify_directories(void)
{ #ifndef WIN32 if (access(".", R_OK | W_OK | X_OK) != 0) #else if (win32_check_directory_write_permissions() != 0) #endif
pg_fatal("You must have read and write access in the current directory.");
snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data, /* Win32 can't stat() a directory with a trailing slash. */
*subdir ? "/" : "",
subdir);
if (stat(subDirName, &statBuf) != 0)
report_status(PG_FATAL, "check for \"%s\" failed: %m",
subDirName); elseif (!S_ISDIR(statBuf.st_mode))
report_status(PG_FATAL, "\"%s\" is not a directory",
subDirName);
}
/* pg_xlog has been renamed to pg_wal in v10 */ if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
check_single_dir(pg_data, "pg_xlog"); else
check_single_dir(pg_data, "pg_wal");
/* pg_clog has been renamed to pg_xact in v10 */ if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
check_single_dir(pg_data, "pg_clog"); else
check_single_dir(pg_data, "pg_xact");
}
/* check bindir */ if (stat(cluster->bindir, &statBuf) != 0)
report_status(PG_FATAL, "check for \"%s\" failed: %m",
cluster->bindir); elseif (!S_ISDIR(statBuf.st_mode))
report_status(PG_FATAL, "\"%s\" is not a directory",
cluster->bindir);
/* pg_resetxlog has been renamed to pg_resetwal in version 10 */ if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
check_exec(cluster->bindir, "pg_resetxlog", check_versions); else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.