*** a/src/bin/pg_dump/dumputils.c --- b/src/bin/pg_dump/dumputils.c *************** *** 38,44 **** static struct } on_exit_nicely_list[MAX_ON_EXIT_NICELY]; static int on_exit_nicely_index; - void (*on_exit_msg_func) (const char *modulename, const char *fmt, va_list ap) = vwrite_msg; #define supports_grant_options(version) ((version) >= 70400) --- 38,43 ---- *************** *** 1365,1386 **** vwrite_msg(const char *modulename, const char *fmt, va_list ap) vfprintf(stderr, _(fmt), ap); } - - /* - * Fail and die, with a message to stderr. Parameters as for write_msg. - */ - void - exit_horribly(const char *modulename, const char *fmt,...) - { - va_list ap; - - va_start(ap, fmt); - on_exit_msg_func(modulename, fmt, ap); - va_end(ap); - - exit_nicely(1); - } - /* Register a callback to be run when exit_nicely is invoked. */ void on_exit_nicely(on_exit_nicely_callback function, void *arg) --- 1364,1369 ---- *** a/src/bin/pg_dump/dumputils.h --- b/src/bin/pg_dump/dumputils.h *************** *** 44,51 **** typedef void (*on_exit_nicely_callback) (int code, void *arg); extern int quote_all_identifiers; extern const char *progname; - extern void (*on_exit_msg_func) (const char *modulename, const char *fmt, va_list ap) - __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0))); extern void init_parallel_dump_utils(void); extern const char *fmtId(const char *identifier); --- 44,49 ---- *************** *** 86,91 **** __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); --- 84,93 ---- extern void vwrite_msg(const char *modulename, const char *fmt, va_list ap) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0))); + /* + * exit_horribly is not implemented in dumputils.c. Rather, pg_dump and + * pg_dumpall have a different implementation of it, with the same signature. + */ extern void exit_horribly(const char *modulename, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3), noreturn)); *** a/src/bin/pg_dump/parallel.c --- b/src/bin/pg_dump/parallel.c *************** *** 72,87 **** typedef struct ShutdownInformation Archive *AHX; } ShutdownInformation; ! static ShutdownInformation shutdown_info; static const char *modulename = gettext_noop("parallel archiver"); static ParallelSlot *GetMyPSlot(ParallelState *pstate); static void - parallel_exit_msg_func(const char *modulename, - const char *fmt, va_list ap) - __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0))); - static void parallel_msg_master(ParallelSlot *slot, const char *modulename, const char *fmt, va_list ap) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0))); --- 72,83 ---- Archive *AHX; } ShutdownInformation; ! static ShutdownInformation shutdown_info = { NULL, NULL }; static const char *modulename = gettext_noop("parallel archiver"); static ParallelSlot *GetMyPSlot(ParallelState *pstate); static void parallel_msg_master(ParallelSlot *slot, const char *modulename, const char *fmt, va_list ap) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0))); *************** *** 129,157 **** GetMyPSlot(ParallelState *pstate) } /* ! * This is the function that will be called from exit_horribly() to print the ! * error message. If the worker process does exit_horribly(), we forward its ! * last words to the master process. The master process then does ! * exit_horribly() with this error message itself and prints it normally. ! * After printing the message, exit_horribly() on the master will shut down ! * the remaining worker processes. */ ! static void ! parallel_exit_msg_func(const char *modulename, const char *fmt, va_list ap) { ParallelState *pstate = shutdown_info.pstate; ParallelSlot *slot; ! Assert(pstate); ! slot = GetMyPSlot(pstate); ! ! if (!slot) ! /* We're the parent, just write the message out */ vwrite_msg(modulename, fmt, ap); else ! /* If we're a worker process, send the msg to the master process */ ! parallel_msg_master(slot, modulename, fmt, ap); } /* Sends the error message from the worker to the master process */ --- 125,168 ---- } /* ! * Fail and die, with a message to stderr. Parameters as for write_msg. ! * ! * This is defined in parallel.c because in parallel mode, things are more ! * complicated. If The worker process does exit_horribly(), we forward its last ! * words to the master process. The master process then does exit_horribly() ! * with this error message itself and prints it normally. After printing the ! * message, exit_horribly() on the master will shut down the remaining worker ! * processes. */ ! void ! exit_horribly(const char *modulename, const char *fmt,...) { + va_list ap; ParallelState *pstate = shutdown_info.pstate; ParallelSlot *slot; ! va_start(ap, fmt); ! if (pstate == NULL) ! { ! /* Not in parallel mode, just write it out */ vwrite_msg(modulename, fmt, ap); + } else ! { ! slot = GetMyPSlot(pstate); ! ! if (!slot) ! /* We're the parent, just write the message out */ ! vwrite_msg(modulename, fmt, ap); ! else ! /* If we're a worker process, send the msg to the master process */ ! parallel_msg_master(slot, modulename, fmt, ap); ! } ! ! va_end(ap); ! ! exit_nicely(1); } /* Sends the error message from the worker to the master process */ *************** *** 408,414 **** ParallelBackupStart(ArchiveHandle *AH, RestoreOptions *ropt) * set and falls back to AHX otherwise. */ shutdown_info.pstate = pstate; - on_exit_msg_func = parallel_exit_msg_func; #ifdef WIN32 tMasterThreadId = GetCurrentThreadId(); --- 419,424 ---- *** a/src/bin/pg_dump/pg_dumpall.c --- b/src/bin/pg_dump/pg_dumpall.c *************** *** 583,588 **** help(void) --- 583,602 ---- printf(_("Report bugs to .\n")); } + /* + * Fail and die, with a message to stderr. Parameters as for write_msg. + */ + void + exit_horribly(const char *modulename, const char *fmt,...) + { + va_list ap; + + va_start(ap, fmt); + vwrite_msg(modulename, fmt, ap); + va_end(ap); + + exit_nicely(1); + } /* * Drop roles