]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix casting away const-ness in pg_restore.c
authorAndrew Dunstan <andrew@dunslane.net>
Wed, 4 Mar 2026 20:44:45 +0000 (15:44 -0500)
committerAndrew Dunstan <andrew@dunslane.net>
Wed, 4 Mar 2026 20:54:02 +0000 (15:54 -0500)
This was intoduced in commit 763aaa06f03

per gripe from Peter Eistentrut.

Author: Mahendra Singh Thalor <mahi6run@gmail.com>

Slightly tweaked by me.

Discussion: https://postgr.es/m/016819c0-666e-42a8-bfc8-2b93fd8d0176@eisentraut.org

src/bin/pg_dump/pg_restore.c

index 14d886fc86e8f6ea70afd50eda40fe4c332ae67f..f85cab4dc8e76a20667149d9a23cd9487bb9209e 100644 (file)
@@ -68,7 +68,7 @@ static int    restore_all_databases(const char *inputFileSpec,
 static int     get_dbnames_list_to_restore(PGconn *conn,
                                                                                SimplePtrList *dbname_oid_list,
                                                                                SimpleStringList db_exclude_patterns);
-static int     get_dbname_oid_list_from_mfile(char *dumpdirpath,
+static int     get_dbname_oid_list_from_mfile(const char *dumpdirpatharg,
                                                                                   SimplePtrList *dbname_oid_list);
 
 /*
@@ -1082,18 +1082,18 @@ get_dbnames_list_to_restore(PGconn *conn,
  * Returns, total number of database names in map.dat file.
  */
 static int
-get_dbname_oid_list_from_mfile(char *dumpdirpath, SimplePtrList *dbname_oid_list)
+get_dbname_oid_list_from_mfile(const char *dumpdirpatharg, SimplePtrList *dbname_oid_list)
 {
        StringInfoData linebuf;
        FILE       *pfile;
        char            map_file_path[MAXPGPATH];
        int                     count = 0;
        int                     len;
-
+       char       *dumpdirpath = pstrdup(dumpdirpatharg);
 
        /*
-        * If there is no map.dat file in dump, then return from here as there is
-        * no database to restore.
+        * If there is no map.dat file in the dump, then return from here as there
+        * is no database to restore.
         */
        if (!file_exists_in_directory(dumpdirpath, "map.dat"))
        {
@@ -1206,7 +1206,7 @@ restore_all_databases(const char *inputFileSpec,
        if (opts->cparams.dbname)
                connected_db = opts->cparams.dbname;
 
-       num_total_db = get_dbname_oid_list_from_mfile((char *) inputFileSpec, &dbname_oid_list);
+       num_total_db = get_dbname_oid_list_from_mfile(inputFileSpec, &dbname_oid_list);
 
        pg_log_info(ngettext("found %d database name in \"%s\"",
                                                 "found %d database names in \"%s\"",