Re: Non-text mode for pg_dumpall

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>, Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
Cc: Vaibhav Dalvi <vaibhav(dot)dalvi(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Non-text mode for pg_dumpall
Date: 2025-11-04 16:55:28
Message-ID: b8c8891c-b05b-480c-8166-1636d954b43e@dunslane.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2025-11-04 Tu 7:53 AM, tushar wrote:
>
>
> On Mon, Nov 3, 2025 at 5:25 PM Mahendra Singh Thalor
> <mahi6run(at)gmail(dot)com> wrote:
>
> On Mon, 3 Nov 2025 at 12:06, Vaibhav Dalvi
> <vaibhav(dot)dalvi(at)enterprisedb(dot)com> wrote:
> >
> > Hi Mahendra,
> >
> > Thank you for your work on this feature.
> > I have just begun reviewing the latest patch and
> > encountered the following errors during the initial setup:
> >
> > ```
> > $ ./db/bin/pg_restore testdump_dir -C -d postgres -F d -p 5556
> > pg_restore: error: could not execute query: ERROR: syntax error
> at or near "\\"
> > LINE 1: \restrict
> aO9K1gzVZTlafidF5fWx8ADGzUnIiAcguFz5qskGaFDygTCjCj...
> > ^
> > Command was: \restrict
> aO9K1gzVZTlafidF5fWx8ADGzUnIiAcguFz5qskGaFDygTCjCj9vg3Xxys1b3hb
> >
> > pg_restore: error: could not execute query: ERROR: syntax error
> at or near "\\"
> > LINE 1: \unrestrict
> aO9K1gzVZTlafidF5fWx8ADGzUnIiAcguFz5qskGaFDygTCj...
> > ^
> > Command was: \unrestrict
> aO9K1gzVZTlafidF5fWx8ADGzUnIiAcguFz5qskGaFDygTCjCj9vg3Xxys1b3hb
> >
> > pg_restore: error: could not execute query: ERROR: syntax error
> at or near "\\"
> > LINE 1: \connect template1
> > ^
> > Command was: \connect template1
> >
> > pg_restore: error: could not execute query: ERROR: syntax error
> at or near "\\"
> > LINE 1: \connect postgres
> > ^
> > Command was: \connect postgres
> > ```
> > To cross-check tried with plain dump(with pg_dumpall) and
> >  restored(SQL file restore) without patch and didn't get above
> > connection errors.
> >
> > It appears there might be an issue with the dump file itself.
> > Please note that this is my first observation as I have just
> > started the review. I will continue with my assessment.
> >
> > Regards,
> > Vaibhav Dalvi
> > EnterpriseDB
>
> Thanks Vaibhav for the review.
> This change was added by me in v04. Only in the case of a file, we
> should restore these commands. Attached patch is fixing the same.
>
> Thanks Mahendra, I am getting a segmentation fault against v05 patch.
>
> [edb(at)1a1c15437e7c bin]$ ./pg_dumpall -Ft   --file  a.3 -v
> pg_dumpall: executing SELECT pg_catalog.set_config('search_path', '',
> false);
> Segmentation fault
>
> Issue is coming with all output file formats -F[t/c/d] except plain
>
>

Yeah, I don't think we need to dump the timestamp in non-text modes.
This fix worked for me:

diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 601b9f9738e..f66cc26d9a2 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -638,7 +638,7 @@ main(int argc, char *argv[])
    if (quote_all_identifiers)
        executeCommand(conn, "SET quote_all_identifiers = true");

-   if (verbose)
+   if (verbose && archDumpFormat == archNull)
        dumpTimestamp("Started on");

    /* create a archive file for global commands. */
@@ -2258,6 +2258,7 @@ createDumpId(void)
 static void
 createOneArchiveEntry(const char *query, const char *tag)
 {
+   Assert(fout != NULL);
    ArchiveEntry(fout,
            nilCatalogId, /* catalog ID */
            createDumpId(), /* dump ID */

cheers

andrew

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-11-04 16:58:00 Re: [PATCH] Fix ALTER SYSTEM empty string bug for GUC_LIST_QUOTE parameters
Previous Message Álvaro Herrera 2025-11-04 16:49:31 Re: BRIN autosummarization lacking a snapshot