LCOV - code coverage report
Current view: top level - src/bin/pg_upgrade - dump.c (source / functions) Hit Total Coverage
Test: PostgreSQL 16devel Lines: 24 24 100.0 %
Date: 2022-12-05 10:11:06 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  dump.c
       3             :  *
       4             :  *  dump functions
       5             :  *
       6             :  *  Copyright (c) 2010-2022, PostgreSQL Global Development Group
       7             :  *  src/bin/pg_upgrade/dump.c
       8             :  */
       9             : 
      10             : #include "postgres_fe.h"
      11             : 
      12             : #include "fe_utils/string_utils.h"
      13             : #include "pg_upgrade.h"
      14             : 
      15             : void
      16           2 : generate_old_dump(void)
      17             : {
      18             :     int         dbnum;
      19             : 
      20           2 :     prep_status("Creating dump of global objects");
      21             : 
      22             :     /* run new pg_dumpall binary for globals */
      23           2 :     exec_prog(UTILITY_LOG_FILE, NULL, true, true,
      24             :               "\"%s/pg_dumpall\" %s --globals-only --quote-all-identifiers "
      25             :               "--binary-upgrade %s -f \"%s/%s\"",
      26             :               new_cluster.bindir, cluster_conn_opts(&old_cluster),
      27           2 :               log_opts.verbose ? "--verbose" : "",
      28             :               log_opts.dumpdir,
      29             :               GLOBALS_DUMP_FILE);
      30           2 :     check_ok();
      31             : 
      32           2 :     prep_status_progress("Creating dump of database schemas");
      33             : 
      34             :     /* create per-db dump files */
      35          14 :     for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
      36             :     {
      37             :         char        sql_file_name[MAXPGPATH],
      38             :                     log_file_name[MAXPGPATH];
      39          12 :         DbInfo     *old_db = &old_cluster.dbarr.dbs[dbnum];
      40             :         PQExpBufferData connstr,
      41             :                     escaped_connstr;
      42             : 
      43          12 :         initPQExpBuffer(&connstr);
      44          12 :         appendPQExpBufferStr(&connstr, "dbname=");
      45          12 :         appendConnStrVal(&connstr, old_db->db_name);
      46          12 :         initPQExpBuffer(&escaped_connstr);
      47          12 :         appendShellString(&escaped_connstr, connstr.data);
      48          12 :         termPQExpBuffer(&connstr);
      49             : 
      50          12 :         pg_log(PG_STATUS, "%s", old_db->db_name);
      51          12 :         snprintf(sql_file_name, sizeof(sql_file_name), DB_DUMP_FILE_MASK, old_db->db_oid);
      52          12 :         snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
      53             : 
      54          12 :         parallel_exec_prog(log_file_name, NULL,
      55             :                            "\"%s/pg_dump\" %s --schema-only --quote-all-identifiers "
      56             :                            "--binary-upgrade --format=custom %s --file=\"%s/%s\" %s",
      57             :                            new_cluster.bindir, cluster_conn_opts(&old_cluster),
      58          12 :                            log_opts.verbose ? "--verbose" : "",
      59             :                            log_opts.dumpdir,
      60             :                            sql_file_name, escaped_connstr.data);
      61             : 
      62          12 :         termPQExpBuffer(&escaped_connstr);
      63             :     }
      64             : 
      65             :     /* reap all children */
      66           2 :     while (reap_child(true) == true)
      67             :         ;
      68             : 
      69           2 :     end_progress_output();
      70           2 :     check_ok();
      71           2 : }

Generated by: LCOV version 1.14