mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
pg_dump: get rid of die_horribly
The old code was using exit_horribly or die_horribly other depending on whether it had an ArchiveHandle on which to close the connection or not; but there were places that were passing a NULL ArchiveHandle to die_horribly, and other places that used exit_horribly while having an AH available. So there wasn't all that much consistency. Improve the situation by keeping only one of the routines, and instead of having to pass the AH down from the caller, arrange for it to be present for an on_exit_nicely callback to operate on. Author: Joachim Wieland Some tweaks by me Per a suggestion from Robert Haas, in the ongoing "parallel pg_dump" saga.
This commit is contained in:
@@ -144,7 +144,6 @@ static int serializable_deferrable = 0;
|
||||
|
||||
|
||||
static void help(const char *progname);
|
||||
static void pgdump_cleanup_at_exit(int code, void *arg);
|
||||
static void setup_connection(Archive *AH, const char *dumpencoding,
|
||||
char *use_role);
|
||||
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
|
||||
@@ -575,7 +574,9 @@ main(int argc, char **argv)
|
||||
|
||||
/* Open the output file */
|
||||
fout = CreateArchive(filename, archiveFormat, compressLevel, archiveMode);
|
||||
on_exit_nicely(pgdump_cleanup_at_exit, fout);
|
||||
|
||||
/* Register the cleanup hook */
|
||||
on_exit_close_archive(fout);
|
||||
|
||||
if (fout == NULL)
|
||||
exit_horribly(NULL, "could not open output file \"%s\" for writing\n", filename);
|
||||
@@ -836,14 +837,6 @@ help(const char *progname)
|
||||
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
pgdump_cleanup_at_exit(int code, void *arg)
|
||||
{
|
||||
Archive *AH = (Archive *) arg;
|
||||
|
||||
DisconnectDatabase(AH);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_connection(Archive *AH, const char *dumpencoding, char *use_role)
|
||||
{
|
||||
|
Reference in New Issue
Block a user