public inbox for [email protected]  
help / color / mirror / Atom feed
pg_restore: remove unnecessary code from restore_all_databases function
2+ messages / 1 participants
[nested] [flat]

* pg_restore: remove unnecessary code from restore_all_databases function
@ 2026-03-15 03:48 Mahendra Singh Thalor <[email protected]>
  2026-03-15 17:33 ` Re: pg_restore: remove unnecessary code from restore_all_databases function Mahendra Singh Thalor <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Mahendra Singh Thalor @ 2026-03-15 03:48 UTC (permalink / raw)
  To: 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


Attachments:

  [text/x-patch] v01-pg_restore-remove-unnecessary-code-from-restore_all.patch (1.2K, 3-v01-pg_restore-remove-unnecessary-code-from-restore_all.patch)
  download | inline diff:
From 162bf76e8c42bf134b04cb49935602610772e9ff Mon Sep 17 00:00:00 2001
From: Mahendra Singh Thalor <[email protected]>
Date: Sun, 15 Mar 2026 09:02:59 +0530
Subject: [PATCH] pg_restore: remove unnecessary code from
 restore_all_databases

In commit 77152d26efefde2eed4, we added some functions and we
missed to remove some unnecessary lines as before these lines
we are using memcpy to get original copy.
---
 src/bin/pg_dump/pg_restore.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index fb44c0cfdfe..9b4b151b318 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ 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;
-		}
-
 		snprintf(subdirdbpath, MAXPGPATH, "%s/databases", inputFileSpec);
 
 		/*
-- 
2.52.0



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: pg_restore: remove unnecessary code from restore_all_databases function
  2026-03-15 03:48 pg_restore: remove unnecessary code from restore_all_databases function Mahendra Singh Thalor <[email protected]>
@ 2026-03-15 17:33 ` Mahendra Singh Thalor <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Mahendra Singh Thalor @ 2026-03-15 17:33 UTC (permalink / raw)
  To: Andrew Dunstan <[email protected]>; +Cc: pgsql-hackers

On Sun, 15 Mar 2026 at 21:46, Andrew Dunstan <[email protected]> wrote:
>
>
> On 2026-03-14 Sa 11:48 PM, Mahendra Singh Thalor wrote:
> > 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. Pushed.
>
>
> cheers
>
>
> andrew
>
>
> --
> Andrew Dunstan
> EDB: https://www.enterprisedb.com
>

Thanks Andrew for committing this.

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-03-15 17:33 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-15 03:48 pg_restore: remove unnecessary code from restore_all_databases function Mahendra Singh Thalor <[email protected]>
2026-03-15 17:33 ` Mahendra Singh Thalor <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox