pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Dunstan <andrew@dunslane.net>
To: Mahendra Singh Thalor <mahi6run@gmail.com>
Cc: Álvaro Herrera <alvherre@kurilemu.de>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Non text modes for pg_dumpall, correspondingly change pg_restore
Date: Tue, 15 Apr 2025 07:17:51 -0400
Message-ID: <966de369-0109-42df-b250-42240ec20910@dunslane.net> (raw)
In-Reply-To: <CAKYtNAqPQJEGc5GSKiBEnCBCx1witrRauZ=2i0M4Fm4Rmug4_Q@mail.gmail.com>
References: <202504141220.343fmoxfsbj4@alvherre.pgsql>
	<6e0e57e5-ace5-4d18-b1c1-7a3b3da36316@dunslane.net>
	<17b357f9-7a99-4db2-87aa-a16679b52757@dunslane.net>
	<CAKYtNAqPQJEGc5GSKiBEnCBCx1witrRauZ=2i0M4Fm4Rmug4_Q@mail.gmail.com>


On 2025-04-14 Mo 6:55 PM, Mahendra Singh Thalor wrote:
>
>
>     --- a/src/bin/pg_dump/pg_restore.c
>     +++ b/src/bin/pg_dump/pg_restore.c
>     @@ -1053,15 +1053,19 @@ get_dbname_oid_list_from_mfile(const char
>     *dumpdirpath, SimpleOidStringList *dbn
>             while ((fgets(line, MAXPGPATH, pfile)) != NULL)
>             {
>                     Oid                     db_oid = InvalidOid;
>     -               char            db_oid_str[MAXPGPATH + 1] = "";
>                     char       *dbname;
>     +               char            *p = line;
>
>                     /* Extract dboid. */
>                     sscanf(line, "%u", &db_oid);
>     -               sscanf(line, "%20s", db_oid_str);
>     +
>     +               while(isdigit(*p))
>     +                       p++;
>     +
>     +               Assert(*p == ' ');
>
>                     /* dbname is the rest of the line */
>     -               dbname = line + strlen(db_oid_str) + 1;
>     +               dbname = ++p;
>
>                     /* Remove \n from dbname. */
>                     dbname[strlen(dbname) - 1] = '\0';
>
>

I don't think an Assert is the right thing here. It's for things that 
should not be possible, and won't trigger anything in a non-assertion 
build. This condition should cause a pg_fatal().


cheers


andrew


--
Andrew Dunstan
EDB:https://www.enterprisedb.com

view thread (10+ messages)  latest in thread

Message-ID: <966de369-0109-42df-b250-42240ec20910@dunslane.net>
Permalink:  ../966de369-0109-42df-b250-42240ec20910@dunslane.net/
Also on:    postgresql.org/message-id/966de369-0109-42df-b250-42240ec20910@dunslane.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andrew@dunslane.net, mahi6run@gmail.com, alvherre@kurilemu.de, pgsql-hackers@lists.postgresql.org
  Subject: Re: pgsql: Non text modes for pg_dumpall, correspondingly change pg_restore
  In-Reply-To: <966de369-0109-42df-b250-42240ec20910@dunslane.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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