LCOV - code coverage report
Current view: top level - src/bin/pg_upgrade - dump.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 24 24 100.0 %
Date: 2019-11-13 21:06:57 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-2019, 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",
      26             :               new_cluster.bindir, cluster_conn_opts(&old_cluster),
      27           2 :               log_opts.verbose ? "--verbose" : "",
      28             :               GLOBALS_DUMP_FILE);
      29           2 :     check_ok();
      30             : 
      31           2 :     prep_status("Creating dump of database schemas\n");
      32             : 
      33             :     /* create per-db dump files */
      34          14 :     for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
      35             :     {
      36             :         char        sql_file_name[MAXPGPATH],
      37             :                     log_file_name[MAXPGPATH];
      38          12 :         DbInfo     *old_db = &old_cluster.dbarr.dbs[dbnum];
      39             :         PQExpBufferData connstr,
      40             :                     escaped_connstr;
      41             : 
      42          12 :         initPQExpBuffer(&connstr);
      43          12 :         appendPQExpBufferStr(&connstr, "dbname=");
      44          12 :         appendConnStrVal(&connstr, old_db->db_name);
      45          12 :         initPQExpBuffer(&escaped_connstr);
      46          12 :         appendShellString(&escaped_connstr, connstr.data);
      47          12 :         termPQExpBuffer(&connstr);
      48             : 
      49          12 :         pg_log(PG_STATUS, "%s", old_db->db_name);
      50          12 :         snprintf(sql_file_name, sizeof(sql_file_name), DB_DUMP_FILE_MASK, old_db->db_oid);
      51          12 :         snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
      52             : 
      53          24 :         parallel_exec_prog(log_file_name, NULL,
      54             :                            "\"%s/pg_dump\" %s --schema-only --quote-all-identifiers "
      55             :                            "--binary-upgrade --format=custom %s --file=\"%s\" %s",
      56             :                            new_cluster.bindir, cluster_conn_opts(&old_cluster),
      57          12 :                            log_opts.verbose ? "--verbose" : "",
      58             :                            sql_file_name, escaped_connstr.data);
      59             : 
      60          12 :         termPQExpBuffer(&escaped_connstr);
      61             :     }
      62             : 
      63             :     /* reap all children */
      64           2 :     while (reap_child(true) == true)
      65             :         ;
      66             : 
      67           2 :     end_progress_output();
      68           2 :     check_ok();
      69           2 : }

Generated by: LCOV version 1.13