pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Docs pg_restore: Shouldn't there be a note about -n ?
9+ messages / 4 participants
[nested] [flat]

Commits from this thread:
  2026-02-03 78bf28e3bf  Docs: consolidate dependency notes in pg_dump and pg_restore
* Docs pg_restore: Shouldn't there be a note about -n ?
@ 2024-09-21 17:33 Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 17:40 ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Florents Tselai @ 2024-09-21 17:33 UTC (permalink / raw)
  To: pgsql-hackers <pgsql-hackers@lists.postgresql.org>

I’m in the process of trying to restore some PG15/16 backups in PG17.

While playing with different -t and -n combinations I was browsing through the docs.

In pg_restore there are two notes about both -t / -n 

> When -n / -t is specified, pg_dump makes no attempt to ...

In pg_dump though there’s the equivalent note only for the -t option.

Shouldn’t it be a note as well for -n ? 

Otherwise I would expect -n to cascade the restore to objects in other schemas;
Which I don’t think it does.

Am I missing something? =

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Docs pg_restore: Shouldn't there be a note about -n ?
  2024-09-21 17:33 Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
@ 2024-09-21 17:40 ` Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 18:22   ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 9+ messages in thread

From: Florents Tselai @ 2024-09-21 17:40 UTC (permalink / raw)
  To: pgsql-hackers <pgsql-hackers@lists.postgresql.org>

On Sat, Sep 21, 2024 at 8:34 PM Florents Tselai <florents.tselai@gmail.com>
wrote:

> I’m in the process of trying to restore some PG15/16 backups in PG17.
>
> While playing with different -t and -n combinations I was browsing through
> the docs.
>
> In *pg_restore* there are two notes about both -t / -n
>
> > When -n / -t is specified, pg_dump makes no attempt to ...
>
> In pg_dump though there’s the equivalent note only for the -t option.
>
> Shouldn’t it be a note as well for -n ?
>
> Otherwise I would expect -n to cascade the restore to objects in other
> schemas;
> Which I don’t think it does.
>
> Am I missing something?
>

Ah,  swapped them by mistake on the previous email:

They're both available in the pg_dump and note on -n missing in pg_restore.

The question remains though:
Shouldn’t there be a note about -n in pg_restore ?

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Docs pg_restore: Shouldn't there be a note about -n ?
  2024-09-21 17:33 Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 17:40 ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
@ 2024-09-21 18:22   ` Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-21 18:48     ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2024-09-21 18:22 UTC (permalink / raw)
  To: Florents Tselai <florents.tselai@gmail.com>; +Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>

Florents Tselai <florents.tselai@gmail.com> writes:
> Ah,  swapped them by mistake on the previous email:
> They're both available in the pg_dump and note on -n missing in pg_restore.
> The question remains though:
> Shouldn’t there be a note about -n in pg_restore ?

Probably.  I see that pg_dump has a third copy of the exact same
note for "-e".  pg_restore lacks that switch for some reason,
but this is surely looking mighty duplicative.  I propose getting
rid of the per-switch Notes and putting a para into the Notes
section, along the lines of

    When -e, -n, or -t is specified, pg_dump makes no attempt to dump
    any other database objects that the selected object(s) might
    depend upon. Therefore, there is no guarantee that the results of
    a selective dump can be successfully restored by themselves into a
    clean database.

and mutatis mutandis for pg_restore.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Docs pg_restore: Shouldn't there be a note about -n ?
  2024-09-21 17:33 Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 17:40 ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 18:22   ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Tom Lane <tgl@sss.pgh.pa.us>
