public inbox for [email protected]  
help / color / mirror / Atom feed
From: jian he <[email protected]>
To: Mahendra Singh Thalor <[email protected]>
Cc: tushar <[email protected]>
Cc: Vaibhav Dalvi <[email protected]>
Cc: [email protected]
Subject: Re: Non-text mode for pg_dumpall
Date: Fri, 2 Jan 2026 16:05:17 +0800
Message-ID: <CACJufxHc5Rp2roGyJOVnCk=Mx8_42_9vCGJSCFpLB5=AFQqHTQ@mail.gmail.com> (raw)
In-Reply-To: <CAKYtNApm8nA6hVMNkSjeNPiwTZBWYkhJKU7haQghUZdw74tYxA@mail.gmail.com>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<CAKYtNAr+OMjcGKwd+AgWA+s=8EWGtg5PkVV3O7X6d3eCv=MUeQ@mail.gmail.com>
	<CAKYtNApzLLeCqt5fHDzZOTnzCdCnBt3Y_fytFmJ0LMNHDPY-yA@mail.gmail.com>
	<CAKYtNArSYJdjez541C0qPZ9R3_yzPDpScAd=-RU4kPRCJh4viQ@mail.gmail.com>
	<CAKYtNArGUTzrfTBxpftL_yAgkKE+hcDgXVfQvjB2HFO9rGhE5g@mail.gmail.com>
	<CA+vB=AEQc3Xqz+KMh35Zsa-SsRP-n=HXGT4RwwNou4-__Prx+A@mail.gmail.com>
	<CAKYtNAqJqDmKcqCzpHg2SO=2MTxvE7rOWCACsoWsO7520tUWKw@mail.gmail.com>
	<CA+vB=AE9ypeQV-hhXscJ6T75BrAFfZh56GX_eM=eVG2n1o_Beg@mail.gmail.com>
	<CA+vB=AGsn4eUxsbLk_oy=iKzd8D_1Ne375XH-2u6Zncu72Q01Q@mail.gmail.com>
	<CAKYtNAqQ5LHWNWyaeVOJaS=2xDJovfv9GShTBzf8_5s=jH7wsg@mail.gmail.com>
	<CAKYtNAoSTBqR24cn3XDOnwk2DCL+nAUkjpB5Xkz1H74rDqa-aQ@mail.gmail.com>
	<[email protected]>
	<CAKYtNAoz9JZC+-Uo4QsA1O0PkEehxhTFy1y3HJjqzv6jwrXvCQ@mail.gmail.com>
	<CA+vB=AETksQZpjyBosrZv6N5A6DjaCtMQop3+MB8GDj0XnYoxQ@mail.gmail.com>
	<CAKYtNAoEUvYEG207zaGY0pEh6TB2sk6hpuz9LdG-fYEC=e2CgQ@mail.gmail.com>
	<CAKYtNAppx6y7M+9Fb5+TtTNhRS6onZo9kHeQS6yQF7PiK6qnEA@mail.gmail.com>
	<CAC6VRoZie9-iC9gWcJs3QGx=2_tA34fMBmj7Ck0VAP2JpDJGug@mail.gmail.com>
	<CAC6VRoZHZWzHZ0Oh++WW=9Q83co4AyG6u4+7HVi1gJiuv1CZ2g@mail.gmail.com>
	<CAC6VRoYWPQZeLDuKVNeMz5z-iiVnv0zWyBwWhxdm4UQO17-AUQ@mail.gmail.com>
	<CAKYtNAoNi8O1wbSZx0a1oSi-YzQtprxqpfZqryRq39hXn_p-OA@mail.gmail.com>
	<CAC6VRoYCqJq=0q3GF+vfDVbY4JUehqsuxYhcmVi7A=1hfNzSJg@mail.gmail.com>
	<CAKYtNApm8nA6hVMNkSjeNPiwTZBWYkhJKU7haQghUZdw74tYxA@mail.gmail.com>

On Tue, Dec 9, 2025 at 2:49 AM Mahendra Singh Thalor <[email protected]> wrote:
>
>
> Here, I am attaching an updated patch for the review and testing. This
> can be applied on commit d0d0ba6cf66c4043501f6f7.
>

