Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

dump.c File Reference

#include "postgres_fe.h"
#include "pg_upgrade.h"
#include <sys/types.h>
Include dependency graph for dump.c:

Go to the source code of this file.

Functions

void generate_old_dump (void)

Function Documentation

void generate_old_dump ( void   ) 

Definition at line 17 of file dump.c.

References ClusterInfo::bindir, check_ok(), cluster_conn_opts(), DB_DUMP_FILE_MASK, DB_DUMP_LOG_FILE_MASK, DbInfo::db_name, DbInfo::db_oid, ClusterInfo::dbarr, DbInfoArr::dbs, end_progress_output(), exec_prog(), GLOBALS_DUMP_FILE, log_opts, DbInfoArr::ndbs, new_cluster, NULL, old_cluster, parallel_exec_prog(), pg_log(), PG_STATUS, prep_status(), reap_child(), snprintf(), UTILITY_LOG_FILE, and LogOpts::verbose.

Referenced by check_and_dump_old_cluster().

{
    int         dbnum;

    prep_status("Creating dump of global objects");

    /* run new pg_dumpall binary for globals */
    exec_prog(UTILITY_LOG_FILE, NULL, true,
              "\"%s/pg_dumpall\" %s --schema-only --globals-only --binary-upgrade %s -f %s",
              new_cluster.bindir, cluster_conn_opts(&old_cluster),
              log_opts.verbose ? "--verbose" : "",
              GLOBALS_DUMP_FILE);
    check_ok();

    prep_status("Creating dump of database schemas\n");

    /* create per-db dump files */
    for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
    {
        char        sql_file_name[MAXPGPATH], log_file_name[MAXPGPATH];
        DbInfo     *old_db = &old_cluster.dbarr.dbs[dbnum];

        pg_log(PG_STATUS, "%s", old_db->db_name);
        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);

        parallel_exec_prog(log_file_name, NULL,
                  "\"%s/pg_dump\" %s --schema-only --binary-upgrade --format=custom %s --file=\"%s\" \"%s\"",
                  new_cluster.bindir, cluster_conn_opts(&old_cluster),
                  log_opts.verbose ? "--verbose" : "", sql_file_name, old_db->db_name);
    }

    /* reap all children */
    while (reap_child(true) == true)
        ;
                
    end_progress_output();
    check_ok();
}