@ 2024-09-21 18:48     ` Florents Tselai <florents.tselai@gmail.com>
  2024-09-25 22:28       ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Florents Tselai @ 2024-09-21 18:48 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>



> On 21 Sep 2024, at 9:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 
> Florents Tselai <florents.tselai@gmail.com> writes:
>> Ah,  swapped them by mistake on the previous email:
>> They're both available in the pg_dump and note on -n missing in pg_restore.
>> The question remains though:
>> Shouldn’t there be a note about -n in pg_restore ?
> 
> Probably.  I see that pg_dump has a third copy of the exact same
> note for "-e".  pg_restore lacks that switch for some reason,
> but this is surely looking mighty duplicative.  I propose getting
> rid of the per-switch Notes and putting a para into the Notes
> section, along the lines of
> 
>    When -e, -n, or -t is specified, pg_dump makes no attempt to dump
>    any other database objects that the selected object(s) might
>    depend upon. Therefore, there is no guarantee that the results of
>    a selective dump can be successfully restored by themselves into a
>    clean database.

Agree with that, but I think there should be a pointer like “see Notes” .
Otherwise I’m pretty sure most would expect pg doing magic.
Can’t remember I scrolledl to the bottom of a page “notes” after finding the option I want.

I would also add an example of what “depend upon” means,
To underline that it’s really not that uncommon.
Something like: 
“If you pg_dump only with -t A and A has foreign key constraints to table B,
Those constraints won’t succeed If B has not been already restored” 



> 
> and mutatis mutandis for pg_restore.
> 
> 			regards, tom lane






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Docs pg_restore: Shouldn't there be a note about -n ?
  2024-09-21 17:33 Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 17:40 ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 18:22   ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-21 18:48     ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
@ 2024-09-25 22:28       ` Florents Tselai <florents.tselai@gmail.com>
  2025-10-25 16:32         ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 1 reply; 9+ messages in thread

From: Florents Tselai @ 2024-09-25 22:28 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>

On Sat, Sep 21, 2024 at 9:48 PM Florents Tselai <florents.tselai@gmail.com>
wrote:

>
>
> > On 21 Sep 2024, at 9:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >
> > Florents Tselai <florents.tselai@gmail.com> writes:
> >> Ah,  swapped them by mistake on the previous email:
> >> They're both available in the pg_dump and note on -n missing in
> pg_restore.
> >> The question remains though:
> >> Shouldn’t there be a note about -n in pg_restore ?
> >
> > Probably.  I see that pg_dump has a third copy of the exact same
> > note for "-e".  pg_restore lacks that switch for some reason,
> > but this is surely looking mighty duplicative.  I propose getting
> > rid of the per-switch Notes and putting a para into the Notes
> > section, along the lines of
> >
> >    When -e, -n, or -t is specified, pg_dump makes no attempt to dump
> >    any other database objects that the selected object(s) might
> >    depend upon. Therefore, there is no guarantee that the results of
> >    a selective dump can be successfully restored by themselves into a
> >    clean database.
>
> Agree with that, but I think there should be a pointer like “see Notes” .
> Otherwise I’m pretty sure most would expect pg doing magic.
> Can’t remember I scrolledl to the bottom of a page “notes” after finding
> the option I want.
>
> I would also add an example of what “depend upon” means,
> To underline that it’s really not that uncommon.
> Something like:
> “If you pg_dump only with -t A and A has foreign key constraints to table
> B,
> Those constraints won’t succeed If B has not been already restored”
>
>
Attached an idea.
The A/B example may be wordy / redundant,
but the -e note on the distinction between installing binaries / creating
an extension I think it's important.

Attachments:

