public inbox for [email protected]  
help / color / mirror / Atom feed
From: Mahendra Singh Thalor <[email protected]>
To: jian he <[email protected]>
Cc: Srinath Reddy <[email protected]>
Cc: [email protected]
Subject: Re: Non-text mode for pg_dumpall
Date: Tue, 11 Feb 2025 22:47:29 +0530
Message-ID: <CAKYtNAoRswr5B_sH-4o-V=UA74EpUKHbnXosG0Mk1=UJQfRWtA@mail.gmail.com> (raw)
In-Reply-To: <CACJufxEAWxWovH_dys5A2z53OGpftX_jJRTd1y8eB3HaojY+1A@mail.gmail.com>
References: <CAKYtNAp9vOtydXL3_pnGJ+TetZtN=FYSnZSMCqXceU3mkHPxPg@mail.gmail.com>
	<[email protected]>
	<CAKYtNAo-6HZy-JhTYS321AxGE_BPCg7WTFVLeXTuFMZ6HYK2vg@mail.gmail.com>
	<CACJufxGcZ1rK94cgfdc9McCD7W-83PT9_cx5VoFeC-HVc10Wzg@mail.gmail.com>
	<CAKYtNAqd4k+4+XANxjDc35i+WPme476DkP7msjYpX85F+4UsUg@mail.gmail.com>
	<CAKYtNAobHS158cfmA3X+Zr+oJ1ffNjjn3+BrU4-MokZ16jSVzw@mail.gmail.com>
	<CACJufxEtDgADBXQhX5cp3mJtNVMy+j+Jdovuk3PWe5qJ0sE3Ag@mail.gmail.com>
	<CAKYtNArwUxqR=LkQY1PT7tw+raMhf53oafo4WmSHGPHiER9d=A@mail.gmail.com>
	<CACJufxHUDGWe=2ZukvMfuwEcSK8CsVYm=9+rtPnrW7CRCfoCsw@mail.gmail.com>
	<CACJufxGOy1kAot+SAD9siKB797rj9K-bqeZOrS4fDYFFLo31bA@mail.gmail.com>
	<CAKYtNApE=x0sZxU3c9KqsYRU3dCztcfhQ+CDWhzgtH83HQUkuA@mail.gmail.com>
	<CACJufxHNNjAhVYJQS8x5U-9Fqsj6+tzG4uCivk2XTAOPTmstTA@mail.gmail.com>
	<CACJufxFJ9yJ=+WAHpXbDxf077Xw3O+ZziTwS55+ZK5APJ+6mUg@mail.gmail.com>
	<CACJufxEA-Q2hatN_BLcNrgfo8-4-m102gDdwVp0NTbuM2zyeDA@mail.gmail.com>
	<CAKYtNAqWjU6-J=VA-9-CVDLh7nX_Y_MgdSgyLFb6yYyZ1NYsyg@mail.gmail.com>
	<CACJufxEFxaiqytZRpL0Xbj8_XEtTm8-A2FE6u_9vigGO3z5oZQ@mail.gmail.com>
	<CAKYtNAr732dgvu43vLRBnDK=dPBVWAFBKaCp0982kwp0Yn8DOA@mail.gmail.com>
	<CACJufxGwXjG80LZ4miX+dXaT+3z5Kf1Mf0P_7FnR+641oqfUyg@mail.gmail.com>
	<CACJufxEQUcjBocKJQ0Amf3AfiS9wFB7zYSHrj1qqD_oWeaJoGQ@mail.gmail.com>
	<CAKYtNApzcsV3a_jR6oduA12yKrx=aBv+vcA=RseT-2rLrC2o_g@mail.gmail.com>
	<CAFC+b6p84_wtbviPu-mLNxfOPLozN8OOjWcz_tjoDf=SuVDMTQ@mail.gmail.com>
	<CAFC+b6qJ9BAmN-J2ha-Q08MPbZ2FqTUB++B0ouvSk72px3D-NA@mail.gmail.com>
	<CAKYtNAqsOwq-u-h0+WEm2nonwZD4S=9ri4-d0vhAGjNQZ7FjnQ@mail.gmail.com>
	<CAKYtNAr+YSMu1TkyXzsxtvCMRoya05_=1V_LFKDrL=XpYJ9DxQ@mail.gmail.com>
	<CACJufxGp5p7_7EwNwg-GuKZO+XB9uxfWTZ+QWhhNvwgUF0Vb0w@mail.gmail.com>
	<CACJufxGoUgqv+T1MXuh_SH_FTwTMpqfUcntHP1c5Q7KnyPXgKQ@mail.gmail.com>
	<CACJufxFWFLZhtgk92HR78tKiYk0yRX-26v2y1eEN2NtjyXtU4A@mail.gmail.com>
	<CAKYtNApkrfDHyN5z+Spbat1xzVOEL9y5o+ALimYmb3eH3T8Vhw@mail.gmail.com>
	<CACJufxFrzYJ0oZNm=v9hg10UpPQNe+p0+2ydNirHxyhUT_JtXw@mail.gmail.com>
	<CAKYtNAqP=URFvX2dqH5RT+wmd9nrnrfH45rvD2H_w9zNBvJqQA@mail.gmail.com>
	<CACJufxEcGGddRgwDLafyi+GJDOamPR4rrPG_0tZp6Rh81mEPfA@mail.gmail.com>
	<CAKYtNApSjr=etW+uVQ2KW0NcV=aZq-QdOd0jULync=84iDWr-w@mail.gmail.com>
	<CACJufxEAWxWovH_dys5A2z53OGpftX_jJRTd1y8eB3HaojY+1A@mail.gmail.com>

