]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Improve writing map.dat preamble
authorAndrew Dunstan <andrew@dunslane.net>
Wed, 4 Mar 2026 21:08:04 +0000 (16:08 -0500)
committerAndrew Dunstan <andrew@dunslane.net>
Wed, 4 Mar 2026 21:08:04 +0000 (16:08 -0500)
Fix code from commit 763aaa06f03

Suggestion from Alvaro Herrera following a bug discovered by Coverity.

src/bin/pg_dump/pg_dumpall.c

index 1165a0f4afe4ea35a2d9e48d9a95d92b0ef97d8d..56e25f9b1562627d5ff035025f1bcec575708569 100644 (file)
@@ -2019,19 +2019,6 @@ dumpDatabases(PGconn *conn)
        if (archDumpFormat != archNull)
        {
                char            map_file_path[MAXPGPATH];
-               char       *map_preamble[] = {
-                       "#################################################################",
-                       "# map.dat",
-                       "#",
-                       "# This file maps oids to database names",
-                       "#",
-                       "# pg_restore will restore all the databases listed here, unless",
-                       "# otherwise excluded. You can also inhibit restoration of a",
-                       "# database by removing the line or commenting out the line with"
-                       "# a # mark.",
-                       "#################################################################",
-                       NULL
-               };
 
                snprintf(db_subdir, MAXPGPATH, "%s/databases", filename);
 
@@ -2046,8 +2033,17 @@ dumpDatabases(PGconn *conn)
                if (!map_file)
                        pg_fatal("could not open file \"%s\": %m", map_file_path);
 
-               for (char **line = map_preamble; *line; line++)
-                       fprintf(map_file, "%s\n", *line);
+               fprintf(map_file,
+                               "#################################################################\n"
+                               "# map.dat\n"
+                               "#\n"
+                               "# This file maps oids to database names\n"
+                               "#\n"
+                               "# pg_restore will restore all the databases listed here, unless\n"
+                               "# otherwise excluded. You can also inhibit restoration of a\n"
+                               "# database by removing the line or commenting out the line with\n"
+                               "# a # mark.\n"
+                               "#################################################################\n");
        }
 
        for (i = 0; i < PQntuples(res); i++)