v1-0001-Note-on-e-t-n.patch (application/octet-stream, 4.8K) download From 1a7376acef244603fee84a199d7a28270b865e7f Mon Sep 17 00:00:00 2001 From: Florents Tselai <florents.tselai@gmail.com> Date: Thu, 26 Sep 2024 01:24:35 +0300 Subject: [PATCH v1] Note on -e, -t, -n --- doc/src/sgml/ref/pg_dump.sgml | 41 +++++++++----------------------- doc/src/sgml/ref/pg_restore.sgml | 21 ++++++++-------- 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index ffc29b04fb..c8971cd30e 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -247,16 +247,6 @@ PostgreSQL documentation dump if its extension is specified by <option>--extension</option>. </para> - <note> - <para> - When <option>-e</option> is specified, - <application>pg_dump</application> makes no attempt to dump any other - database objects that the selected extension(s) might depend upon. - Therefore, there is no guarantee that the results of a - specific-extension dump can be successfully restored by themselves - into a clean database. - </para> - </note> </listitem> </varlistentry> @@ -431,16 +421,6 @@ PostgreSQL documentation <xref linkend="pg-dump-examples"/> below. </para> - <note> - <para> - When <option>-n</option> is specified, <application>pg_dump</application> - makes no attempt to dump any other database objects that the selected - schema(s) might depend upon. Therefore, there is no guarantee - that the results of a specific-schema dump can be successfully - restored by themselves into a clean database. - </para> - </note> - <note> <para> Non-schema objects such as large objects are not dumped when <option>-n</option> is @@ -581,16 +561,6 @@ PostgreSQL documentation be dumped. </para> - <note> - <para> - When <option>-t</option> is specified, <application>pg_dump</application> - makes no attempt to dump any other database objects that the selected - table(s) might depend upon. Therefore, there is no guarantee - that the results of a specific-table dump can be successfully - restored by themselves into a clean database. - </para> - </note> - </listitem> </varlistentry> @@ -1589,6 +1559,17 @@ CREATE DATABASE foo WITH TEMPLATE template0; catalogs might be left in the wrong state. </para> + <para> + When <option>-e</option>, <option>-n</option> or <option>-t</option> is specified, + <application>pg_dump</application> makes no attempt to dump any other + database objects that the selected extension(s) might depend upon. + Therefore, there is no guarantee that the results of a + specific-table or specific-schema dump can be successfully restored by themselves + into a clean database. + For <option>-e</option> in particular, note that the referred extension + must be installed (i.e. its shared object) separately, before it can be restored. + </para> + <para> The dump file produced by <application>pg_dump</application> does not contain the statistics used by the optimizer to make diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml index b8b27e1719..00132f3000 100644 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@ -519,16 +519,6 @@ PostgreSQL documentation specify table(s) in a particular schema. </para> - <note> - <para> - When <option>-t</option> is specified, <application>pg_restore</application> - makes no attempt to restore any other database objects that the - selected table(s) might depend upon. Therefore, there is no - guarantee that a specific-table restore into a clean database will - succeed. - </para> - </note> - <note> <para> This flag does not behave identically to the <option>-t</option> @@ -995,6 +985,17 @@ PostgreSQL documentation <refsect1 id="app-pgrestore-notes"> <title>Notes</title> + <para> + When <option>-n</option> or <option>-t</option> is specified, + <application>pg_restore</application> + makes no attempt to restore any other database objects that the + selected table(s) or schema(s) might depend upon. + Therefore, there is no guarantee that a specific-table restore into a clean database will succeed. + For example, if <command>pg_restore -t A</command> is requested, + and <literal>A</literal> has foreign key constraints to table <literal>B</literal>, + <literal>B</literal> should have been restored prior to that. + </para> + <para> If your installation has any local additions to the <literal>template1</literal> database, be careful to load the output of -- 2.39.5 (Apple Git-154)
^ permalink raw reply [nested|flat] 9+ messages in thread

* Re: Docs pg_restore: Shouldn't there be a note about -n ?
  2024-09-21 17:33 Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 17:40 ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 18:22   ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-21 18:48     ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-25 22:28       ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
@ 2025-10-25 16:32         ` Álvaro Herrera <alvherre@kurilemu.de>
  2026-01-04 23:25           ` Re: Docs pg_restore: Shouldn't there be a note about -n ? David Rowley <dgrowleyml@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Álvaro Herrera @ 2025-10-25 16:32 UTC (permalink / raw)
  To: Florents Tselai <florents.tselai@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers <pgsql-hackers@lists.postgresql.org>

On 2024-Sep-26, Florents Tselai wrote:

> Attached an idea.
> The A/B example may be wordy / redundant,

Yeah, it seems a little wordy to me, how about something like the
attached?

> but the -e note on the distinction between installing binaries / creating
> an extension I think it's important.

Hmm, ok, but I think that's a slightly unrelated topic because the shlib
is not a database object.  Maybe it would be more appropriate to add a
mention of this directly in the docs for -e instead of trying to cram it
in the note about other database objects.  I'll wait for you to propose
something for that part.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/

Attachments:

