Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vbaAZ-0088lK-14 for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Jan 2026 08:06:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vbaAY-009gTe-0K for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Jan 2026 08:05:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vbaAX-009gTW-2T for pgsql-hackers@lists.postgresql.org; Fri, 02 Jan 2026 08:05:58 +0000 Received: from mail-vk1-xa2e.google.com ([2607:f8b0:4864:20::a2e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vbaAV-0043I0-21 for pgsql-hackers@lists.postgresql.org; Fri, 02 Jan 2026 08:05:58 +0000 Received: by mail-vk1-xa2e.google.com with SMTP id 71dfb90a1353d-55b6a642a4cso8321400e0c.3 for ; Fri, 02 Jan 2026 00:05:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767341154; x=1767945954; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KnWB+ciwbrbJwgYjJ71fzoJm1I8T5m3poSJe4NMuOK8=; b=Uw5/2KoU6lmN0UhYqhsSCrL41oqgCCJdRJefxjzcLFTQkE266i8Mgl+QoJ5zkaUA+b z732KJB3or8k7WUQesdR/KK99mSNb4lyvTWh3wl9qAZtl1De4Hr3vJp/0tvb1801AGaM xeLo5j5CVhtNSJ9WtjkYZLZ1eYvdahWqSVhasxPmC/ixjXzG8rhNcFFWfe2gG0DS3ahh i9QU2Ra6JzcMfvQ8uN6Bk46fg80upL1u06SNYxJtnGqLAXTpJ7NYOZmQtkyT70BZFzCj 9EZskGpov+v6gaRQfvSSrsxGi5ddWpinl7T6cIWqWxhf+odFoqRFeZ4ll05V43Hf8vjx 6ksg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767341154; x=1767945954; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=KnWB+ciwbrbJwgYjJ71fzoJm1I8T5m3poSJe4NMuOK8=; b=QbXDp2yeIuEk0SPokaHlm8/83YqDsXMUmLBovJbIPG2PS0Nrr/jhbR2uciXQoHmSmp zzflqMRnNcHYAGuUTTIXShme25/Thiw/qzoc47ow6zpdsVaw/SnwvoeVxuiZ/SRpWG8p ZWOpHCiz9LohlRWRypvBLtBQZmdkeIhWpOVG3ghdzy/BWEBVkOQJhh/jktgmzdXjY8un st4oks4DbisgchcZrmk/SovTkr7QEoiKzdEyersYV2tFsGwcFp1HL3K8mubbA+34n6Yo 23h8D/G41xfh9iF3RKNB3Se706ca8CdlV3m2Rx31hUUxCW74sTDYaiIUOT684nxqcnNU qvlA== X-Forwarded-Encrypted: i=1; AJvYcCUycRQr44CuOVhzEA6xQ7RW5ci1GVLoBoFyFoVIWQy0TCmxYcqiMGP/LaGRPJtuV6v9GF/bGzXD69uUKQpq@lists.postgresql.org X-Gm-Message-State: AOJu0YzvBj9BkkgogL6zcKVXrEiLPKuZPGvHsd8VB+fEYUyBvkENEO/D +QInIL8Oe1n6qwueojYO2AOprG8iGx5SP2KU+wQUo1XW6EEG0RKEtdeOZAXzA3llFrJAUXCQAjF vp0il1SJkz1uZMzRO0AhOhJeSBfBwnyk= X-Gm-Gg: AY/fxX6k6NOKjo+qfqEMaiwQW1A8szkORYoVoX2kGxnj2D52KXOMsaZj4yG9jzfHfb+ 4lnXR2wC0pXCb1R7ZPJYaBZMgHVuvUEbDMHziPkHWiWqzXTA3KwymbH0krugAI4zXgtnZCOr727 8k3xjAL3m2lzyAGBQTOMO2RCUDsKW8qkcka0xyDzhV4NHMlmsVVcbedU86GSapYLDJaSJjT4rma yzD/t4nI9UiTlM8XHYNXm02nziGNgVb3+zLOhKdHOZkxlGzN+9hKvKJK4jQLIfsXckyuskm3gEi 1k9oTCI39yGKgBpNpl2H/EBZkATHAHpbNBmjvDa/5zFzCGllak8i+4Xp1kdk9hdUBQCqTt+sxJD NolbhbQw30YejcWdQ1HjFro1WIEJhWHEH/lI0ejDLnoVYVYWvmxAzO6tpkT+nfTMKIp4TmmHoya ot0339KHe+fg== X-Google-Smtp-Source: AGHT+IHXFNeEDpGCTvRptvMKDIy0+M2rkFE0mooPeavMWHYRLGLPvWTtp2OO/gXavfEnywaO5B5Qb8jCFEZfHj9e0Jk= X-Received: by 2002:a05:6122:459f:b0:560:2368:191 with SMTP id 71dfb90a1353d-5615be633d4mr13106676e0c.10.1767341153699; Fri, 02 Jan 2026 00:05:53 -0800 (PST) MIME-Version: 1.0 References: <3f22a8bb-29e8-40cc-97a1-309181da2c13@dunslane.net> <2bed001a-462c-42da-9a6b-3c7884502932@dunslane.net> <20250824010811.4d.nmisch@google.com> <82eb35b8-7f07-493b-b689-0934919e1dc3@dunslane.net> <17555e46-4fb2-4265-90e0-95cb8ed584a6@dunslane.net> In-Reply-To: From: jian he Date: Fri, 2 Jan 2026 16:05:17 +0800 X-Gm-Features: AQt7F2od8RqLc9GcEOotdONoubaNY0yknQGNo4iqvOAVJgTWhU_iVk2T7D4hJN8 Message-ID: Subject: Re: Non-text mode for pg_dumpall To: Mahendra Singh Thalor Cc: tushar , Vaibhav Dalvi , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Dec 9, 2025 at 2:49=E2=80=AFAM Mahendra Singh Thalor 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, pg_dumpall first creates two files: + toc.dat/toc.dmp/toc.tar and map.dat, in the directory + specified by . + 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 + pg_restore. Data for individual databases is placed in + databases subdirectory, named using the database's oid. 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. $ pg_dumpall > db.out + + + +$ pg_dumpall --format=3Dd/a/c/p -f db.out The text in the section should work correctly when pasted directly= into the terminal. but ``pg_dumpall --format=3Dd/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 =3D {0, 0}; + Assert(fout !=3D NULL); + + ArchiveEntry(fout, + nilCatalogId, /* catalog ID */ + createDumpId(), /* dump ID */ + ARCHIVE_OPTS(.tag =3D tag, + .description =3D tag, + .section =3D SECTION_PRE_DATA, + .createStmt =3D 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 !=3D 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/