PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
dump.c File Reference
#include "postgres_fe.h"
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
Include dependency graph for dump.c:

Go to the source code of this file.

Functions

void generate_old_dump (void)
 

Function Documentation

◆ generate_old_dump()

void generate_old_dump ( void  )

Definition at line 16 of file dump.c.

17{
18 int dbnum;
19
20 prep_status("Creating dump of global objects");
21
22 /* run new pg_dumpall binary for globals */
23 exec_prog(UTILITY_LOG_FILE, NULL, true, true,
24 "\"%s/pg_dumpall\" %s --globals-only --quote-all-identifiers "
25 "--binary-upgrade %s --no-sync -f \"%s/%s\"",
27 log_opts.verbose ? "--verbose" : "",
30 check_ok();
31
32 prep_status_progress("Creating dump of database schemas");
33
34 /* create per-db dump files */
35 for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
36 {
37 char sql_file_name[MAXPGPATH],
38 log_file_name[MAXPGPATH];
39 DbInfo *old_db = &old_cluster.dbarr.dbs[dbnum];
41 escaped_connstr;
42
44 appendPQExpBufferStr(&connstr, "dbname=");
46 initPQExpBuffer(&escaped_connstr);
47 appendShellString(&escaped_connstr, connstr.data);
49
50 pg_log(PG_STATUS, "%s", old_db->db_name);
51 snprintf(sql_file_name, sizeof(sql_file_name), DB_DUMP_FILE_MASK, old_db->db_oid);
52 snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
53
54 parallel_exec_prog(log_file_name, NULL,
55 "\"%s/pg_dump\" %s --schema-only --quote-all-identifiers "
56 "--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s",
58 log_opts.verbose ? "--verbose" : "",
60 sql_file_name, escaped_connstr.data);
61
62 termPQExpBuffer(&escaped_connstr);
63 }
64
65 /* reap all children */
66 while (reap_child(true) == true)
67 ;
68
70 check_ok();
71}
bool exec_prog(const char *log_filename, const char *opt_log_file, bool report_error, bool exit_on_error, const char *fmt,...)
Definition: exec.c:85
bool reap_child(bool wait_for_child)
Definition: parallel.c:278
void parallel_exec_prog(const char *log_file, const char *opt_log_file, const char *fmt,...)
Definition: parallel.c:62
static void check_ok(void)
Definition: initdb.c:2119
#define MAXPGPATH
static char * connstr
Definition: pg_dumpall.c:88
ClusterInfo new_cluster
Definition: pg_upgrade.c:68
ClusterInfo old_cluster
Definition: pg_upgrade.c:67
PGresult char * cluster_conn_opts(ClusterInfo *cluster)
Definition: server.c:92
#define GLOBALS_DUMP_FILE
Definition: pg_upgrade.h:30
#define DB_DUMP_LOG_FILE_MASK
Definition: pg_upgrade.h:43
#define UTILITY_LOG_FILE
Definition: pg_upgrade.h:45
void void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2
LogOpts log_opts
Definition: util.c:17
void void prep_status_progress(const char *fmt,...) pg_attribute_printf(1
@ PG_STATUS
Definition: pg_upgrade.h:267
void prep_status(const char *fmt,...) pg_attribute_printf(1
void end_progress_output(void)
Definition: util.c:43
#define DB_DUMP_FILE_MASK
Definition: pg_upgrade.h:31
#define snprintf
Definition: port.h:238
void initPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:90
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
Definition: pqexpbuffer.c:367
void termPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:129
void appendShellString(PQExpBuffer buf, const char *str)
Definition: string_utils.c:429
void appendConnStrVal(PQExpBuffer buf, const char *str)
Definition: string_utils.c:545
char * bindir
Definition: pg_upgrade.h:288
DbInfoArr dbarr
Definition: pg_upgrade.h:284
DbInfo * dbs
Definition: pg_upgrade.h:215
char * db_name
Definition: pg_upgrade.h:194
Oid db_oid
Definition: pg_upgrade.h:193
char * dumpdir
Definition: pg_upgrade.h:312
bool verbose
Definition: pg_upgrade.h:307

References appendConnStrVal(), appendPQExpBufferStr(), appendShellString(), ClusterInfo::bindir, check_ok(), cluster_conn_opts(), connstr, PQExpBufferData::data, DB_DUMP_FILE_MASK, DB_DUMP_LOG_FILE_MASK, DbInfo::db_name, DbInfo::db_oid, ClusterInfo::dbarr, DbInfoArr::dbs, LogOpts::dumpdir, end_progress_output(), exec_prog(), GLOBALS_DUMP_FILE, initPQExpBuffer(), log_opts, MAXPGPATH, DbInfoArr::ndbs, new_cluster, old_cluster, parallel_exec_prog(), pg_log(), PG_STATUS, prep_status(), prep_status_progress(), reap_child(), snprintf, termPQExpBuffer(), UTILITY_LOG_FILE, and LogOpts::verbose.

Referenced by check_and_dump_old_cluster().