v2-0001-Add-note-to-pg_dump-pg_restore-pages.patch (text/x-diff, 4.9K) download From 82865cf57d28e07e2d8254020b3b98671487b1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <alvherre@kurilemu.de> Date: Sat, 25 Oct 2025 19:26:28 +0300 Subject: [PATCH v2] Add note to pg_dump/pg_restore pages Author: Florents Tselai <florents.tselai@gmail.com> Discussion: https://postgr.es/m/284C4D55-4F90-4AA0-84C8-1E6A28DDF271@gmail.com --- doc/src/sgml/ref/pg_dump.sgml | 41 +++++++++----------------------- doc/src/sgml/ref/pg_restore.sgml | 20 ++++++++-------- 2 files changed, 21 insertions(+), 40 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index fd4ecf01a0a..17b5be26615 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -261,16 +261,6 @@ PostgreSQL documentation dump if its extension is specified by <option>--extension</option>. </para> - <note> - <para> - When <option>-e</option> is specified, - <application>pg_dump</application> makes no attempt to dump any other - database objects that the selected extension(s) might depend upon. - Therefore, there is no guarantee that the results of a - specific-extension dump can be successfully restored by themselves - into a clean database. - </para> - </note> </listitem> </varlistentry> @@ -445,16 +435,6 @@ PostgreSQL documentation <xref linkend="pg-dump-examples"/> below. </para> - <note> - <para> - When <option>-n</option> is specified, <application>pg_dump</application> - makes no attempt to dump any other database objects that the selected - schema(s) might depend upon. Therefore, there is no guarantee - that the results of a specific-schema dump can be successfully - restored by themselves into a clean database. - </para> - </note> - <note> <para> Non-schema objects such as large objects are not dumped when <option>-n</option> is @@ -596,16 +576,6 @@ PostgreSQL documentation be dumped. </para> - <note> - <para> - When <option>-t</option> is specified, <application>pg_dump</application> - makes no attempt to dump any other database objects that the selected - table(s) might depend upon. Therefore, there is no guarantee - that the results of a specific-table dump can be successfully - restored by themselves into a clean database. - </para> - </note> - </listitem> </varlistentry> @@ -1689,6 +1659,17 @@ CREATE DATABASE foo WITH TEMPLATE template0; </programlisting> </para> + <para> + When options <option>-e</option>, <option>-n</option> or <option>-t</option> + are specified, <application>pg_dump</application> makes no attempt to dump + any other database objects that the selected object(s) might depend upon. + Therefore, there is no guarantee that the results of a dump so generated + can be successfully restored by themselves into a clean database. + For example, if a table whose definition includes a foreign key is + specified to be restore, the table referenced by the foreign key is + not automatically restored. + </para> + <para> When a dump without schema is chosen and the option <option>--disable-triggers</option> is used, <application>pg_dump</application> emits commands diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml index a468a38361a..8ceff99714d 100644 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@ -452,16 +452,6 @@ PostgreSQL documentation specify table(s) in a particular schema. </para> - <note> - <para> - When <option>-t</option> is specified, <application>pg_restore</application> - makes no attempt to restore any other database objects that the - selected table(s) might depend upon. Therefore, there is no - guarantee that a specific-table restore into a clean database will - succeed. - </para> - </note> - <note> <para> This flag does not behave identically to the <option>-t</option> @@ -1089,6 +1079,16 @@ PostgreSQL documentation <refsect1 id="app-pgrestore-notes"> <title>Notes</title> + <para> + When options <option>-n</option> or <option>-t</option> are specified, + <application>pg_restore</application> makes no attempt to restore + any other database objects that the selected table(s) or schema(s) + might depend upon. Therefore, there is no guarantee that a specific-table + restore into a clean database will succeed. For example, if a table + whose definition includes a foreign key is specified to be restore, the + table referenced by the foreign key is not automatically restored. + </para> + <para> If your installation has any local additions to the <literal>template1</literal> database, be careful to load the output of -- 2.47.3
^ permalink raw reply [nested|flat] 9+ messages in thread

* Re: Docs pg_restore: Shouldn't there be a note about -n ?
  2024-09-21 17:33 Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 17:40 ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 18:22   ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-21 18:48     ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-25 22:28       ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2025-10-25 16:32         ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Álvaro Herrera <alvherre@kurilemu.de>
@ 2026-01-04 23:25           ` David Rowley <dgrowleyml@gmail.com>
  2026-01-05 17:11             ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: David Rowley @ 2026-01-04 23:25 UTC (permalink / raw)
  To: Álvaro Herrera <alvherre@kurilemu.de>; +Cc: Florents Tselai <florents.tselai@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers <pgsql-hackers@lists.postgresql.org>

On Sun, 26 Oct 2025 at 05:32, Álvaro Herrera <alvherre@kurilemu.de> wrote:
>
> On 2024-Sep-26, Florents Tselai wrote:
> > but the -e note on the distinction between installing binaries / creating
> > an extension I think it's important.
>
> Hmm, ok, but I think that's a slightly unrelated topic because the shlib
> is not a database object.  Maybe it would be more appropriate to add a
> mention of this directly in the docs for -e instead of trying to cram it
> in the note about other database objects.  I'll wait for you to propose
> something for that part.

This seems to be waiting on Florents. I've adjusted the CF entry to
reflect that.

Florents, are you planning on coming back to this?

David





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Docs pg_restore: Shouldn't there be a note about -n ?
  2024-09-21 17:33 Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 17:40 ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 18:22   ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-21 18:48     ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-25 22:28       ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2025-10-25 16:32         ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Álvaro Herrera <alvherre@kurilemu.de>
  2026-01-04 23:25           ` Re: Docs pg_restore: Shouldn't there be a note about -n ? David Rowley <dgrowleyml@gmail.com>
