| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Mahendra Singh Thalor <mahi6run(at)gmail(dot)com> |
| Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, Noah Misch <noah(at)leadboat(dot)com>, tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>, 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: | 2026-10-08 08:08:27 |
| Message-ID: | CACJufxF4HBnSk+0QSyf2Jb5hu=Z4CtdrahLhZtCj=E7xmpK4rA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, Aug 27, 2026 at 2:23 PM Mahendra Singh Thalor
<mahi6run(at)gmail(dot)com> wrote:
>
> Thanks Noah and Andrew for the feedback. Based on review comments, I
> re-implemented these patches.
>
at [1], Noah mentioned that
"""
There should be one appendPQExpBuffer(delQry, "DROP ROLE ..."), not one for
plain format and another for non-plain formats. Having two creates excess
risk of format-specific bugs, something pg_dump.c has long avoided well. (I'm
echoing my postgr.es/m/20250708212819.09.nmisch@google.com review. I wrote,
"The strength of the archiver architecture shows in how rarely new features
need format-specific logic and how rarely format-specific bugs get reported."
That holds for the way pg_dump.c uses the archiver, but it doesn't hold for
the way pg_dumpall.c now uses the archiver.)
"""
That means we cannot use
if (archDumpFormat == archNull)
fprintf(OPF, "DROP ROLE"....)
else
ArchiveEntry(fout, ....)
All of the below is wrong.
+static void dropDBsText(PGconn *conn);
+static void dropTablespacesText(PGconn *conn);
+static void dropRolesText(PGconn *conn)
Therefore, we should unify it using ArchiveEntry, because we cannot
use fprintf for non-plain text formats.
With that, plain-text format also needs CreateArchive(). We must be
careful with fprintf(OPF): both RestoreArchive() and fprintf(OPF)
write to the same output, so their writes must be ordered correctly.
I also refactored check_for_invalid_global_names. if one database name
contained \r\n, call pg_fatal.
[1] https://www.postgresql.org/message-id/20260607000218.96.noahmisch%40microsoft.com
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-refactor-check_for_invalid_global_names-and-pgindent.txt | text/plain | 4.9 KB |
| v2-0002-using-ArchiveEntry-not-using-fprintf-for-global-objects.txt | text/plain | 26.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | ZizhuanLiu X-MAN | 2026-10-08 08:12:26 | Re: Optimize MCV stats for sortable types and utilize sorted-order properties |
| Previous Message | Andrey Rachitskiy | 2026-10-08 08:02:55 | Re: Fix PGTYPESdate_fmt_asc overflow when a year does not fit "yyyy" |