pg_restore: remove unnecessary code from restore_all_databases function

From: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_restore: remove unnecessary code from restore_all_databases function
Date: 2026-03-15 03:48:26
Message-ID: CAKYtNAqN49Hqd4v0wWH3uW6d6QsH+8e8bR_MVf4CboTZSzd+Aw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

+++ b/src/bin/pg_dump/pg_restore.c
@@ -1268,16 +1268,6 @@ restore_all_databases(const char *inputFileSpec,
*/
memcpy(tmpopts, original_opts, sizeof(RestoreOptions));

- /*
- * We need to reset override_dbname so that objects can be
restored
- * into an already created database. (used with -d/--dbname
option)
- */
- if (tmpopts->cparams.override_dbname)
- {
- pfree(tmpopts->cparams.override_dbname);
- tmpopts->cparams.override_dbname = NULL;
- }
-

In commit 77152d26efefde2eed4, we added some functions and we missed to
remove some unnecessary lines. Those lines are not needed as we are using
memcpy to get the original copy before these lines.

Here, I am attaching a patch to fix this. Please review it.

--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
v01-pg_restore-remove-unnecessary-code-from-restore_all.patch text/x-patch 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mahendra Singh Thalor 2026-03-15 04:18:06 Re: pg_restore --format= option(without any value) should report an error as pg_dump is reporting an error
Previous Message Xuneng Zhou 2026-03-15 03:47:06 Re: Streamify more code paths