PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_backup_utils.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * pg_backup_utils.h
4 * Utility routines shared by pg_dump and pg_restore.
5 *
6 *
7 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/bin/pg_dump/pg_backup_utils.h
11 *
12 *-------------------------------------------------------------------------
13 */
14
15#ifndef PG_BACKUP_UTILS_H
16#define PG_BACKUP_UTILS_H
17
18#include "common/logging.h"
19
20/* bits returned by set_dump_section */
21#define DUMP_PRE_DATA 0x01
22#define DUMP_DATA 0x02
23#define DUMP_POST_DATA 0x04
24#define DUMP_UNSECTIONED 0xff
25
26typedef void (*on_exit_nicely_callback) (int code, void *arg);
27
28extern const char *progname;
29
30extern void set_dump_section(const char *arg, int *dumpSections);
32pg_noreturn extern void exit_nicely(int code);
33
34/*
35 * On Windows the parallel workers are threads inside the leader process.
36 * When a cancel is processed there, the leader sends cancels to the workers'
37 * in-flight queries; without this flag each worker would then report the
38 * resulting "canceling statement due to user request" error and clutter the
39 * screen in the brief window before the whole process exits. The cancel
40 * thread sets this flag before sending any cancel, and worker threads check
41 * it before reporting a query failure.
42 *
43 * On other platforms the workers are separate processes that just _exit()
44 * when cancelled, so they never reach the error-reporting code; there the
45 * check is compiled out to a constant false and the underlying flag doesn't
46 * exist.
47 */
48#ifdef WIN32
49extern void set_cancel_in_progress(void);
50extern bool is_cancel_in_progress(void);
51#else
52#define is_cancel_in_progress() false
53#endif
54
55/* In pg_dump, we modify pg_fatal to call exit_nicely instead of exit */
56#undef pg_fatal
57#define pg_fatal(...) do { \
58 pg_log_generic(PG_LOG_ERROR, PG_LOG_PRIMARY, __VA_ARGS__); \
59 exit_nicely(1); \
60 } while(0)
61
62#endif /* PG_BACKUP_UTILS_H */
#define pg_noreturn
Definition c.h:249
Datum arg
Definition elog.c:1323
on_exit_nicely_callback function
void(* on_exit_nicely_callback)(int code, void *arg)
pg_noreturn void exit_nicely(int code)
void set_dump_section(const char *arg, int *dumpSections)
#define is_cancel_in_progress()
void on_exit_nicely(on_exit_nicely_callback function, void *arg)
const char * progname
Definition main.c:44
static int fb(int x)