On Tue, 11 Feb 2025 at 20:40, jian he <[email protected]> wrote:
>
> hi.
> review based on v16.
>
> because of
>
https://postgr.es/m/CAFC+b6pWQiSL+3rvLxN9vhC8aONp4OV9c6u+BVD6kmWmDbd1WQ@mail.gmail.com
>
> in copy_global_file_to_out_file, now it is:
>     if (strcmp(outfile, "-") == 0)
>         OPF = stdout;
> I am confused, why "-" means stdout.
> ``touch ./- `` command works fine.
> i think dash is not special character, you may see
> https://stackoverflow.com/a/40650391/15603477

"-" is used for stdout. This is mentioned in the doc.
pg_restore link <https://www.postgresql.org/docs/current/app-pgrestore.html;

> -f *filename*
> --file=*filename*
>
> Specify output file for generated script, or for the listing when used
> with -l. Use - for stdout.
>

>
>
> + /* Create a subdirectory with 'databases' name under main directory. */
> + if (mkdir(db_subdir, 0755) != 0)
> + pg_log_error("could not create subdirectory \"%s\": %m", db_subdir);
> here we should use pg_fatal?

Yes, we should use pg_fatal.

>
>
> pg_log_info("executing %s", sqlstatement.data);
> change to
> pg_log_info("executing query: %s", sqlstatement.data);
> message would be more similar to the next pg_log_error(...) message.

Okay.

>
>
> + /*
> + * User is suggested to use single database dump for --list option.
> + */
> + if (opts->tocSummary)
> + pg_fatal("option -l/--list cannot be used when using dump of
pg_dumpall");
> maybe change to
> + pg_fatal("option -l/--list cannot be used when restoring multiple
databases");

okay.

>
> $BIN10/pg_restore --format=directory --list dir10_x
> if the directory only has one database, then we can actually print out
> the tocSummary.
> if the directory has more than one database then pg_fatal.
> To tolerate this corner case (only one database) means that pg_restore
> --list requires a DB connection,
> but I am not sure that is fine.
> anyway, the attached patch allows this corner case.

No, we don't need this corner case. If a user wants to restore a
single database with --list option, then the user should give a particular
dump file with pg_restore.

>
>
> PrintTOCSummary can only print out summary for a single database.
> so we don't need to change PrintTOCSummary.
>
>
> + /*
> + * To restore multiple databases, -C (create database) option should
> be specified
> + * or all databases should be created before pg_restore.
> + */
> + if (opts->createDB != 1)
> + pg_log_info("restoring dump of pg_dumpall without -C option, there
> might be multiple databases in directory.");
>
> we can change it to
> + if (opts->createDB != 1 && num_db_restore > 0)
> + pg_log_info("restoring multiple databases without -C option.");

okay.

>
>
> Bug.
> when pg_restore --globals-only can be applied when we are restoring a
> single database (can be an output of pg_dump).

As of now, we are ignoring this option. We can add an error in the "else"
part of the global.dat file.
Ex: option --globals-only is only supported with dump of pg_dumpall.
Similarly --exclude-database also.

>
>
> There are some tests per https://commitfest.postgresql.org/52/5495, I
> will check it later.
> The attached patch is the change for the above reviews.


-- 
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com


view thread (36+ messages)  latest in thread

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]
  Subject: Re: Non-text mode for pg_dumpall
  In-Reply-To: <CAKYtNAoRswr5B_sH-4o-V=UA74EpUKHbnXosG0Mk1=UJQfRWtA@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