Fix casting away const-ness in pg_restore.c

This was intoduced in commit 763aaa06f0

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
This commit is contained in:
Andrew Dunstan 2026-03-04 15:44:45 -05:00
parent e6a1d8f5ac
commit 01c729e0c7

View 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\"",