break;
default:
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ /* getopt_long already emitted a complaint */
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
if (optind < argc)
{
- fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
- progname, argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ pg_log_error("too many command-line arguments (first is \"%s\")",
+ argv[optind]);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
conn = PQconnectdbParams(keywords, values, true);
if (!conn)
- {
- pg_log_error("could not connect to database %s",
- my_opts->dbname);
- exit(1);
- }
+ pg_fatal("could not connect to database %s",
+ my_opts->dbname);
if (PQstatus(conn) == CONNECTION_BAD &&
PQconnectionNeedsPassword(conn) &&
PQerrorMessage(conn));
PQclear(res);
PQfinish(conn);
- exit(-1);
+ exit(1);
}
PQclear(res);
if (!res || PQresultStatus(res) > 2)
{
pg_log_error("query failed: %s", PQerrorMessage(conn));
- pg_log_error("query was: %s", todo);
+ pg_log_error_detail("Query was: %s", todo);
PQclear(res);
PQfinish(conn);
- exit(-1);
+ exit(1);
}
/* get the number of fields */
{
switch (c)
{
- case '?':
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
- exit(1);
case 'h':
param.pg_host = pg_strdup(optarg);
break;
case 'l':
param.transaction_limit = strtol(optarg, NULL, 10);
if (param.transaction_limit < 0)
- {
- pg_log_error("transaction limit must not be negative (0 disables)");
- exit(1);
- }
+ pg_fatal("transaction limit must not be negative (0 disables)");
break;
case 'n':
param.dry_run = 1;
case 'p':
port = strtol(optarg, NULL, 10);
if ((port < 1) || (port > 65535))
- {
- pg_log_error("invalid port number: %s", optarg);
- exit(1);
- }
+ pg_fatal("invalid port number: %s", optarg);
param.pg_port = pg_strdup(optarg);
break;
case 'U':
param.pg_prompt = TRI_YES;
break;
default:
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ /* getopt_long already emitted a complaint */
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
if (optind >= argc)
{
pg_log_error("missing required argument: database name");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
char *result = escape_single_quotes_ascii(src);
if (!result)
- {
- pg_log_error("out of memory");
- exit(1);
- }
+ pg_fatal("out of memory");
return result;
}
int n;
if ((infile = fopen(path, "r")) == NULL)
- {
- pg_log_error("could not open file \"%s\" for reading: %m", path);
- exit(1);
- }
+ pg_fatal("could not open file \"%s\" for reading: %m", path);
initStringInfo(&line);
char **line;
if ((out_file = fopen(path, "w")) == NULL)
- {
- pg_log_error("could not open file \"%s\" for writing: %m", path);
- exit(1);
- }
+ pg_fatal("could not open file \"%s\" for writing: %m", path);
for (line = lines; *line != NULL; line++)
{
if (fputs(*line, out_file) < 0)
- {
- pg_log_error("could not write file \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not write file \"%s\": %m", path);
free(*line);
}
if (fclose(out_file))
- {
- pg_log_error("could not write file \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not close file \"%s\": %m", path);
}
/*
if (geteuid() == 0) /* 0 is root's uid */
{
pg_log_error("cannot be run as root");
- fprintf(stderr,
- _("Please log in (using, e.g., \"su\") as the (unprivileged) user that will\n"
- "own the server process.\n"));
+ pg_log_error_hint("Please log in (using, e.g., \"su\") as the (unprivileged) user that will own the server process.");
exit(1);
}
#endif
if ((enc = pg_valid_server_encoding(encoding_name)) >= 0)
return enc;
}
- pg_log_error("\"%s\" is not a valid server encoding name",
- encoding_name ? encoding_name : "(null)");
- exit(1);
+ pg_fatal("\"%s\" is not a valid server encoding name",
+ encoding_name ? encoding_name : "(null)");
}
/*
if (errno == ENOENT)
{
pg_log_error("file \"%s\" does not exist", path);
- fprintf(stderr,
- _("This might mean you have a corrupted installation or identified\n"
- "the wrong directory with the invocation option -L.\n"));
+ pg_log_error_hint("This might mean you have a corrupted installation or identified the wrong directory with the invocation option -L.");
}
else
{
pg_log_error("could not access file \"%s\": %m", path);
- fprintf(stderr,
- _("This might mean you have a corrupted installation or identified\n"
- "the wrong directory with the invocation option -L.\n"));
+ pg_log_error_hint("This might mean you have a corrupted installation or identified the wrong directory with the invocation option -L.");
}
exit(1);
}
if (!S_ISREG(statbuf.st_mode))
{
pg_log_error("file \"%s\" is not a regular file", path);
- fprintf(stderr,
- _("This might mean you have a corrupted installation or identified\n"
- "the wrong directory with the invocation option -L.\n"));
+ pg_log_error_hint("This might mean you have a corrupted installation or identified the wrong directory with the invocation option -L.");
exit(1);
}
}
path = psprintf("%s/%s/PG_VERSION", pg_data, extrapath);
if ((version_file = fopen(path, PG_BINARY_W)) == NULL)
- {
- pg_log_error("could not open file \"%s\" for writing: %m", path);
- exit(1);
- }
+ pg_fatal("could not open file \"%s\" for writing: %m", path);
if (fprintf(version_file, "%s\n", PG_MAJORVERSION) < 0 ||
fclose(version_file))
- {
- pg_log_error("could not write file \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not write file \"%s\": %m", path);
free(path);
}
path = psprintf("%s/postgresql.conf", pg_data);
conf_file = fopen(path, PG_BINARY_W);
if (conf_file == NULL)
- {
- pg_log_error("could not open file \"%s\" for writing: %m", path);
- exit(1);
- }
+ pg_fatal("could not open file \"%s\" for writing: %m", path);
if (fclose(conf_file))
- {
- pg_log_error("could not write file \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not write file \"%s\": %m", path);
free(path);
}
writefile(path, conflines);
if (chmod(path, pg_file_create_mode) != 0)
- {
- pg_log_error("could not change permissions of \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not change permissions of \"%s\": %m", path);
/*
* create the automatic configuration file to store the configuration
writefile(path, autoconflines);
if (chmod(path, pg_file_create_mode) != 0)
- {
- pg_log_error("could not change permissions of \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not change permissions of \"%s\": %m", path);
free(conflines);
writefile(path, conflines);
if (chmod(path, pg_file_create_mode) != 0)
- {
- pg_log_error("could not change permissions of \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not change permissions of \"%s\": %m", path);
free(conflines);
writefile(path, conflines);
if (chmod(path, pg_file_create_mode) != 0)
- {
- pg_log_error("could not change permissions of \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not change permissions of \"%s\": %m", path);
free(conflines);
{
pg_log_error("input file \"%s\" does not belong to PostgreSQL %s",
bki_file, PG_VERSION);
- fprintf(stderr,
- _("Check your installation or specify the correct path "
- "using the option -L.\n"));
+ pg_log_error_hint("Specify the correct path using the option -L.");
exit(1);
}
FILE *pwf = fopen(pwfilename, "r");
if (!pwf)
- {
- pg_log_error("could not open file \"%s\" for reading: %m",
- pwfilename);
- exit(1);
- }
+ pg_fatal("could not open file \"%s\" for reading: %m",
+ pwfilename);
pwd1 = pg_get_line(pwf, NULL);
if (!pwd1)
{
if (ferror(pwf))
- pg_log_error("could not read password from file \"%s\": %m",
- pwfilename);
+ pg_fatal("could not read password from file \"%s\": %m",
+ pwfilename);
else
- pg_log_error("password file \"%s\" is empty",
- pwfilename);
- exit(1);
+ pg_fatal("password file \"%s\" is empty",
+ pwfilename);
}
fclose(pwf);
save = setlocale(category, NULL);
if (!save)
- {
- pg_log_error("setlocale() failed");
- exit(1);
- }
+ pg_fatal("setlocale() failed");
/* save may be pointing at a modifiable scratch variable, so copy it. */
save = pg_strdup(save);
/* restore old value. */
if (!setlocale(category, save))
- {
- pg_log_error("failed to restore old locale \"%s\"", save);
- exit(1);
- }
+ pg_fatal("failed to restore old locale \"%s\"", save);
free(save);
/* complain if locale wasn't valid */
if (res == NULL)
{
if (*locale)
- pg_log_error("invalid locale name \"%s\"", locale);
+ pg_fatal("invalid locale name \"%s\"", locale);
else
{
/*
* setlocale's behavior is implementation-specific, it's hard to
* be sure what it didn't like. Print a safe generic message.
*/
- pg_log_error("invalid locale settings; check LANG and LC_* environment variables");
+ pg_fatal("invalid locale settings; check LANG and LC_* environment variables");
}
- exit(1);
}
}
user_enc == PG_SQL_ASCII))
{
pg_log_error("encoding mismatch");
- fprintf(stderr,
- _("The encoding you selected (%s) and the encoding that the\n"
- "selected locale uses (%s) do not match. This would lead to\n"
- "misbehavior in various character string processing functions.\n"
- "Rerun %s and either do not specify an encoding explicitly,\n"
- "or choose a matching combination.\n"),
- pg_encoding_to_char(user_enc),
- pg_encoding_to_char(locale_enc),
- progname);
+ pg_log_error_detail("The encoding you selected (%s) and the encoding that the "
+ "selected locale uses (%s) do not match. This would lead to "
+ "misbehavior in various character string processing functions.",
+ pg_encoding_to_char(user_enc),
+ pg_encoding_to_char(locale_enc));
+ pg_log_error_hint("Rerun %s and either do not specify an encoding explicitly, "
+ "or choose a matching combination.",
+ progname);
return false;
}
return true;
if (locale_provider == COLLPROVIDER_ICU)
{
if (!icu_locale)
- {
- pg_log_error("ICU locale must be specified");
- exit(1);
- }
+ pg_fatal("ICU locale must be specified");
/*
* In supported builds, the ICU locale ID will be checked by the
- * backend when performing the post-boostrap initialization.
+ * backend during post-bootstrap initialization.
*/
#ifndef USE_ICU
- pg_log_error("ICU is not supported in this build");
- exit(1);
+ pg_fatal("ICU is not supported in this build");
#endif
}
}
return;
}
- pg_log_error("invalid authentication method \"%s\" for \"%s\" connections",
- authmethod, conntype);
- exit(1);
+ pg_fatal("invalid authentication method \"%s\" for \"%s\" connections",
+ authmethod, conntype);
}
static void
strcmp(authmethodhost, "password") == 0 ||
strcmp(authmethodhost, "scram-sha-256") == 0) &&
!(pwprompt || pwfilename))
- {
- pg_log_error("must specify a password for the superuser to enable password authentication");
- exit(1);
- }
+ pg_fatal("must specify a password for the superuser to enable password authentication");
}
else
{
pg_log_error("no data directory specified");
- fprintf(stderr,
- _("You must identify the directory where the data for this database system\n"
- "will reside. Do this with either the invocation option -D or the\n"
- "environment variable PGDATA.\n"));
+ pg_log_error_hint("You must identify the directory where the data for this database system "
+ "will reside. Do this with either the invocation option -D or the "
+ "environment variable PGDATA.");
exit(1);
}
}
* have embedded spaces.
*/
if (setenv("PGDATA", pg_data, 1) != 0)
- {
- pg_log_error("could not set environment");
- exit(1);
- }
+ pg_fatal("could not set environment");
}
strlcpy(full_path, progname, sizeof(full_path));
if (ret == -1)
- pg_log_error("The program \"%s\" is needed by %s but was not found in the\n"
- "same directory as \"%s\".\n"
- "Check your installation.",
- "postgres", progname, full_path);
+ pg_fatal("program \"%s\" is needed by %s but was not found in the same directory as \"%s\"",
+ "postgres", progname, full_path);
else
- pg_log_error("The program \"%s\" was found by \"%s\"\n"
- "but was not the same version as %s.\n"
- "Check your installation.",
- "postgres", full_path, progname);
- exit(1);
+ pg_fatal("program \"%s\" was found by \"%s\" but was not the same version as %s",
+ "postgres", full_path, progname);
}
/* store binary directory */
get_share_path(backend_exec, share_path);
}
else if (!is_absolute_path(share_path))
- {
- pg_log_error("input file location must be an absolute path");
- exit(1);
- }
+ pg_fatal("input file location must be an absolute path");
canonicalize_path(share_path);
}
/* Couldn't recognize the locale's codeset */
pg_log_error("could not find suitable encoding for locale \"%s\"",
lc_ctype);
- fprintf(stderr, _("Rerun %s with the -E option.\n"), progname);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Rerun %s with the -E option.", progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
else if (!pg_valid_server_encoding_id(ctype_enc))
#else
pg_log_error("locale \"%s\" requires unsupported encoding \"%s\"",
lc_ctype, pg_encoding_to_char(ctype_enc));
- fprintf(stderr,
- _("Encoding \"%s\" is not allowed as a server-side encoding.\n"
- "Rerun %s with a different locale selection.\n"),
- pg_encoding_to_char(ctype_enc), progname);
+ pg_log_error_detail("Encoding \"%s\" is not allowed as a server-side encoding.",
+ pg_encoding_to_char(ctype_enc));
+ pg_log_error_hint("Rerun %s with a different locale selection.",
+ progname);
exit(1);
#endif
}
fflush(stdout);
if (pg_mkdir_p(pg_data, pg_dir_create_mode) != 0)
- {
- pg_log_error("could not create directory \"%s\": %m", pg_data);
- exit(1);
- }
+ pg_fatal("could not create directory \"%s\": %m", pg_data);
else
check_ok();
fflush(stdout);
if (chmod(pg_data, pg_dir_create_mode) != 0)
- {
- pg_log_error("could not change permissions of directory \"%s\": %m",
- pg_data);
- exit(1);
- }
+ pg_fatal("could not change permissions of directory \"%s\": %m",
+ pg_data);
else
check_ok();
if (ret != 4)
warn_on_mount_point(ret);
else
- fprintf(stderr,
- _("If you want to create a new database system, either remove or empty\n"
- "the directory \"%s\" or run %s\n"
- "with an argument other than \"%s\".\n"),
- pg_data, progname, pg_data);
+ pg_log_error_hint("If you want to create a new database system, either remove or empty "
+ "the directory \"%s\" or run %s "
+ "with an argument other than \"%s\".",
+ pg_data, progname, pg_data);
exit(1); /* no further message needed */
default:
/* Trouble accessing directory */
- pg_log_error("could not access directory \"%s\": %m", pg_data);
- exit(1);
+ pg_fatal("could not access directory \"%s\": %m", pg_data);
}
}
/* clean up xlog directory name, check it's absolute */
canonicalize_path(xlog_dir);
if (!is_absolute_path(xlog_dir))
- {
- pg_log_error("WAL directory location must be an absolute path");
- exit(1);
- }
+ pg_fatal("WAL directory location must be an absolute path");
/* check if the specified xlog directory exists/is empty */
switch ((ret = pg_check_dir(xlog_dir)))
fflush(stdout);
if (pg_mkdir_p(xlog_dir, pg_dir_create_mode) != 0)
- {
- pg_log_error("could not create directory \"%s\": %m",
- xlog_dir);
- exit(1);
- }
+ pg_fatal("could not create directory \"%s\": %m",
+ xlog_dir);
else
check_ok();
fflush(stdout);
if (chmod(xlog_dir, pg_dir_create_mode) != 0)
- {
- pg_log_error("could not change permissions of directory \"%s\": %m",
- xlog_dir);
- exit(1);
- }
+ pg_fatal("could not change permissions of directory \"%s\": %m",
+ xlog_dir);
else
check_ok();
if (ret != 4)
warn_on_mount_point(ret);
else
- fprintf(stderr,
- _("If you want to store the WAL there, either remove or empty the directory\n"
- "\"%s\".\n"),
- xlog_dir);
+ pg_log_error_hint("If you want to store the WAL there, either remove or empty the directory \"%s\".",
+ xlog_dir);
exit(1);
default:
/* Trouble accessing directory */
- pg_log_error("could not access directory \"%s\": %m", xlog_dir);
- exit(1);
+ pg_fatal("could not access directory \"%s\": %m", xlog_dir);
}
#ifdef HAVE_SYMLINK
if (symlink(xlog_dir, subdirloc) != 0)
- {
- pg_log_error("could not create symbolic link \"%s\": %m",
- subdirloc);
- exit(1);
- }
+ pg_fatal("could not create symbolic link \"%s\": %m",
+ subdirloc);
#else
- pg_log_error("symlinks are not supported on this platform");
- exit(1);
+ pg_fatal("symlinks are not supported on this platform");
#endif
}
else
{
/* Without -X option, just make the subdirectory normally */
if (mkdir(subdirloc, pg_dir_create_mode) < 0)
- {
- pg_log_error("could not create directory \"%s\": %m",
- subdirloc);
- exit(1);
- }
+ pg_fatal("could not create directory \"%s\": %m",
+ subdirloc);
}
free(subdirloc);
warn_on_mount_point(int error)
{
if (error == 2)
- fprintf(stderr,
- _("It contains a dot-prefixed/invisible file, perhaps due to it being a mount point.\n"));
+ pg_log_error_detail("It contains a dot-prefixed/invisible file, perhaps due to it being a mount point.");
else if (error == 3)
- fprintf(stderr,
- _("It contains a lost+found directory, perhaps due to it being a mount point.\n"));
+ pg_log_error_detail("It contains a lost+found directory, perhaps due to it being a mount point.");
- fprintf(stderr,
- _("Using a mount point directly as the data directory is not recommended.\n"
- "Create a subdirectory under the mount point.\n"));
+ pg_log_error_hint("Using a mount point directly as the data directory is not recommended.\n"
+ "Create a subdirectory under the mount point.");
}
* pg_mkdir_p() here, which avoids some failure modes; cf bug #13853.
*/
if (mkdir(path, pg_dir_create_mode) < 0)
- {
- pg_log_error("could not create directory \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not create directory \"%s\": %m", path);
free(path);
}
else if (strcmp(optarg, "libc") == 0)
locale_provider = COLLPROVIDER_LIBC;
else
- {
- pg_log_error("unrecognized locale provider: %s", optarg);
- exit(1);
- }
+ pg_fatal("unrecognized locale provider: %s", optarg);
break;
case 16:
icu_locale = pg_strdup(optarg);
break;
default:
/* getopt_long already emitted a complaint */
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
{
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (icu_locale && locale_provider != COLLPROVIDER_ICU)
- {
- pg_log_error("%s cannot be specified unless locale provider \"%s\" is chosen",
- "--icu-locale", "icu");
- exit(1);
- }
+ pg_fatal("%s cannot be specified unless locale provider \"%s\" is chosen",
+ "--icu-locale", "icu");
atexit(cleanup_directories_atexit);
/* must check that directory is readable */
if (pg_check_dir(pg_data) <= 0)
- {
- pg_log_error("could not access directory \"%s\": %m", pg_data);
- exit(1);
- }
+ pg_fatal("could not access directory \"%s\": %m", pg_data);
fputs(_("syncing data to disk ... "), stdout);
fflush(stdout);
}
if (pwprompt && pwfilename)
- {
- pg_log_error("password prompt and password file cannot be specified together");
- exit(1);
- }
+ pg_fatal("password prompt and password file cannot be specified together");
check_authmethod_unspecified(&authmethodlocal);
check_authmethod_unspecified(&authmethodhost);
/* verify that wal segment size is valid */
if (endptr == str_wal_segment_size_mb || *endptr != '\0')
- {
- pg_log_error("argument of --wal-segsize must be a number");
- exit(1);
- }
+ pg_fatal("argument of --wal-segsize must be a number");
if (!IsValidWalSegSize(wal_segment_size_mb * 1024 * 1024))
- {
- pg_log_error("argument of --wal-segsize must be a power of 2 between 1 and 1024");
- exit(1);
- }
+ pg_fatal("argument of --wal-segsize must be a power of 2 between 1 and 1024");
}
get_restricted_token();
username = effective_user;
if (strncmp(username, "pg_", 3) == 0)
- {
- pg_log_error("superuser name \"%s\" is disallowed; role names cannot begin with \"pg_\"", username);
- exit(1);
- }
+ pg_fatal("superuser name \"%s\" is disallowed; role names cannot begin with \"pg_\"", username);
printf(_("The files belonging to this database system will be owned "
"by user \"%s\".\n"
{
printf("\n");
pg_log_warning("enabling \"trust\" authentication for local connections");
- fprintf(stderr, _("You can change this by editing pg_hba.conf or using the option -A, or\n"
- "--auth-local and --auth-host, the next time you run initdb.\n"));
+ pg_log_warning_hint("You can change this by editing pg_hba.conf or using the option -A, or "
+ "--auth-local and --auth-host, the next time you run initdb.");
}
if (!noinstructions)
#define log_no_match(...) do { \
if (opts.strict_names) \
- pg_log_generic(PG_LOG_ERROR, __VA_ARGS__); \
+ pg_log_error(__VA_ARGS__); \
else \
- pg_log_generic(PG_LOG_WARNING, __VA_ARGS__); \
+ pg_log_warning(__VA_ARGS__); \
} while(0)
#define FREE_AND_SET_NULL(x) do { \
else if (pg_strcasecmp(optarg, "none") == 0)
opts.skip = "none";
else
- {
- pg_log_error("invalid argument for option %s", "--skip");
- exit(1);
- }
+ pg_fatal("invalid argument for option %s", "--skip");
break;
case 7:
errno = 0;
optval = strtoul(optarg, &endptr, 10);
if (endptr == optarg || *endptr != '\0' || errno != 0)
- {
- pg_log_error("invalid start block");
- exit(1);
- }
+ pg_fatal("invalid start block");
if (optval > MaxBlockNumber)
- {
- pg_log_error("start block out of bounds");
- exit(1);
- }
+ pg_fatal("start block out of bounds");
opts.startblock = optval;
break;
case 8:
errno = 0;
optval = strtoul(optarg, &endptr, 10);
if (endptr == optarg || *endptr != '\0' || errno != 0)
- {
- pg_log_error("invalid end block");
- exit(1);
- }
+ pg_fatal("invalid end block");
if (optval > MaxBlockNumber)
- {
- pg_log_error("end block out of bounds");
- exit(1);
- }
+ pg_fatal("end block out of bounds");
opts.endblock = optval;
break;
case 9:
opts.install_schema = pg_strdup(optarg);
break;
default:
- fprintf(stderr,
- _("Try \"%s --help\" for more information.\n"),
- progname);
+ /* getopt_long already emitted a complaint */
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
if (opts.endblock >= 0 && opts.endblock < opts.startblock)
- {
- pg_log_error("end block precedes start block");
- exit(1);
- }
+ pg_fatal("end block precedes start block");
/*
* A single non-option arguments specifies a database name or connection
{
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (opts.alldb)
{
if (db != NULL)
- {
- pg_log_error("cannot specify a database name with --all");
- exit(1);
- }
+ pg_fatal("cannot specify a database name with --all");
cparams.dbname = maintenance_db;
}
else if (db != NULL)
{
if (opts.dbpattern)
- {
- pg_log_error("cannot specify both a database name and database patterns");
- exit(1);
- }
+ pg_fatal("cannot specify both a database name and database patterns");
cparams.dbname = db;
}
{
if (conn != NULL)
disconnectDatabase(conn);
- pg_log_error("no databases to check");
+ pg_log_warning("no databases to check");
exit(0);
}
/* Querying the catalog failed. */
pg_log_error("database \"%s\": %s",
PQdb(conn), PQerrorMessage(conn));
- pg_log_info("query was: %s", amcheck_sql);
+ pg_log_error_detail("Query was: %s", amcheck_sql);
PQclear(result);
disconnectDatabase(conn);
exit(1);
{
if (conn != NULL)
disconnectDatabase(conn);
- pg_log_error("no relations to check");
- exit(1);
+ pg_fatal("no relations to check");
}
progress_report(reltotal, relprogress, pagestotal, pageschecked,
NULL, true, false);
pg_log_error("error sending command to database \"%s\": %s",
PQdb(slot->connection),
PQerrorMessage(slot->connection));
- pg_log_error("command was: %s", sql);
+ pg_log_error_detail("Command was: %s", sql);
exit(1);
}
}
pg_log_warning("btree index \"%s.%s.%s\": btree checking function returned unexpected number of rows: %d",
rel->datinfo->datname, rel->nspname, rel->relname, ntups);
if (opts.verbose)
- pg_log_info("query was: %s", rel->sql);
- pg_log_warning("Are %s's and amcheck's versions compatible?",
- progname);
+ pg_log_warning_detail("Query was: %s", rel->sql);
+ pg_log_warning_hint("Are %s's and amcheck's versions compatible?",
+ progname);
progress_since_last_stderr = false;
}
}
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
pg_log_error("query failed: %s", PQerrorMessage(conn));
- pg_log_info("query was: %s", sql.data);
+ pg_log_error_detail("Query was: %s", sql.data);
disconnectDatabase(conn);
exit(1);
}
*/
fatal = opts.strict_names;
if (pattern_id >= opts.include.len)
- {
- pg_log_error("internal error: received unexpected database pattern_id %d",
- pattern_id);
- exit(1);
- }
+ pg_fatal("internal error: received unexpected database pattern_id %d",
+ pattern_id);
log_no_match("no connectable databases to check matching \"%s\"",
opts.include.data[pattern_id].pattern);
}
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
pg_log_error("query failed: %s", PQerrorMessage(conn));
- pg_log_info("query was: %s", sql.data);
+ pg_log_error_detail("Query was: %s", sql.data);
disconnectDatabase(conn);
exit(1);
}
*/
if (pattern_id >= opts.include.len)
- {
- pg_log_error("internal error: received unexpected relation pattern_id %d",
- pattern_id);
- exit(1);
- }
+ pg_fatal("internal error: received unexpected relation pattern_id %d",
+ pattern_id);
opts.include.data[pattern_id].matched = true;
}
rc = unlink(WALFilePath);
if (rc != 0)
- {
- pg_log_error("could not remove file \"%s\": %m",
- WALFilePath);
- exit(1);
- }
+ pg_fatal("could not remove file \"%s\": %m",
+ WALFilePath);
}
}
if (errno)
- {
- pg_log_error("could not read archive location \"%s\": %m",
- archiveLocation);
- exit(1);
- }
+ pg_fatal("could not read archive location \"%s\": %m",
+ archiveLocation);
if (closedir(xldir))
- {
- pg_log_error("could not close archive location \"%s\": %m",
- archiveLocation);
- exit(1);
- }
- }
- else
- {
- pg_log_error("could not open archive location \"%s\": %m",
+ pg_fatal("could not close archive location \"%s\": %m",
archiveLocation);
- exit(1);
}
+ else
+ pg_fatal("could not open archive location \"%s\": %m",
+ archiveLocation);
}
/*
if (!fnameOK)
{
pg_log_error("invalid file name argument");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(2);
}
}
* from xlogfile names */
break;
default:
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ /* getopt already emitted a complaint */
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(2);
- break;
}
}
else
{
pg_log_error("must specify archive location");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(2);
}
else
{
pg_log_error("must specify oldest kept WAL file");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(2);
}
if (optind < argc)
{
pg_log_error("too many command-line arguments");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(2);
}
{
streamer->file = fopen(pathname, "wb");
if (streamer->file == NULL)
- {
- pg_log_error("could not create file \"%s\": %m", pathname);
- exit(1);
- }
+ pg_fatal("could not create file \"%s\": %m", pathname);
streamer->should_close_file = true;
}
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
errno = ENOSPC;
- pg_log_error("could not write to file \"%s\": %m",
- mystreamer->pathname);
- exit(1);
+ pg_fatal("could not write to file \"%s\": %m",
+ mystreamer->pathname);
}
}
mystreamer = (bbstreamer_plain_writer *) streamer;
if (mystreamer->should_close_file && fclose(mystreamer->file) != 0)
- {
- pg_log_error("could not close file \"%s\": %m",
- mystreamer->pathname);
- exit(1);
- }
+ pg_fatal("could not close file \"%s\": %m",
+ mystreamer->pathname);
mystreamer->file = NULL;
mystreamer->should_close_file = false;
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
errno = ENOSPC;
- pg_log_error("could not write to file \"%s\": %m",
- mystreamer->filename);
- exit(1);
+ pg_fatal("could not write to file \"%s\": %m",
+ mystreamer->filename);
}
break;
default:
/* Shouldn't happen. */
- pg_log_error("unexpected state while extracting archive");
- exit(1);
+ pg_fatal("unexpected state while extracting archive");
}
}
pg_str_endswith(filename, "/pg_xlog") ||
pg_str_endswith(filename, "/archive_status")) &&
errno == EEXIST))
- {
- pg_log_error("could not create directory \"%s\": %m",
- filename);
- exit(1);
- }
+ pg_fatal("could not create directory \"%s\": %m",
+ filename);
}
#ifndef WIN32
if (chmod(filename, mode))
- {
- pg_log_error("could not set permissions on directory \"%s\": %m",
- filename);
- exit(1);
- }
+ pg_fatal("could not set permissions on directory \"%s\": %m",
+ filename);
#endif
}
extract_link(const char *filename, const char *linktarget)
{
if (symlink(linktarget, filename) != 0)
- {
- pg_log_error("could not create symbolic link from \"%s\" to \"%s\": %m",
- filename, linktarget);
- exit(1);
- }
+ pg_fatal("could not create symbolic link from \"%s\" to \"%s\": %m",
+ filename, linktarget);
}
/*
file = fopen(filename, "wb");
if (file == NULL)
- {
- pg_log_error("could not create file \"%s\": %m", filename);
- exit(1);
- }
+ pg_fatal("could not create file \"%s\": %m", filename);
#ifndef WIN32
if (chmod(filename, mode))
- {
- pg_log_error("could not set permissions on file \"%s\": %m",
- filename);
- exit(1);
- }
+ pg_fatal("could not set permissions on file \"%s\": %m",
+ filename);
#endif
return file;
{
streamer->gzfile = gzopen(pathname, "wb");
if (streamer->gzfile == NULL)
- {
- pg_log_error("could not create compressed file \"%s\": %m",
- pathname);
- exit(1);
- }
+ pg_fatal("could not create compressed file \"%s\": %m",
+ pathname);
}
else
{
int fd = dup(fileno(file));
if (fd < 0)
- {
- pg_log_error("could not duplicate stdout: %m");
- exit(1);
- }
+ pg_fatal("could not duplicate stdout: %m");
streamer->gzfile = gzdopen(fd, "wb");
if (streamer->gzfile == NULL)
- {
- pg_log_error("could not open output file: %m");
- exit(1);
- }
+ pg_fatal("could not open output file: %m");
}
if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) != 0 &&
gzsetparams(streamer->gzfile, compress->level,
Z_DEFAULT_STRATEGY) != Z_OK)
- {
- pg_log_error("could not set compression level %d: %s",
- compress->level, get_gz_error(streamer->gzfile));
- exit(1);
- }
+ pg_fatal("could not set compression level %d: %s",
+ compress->level, get_gz_error(streamer->gzfile));
return &streamer->base;
#else
- pg_log_error("this build does not support compression");
- exit(1);
+ pg_fatal("this build does not support gzip compression");
#endif
}
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
errno = ENOSPC;
- pg_log_error("could not write to compressed file \"%s\": %s",
- mystreamer->pathname, get_gz_error(mystreamer->gzfile));
- exit(1);
+ pg_fatal("could not write to compressed file \"%s\": %s",
+ mystreamer->pathname, get_gz_error(mystreamer->gzfile));
}
}
errno = 0; /* in case gzclose() doesn't set it */
if (gzclose(mystreamer->gzfile) != 0)
- {
- pg_log_error("could not close compressed file \"%s\": %m",
- mystreamer->pathname);
- exit(1);
- }
+ pg_fatal("could not close compressed file \"%s\": %m",
+ mystreamer->pathname);
mystreamer->gzfile = NULL;
}
* possible value for safety.
*/
if (inflateInit2(zs, 15 + 16) != Z_OK)
- {
- pg_log_error("could not initialize compression library");
- exit(1);
- }
+ pg_fatal("could not initialize compression library");
return &streamer->base;
#else
- pg_log_error("this build does not support compression");
- exit(1);
+ pg_fatal("this build does not support gzip compression");
#endif
}
default:
/* Shouldn't happen. */
- pg_log_error("unexpected state while injecting recovery settings");
- exit(1);
+ pg_fatal("unexpected state while injecting recovery settings");
}
bbstreamer_content(mystreamer->base.bbs_next, &mystreamer->member,
ctxError = LZ4F_createCompressionContext(&streamer->cctx, LZ4F_VERSION);
if (LZ4F_isError(ctxError))
- pg_log_error("could not create lz4 compression context: %s",
- LZ4F_getErrorName(ctxError));
+ pg_log_error("could not create lz4 compression context: %s",
+ LZ4F_getErrorName(ctxError));
return &streamer->base;
#else
- pg_log_error("this build does not support compression");
- exit(1);
+ pg_fatal("this build does not support lz4 compression");
#endif
}
/* Initialize internal stream state for decompression */
ctxError = LZ4F_createDecompressionContext(&streamer->dctx, LZ4F_VERSION);
if (LZ4F_isError(ctxError))
- {
- pg_log_error("could not initialize compression library: %s",
- LZ4F_getErrorName(ctxError));
- exit(1);
- }
+ pg_fatal("could not initialize compression library: %s",
+ LZ4F_getErrorName(ctxError));
return &streamer->base;
#else
- pg_log_error("this build does not support compression");
- exit(1);
+ pg_fatal("this build does not support lz4 compression");
#endif
}
*/
bbstreamer_buffer_bytes(streamer, &data, &len, len);
if (len > 2 * TAR_BLOCK_SIZE)
- {
- pg_log_error("tar file trailer exceeds 2 blocks");
- exit(1);
- }
+ pg_fatal("tar file trailer exceeds 2 blocks");
return;
default:
/* Shouldn't happen. */
- pg_log_error("unexpected state while parsing tar archive");
- exit(1);
+ pg_fatal("unexpected state while parsing tar archive");
}
}
}
*/
strlcpy(member->pathname, &buffer[0], MAXPGPATH);
if (member->pathname[0] == '\0')
- {
- pg_log_error("tar member has empty name");
- exit(1);
- }
+ pg_fatal("tar member has empty name");
member->size = read_tar_number(&buffer[124], 12);
member->mode = read_tar_number(&buffer[100], 8);
member->uid = read_tar_number(&buffer[108], 8);
if (mystreamer->next_context != BBSTREAMER_ARCHIVE_TRAILER &&
(mystreamer->next_context != BBSTREAMER_MEMBER_HEADER ||
mystreamer->base.bbs_buffer.len > 0))
- {
- pg_log_error("COPY stream ended before last file was finished");
- exit(1);
- }
+ pg_fatal("COPY stream ended before last file was finished");
/* Send the archive trailer, even if empty. */
bbstreamer_content(streamer->bbs_next, NULL,
streamer->cctx = ZSTD_createCCtx();
if (!streamer->cctx)
- {
- pg_log_error("could not create zstd compression context");
- exit(1);
- }
+ pg_fatal("could not create zstd compression context");
/* Set compression level, if specified */
if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) != 0)
ret = ZSTD_CCtx_setParameter(streamer->cctx, ZSTD_c_compressionLevel,
compress->level);
if (ZSTD_isError(ret))
- {
- pg_log_error("could not set zstd compression level to %d: %s",
- compress->level, ZSTD_getErrorName(ret));
- exit(1);
- }
+ pg_fatal("could not set zstd compression level to %d: %s",
+ compress->level, ZSTD_getErrorName(ret));
}
/* Set # of workers, if specified */
ret = ZSTD_CCtx_setParameter(streamer->cctx, ZSTD_c_nbWorkers,
compress->workers);
if (ZSTD_isError(ret))
- {
- pg_log_error("could not set compression worker count to %d: %s",
- compress->workers, ZSTD_getErrorName(ret));
- exit(1);
- }
+ pg_fatal("could not set compression worker count to %d: %s",
+ compress->workers, ZSTD_getErrorName(ret));
}
/* Initialize the ZSTD output buffer. */
return &streamer->base;
#else
- pg_log_error("this build does not support zstd compression");
- exit(1);
+ pg_fatal("this build does not support zstd compression");
#endif
}
streamer->dctx = ZSTD_createDCtx();
if (!streamer->dctx)
- {
- pg_log_error("could not create zstd decompression context");
- exit(1);
- }
+ pg_fatal("could not create zstd decompression context");
/* Initialize the ZSTD output buffer. */
streamer->zstd_outBuf.dst = streamer->base.bbs_buffer.data;
return &streamer->base;
#else
- pg_log_error("this build does not support compression");
- exit(1);
+ pg_fatal("this build does not support zstd compression");
#endif
}
&mystreamer->zstd_outBuf, &inBuf);
if (ZSTD_isError(ret))
- pg_log_error("could not decompress data: %s", ZSTD_getErrorName(ret));
+ pg_log_error("could not decompress data: %s",
+ ZSTD_getErrorName(ret));
}
}
for (arg_ptr = arg; *arg_ptr; arg_ptr++)
{
if (dst_ptr - dst >= MAXPGPATH)
- {
- pg_log_error("directory name too long");
- exit(1);
- }
+ pg_fatal("directory name too long");
if (*arg_ptr == '\\' && *(arg_ptr + 1) == '=')
; /* skip backslash escaping = */
else if (*arg_ptr == '=' && (arg_ptr == arg || *(arg_ptr - 1) != '\\'))
{
if (*cell->new_dir)
- {
- pg_log_error("multiple \"=\" signs in tablespace mapping");
- exit(1);
- }
+ pg_fatal("multiple \"=\" signs in tablespace mapping");
else
dst = dst_ptr = cell->new_dir;
}
}
if (!*cell->old_dir || !*cell->new_dir)
- {
- pg_log_error("invalid tablespace mapping format \"%s\", must be \"OLDDIR=NEWDIR\"", arg);
- exit(1);
- }
+ pg_fatal("invalid tablespace mapping format \"%s\", must be \"OLDDIR=NEWDIR\"", arg);
/*
* This check isn't absolutely necessary. But all tablespaces are created
* consistent with the new_dir check.
*/
if (!is_absolute_path(cell->old_dir))
- {
- pg_log_error("old directory is not an absolute path in tablespace mapping: %s",
- cell->old_dir);
- exit(1);
- }
+ pg_fatal("old directory is not an absolute path in tablespace mapping: %s",
+ cell->old_dir);
if (!is_absolute_path(cell->new_dir))
- {
- pg_log_error("new directory is not an absolute path in tablespace mapping: %s",
- cell->new_dir);
- exit(1);
- }
+ pg_fatal("new directory is not an absolute path in tablespace mapping: %s",
+ cell->new_dir);
/*
* Comparisons done with these values should involve similarly
MemSet(xlogend, 0, sizeof(xlogend));
r = read(bgpipe[0], xlogend, sizeof(xlogend) - 1);
if (r < 0)
- {
- pg_log_error("could not read from ready pipe: %m");
- exit(1);
- }
+ pg_fatal("could not read from ready pipe: %m");
if (sscanf(xlogend, "%X/%X", &hi, &lo) != 2)
- {
- pg_log_error("could not parse write-ahead log location \"%s\"",
- xlogend);
- exit(1);
- }
+ pg_fatal("could not parse write-ahead log location \"%s\"",
+ xlogend);
xlogendptr = ((uint64) hi) << 32 | lo;
has_xlogendptr = 1;
/* Convert the starting position */
if (sscanf(startpos, "%X/%X", &hi, &lo) != 2)
- {
- pg_log_error("could not parse write-ahead log location \"%s\"",
- startpos);
- exit(1);
- }
+ pg_fatal("could not parse write-ahead log location \"%s\"",
+ startpos);
param->startptr = ((uint64) hi) << 32 | lo;
/* Round off to even segment position */
param->startptr -= XLogSegmentOffset(param->startptr, WalSegSz);
#ifndef WIN32
/* Create our background pipe */
if (pipe(bgpipe) < 0)
- {
- pg_log_error("could not create pipe for background process: %m");
- exit(1);
- }
+ pg_fatal("could not create pipe for background process: %m");
#endif
/* Get a second connection */
"pg_xlog" : "pg_wal");
if (pg_mkdir_p(statusdir, pg_dir_create_mode) != 0 && errno != EEXIST)
- {
- pg_log_error("could not create directory \"%s\": %m", statusdir);
- exit(1);
- }
+ pg_fatal("could not create directory \"%s\": %m", statusdir);
}
/*
exit(ret);
}
else if (bgchild < 0)
- {
- pg_log_error("could not create background process: %m");
- exit(1);
- }
+ pg_fatal("could not create background process: %m");
/*
* Else we are in the parent process and all is well.
#else /* WIN32 */
bgchild = _beginthreadex(NULL, 0, (void *) LogStreamerMain, param, 0, NULL);
if (bgchild == 0)
- {
- pg_log_error("could not create background thread: %m");
- exit(1);
- }
+ pg_fatal("could not create background thread: %m");
#endif
}
* Does not exist, so create
*/
if (pg_mkdir_p(dirname, pg_dir_create_mode) == -1)
- {
- pg_log_error("could not create directory \"%s\": %m", dirname);
- exit(1);
- }
+ pg_fatal("could not create directory \"%s\": %m", dirname);
if (created)
*created = true;
return;
/*
* Exists, not empty
*/
- pg_log_error("directory \"%s\" exists but is not empty", dirname);
- exit(1);
+ pg_fatal("directory \"%s\" exists but is not empty", dirname);
case -1:
/*
* Access problem
*/
- pg_log_error("could not access directory \"%s\": %m", dirname);
- exit(1);
+ pg_fatal("could not access directory \"%s\": %m", dirname);
}
}
errno = 0;
result = strtod(src, &after_num);
if (src == after_num)
- {
- pg_log_error("transfer rate \"%s\" is not a valid value", src);
- exit(1);
- }
+ pg_fatal("transfer rate \"%s\" is not a valid value", src);
if (errno != 0)
- {
- pg_log_error("invalid transfer rate \"%s\": %m", src);
- exit(1);
- }
+ pg_fatal("invalid transfer rate \"%s\": %m", src);
if (result <= 0)
{
/*
* Reject obviously wrong values here.
*/
- pg_log_error("transfer rate must be greater than zero");
- exit(1);
+ pg_fatal("transfer rate must be greater than zero");
}
/*
after_num++;
if (*after_num != '\0')
- {
- pg_log_error("invalid --max-rate unit: \"%s\"", suffix);
- exit(1);
- }
+ pg_fatal("invalid --max-rate unit: \"%s\"", suffix);
/* Valid integer? */
if ((uint64) result != (uint64) ((uint32) result))
- {
- pg_log_error("transfer rate \"%s\" exceeds integer range", src);
- exit(1);
- }
+ pg_fatal("transfer rate \"%s\" exceeds integer range", src);
/*
* The range is checked on the server side too, but avoid the server
* connection if a nonsensical value was passed.
*/
if (result < MAX_RATE_LOWER || result > MAX_RATE_UPPER)
- {
- pg_log_error("transfer rate \"%s\" is out of range", src);
- exit(1);
- }
+ pg_fatal("transfer rate \"%s\" is out of range", src);
return (int32) result;
}
/* Get the COPY data stream. */
res = PQgetResult(conn);
if (PQresultStatus(res) != PGRES_COPY_OUT)
- {
- pg_log_error("could not get COPY data stream: %s",
- PQerrorMessage(conn));
- exit(1);
- }
+ pg_fatal("could not get COPY data stream: %s",
+ PQerrorMessage(conn));
PQclear(res);
/* Loop over chunks until done. */
break;
}
else if (r == -2)
- {
- pg_log_error("could not read COPY data: %s",
- PQerrorMessage(conn));
- exit(1);
- }
+ pg_fatal("could not read COPY data: %s",
+ PQerrorMessage(conn));
if (bgchild_exited)
- {
- pg_log_error("background process terminated unexpectedly");
- exit(1);
- }
+ pg_fatal("background process terminated unexpectedly");
(*callback) (r, copybuf, callback_data);
if (must_parse_archive && !is_tar && !is_compressed_tar)
{
pg_log_error("unable to parse archive: %s", archive_name);
- pg_log_info("only tar archives can be parsed");
+ pg_log_error_detail("Only tar archives can be parsed.");
if (format == 'p')
- pg_log_info("plain format requires pg_basebackup to parse the archive");
+ pg_log_error_detail("Plain format requires pg_basebackup to parse the archive.");
if (inject_manifest)
- pg_log_info("using - as the output directory requires pg_basebackup to parse the archive");
+ pg_log_error_detail("Using - as the output directory requires pg_basebackup to parse the archive.");
if (writerecoveryconf)
- pg_log_info("the -R option requires pg_basebackup to parse the archive");
+ pg_log_error_detail("The -R option requires pg_basebackup to parse the archive.");
exit(1);
}
/* Sanity check. */
if (state->manifest_buffer != NULL ||
state->manifest_file !=NULL)
- {
- pg_log_error("archives should precede manifest");
- exit(1);
- }
+ pg_fatal("archives should precede manifest");
/* Parse the rest of the CopyData message. */
archive_name = GetCopyDataString(r, copybuf, &cursor);
if (archive_name[0] == '\0' || archive_name[0] == '.' ||
strchr(archive_name, '/') != NULL ||
strchr(archive_name, '\\') != NULL)
- {
- pg_log_error("invalid archive name: \"%s\"",
- archive_name);
- exit(1);
- }
+ pg_fatal("invalid archive name: \"%s\"",
+ archive_name);
/*
* An empty spclocation is treated as NULL. We expect this
*/
if (errno == 0)
errno = ENOSPC;
- pg_log_error("could not write to file \"%s\": %m",
- state->manifest_filename);
- exit(1);
+ pg_fatal("could not write to file \"%s\": %m",
+ state->manifest_filename);
}
}
else if (state->streamer != NULL)
r - 1, BBSTREAMER_UNKNOWN);
}
else
- {
- pg_log_error("unexpected payload data");
- exit(1);
- }
+ pg_fatal("unexpected payload data");
break;
}
state->manifest_file =
fopen(state->manifest_filename, "wb");
if (state->manifest_file == NULL)
- {
- pg_log_error("could not create file \"%s\": %m",
- state->manifest_filename);
- exit(1);
- }
+ pg_fatal("could not create file \"%s\": %m",
+ state->manifest_filename);
}
}
break;
ReportCopyDataParseError(size_t r, char *copybuf)
{
if (r == 0)
- pg_log_error("empty COPY message");
+ pg_fatal("empty COPY message");
else
- pg_log_error("malformed COPY message of type %d, length %zu",
- copybuf[0], r);
- exit(1);
+ pg_fatal("malformed COPY message of type %d, length %zu",
+ copybuf[0], r);
}
/*
initPQExpBuffer(&buf);
ReceiveBackupManifestInMemory(conn, &buf);
if (PQExpBufferDataBroken(buf))
- {
- pg_log_error("out of memory");
- exit(1);
- }
+ pg_fatal("out of memory");
/* Inject it into the output tarfile. */
bbstreamer_inject_file(manifest_inject_streamer, "backup_manifest",
"%s/backup_manifest.tmp", basedir);
state.file = fopen(state.filename, "wb");
if (state.file == NULL)
- {
- pg_log_error("could not create file \"%s\": %m", state.filename);
- exit(1);
- }
+ pg_fatal("could not create file \"%s\": %m", state.filename);
ReceiveCopyData(conn, ReceiveBackupManifestChunk, &state);
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
errno = ENOSPC;
- pg_log_error("could not write to file \"%s\": %m", state->filename);
- exit(1);
+ pg_fatal("could not write to file \"%s\": %m", state->filename);
}
}
{
const char *serverver = PQparameterStatus(conn, "server_version");
- pg_log_error("incompatible server version %s",
- serverver ? serverver : "'unknown'");
- exit(1);
+ pg_fatal("incompatible server version %s",
+ serverver ? serverver : "'unknown'");
}
if (serverMajor >= 1500)
use_new_option_syntax = true;
char *colon;
if (serverMajor < 1500)
- {
- pg_log_error("backup targets are not supported by this server version");
- exit(1);
- }
+ pg_fatal("backup targets are not supported by this server version");
if (writerecoveryconf)
- {
- pg_log_error("recovery configuration cannot be written when a backup target is used");
- exit(1);
- }
+ pg_fatal("recovery configuration cannot be written when a backup target is used");
AppendPlainCommandOption(&buf, use_new_option_syntax, "TABLESPACE_MAP");
if (compressloc == COMPRESS_LOCATION_SERVER)
{
if (!use_new_option_syntax)
- {
- pg_log_error("server does not support server-side compression");
- exit(1);
- }
+ pg_fatal("server does not support server-side compression");
AppendStringCommandOption(&buf, use_new_option_syntax,
"COMPRESSION", compression_algorithm);
if (compression_detail != NULL)
basebkp = psprintf("BASE_BACKUP %s", buf.data);
if (PQsendQuery(conn, basebkp) == 0)
- {
- pg_log_error("could not send replication command \"%s\": %s",
- "BASE_BACKUP", PQerrorMessage(conn));
- exit(1);
- }
+ pg_fatal("could not send replication command \"%s\": %s",
+ "BASE_BACKUP", PQerrorMessage(conn));
/*
* Get the starting WAL location
*/
res = PQgetResult(conn);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- pg_log_error("could not initiate base backup: %s",
- PQerrorMessage(conn));
- exit(1);
- }
+ pg_fatal("could not initiate base backup: %s",
+ PQerrorMessage(conn));
if (PQntuples(res) != 1)
- {
- pg_log_error("server returned unexpected response to BASE_BACKUP command; got %d rows and %d fields, expected %d rows and %d fields",
- PQntuples(res), PQnfields(res), 1, 2);
- exit(1);
- }
+ pg_fatal("server returned unexpected response to BASE_BACKUP command; got %d rows and %d fields, expected %d rows and %d fields",
+ PQntuples(res), PQnfields(res), 1, 2);
strlcpy(xlogstart, PQgetvalue(res, 0, 0), sizeof(xlogstart));
*/
res = PQgetResult(conn);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- pg_log_error("could not get backup header: %s",
- PQerrorMessage(conn));
- exit(1);
- }
+ pg_fatal("could not get backup header: %s",
+ PQerrorMessage(conn));
if (PQntuples(res) < 1)
- {
- pg_log_error("no data returned from server");
- exit(1);
- }
+ pg_fatal("no data returned from server");
/*
* Sum up the total size, for progress reporting
writing_to_stdout = format == 't' && basedir != NULL &&
strcmp(basedir, "-") == 0;
if (writing_to_stdout && PQntuples(res) > 1)
- {
- pg_log_error("can only write single tablespace to stdout, database has %d",
- PQntuples(res));
- exit(1);
- }
+ pg_fatal("can only write single tablespace to stdout, database has %d",
+ PQntuples(res));
/*
* If we're streaming WAL, start the streaming session before we start
*/
res = PQgetResult(conn);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- pg_log_error("backup failed: %s",
- PQerrorMessage(conn));
- exit(1);
- }
+ pg_fatal("backup failed: %s",
+ PQerrorMessage(conn));
if (PQntuples(res) != 1)
- {
- pg_log_error("no write-ahead log end position returned from server");
- exit(1);
- }
+ pg_fatal("no write-ahead log end position returned from server");
strlcpy(xlogend, PQgetvalue(res, 0, 0), sizeof(xlogend));
if (verbose && includewal != NO_WAL)
pg_log_info("write-ahead log end point: %s", xlogend);
#ifndef WIN32
if (write(bgpipe[1], xlogend, strlen(xlogend)) != strlen(xlogend))
- {
- pg_log_info("could not send command to background pipe: %m");
- exit(1);
- }
+ pg_fatal("could not send command to background pipe: %m");
/* Just wait for the background process to exit */
r = waitpid(bgchild, &status, 0);
if (r == (pid_t) -1)
- {
- pg_log_error("could not wait for child process: %m");
- exit(1);
- }
+ pg_fatal("could not wait for child process: %m");
if (r != bgchild)
- {
- pg_log_error("child %d died, expected %d", (int) r, (int) bgchild);
- exit(1);
- }
+ pg_fatal("child %d died, expected %d", (int) r, (int) bgchild);
if (status != 0)
- {
- pg_log_error("%s", wait_result_to_str(status));
- exit(1);
- }
+ pg_fatal("%s", wait_result_to_str(status));
/* Exited normally, we're happy! */
#else /* WIN32 */
* it's there.
*/
if (sscanf(xlogend, "%X/%X", &hi, &lo) != 2)
- {
- pg_log_error("could not parse write-ahead log location \"%s\"",
- xlogend);
- exit(1);
- }
+ pg_fatal("could not parse write-ahead log location \"%s\"",
+ xlogend);
xlogendptr = ((uint64) hi) << 32 | lo;
InterlockedIncrement(&has_xlogendptr);
WAIT_OBJECT_0)
{
_dosmaperr(GetLastError());
- pg_log_error("could not wait for child thread: %m");
- exit(1);
+ pg_fatal("could not wait for child thread: %m");
}
if (GetExitCodeThread((HANDLE) bgchild_handle, &status) == 0)
{
_dosmaperr(GetLastError());
- pg_log_error("could not get child thread exit status: %m");
- exit(1);
+ pg_fatal("could not get child thread exit status: %m");
}
if (status != 0)
- {
- pg_log_error("child thread exited with error %u",
- (unsigned int) status);
- exit(1);
- }
+ pg_fatal("child thread exited with error %u",
+ (unsigned int) status);
/* Exited normally, we're happy */
#endif
}
else
{
if (rename(tmp_filename, filename) != 0)
- {
- pg_log_error("could not rename file \"%s\" to \"%s\": %m",
- tmp_filename, filename);
- exit(1);
- }
+ pg_fatal("could not rename file \"%s\" to \"%s\": %m",
+ tmp_filename, filename);
}
}
else if (strcmp(optarg, "t") == 0 || strcmp(optarg, "tar") == 0)
format = 't';
else
- {
- pg_log_error("invalid output format \"%s\", must be \"plain\" or \"tar\"",
- optarg);
- exit(1);
- }
+ pg_fatal("invalid output format \"%s\", must be \"plain\" or \"tar\"",
+ optarg);
break;
case 'r':
maxrate = parse_max_rate(optarg);
includewal = STREAM_WAL;
}
else
- {
- pg_log_error("invalid wal-method option \"%s\", must be \"fetch\", \"stream\", or \"none\"",
- optarg);
- exit(1);
- }
+ pg_fatal("invalid wal-method option \"%s\", must be \"fetch\", \"stream\", or \"none\"",
+ optarg);
break;
case 1:
xlog_dir = pg_strdup(optarg);
else if (pg_strcasecmp(optarg, "spread") == 0)
fastcheckpoint = false;
else
- {
- pg_log_error("invalid checkpoint argument \"%s\", must be \"fast\" or \"spread\"",
- optarg);
- exit(1);
- }
+ pg_fatal("invalid checkpoint argument \"%s\", must be \"fast\" or \"spread\"",
+ optarg);
break;
case 'd':
connection_string = pg_strdup(optarg);
manifest_checksums = pg_strdup(optarg);
break;
default:
-
- /*
- * getopt_long already emitted a complaint
- */
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ /* getopt_long already emitted a complaint */
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
{
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (backup_target != NULL && format != '\0')
{
pg_log_error("cannot specify both format and backup target");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (format == '\0')
if (basedir == NULL && backup_target == NULL)
{
pg_log_error("must specify output directory or backup target");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (basedir != NULL && backup_target != NULL)
{
pg_log_error("cannot specify both output directory and backup target");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
char *error_detail;
if (!parse_bc_algorithm(compression_algorithm, &alg))
- {
- pg_log_error("unrecognized compression algorithm \"%s\"",
- compression_algorithm);
- exit(1);
- }
+ pg_fatal("unrecognized compression algorithm \"%s\"",
+ compression_algorithm);
parse_bc_specification(alg, compression_detail, &client_compress);
error_detail = validate_bc_specification(&client_compress);
if (error_detail != NULL)
- {
- pg_log_error("invalid compression specification: %s",
- error_detail);
- exit(1);
- }
+ pg_fatal("invalid compression specification: %s",
+ error_detail);
}
else
{
if (backup_target != NULL && compressloc == COMPRESS_LOCATION_CLIENT)
{
pg_log_error("client-side compression is not possible when a backup target is specified");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
client_compress.algorithm != BACKUP_COMPRESSION_NONE)
{
pg_log_error("only tar mode backups can be compressed");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (backup_target != NULL && includewal == STREAM_WAL)
{
pg_log_error("WAL cannot be streamed when a backup target is specified");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (format == 't' && includewal == STREAM_WAL && strcmp(basedir, "-") == 0)
{
pg_log_error("cannot stream write-ahead logs in tar mode to stdout");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (replication_slot && includewal != STREAM_WAL)
{
pg_log_error("replication slots can only be used with WAL streaming");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (replication_slot)
{
pg_log_error("--no-slot cannot be used with slot name");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
temp_replication_slot = false;
{
pg_log_error("%s needs a slot to be specified using --slot",
"--create-slot");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
{
pg_log_error("%s and %s are incompatible options",
"--create-slot", "--no-slot");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
if (backup_target != NULL)
{
pg_log_error("WAL directory location cannot be specified along with a backup target");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (format != 'p')
{
pg_log_error("WAL directory location can only be specified in plain mode");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (!is_absolute_path(xlog_dir))
{
pg_log_error("WAL directory location must be an absolute path");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
{
pg_log_error("%s and %s are incompatible options",
"--progress", "--no-estimate-size");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
{
pg_log_error("%s and %s are incompatible options",
"--no-manifest", "--manifest-checksums");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
{
pg_log_error("%s and %s are incompatible options",
"--no-manifest", "--manifest-force-encode");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
#ifdef HAVE_SYMLINK
if (symlink(xlog_dir, linkloc) != 0)
- {
- pg_log_error("could not create symbolic link \"%s\": %m", linkloc);
- exit(1);
- }
+ pg_fatal("could not create symbolic link \"%s\": %m", linkloc);
#else
- pg_log_error("symlinks are not supported on this platform");
- exit(1);
+ pg_fatal("symlinks are not supported on this platform");
#endif
free(linkloc);
}
Assert(dest_folder != NULL);
dir = opendir(dest_folder);
if (dir == NULL)
- {
- pg_log_error("could not open directory \"%s\": %m", dest_folder);
- exit(1);
- }
+ pg_fatal("could not open directory \"%s\": %m", dest_folder);
return dir;
}
{
Assert(dest_dir != NULL && dest_folder != NULL);
if (closedir(dest_dir))
- {
- pg_log_error("could not close directory \"%s\": %m", dest_folder);
- exit(1);
- }
+ pg_fatal("could not close directory \"%s\": %m", dest_folder);
}
snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
if (stat(fullpath, &statbuf) != 0)
- {
- pg_log_error("could not stat file \"%s\": %m", fullpath);
- exit(1);
- }
+ pg_fatal("could not stat file \"%s\": %m", fullpath);
if (statbuf.st_size != WalSegSz)
{
fd = open(fullpath, O_RDONLY | PG_BINARY, 0);
if (fd < 0)
- {
- pg_log_error("could not open compressed file \"%s\": %m",
- fullpath);
- exit(1);
- }
+ pg_fatal("could not open compressed file \"%s\": %m",
+ fullpath);
if (lseek(fd, (off_t) (-4), SEEK_END) < 0)
- {
- pg_log_error("could not seek in compressed file \"%s\": %m",
- fullpath);
- exit(1);
- }
+ pg_fatal("could not seek in compressed file \"%s\": %m",
+ fullpath);
r = read(fd, (char *) buf, sizeof(buf));
if (r != sizeof(buf))
{
if (r < 0)
- pg_log_error("could not read compressed file \"%s\": %m",
- fullpath);
+ pg_fatal("could not read compressed file \"%s\": %m",
+ fullpath);
else
- pg_log_error("could not read compressed file \"%s\": read %d of %zu",
- fullpath, r, sizeof(buf));
- exit(1);
+ pg_fatal("could not read compressed file \"%s\": read %d of %zu",
+ fullpath, r, sizeof(buf));
}
close(fd);
fd = open(fullpath, O_RDONLY | PG_BINARY, 0);
if (fd < 0)
- {
- pg_log_error("could not open file \"%s\": %m", fullpath);
- exit(1);
- }
+ pg_fatal("could not open file \"%s\": %m", fullpath);
status = LZ4F_createDecompressionContext(&ctx, LZ4F_VERSION);
if (LZ4F_isError(status))
- {
- pg_log_error("could not create LZ4 decompression context: %s",
- LZ4F_getErrorName(status));
- exit(1);
- }
+ pg_fatal("could not create LZ4 decompression context: %s",
+ LZ4F_getErrorName(status));
outbuf = pg_malloc0(LZ4_CHUNK_SZ);
readbuf = pg_malloc0(LZ4_CHUNK_SZ);
r = read(fd, readbuf, LZ4_CHUNK_SZ);
if (r < 0)
- {
- pg_log_error("could not read file \"%s\": %m", fullpath);
- exit(1);
- }
+ pg_fatal("could not read file \"%s\": %m", fullpath);
/* Done reading the file */
if (r == 0)
status = LZ4F_decompress(ctx, outbuf, &out_size,
readp, &read_size, &dec_opt);
if (LZ4F_isError(status))
- {
- pg_log_error("could not decompress file \"%s\": %s",
- fullpath,
- LZ4F_getErrorName(status));
- exit(1);
- }
+ pg_fatal("could not decompress file \"%s\": %s",
+ fullpath,
+ LZ4F_getErrorName(status));
readp += read_size;
uncompressed_size += out_size;
status = LZ4F_freeDecompressionContext(ctx);
if (LZ4F_isError(status))
- {
- pg_log_error("could not free LZ4 decompression context: %s",
- LZ4F_getErrorName(status));
- exit(1);
- }
+ pg_fatal("could not free LZ4 decompression context: %s",
+ LZ4F_getErrorName(status));
if (uncompressed_size != WalSegSz)
{
#else
pg_log_error("could not check file \"%s\"",
dirent->d_name);
- pg_log_error("this build does not support compression with %s",
- "LZ4");
+ pg_log_error_detail("This build does not support compression with %s.",
+ "LZ4");
exit(1);
#endif
}
}
if (errno)
- {
- pg_log_error("could not read directory \"%s\": %m", basedir);
- exit(1);
- }
+ pg_fatal("could not read directory \"%s\": %m", basedir);
close_destination_dir(dir, basedir);
break;
case 'E':
if (sscanf(optarg, "%X/%X", &hi, &lo) != 2)
- {
- pg_log_error("could not parse end position \"%s\"", optarg);
- exit(1);
- }
+ pg_fatal("could not parse end position \"%s\"", optarg);
endpos = ((uint64) hi) << 32 | lo;
break;
case 'n':
else if (pg_strcasecmp(optarg, "none") == 0)
compression_method = COMPRESSION_NONE;
else
- {
- pg_log_error("invalid value \"%s\" for option %s",
- optarg, "--compression-method");
- exit(1);
- }
+ pg_fatal("invalid value \"%s\" for option %s",
+ optarg, "--compression-method");
break;
default:
-
- /*
- * getopt_long already emitted a complaint
- */
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ /* getopt_long already emitted a complaint */
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
{
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (do_drop_slot && do_create_slot)
{
pg_log_error("cannot use --create-slot together with --drop-slot");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
/* translator: second %s is an option name */
pg_log_error("%s needs a slot to be specified using --slot",
do_drop_slot ? "--drop-slot" : "--create-slot");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (synchronous && !do_sync)
{
pg_log_error("cannot use --synchronous together with --no-sync");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (basedir == NULL && !do_drop_slot && !do_create_slot)
{
pg_log_error("no target directory specified");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
{
pg_log_error("cannot use --compress with --compression-method=%s",
"none");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
break;
compresslevel = Z_DEFAULT_COMPRESSION;
}
#else
- pg_log_error("this build does not support compression with %s",
- "gzip");
- exit(1);
+ pg_fatal("this build does not support compression with %s",
+ "gzip");
#endif
break;
case COMPRESSION_LZ4:
{
pg_log_error("cannot use --compress with --compression-method=%s",
"lz4");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
#else
- pg_log_error("this build does not support compression with %s",
- "LZ4");
- exit(1);
+ pg_fatal("this build does not support compression with %s",
+ "LZ4");
#endif
break;
case COMPRESSION_ZSTD:
- pg_log_error("compression with %s is not yet supported", "ZSTD");
- exit(1);
-
+ pg_fatal("compression with %s is not yet supported", "ZSTD");
+ break;
}
* be defined in this context.
*/
if (db_name)
- {
- pg_log_error("replication connection using slot \"%s\" is unexpectedly database specific",
- replication_slot);
- exit(1);
- }
+ pg_fatal("replication connection using slot \"%s\" is unexpectedly database specific",
+ replication_slot);
/*
* Set umask so that directories/files are created with the same
exit(0);
}
else if (noloop)
- {
- pg_log_error("disconnected");
- exit(1);
- }
+ pg_fatal("disconnected");
else
{
/* translator: check source for value for %d */
return true;
if (fsync(outfd) != 0)
- {
- pg_log_fatal("could not fsync file \"%s\": %m", outfile);
- exit(1);
- }
+ pg_fatal("could not fsync file \"%s\": %m", outfile);
return true;
}
/* replication options */
case 'I':
if (sscanf(optarg, "%X/%X", &hi, &lo) != 2)
- {
- pg_log_error("could not parse start position \"%s\"", optarg);
- exit(1);
- }
+ pg_fatal("could not parse start position \"%s\"", optarg);
startpos = ((uint64) hi) << 32 | lo;
break;
case 'E':
if (sscanf(optarg, "%X/%X", &hi, &lo) != 2)
- {
- pg_log_error("could not parse end position \"%s\"", optarg);
- exit(1);
- }
+ pg_fatal("could not parse end position \"%s\"", optarg);
endpos = ((uint64) hi) << 32 | lo;
break;
case 'o':
break;
default:
-
- /*
- * getopt_long already emitted a complaint
- */
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ /* getopt_long already emitted a complaint */
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
{
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (replication_slot == NULL)
{
pg_log_error("no slot specified");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (do_start_slot && outfile == NULL)
{
pg_log_error("no target file specified");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (!do_drop_slot && dbname == NULL)
{
pg_log_error("no database specified");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (!do_drop_slot && !do_create_slot && !do_start_slot)
{
pg_log_error("at least one action needs to be specified");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (do_drop_slot && (do_create_slot || do_start_slot))
{
pg_log_error("cannot use --create-slot or --start together with --drop-slot");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (startpos != InvalidXLogRecPtr && (do_create_slot || do_drop_slot))
{
pg_log_error("cannot use --create-slot or --drop-slot together with --startpos");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (endpos != InvalidXLogRecPtr && !do_start_slot)
{
pg_log_error("--endpos may only be specified with --start");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (two_phase && !do_create_slot)
{
pg_log_error("--two-phase may only be specified with --create-slot");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
exit(1);
if (db_name == NULL)
- {
- pg_log_error("could not establish database-specific replication connection");
- exit(1);
- }
+ pg_fatal("could not establish database-specific replication connection");
/*
* Set umask so that directories/files are created with the same
exit(0);
}
else if (noloop)
- {
- pg_log_error("disconnected");
- exit(1);
- }
+ pg_fatal("disconnected");
else
{
/* translator: check source for value for %d */
/* fsync file in case of a previous crash */
if (stream->walmethod->sync(f) != 0)
{
- pg_log_fatal("could not fsync existing write-ahead log file \"%s\": %s",
+ pg_log_error("could not fsync existing write-ahead log file \"%s\": %s",
fn, stream->walmethod->getlasterror());
stream->walmethod->close(f, CLOSE_UNLINK);
exit(1);
if (stream->synchronous && lastFlushPosition < blockpos && walfile != NULL)
{
if (stream->walmethod->sync(walfile) != 0)
- {
- pg_log_fatal("could not fsync file \"%s\": %s",
- current_walfile_name, stream->walmethod->getlasterror());
- exit(1);
- }
+ pg_fatal("could not fsync file \"%s\": %s",
+ current_walfile_name, stream->walmethod->getlasterror());
lastFlushPosition = blockpos;
/*
* shutdown of the server.
*/
if (stream->walmethod->sync(walfile) != 0)
- {
- pg_log_fatal("could not fsync file \"%s\": %s",
- current_walfile_name, stream->walmethod->getlasterror());
- exit(1);
- }
+ pg_fatal("could not fsync file \"%s\": %s",
+ current_walfile_name, stream->walmethod->getlasterror());
lastFlushPosition = blockpos;
}
{
conn_opts = PQconninfoParse(connection_string, &err_msg);
if (conn_opts == NULL)
- {
- pg_log_error("%s", err_msg);
- exit(1);
- }
+ pg_fatal("%s", err_msg);
for (conn_opt = conn_opts; conn_opt->keyword != NULL; conn_opt++)
{
* and PQconnectdbParams returns NULL, we call exit(1) directly.
*/
if (!tmpconn)
- {
- pg_log_error("could not connect to server");
- exit(1);
- }
+ pg_fatal("could not connect to server");
/* If we need a password and -w wasn't given, loop back and get one */
if (PQstatus(tmpconn) == CONNECTION_BAD &&
if (tar_sync(f) < 0)
{
/* XXX this seems pretty bogus; why is only this case fatal? */
- pg_log_fatal("could not fsync file \"%s\": %s",
- tf->pathname, tar_getlasterror());
- exit(1);
+ pg_fatal("could not fsync file \"%s\": %s",
+ tf->pathname, tar_getlasterror());
}
/* Clean up and done */
f = open(fn, PG_BINARY | flags, 0);
if (f < 0)
- {
- pg_log_error("could not open file \"%s\": %m", fn);
- exit(1);
- }
+ pg_fatal("could not open file \"%s\": %m", fn);
files_scanned++;
if (r != BLCKSZ)
{
if (r < 0)
- pg_log_error("could not read block %u in file \"%s\": %m",
- blockno, fn);
+ pg_fatal("could not read block %u in file \"%s\": %m",
+ blockno, fn);
else
- pg_log_error("could not read block %u in file \"%s\": read %d of %d",
- blockno, fn, r, BLCKSZ);
- exit(1);
+ pg_fatal("could not read block %u in file \"%s\": read %d of %d",
+ blockno, fn, r, BLCKSZ);
}
blocks_scanned++;
/* Seek back to beginning of block */
if (lseek(f, -BLCKSZ, SEEK_CUR) < 0)
- {
- pg_log_error("seek failed for block %u in file \"%s\": %m", blockno, fn);
- exit(1);
- }
+ pg_fatal("seek failed for block %u in file \"%s\": %m", blockno, fn);
/* Write block with checksum */
w = write(f, buf.data, BLCKSZ);
if (w != BLCKSZ)
{
if (w < 0)
- pg_log_error("could not write block %u in file \"%s\": %m",
- blockno, fn);
+ pg_fatal("could not write block %u in file \"%s\": %m",
+ blockno, fn);
else
- pg_log_error("could not write block %u in file \"%s\": wrote %d of %d",
- blockno, fn, w, BLCKSZ);
- exit(1);
+ pg_fatal("could not write block %u in file \"%s\": wrote %d of %d",
+ blockno, fn, w, BLCKSZ);
}
}
snprintf(path, sizeof(path), "%s/%s", basedir, subdir);
dir = opendir(path);
if (!dir)
- {
- pg_log_error("could not open directory \"%s\": %m", path);
- exit(1);
- }
+ pg_fatal("could not open directory \"%s\": %m", path);
while ((de = readdir(dir)) != NULL)
{
char fn[MAXPGPATH];
snprintf(fn, sizeof(fn), "%s/%s", path, de->d_name);
if (lstat(fn, &st) < 0)
- {
- pg_log_error("could not stat file \"%s\": %m", fn);
- exit(1);
- }
+ pg_fatal("could not stat file \"%s\": %m", fn);
if (S_ISREG(st.st_mode))
{
char fnonly[MAXPGPATH];
*segmentpath++ = '\0';
segmentno = atoi(segmentpath);
if (segmentno == 0)
- {
- pg_log_error("invalid segment number %d in file name \"%s\"",
- segmentno, fn);
- exit(1);
- }
+ pg_fatal("invalid segment number %d in file name \"%s\"",
+ segmentno, fn);
}
forkpath = strchr(fnonly, '_');
path, de->d_name, TABLESPACE_VERSION_DIRECTORY);
if (lstat(tblspc_path, &tblspc_st) < 0)
- {
- pg_log_error("could not stat file \"%s\": %m",
- tblspc_path);
- exit(1);
- }
+ pg_fatal("could not stat file \"%s\": %m",
+ tblspc_path);
/*
* Move backwards once as the scan needs to happen for the
showprogress = true;
break;
default:
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ /* getopt_long already emitted a complaint */
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
if (DataDir == NULL)
{
pg_log_error("no data directory specified");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
{
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (mode != PG_MODE_CHECK && only_filenode)
{
pg_log_error("option -f/--filenode can only be used with --check");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
/* Read the control file and check compatibility */
ControlFile = get_controlfile(DataDir, &crc_ok);
if (!crc_ok)
- {
- pg_log_error("pg_control CRC value is incorrect");
- exit(1);
- }
+ pg_fatal("pg_control CRC value is incorrect");
if (ControlFile->pg_control_version != PG_CONTROL_VERSION)
- {
- pg_log_error("cluster is not compatible with this version of pg_checksums");
- exit(1);
- }
+ pg_fatal("cluster is not compatible with this version of pg_checksums");
if (ControlFile->blcksz != BLCKSZ)
{
pg_log_error("database cluster is not compatible");
- fprintf(stderr, _("The database cluster was initialized with block size %u, but pg_checksums was compiled with block size %u.\n"),
- ControlFile->blcksz, BLCKSZ);
+ pg_log_error_detail("The database cluster was initialized with block size %u, but pg_checksums was compiled with block size %u.",
+ ControlFile->blcksz, BLCKSZ);
exit(1);
}
*/
if (ControlFile->state != DB_SHUTDOWNED &&
ControlFile->state != DB_SHUTDOWNED_IN_RECOVERY)
- {
- pg_log_error("cluster must be shut down");
- exit(1);
- }
+ pg_fatal("cluster must be shut down");
if (ControlFile->data_checksum_version == 0 &&
mode == PG_MODE_CHECK)
- {
- pg_log_error("data checksums are not enabled in cluster");
- exit(1);
- }
+ pg_fatal("data checksums are not enabled in cluster");
if (ControlFile->data_checksum_version == 0 &&
mode == PG_MODE_DISABLE)
- {
- pg_log_error("data checksums are already disabled in cluster");
- exit(1);
- }
+ pg_fatal("data checksums are already disabled in cluster");
if (ControlFile->data_checksum_version > 0 &&
mode == PG_MODE_ENABLE)
- {
- pg_log_error("data checksums are already enabled in cluster");
- exit(1);
- }
+ pg_fatal("data checksums are already enabled in cluster");
/* Operate on all files if checking or enabling checksums */
if (mode == PG_MODE_CHECK || mode == PG_MODE_ENABLE)
break;
default:
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ /* getopt_long already emitted a complaint */
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
}
{
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
- progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
if (DataDir == NULL)
{
pg_log_error("no data directory specified");
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
strlcpy(full_path, progname, sizeof(full_path));
if (ret == -1)
- write_stderr(_("The program \"%s\" is needed by %s but was not found in the\n"
- "same directory as \"%s\".\n"
- "Check your installation.\n"),
+ write_stderr(_("program \"%s\" is needed by %s but was not found in the same directory as \"%s\"\n"),
target, progname, full_path);
else
- write_stderr(_("The program \"%s\" was found by \"%s\"\n"
- "but was not the same version as %s.\n"
- "Check your installation.\n"),
+ write_stderr(_("program \"%s\" was found by \"%s\" but was not the same version as %s\n"),
target, full_path, progname);
exit(1);
}
/* With partitions there can only be one parent */
if (tblinfo[i].numParents != 1)
- fatal("invalid number of parents %d for table \"%s\"",
- tblinfo[i].numParents,
- tblinfo[i].dobj.name);
+ pg_fatal("invalid number of parents %d for table \"%s\"",
+ tblinfo[i].numParents,
+ tblinfo[i].dobj.name);
attachinfo = (TableAttachInfo *) palloc(sizeof(TableAttachInfo));
attachinfo->dobj.objType = DO_TABLE_ATTACH;
parent = findTableByOid(inhinfo[i].inhparent);
if (parent == NULL)
- {
- pg_log_error("failed sanity check, parent OID %u of table \"%s\" (OID %u) not found",
- inhinfo[i].inhparent,
- self->dobj.name,
- oid);
- exit_nicely(1);
- }
+ pg_fatal("failed sanity check, parent OID %u of table \"%s\" (OID %u) not found",
+ inhinfo[i].inhparent,
+ self->dobj.name,
+ oid);
self->parents[j++] = parent;
}
}
if (j > 0)
{
if (argNum >= arraysize)
- {
- pg_log_error("could not parse numeric array \"%s\": too many numbers", str);
- exit_nicely(1);
- }
+ pg_fatal("could not parse numeric array \"%s\": too many numbers", str);
temp[j] = '\0';
array[argNum++] = atooid(temp);
j = 0;
{
if (!(isdigit((unsigned char) s) || s == '-') ||
j >= sizeof(temp) - 1)
- {
- pg_log_error("could not parse numeric array \"%s\": invalid character in number", str);
- exit_nicely(1);
- }
+ pg_fatal("could not parse numeric array \"%s\": invalid character in number", str);
temp[j++] = s;
}
}
*alg = COMPR_ALG_NONE;
else
{
- fatal("invalid compression code: %d", compression);
+ pg_fatal("invalid compression code: %d", compression);
*alg = COMPR_ALG_NONE; /* keep compiler quiet */
}
#ifndef HAVE_LIBZ
if (alg == COMPR_ALG_LIBZ)
- fatal("not built with zlib support");
+ pg_fatal("not built with zlib support");
#endif
cs = (CompressorState *) pg_malloc0(sizeof(CompressorState));
#ifdef HAVE_LIBZ
ReadDataFromArchiveZlib(AH, readF);
#else
- fatal("not built with zlib support");
+ pg_fatal("not built with zlib support");
#endif
}
}
#ifdef HAVE_LIBZ
WriteDataToArchiveZlib(AH, cs, data, dLen);
#else
- fatal("not built with zlib support");
+ pg_fatal("not built with zlib support");
#endif
break;
case COMPR_ALG_NONE:
cs->zlibOutSize = ZLIB_OUT_SIZE;
if (deflateInit(zp, level) != Z_OK)
- fatal("could not initialize compression library: %s",
- zp->msg);
+ pg_fatal("could not initialize compression library: %s",
+ zp->msg);
/* Just be paranoid - maybe End is called after Start, with no Write */
zp->next_out = (void *) cs->zlibOut;
DeflateCompressorZlib(AH, cs, true);
if (deflateEnd(zp) != Z_OK)
- fatal("could not close compression stream: %s", zp->msg);
+ pg_fatal("could not close compression stream: %s", zp->msg);
free(cs->zlibOut);
free(cs->zp);
{
res = deflate(zp, flush ? Z_FINISH : Z_NO_FLUSH);
if (res == Z_STREAM_ERROR)
- fatal("could not compress data: %s", zp->msg);
+ pg_fatal("could not compress data: %s", zp->msg);
if ((flush && (zp->avail_out < cs->zlibOutSize))
|| (zp->avail_out == 0)
|| (zp->avail_in != 0)
out = pg_malloc(ZLIB_OUT_SIZE + 1);
if (inflateInit(zp) != Z_OK)
- fatal("could not initialize compression library: %s",
- zp->msg);
+ pg_fatal("could not initialize compression library: %s",
+ zp->msg);
/* no minimal chunk size for zlib */
while ((cnt = readF(AH, &buf, &buflen)))
res = inflate(zp, 0);
if (res != Z_OK && res != Z_STREAM_END)
- fatal("could not uncompress data: %s", zp->msg);
+ pg_fatal("could not uncompress data: %s", zp->msg);
out[ZLIB_OUT_SIZE - zp->avail_out] = '\0';
ahwrite(out, 1, ZLIB_OUT_SIZE - zp->avail_out, AH);
zp->avail_out = ZLIB_OUT_SIZE;
res = inflate(zp, 0);
if (res != Z_OK && res != Z_STREAM_END)
- fatal("could not uncompress data: %s", zp->msg);
+ pg_fatal("could not uncompress data: %s", zp->msg);
out[ZLIB_OUT_SIZE - zp->avail_out] = '\0';
ahwrite(out, 1, ZLIB_OUT_SIZE - zp->avail_out, AH);
}
if (inflateEnd(zp) != Z_OK)
- fatal("could not close compression library: %s", zp->msg);
+ pg_fatal("could not close compression library: %s", zp->msg);
free(buf);
free(out);
fp = cfopen(fname, mode, compression);
free_keep_errno(fname);
#else
- fatal("not built with zlib support");
+ pg_fatal("not built with zlib support");
fp = NULL; /* keep compiler quiet */
#endif
}
fp = NULL;
}
#else
- fatal("not built with zlib support");
+ pg_fatal("not built with zlib support");
#endif
}
else
int errnum;
const char *errmsg = gzerror(fp->compressedfp, &errnum);
- fatal("could not read from input file: %s",
- errnum == Z_ERRNO ? strerror(errno) : errmsg);
+ pg_fatal("could not read from input file: %s",
+ errnum == Z_ERRNO ? strerror(errno) : errmsg);
}
}
else
if (ret == EOF)
{
if (!gzeof(fp->compressedfp))
- fatal("could not read from input file: %s", strerror(errno));
+ pg_fatal("could not read from input file: %s", strerror(errno));
else
- fatal("could not read from input file: end of file");
+ pg_fatal("could not read from input file: end of file");
}
}
else
../../common/exec.c ../../common/fe_memutils.c \
../../common/wait_error.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS) \
- fatal simple_prompt \
+ simple_prompt \
ExecuteSqlCommand:3 warn_or_exit_horribly:2
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS) \
- fatal:1:c-format \
warn_or_exit_horribly:2:c-format
/* Initialize socket access */
err = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (err != 0)
- {
- pg_log_error("%s() failed: error code %d", "WSAStartup", err);
- exit_nicely(1);
- }
+ pg_fatal("%s() failed: error code %d", "WSAStartup", err);
parallel_init_done = true;
}
*
* Note that we don't expect to come here during normal exit (the workers
* should be long gone, and the ParallelState too). We're only here in a
- * fatal() situation, so intervening to cancel active commands is
+ * pg_fatal() situation, so intervening to cancel active commands is
* appropriate.
*/
static void
/* Create communication pipes for this worker */
if (pgpipe(pipeMW) < 0 || pgpipe(pipeWM) < 0)
- fatal("could not create communication channels: %m");
+ pg_fatal("could not create communication channels: %m");
/* leader's ends of the pipes */
slot->pipeRead = pipeWM[PIPE_READ];
else if (pid < 0)
{
/* fork failed */
- fatal("could not create worker process: %m");
+ pg_fatal("could not create worker process: %m");
}
/* In Leader after successful fork */
Assert(*te != NULL);
}
else
- fatal("unrecognized command received from leader: \"%s\"",
- msg);
+ pg_fatal("unrecognized command received from leader: \"%s\"",
+ msg);
}
/*
AH->public.n_errors += n_errors;
}
else
- fatal("invalid message received from worker: \"%s\"",
- msg);
+ pg_fatal("invalid message received from worker: \"%s\"",
+ msg);
return status;
}
res = PQexec(AH->connection, query->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- fatal("could not obtain lock on relation \"%s\"\n"
- "This usually means that someone requested an ACCESS EXCLUSIVE lock "
- "on the table after the pg_dump parent process had gotten the "
- "initial ACCESS SHARE lock on the table.", qualId);
+ pg_fatal("could not obtain lock on relation \"%s\"\n"
+ "This usually means that someone requested an ACCESS EXCLUSIVE lock "
+ "on the table after the pg_dump parent process had gotten the "
+ "initial ACCESS SHARE lock on the table.", qualId);
PQclear(res);
destroyPQExpBuffer(query);
{
/* If do_wait is true, we must have detected EOF on some socket */
if (do_wait)
- fatal("a worker process died unexpectedly");
+ pg_fatal("a worker process died unexpectedly");
return false;
}
pstate->te[worker] = NULL;
}
else
- fatal("invalid message received from worker: \"%s\"",
- msg);
+ pg_fatal("invalid message received from worker: \"%s\"",
+ msg);
/* Free the string returned from getMessageFromWorker */
free(msg);
int len = strlen(str) + 1;
if (pipewrite(pipefd[PIPE_WRITE], str, len) != len)
- fatal("could not write to the communication channel: %m");
+ pg_fatal("could not write to the communication channel: %m");
}
/*
}
if (i < 0)
- fatal("%s() failed: %m", "select");
+ pg_fatal("%s() failed: %m", "select");
for (i = 0; i < pstate->numWorkers; i++)
{
if (pipewrite(pstate->parallelSlot[worker].pipeWrite, str, len) != len)
{
- fatal("could not write to the communication channel: %m");
+ pg_fatal("could not write to the communication channel: %m");
}
}
res = fclose(AH->OF);
if (res != 0)
- fatal("could not close output file: %m");
+ pg_fatal("could not close output file: %m");
}
/* Public */
/* ok no matter which section we were in */
break;
default:
- fatal("unexpected section code %d",
- (int) te->section);
+ pg_fatal("unexpected section code %d",
+ (int) te->section);
break;
}
}
{
/* We haven't got round to making this work for all archive formats */
if (AH->ClonePtr == NULL || AH->ReopenPtr == NULL)
- fatal("parallel restore is not supported with this archive file format");
+ pg_fatal("parallel restore is not supported with this archive file format");
/* Doesn't work if the archive represents dependencies as OIDs */
if (AH->version < K_VERS_1_8)
- fatal("parallel restore is not supported with archives made by pre-8.0 pg_dump");
+ pg_fatal("parallel restore is not supported with archives made by pre-8.0 pg_dump");
/*
* It's also not gonna work if we can't reopen the input file, so
for (te = AH->toc->next; te != AH->toc; te = te->next)
{
if (te->hadDumper && (te->reqs & REQ_DATA) != 0)
- fatal("cannot restore from compressed archive (compression not supported in this installation)");
+ pg_fatal("cannot restore from compressed archive (compression not supported in this installation)");
}
}
#endif
{
pg_log_info("connecting to database for restore");
if (AH->version < K_VERS_1_3)
- fatal("direct database connections are not supported in pre-1.3 archives");
+ pg_fatal("direct database connections are not supported in pre-1.3 archives");
/*
* We don't want to guess at whether the dump will successfully
ArchiveHandle *AH = (ArchiveHandle *) AHX;
if (!AH->currToc)
- fatal("internal error -- WriteData cannot be called outside the context of a DataDumper routine");
+ pg_fatal("internal error -- WriteData cannot be called outside the context of a DataDumper routine");
AH->WriteDataPtr(AH, data, dLen);
}
ArchiveHandle *AH = (ArchiveHandle *) AHX;
if (!AH->StartBlobPtr)
- fatal("large-object output not supported in chosen format");
+ pg_fatal("large-object output not supported in chosen format");
AH->StartBlobPtr(AH, AH->currToc, oid);
{
loOid = lo_create(AH->connection, oid);
if (loOid == 0 || loOid != oid)
- fatal("could not create large object %u: %s",
- oid, PQerrorMessage(AH->connection));
+ pg_fatal("could not create large object %u: %s",
+ oid, PQerrorMessage(AH->connection));
}
AH->loFd = lo_open(AH->connection, oid, INV_WRITE);
if (AH->loFd == -1)
- fatal("could not open large object %u: %s",
- oid, PQerrorMessage(AH->connection));
+ pg_fatal("could not open large object %u: %s",
+ oid, PQerrorMessage(AH->connection));
}
else
{
/* Setup the file */
fh = fopen(ropt->tocFile, PG_BINARY_R);
if (!fh)
- fatal("could not open TOC file \"%s\": %m", ropt->tocFile);
+ pg_fatal("could not open TOC file \"%s\": %m", ropt->tocFile);
initStringInfo(&linebuf);
/* Find TOC entry */
te = getTocEntryByDumpId(AH, id);
if (!te)
- fatal("could not find entry for ID %d",
- id);
+ pg_fatal("could not find entry for ID %d",
+ id);
/* Mark it wanted */
ropt->idWanted[id - 1] = true;
pg_free(linebuf.data);
if (fclose(fh) != 0)
- fatal("could not close TOC file: %m");
+ pg_fatal("could not close TOC file: %m");
}
/**********************
if (!AH->OF)
{
if (filename)
- fatal("could not open output file \"%s\": %m", filename);
+ pg_fatal("could not open output file \"%s\": %m", filename);
else
- fatal("could not open output file: %m");
+ pg_fatal("could not open output file: %m");
}
}
res = fclose(AH->OF);
if (res != 0)
- fatal("could not close output file: %m");
+ pg_fatal("could not close output file: %m");
AH->gzOut = savedContext.gzOut;
AH->OF = savedContext.OF;
case STAGE_INITIALIZING:
if (AH->stage != AH->lastErrorStage)
- pg_log_generic(PG_LOG_INFO, "while INITIALIZING:");
+ pg_log_info("while INITIALIZING:");
break;
case STAGE_PROCESSING:
if (AH->stage != AH->lastErrorStage)
- pg_log_generic(PG_LOG_INFO, "while PROCESSING TOC:");
+ pg_log_info("while PROCESSING TOC:");
break;
case STAGE_FINALIZING:
if (AH->stage != AH->lastErrorStage)
- pg_log_generic(PG_LOG_INFO, "while FINALIZING:");
+ pg_log_info("while FINALIZING:");
break;
}
if (AH->currentTE != NULL && AH->currentTE != AH->lastErrorTE)
{
- pg_log_generic(PG_LOG_INFO, "from TOC entry %d; %u %u %s %s %s",
- AH->currentTE->dumpId,
- AH->currentTE->catalogId.tableoid,
- AH->currentTE->catalogId.oid,
- AH->currentTE->desc ? AH->currentTE->desc : "(no desc)",
- AH->currentTE->tag ? AH->currentTE->tag : "(no tag)",
- AH->currentTE->owner ? AH->currentTE->owner : "(no owner)");
+ pg_log_info("from TOC entry %d; %u %u %s %s %s",
+ AH->currentTE->dumpId,
+ AH->currentTE->catalogId.tableoid,
+ AH->currentTE->catalogId.oid,
+ AH->currentTE->desc ? AH->currentTE->desc : "(no desc)",
+ AH->currentTE->tag ? AH->currentTE->tag : "(no tag)",
+ AH->currentTE->owner ? AH->currentTE->owner : "(no owner)");
}
AH->lastErrorStage = AH->stage;
AH->lastErrorTE = AH->currentTE;
va_start(ap, fmt);
- pg_log_generic_v(PG_LOG_ERROR, fmt, ap);
+ pg_log_generic_v(PG_LOG_ERROR, PG_LOG_PRIMARY, fmt, ap);
va_end(ap);
if (AH->public.exit_on_error)
{
/* this check is purely paranoia, maxDumpId should be correct */
if (te->dumpId <= 0 || te->dumpId > maxDumpId)
- fatal("bad dumpId");
+ pg_fatal("bad dumpId");
/* tocsByDumpId indexes all TOCs by their dump ID */
AH->tocsByDumpId[te->dumpId] = te;
* item's dump ID, so there should be a place for it in the array.
*/
if (tableId <= 0 || tableId > maxDumpId)
- fatal("bad table dumpId for TABLE DATA item");
+ pg_fatal("bad table dumpId for TABLE DATA item");
AH->tableDataId[tableId] = te->dumpId;
}
break;
default:
- fatal("unexpected data offset flag %d", offsetFlg);
+ pg_fatal("unexpected data offset flag %d", offsetFlg);
}
/*
else
{
if (AH->ReadBytePtr(AH) != 0)
- fatal("file offset in dump file is too large");
+ pg_fatal("file offset in dump file is too large");
}
}
char buf[MAXPGPATH];
if (snprintf(buf, MAXPGPATH, "%s/toc.dat", AH->fSpec) >= MAXPGPATH)
- fatal("directory name too long: \"%s\"",
- AH->fSpec);
+ pg_fatal("directory name too long: \"%s\"",
+ AH->fSpec);
if (stat(buf, &st) == 0 && S_ISREG(st.st_mode))
{
AH->format = archDirectory;
#ifdef HAVE_LIBZ
if (snprintf(buf, MAXPGPATH, "%s/toc.dat.gz", AH->fSpec) >= MAXPGPATH)
- fatal("directory name too long: \"%s\"",
- AH->fSpec);
+ pg_fatal("directory n