hi.

more comments about
v12_09122025-Non-text-modes-for-pg_dumpall-correspondingly-change.patch

+        In all other modes, <application>pg_dumpall</application>
first creates two files:
+        <filename>toc.dat/toc.dmp/toc.tar</filename> and
<filename>map.dat</filename>, in the directory
+        specified by <option>--file</option>.
+        The first file contains global data, such as roles and
tablespaces. The second
+        contains a mapping between database oids and names. These
files are used by
+        <application>pg_restore</application>. Data for individual
databases is placed in
+        <filename>databases</filename> subdirectory, named using the
database's <type>oid</type>.

I tried all these 3 formats, there is no "toc.dmp/toc.tar".
Am I missing  something?


-
+   If format is given, then dump will be based on format, default plain.
 <screen>
 <prompt>$</prompt> <userinput>pg_dumpall &gt; db.out</userinput>
+</screen>
+
+<screen>
+<prompt>$</prompt> <userinput>pg_dumpall --format=d/a/c/p -f db.out</userinput>
 </screen>

The text in the <screen> section should work correctly when pasted directly into
the terminal.
but ``pg_dumpall --format=d/a/c/p -f db.out``
will error out:
``pg_dumpall: error: unrecognized output format "d/a/c/p"; please
specify "c", "d", "p", or "t"``


 PGresult *
-executeQuery(PGconn *conn, const char *query)
+executeQuery(PGconn *conn, const char *query, bool is_archive)
 {
  PGresult   *res;

@@ -287,7 +287,8 @@ executeQuery(PGconn *conn, const char *query)
  {
  pg_log_error("query failed: %s", PQerrorMessage(conn));
  pg_log_error_detail("Query was: %s", query);
- PQfinish(conn);
+ if (!is_archive)
+ PQfinish(conn);
  exit_nicely(1);
  }
It would be nice to add some comments explaining why we don't call
PQfinish for archive format.


+/*
+ * createOneArchiveEntry
+ *
+ * This creates one archive entry based on format.
+ */
+static void
+createOneArchiveEntry(const char *query, const char *tag)
+{
+ CatalogId nilCatalogId = {0, 0};
+ Assert(fout != NULL);
+
+ ArchiveEntry(fout,
+ nilCatalogId, /* catalog ID */
+ createDumpId(), /* dump ID */
+ ARCHIVE_OPTS(.tag = tag,
+ .description = tag,
+ .section = SECTION_PRE_DATA,
+ .createStmt = query));
+}
this is only used when archDumpFormat is not archNull.
comments can change to
"This creates one archive entry for non-text archive"



+static int
+restore_one_database(const char *inputFileSpec, RestoreOptions *opts,
+ int numWorkers, bool append_data, int num, bool globals_only)
I guess, "num" means number of databases, but the name is
"restore_one_database".
seems confusing. Similarly, I am confused by
restore_global_objects parameter "num".


+ pg_log_error("option %s must be specified when restoring an archive
created by pg_dumpall",
+ "-C/--create");
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
+ pg_log_error_hint("Individual databases can be restored using their
specific archives.");
Here we report that --create must be specified.
The second pg_log_error_hint() message about restoring individual databases
seems unrelated to this requirement, and seems confusing in this context.


get_dbnames_list_to_restore
+ if (!conn && db_exclude_patterns.head != NULL)
+ pg_log_info("considering PATTERN as NAME for --exclude-database
option as no database connection while doing pg_restore");
is unreachable. because conn is always not NULL,
Since restore_all_databases "template1", template database "template1" is
undroppable, see ``dbcommands.c:1734``.


get_dbname_oid_list_from_mfile does not handle database names that contain
newline characters correctly.
For example:
CREATE DATABASE "test
\r";

I am unable to dump and restore a database with such a name.



--
jian
https://www.enterprisedb.com/






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: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Non-text mode for pg_dumpall
  In-Reply-To: <CACJufxHc5Rp2roGyJOVnCk=Mx8_42_9vCGJSCFpLB5=AFQqHTQ@mail.gmail.com>

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

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