aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_dump.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2012-03-20 18:38:11 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2012-03-20 18:58:00 -0300
commit9d23a70d513aa1312135d6cedd444e7e3e933edb (patch)
treef816220425ed6012b91e904ff7a6e2c124728cea /src/bin/pg_dump/pg_dump.c
parentb251cf31936b4507ad8ba78f34a14f592c664f43 (diff)
downloadpostgresql-9d23a70d513aa1312135d6cedd444e7e3e933edb.tar.gz
postgresql-9d23a70d513aa1312135d6cedd444e7e3e933edb.zip
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.
Diffstat (limited to 'src/bin/pg_dump/pg_dump.c')
-rw-r--r--src/bin/pg_dump/pg_dump.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 4545f97a63d..14389bd0d37 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -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);
@@ -837,14 +838,6 @@ help(const char *progname)
}
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)
{
PGconn *conn = GetConnection(AH);