@ 2026-01-05 17:11             ` Florents Tselai <florents.tselai@gmail.com>
  2026-02-03 18:37               ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 1 reply; 9+ messages in thread

From: Florents Tselai @ 2026-01-05 17:11 UTC (permalink / raw)
  To: David Rowley <dgrowleyml@gmail.com>; +Cc: Álvaro Herrera <alvherre@kurilemu.de>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers <pgsql-hackers@lists.postgresql.org>

On Mon, Jan 5, 2026 at 1:25 AM David Rowley <dgrowleyml@gmail.com> wrote:

> On Sun, 26 Oct 2025 at 05:32, Álvaro Herrera <alvherre@kurilemu.de> wrote:
> >
> > On 2024-Sep-26, Florents Tselai wrote:
> > > but the -e note on the distinction between installing binaries /
> creating
> > > an extension I think it's important.
> >
> > Hmm, ok, but I think that's a slightly unrelated topic because the shlib
> > is not a database object.  Maybe it would be more appropriate to add a
> > mention of this directly in the docs for -e instead of trying to cram it
> > in the note about other database objects.  I'll wait for you to propose
> > something for that part.
>
> This seems to be waiting on Florents. I've adjusted the CF entry to
> reflect that.
>
> Florents, are you planning on coming back to this?
>

Thanks for pushing.

I consolidated the dependency warnings into the main "Notes" section for
both pg_dump and pg_restore, removing the repetitive per-switch notes.

 For the -e switch in pg_dump, I replaced the removed dependency note
with a specific warning that extension installation files (shared libs,
control files) are not included.
 I agree that maintaining a specific note for -e is the right move.
Given the broad usage of pg_dump, it is helpful to be explicit that the
dump only captures the SQL definitions and not the underlying system
binaries.

Attachments:

v3-0001-Docs-Consolidate-dependency-notes-in-pg_dump-and-.patch (application/octet-stream, 4.4K) download From 8222a588e555aa9983b2eedeb26b267c28cfed24 Mon Sep 17 00:00:00 2001 From: Florents Tselai <florents.tselai@gmail.com> Date: Mon, 5 Jan 2026 19:03:17 +0200 Subject: [PATCH v3] Docs: Consolidate dependency notes in pg_dump and pg_restore Previously, pg_dump had repetitive notes attached to the -n (schema), -t (table), and -e (extension) switches warning that dependent database objects are not automatically included. pg_restore had a similar note for -t but lacked one for -n. This commit removes the individual per-switch notes and replaces them with a consolidated paragraph in the "Notes" section of both reference pages. Additionally, the removed note for the -e switch in pg_dump is replaced with a specific warning that extension installation files (such as shared libraries and control files) are not included in the dump and must be present on the destination system. --- doc/src/sgml/ref/pg_dump.sgml | 22 ++++++++++++++++------ doc/src/sgml/ref/pg_restore.sgml | 20 ++++++++++---------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 688e23c0e90..011a9a6f97e 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -263,14 +263,13 @@ PostgreSQL documentation <note> <para> - When <option>-e</option> is specified, - <application>pg_dump</application> makes no attempt to dump any other - database objects that the selected extension(s) might depend upon. - Therefore, there is no guarantee that the results of a - specific-extension dump can be successfully restored by themselves - into a clean database. + <application>pg_dump</application> does not dump the extension's + underlying installation files (such as shared libraries or control + files). These must be available on the destination system for the + restore to succeed. </para> </note> + </listitem> </varlistentry> @@ -1689,6 +1688,17 @@ CREATE DATABASE foo WITH TEMPLATE template0; </programlisting> </para> + <para> + When options <option>-e</option>, <option>-n</option> or <option>-t</option> + are specified, <application>pg_dump</application> makes no attempt to dump + any other database objects that the selected object(s) might depend upon. + Therefore, there is no guarantee that the results of a dump so generated + can be successfully restored by themselves into a clean database. + For example, if a table whose definition includes a foreign key is + specified to be restored, the table referenced by the foreign key is + not automatically restored. + </para> + <para> When a dump without schema is chosen and the option <option>--disable-triggers</option> is used, <application>pg_dump</application> emits commands diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml index a468a38361a..9bdbb7e1a7d 100644 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@ -452,16 +452,6 @@ PostgreSQL documentation specify table(s) in a particular schema. </para> - <note> - <para> - When <option>-t</option> is specified, <application>pg_restore</application> - makes no attempt to restore any other database objects that the - selected table(s) might depend upon. Therefore, there is no - guarantee that a specific-table restore into a clean database will - succeed. - </para> - </note> - <note> <para> This flag does not behave identically to the <option>-t</option> @@ -1089,6 +1079,16 @@ PostgreSQL documentation <refsect1 id="app-pgrestore-notes"> <title>Notes</title> + <para> + When options <option>-n</option> or <option>-t</option> are specified, + <application>pg_restore</application> makes no attempt to restore + any other database objects that the selected table(s) or schema(s) + might depend upon. Therefore, there is no guarantee that a specific-table + restore into a clean database will succeed. For example, if a table + whose definition includes a foreign key is specified to be restored, the + table referenced by the foreign key is not automatically restored. + </para> + <para> If your installation has any local additions to the <literal>template1</literal> database, be careful to load the output of -- 2.52.0
^ permalink raw reply [nested|flat] 9+ messages in thread

* Re: Docs pg_restore: Shouldn't there be a note about -n ?
  2024-09-21 17:33 Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 17:40 ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-21 18:22   ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-21 18:48     ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2024-09-25 22:28       ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
  2025-10-25 16:32         ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Álvaro Herrera <alvherre@kurilemu.de>
  2026-01-04 23:25           ` Re: Docs pg_restore: Shouldn't there be a note about -n ? David Rowley <dgrowleyml@gmail.com>
  2026-01-05 17:11             ` Re: Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
@ 2026-02-03 18:37               ` Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 9+ messages in thread

