2010-05-12 04:19:11 +02:00
|
|
|
/*
|
|
|
|
* dump.c
|
|
|
|
*
|
|
|
|
* dump functions
|
2010-07-03 16:23:14 +02:00
|
|
|
*
|
2013-01-01 23:15:01 +01:00
|
|
|
* Copyright (c) 2010-2013, PostgreSQL Global Development Group
|
2010-09-20 22:08:53 +02:00
|
|
|
* contrib/pg_upgrade/dump.c
|
2010-05-12 04:19:11 +02:00
|
|
|
*/
|
|
|
|
|
2011-08-27 03:16:24 +02:00
|
|
|
#include "postgres.h"
|
|
|
|
|
2010-05-12 04:19:11 +02:00
|
|
|
#include "pg_upgrade.h"
|
|
|
|
|
2012-03-13 00:47:54 +01:00
|
|
|
#include <sys/types.h>
|
2010-05-12 04:19:11 +02:00
|
|
|
|
|
|
|
void
|
2010-10-19 23:38:16 +02:00
|
|
|
generate_old_dump(void)
|
2010-05-12 04:19:11 +02:00
|
|
|
{
|
2012-11-30 22:30:13 +01:00
|
|
|
int dbnum;
|
2010-05-12 04:19:11 +02:00
|
|
|
|
2012-12-01 04:32:19 +01:00
|
|
|
prep_status("Creating dump of global objects");
|
2012-11-30 22:30:13 +01:00
|
|
|
|
|
|
|
/* run new pg_dumpall binary for globals */
|
2012-08-27 20:21:09 +02:00
|
|
|
exec_prog(UTILITY_LOG_FILE, NULL, true,
|
2012-11-30 22:30:13 +01:00
|
|
|
"\"%s/pg_dumpall\" %s --schema-only --globals-only --binary-upgrade %s -f %s",
|
2012-09-03 19:52:34 +02:00
|
|
|
new_cluster.bindir, cluster_conn_opts(&old_cluster),
|
2012-03-13 00:47:54 +01:00
|
|
|
log_opts.verbose ? "--verbose" : "",
|
2012-11-30 22:30:13 +01:00
|
|
|
GLOBALS_DUMP_FILE);
|
2012-12-01 04:32:19 +01:00
|
|
|
check_ok();
|
|
|
|
|
|
|
|
prep_status("Creating dump of database schemas\n");
|
2012-09-05 23:41:43 +02:00
|
|
|
|
2012-11-30 22:30:13 +01:00
|
|
|
/* create per-db dump files */
|
|
|
|
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
|
2010-05-12 04:19:11 +02:00
|
|
|
{
|
2012-12-27 01:26:30 +01:00
|
|
|
char sql_file_name[MAXPGPATH], log_file_name[MAXPGPATH];
|
2012-11-30 22:30:13 +01:00
|
|
|
DbInfo *old_db = &old_cluster.dbarr.dbs[dbnum];
|
2010-05-12 04:19:11 +02:00
|
|
|
|
2012-12-07 18:26:13 +01:00
|
|
|
pg_log(PG_STATUS, "%s", old_db->db_name);
|
2012-12-27 01:26:30 +01:00
|
|
|
snprintf(sql_file_name, sizeof(sql_file_name), DB_DUMP_FILE_MASK, old_db->db_oid);
|
|
|
|
snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
|
2010-05-12 04:19:11 +02:00
|
|
|
|
2012-12-27 01:26:30 +01:00
|
|
|
parallel_exec_prog(log_file_name, NULL,
|
2012-11-30 22:30:13 +01:00
|
|
|
"\"%s/pg_dump\" %s --schema-only --binary-upgrade --format=custom %s --file=\"%s\" \"%s\"",
|
|
|
|
new_cluster.bindir, cluster_conn_opts(&old_cluster),
|
2012-12-27 01:26:30 +01:00
|
|
|
log_opts.verbose ? "--verbose" : "", sql_file_name, old_db->db_name);
|
2010-05-12 04:19:11 +02:00
|
|
|
}
|
|
|
|
|
2012-12-27 01:26:30 +01:00
|
|
|
/* reap all children */
|
|
|
|
while (reap_child(true) == true)
|
|
|
|
;
|
|
|
|
|
2012-11-30 22:30:13 +01:00
|
|
|
end_progress_output();
|
|
|
|
check_ok();
|
2010-05-12 04:19:11 +02:00
|
|
|
}
|