From: Álvaro Herrera @ 2026-02-03 18:37 UTC (permalink / raw)
  To: Florents Tselai <florents.tselai@gmail.com>; +Cc: David Rowley <dgrowleyml@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers <pgsql-hackers@lists.postgresql.org>

On 2026-Jan-05, Florents Tselai wrote:

> I consolidated the dependency warnings into the main "Notes" section for
> both pg_dump and pg_restore, removing the repetitive per-switch notes.
> 
>  For the -e switch in pg_dump, I replaced the removed dependency note
> with a specific warning that extension installation files (shared libs,
> control files) are not included.
>  I agree that maintaining a specific note for -e is the right move.
> Given the broad usage of pg_dump, it is helpful to be explicit that the
> dump only captures the SQL definitions and not the underlying system
> binaries.

Makes sense.  I have pushed this.

I just noticed though, that the issue in pg_restore applies not only to
the -n and -t switches, but also to -L (where you specify a file with a
list of objects to restore) and --filter.  Maybe we can this new
paragraph mention that as well.

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/
"No renuncies a nada. No te aferres a nada."





^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2026-02-03 18:37 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-09-21 17:33 Docs pg_restore: Shouldn't there be a note about -n ? Florents Tselai <florents.tselai@gmail.com>
2024-09-21 17:40 ` Florents Tselai <florents.tselai@gmail.com>
2024-09-21 18:22   ` Tom Lane <tgl@sss.pgh.pa.us>
2024-09-21 18:48     ` Florents Tselai <florents.tselai@gmail.com>
2024-09-25 22:28       ` Florents Tselai <florents.tselai@gmail.com>
2025-10-25 16:32         ` Álvaro Herrera <alvherre@kurilemu.de>
2026-01-04 23:25           ` David Rowley <dgrowleyml@gmail.com>
2026-01-05 17:11             ` Florents Tselai <florents.tselai@gmail.com>
2026-02-03 18:37               ` Álvaro Herrera <alvherre@kurilemu.de>

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