Proposal to include --exclude-extension Flag in pg_dump

Started by Ayush Vatsaabout 2 years ago15 messages
#1Ayush Vatsa
ayushvatsa1810@gmail.com
1 attachment(s)

Hi PostgreSQL Community,
Recently I have been working on pg_dump regarding my project and wanted to
exclude an extension from the dump generated. I wonder why it doesn't have
--exclude-extension type of support whereas --extension exists!
Since I needed that support, I took the initiative to contribute to the
community by adding the --exclude-extension flag.
Attached is the patch for the same. Looking forward to your feedback.

Regards
Ayush Vatsa
Amazon Web services (AWS)

Attachments:

v1-0001-Add-support-for-exclude-extension-in-pg_dump.patchapplication/octet-stream; name=v1-0001-Add-support-for-exclude-extension-in-pg_dump.patchDownload
From 471775d8b6a4bb90dd0570a4c834e9cddd5fefa3 Mon Sep 17 00:00:00 2001
From: Ayush Vatsa <ayuvatsa@amazon.com>
Date: Mon, 25 Dec 2023 14:46:05 +0530
Subject: [PATCH] Add support for --exclude-extension in pg_dump

When specified, extensions matching the given pattern are excluded
in dumps.
---
 doc/src/sgml/ref/pg_dump.sgml | 24 +++++++++++++++++++++++-
 src/bin/pg_dump/pg_dump.c     | 28 ++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0e5ba4f712..b3f3ff3188 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -256,6 +256,27 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>--exclude-extension=<replaceable class="parameter">pattern</replaceable></option></term>
+      <listitem>
+       <para>
+        Do not dump any extensions matching <replaceable
+        class="parameter">pattern</replaceable>.  The pattern is
+        interpreted according to the same rules as for <option>-e</option>.
+        <option>--exclude-extension</option> can be given more than once to exclude extensions
+        matching any of several patterns.
+       </para>
+
+       <para>
+        When both <option>-e</option> and <option>--exclude-extension</option> are given, the behavior
+        is to dump just the extensions that match at least one <option>-e</option>
+        switch but no <option>--exclude-extension</option> switches.  If <option>--exclude-extension</option>
+        appears without <option>-e</option>, then extensions matching <option>--exclude-extension</option> are
+        excluded from what is otherwise a normal dump.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>-E <replaceable class="parameter">encoding</replaceable></option></term>
       <term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term>
@@ -1278,7 +1299,8 @@ PostgreSQL documentation
        </para>
        <para>
         This option has no effect
-        on <option>-N</option>/<option>--exclude-schema</option>,
+        on <option>--exclude-extension</option>,
+        <option>-N</option>/<option>--exclude-schema</option>,
         <option>-T</option>/<option>--exclude-table</option>,
         or <option>--exclude-table-data</option>.  An exclude pattern failing
         to match any objects is not considered an error.
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 8c0b5486b9..1185c74a54 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -136,6 +136,9 @@ static SimpleOidList foreign_servers_include_oids = {NULL, NULL};
 static SimpleStringList extension_include_patterns = {NULL, NULL};
 static SimpleOidList extension_include_oids = {NULL, NULL};
 
+static SimpleStringList extension_exclude_patterns = {NULL, NULL};
+static SimpleOidList extension_exclude_oids = {NULL, NULL};
+
 static const CatalogId nilCatalogId = {0, 0};
 
 /* override for standard extra_float_digits setting */
@@ -436,6 +439,7 @@ main(int argc, char **argv)
 		{"exclude-table-data-and-children", required_argument, NULL, 14},
 		{"sync-method", required_argument, NULL, 15},
 		{"filter", required_argument, NULL, 16},
+		{"exclude-extension", required_argument, NULL, 17},
 
 		{NULL, 0, NULL, 0}
 	};
@@ -671,6 +675,11 @@ main(int argc, char **argv)
 				read_dump_filters(optarg, &dopt);
 				break;
 
+			case 17:			/* exclude extension(s) */
+				simple_string_list_append(&extension_exclude_patterns,
+										  optarg);
+				break;
+
 			default:
 				/* getopt_long already emitted a complaint */
 				pg_log_error_hint("Try \"%s --help\" for more information.", progname);
@@ -889,6 +898,10 @@ main(int argc, char **argv)
 		if (extension_include_oids.head == NULL)
 			pg_fatal("no matching extensions were found");
 	}
+	expand_extension_name_patterns(fout, &extension_exclude_patterns,
+									&extension_exclude_oids,
+									false);
+	/* non-matching exclusion patterns aren't an error */
 
 	/*
 	 * Dumping LOs is the default for dumps where an inclusion switch is not
@@ -1094,6 +1107,7 @@ help(const char *progname)
 	printf(_("  -c, --clean                  clean (drop) database objects before recreating\n"));
 	printf(_("  -C, --create                 include commands to create database in dump\n"));
 	printf(_("  -e, --extension=PATTERN      dump the specified extension(s) only\n"));
+	printf(_("  --exclude-extension=PATTERN  do NOT dump the specified extension(s)\n"));
 	printf(_("  -E, --encoding=ENCODING      dump the data in encoding ENCODING\n"));
 	printf(_("  -n, --schema=PATTERN         dump the specified schema(s) only\n"));
 	printf(_("  -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
@@ -2025,6 +2039,11 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
 			extinfo->dobj.dump = extinfo->dobj.dump_contains =
 				dopt->include_everything ?
 				DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
+
+		if (extension_exclude_oids.head != NULL && 
+				simple_oid_list_member(&extension_exclude_oids,
+									   extinfo->dobj.catId.oid))
+			extinfo->dobj.dump = extinfo->dobj.dump_contains = DUMP_COMPONENT_NONE;
 	}
 }
 
@@ -18149,6 +18168,15 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
 			!simple_oid_list_member(&extension_include_oids,
 									curext->dobj.catId.oid))
 			continue;
+		
+		/*
+		 * Check if this extension is listed as to exclude in the dump.  If
+		 * yes, any table data associated with it is discarded.
+		 */
+		if (extension_exclude_oids.head != NULL &&
+			simple_oid_list_member(&extension_exclude_oids,
+									curext->dobj.catId.oid))
+			continue;
 
 		if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
 		{
-- 
2.41.0

#2Ayush Vatsa
ayushvatsa1810@gmail.com
In reply to: Ayush Vatsa (#1)
Re: Proposal to include --exclude-extension Flag in pg_dump

Added a CF entry for the same https://commitfest.postgresql.org/46/4721/

Regards
Ayush Vatsa
Amazon Web Services (AWS)

On Mon, 25 Dec 2023 at 15:48, Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

Show quoted text

Hi PostgreSQL Community,
Recently I have been working on pg_dump regarding my project and wanted to
exclude an extension from the dump generated. I wonder why it doesn't have
--exclude-extension type of support whereas --extension exists!
Since I needed that support, I took the initiative to contribute to the
community by adding the --exclude-extension flag.
Attached is the patch for the same. Looking forward to your feedback.

Regards
Ayush Vatsa
Amazon Web services (AWS)

#3Junwang Zhao
zhjwpku@gmail.com
In reply to: Ayush Vatsa (#2)
Re: Proposal to include --exclude-extension Flag in pg_dump

Hi

On Mon, Dec 25, 2023 at 6:22 PM Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

Added a CF entry for the same https://commitfest.postgresql.org/46/4721/

Regards
Ayush Vatsa
Amazon Web Services (AWS)

On Mon, 25 Dec 2023 at 15:48, Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

Hi PostgreSQL Community,
Recently I have been working on pg_dump regarding my project and wanted to exclude an extension from the dump generated. I wonder why it doesn't have --exclude-extension type of support whereas --extension exists!
Since I needed that support, I took the initiative to contribute to the community by adding the --exclude-extension flag.
Attached is the patch for the same. Looking forward to your feedback.

Regards
Ayush Vatsa
Amazon Web services (AWS)

printf(_(" -e, --extension=PATTERN dump the specified
extension(s) only\n"));
+ printf(_(" --exclude-extension=PATTERN do NOT dump the specified
extension(s)\n"));
printf(_(" -E, --encoding=ENCODING dump the data in encoding
ENCODING\n"));

long options should not mess with short options, does the following
make sense to you?

printf(_(" --enable-row-security enable row security (dump only
content user has\n"
" access to)\n"));
+ printf(_(" --exclude-extension=PATTERN do NOT dump the specified
extension(s)\n"));
printf(_(" --exclude-table-and-children=PATTERN\n"

--
Regards
Junwang Zhao

#4Ayush Vatsa
ayushvatsa1810@gmail.com
In reply to: Junwang Zhao (#3)
Re: Proposal to include --exclude-extension Flag in pg_dump

Hi,

long options should not mess with short options, does the following
make sense to you?

Yes that makes sense, a reason to keep them together is that they are of
the same kind
But I will update the patch accordingly.

One more thing I wanted to ask is, Should I separate them in the
pg_dump.sgml file too? Like writing documentation of --exclude-extension
with other long options?

After your feedback I will update on both places in a single patch

Regards,
Ayush Vatsa
Amazon Web Services (AWS)

On Mon, 25 Dec 2023 at 16:28, Junwang Zhao <zhjwpku@gmail.com> wrote:

Show quoted text

Hi

On Mon, Dec 25, 2023 at 6:22 PM Ayush Vatsa <ayushvatsa1810@gmail.com>
wrote:

Added a CF entry for the same https://commitfest.postgresql.org/46/4721/

Regards
Ayush Vatsa
Amazon Web Services (AWS)

On Mon, 25 Dec 2023 at 15:48, Ayush Vatsa <ayushvatsa1810@gmail.com>

wrote:

Hi PostgreSQL Community,
Recently I have been working on pg_dump regarding my project and wanted

to exclude an extension from the dump generated. I wonder why it doesn't
have --exclude-extension type of support whereas --extension exists!

Since I needed that support, I took the initiative to contribute to the

community by adding the --exclude-extension flag.

Attached is the patch for the same. Looking forward to your feedback.

Regards
Ayush Vatsa
Amazon Web services (AWS)

printf(_(" -e, --extension=PATTERN dump the specified
extension(s) only\n"));
+ printf(_(" --exclude-extension=PATTERN do NOT dump the specified
extension(s)\n"));
printf(_(" -E, --encoding=ENCODING dump the data in encoding
ENCODING\n"));

long options should not mess with short options, does the following
make sense to you?

printf(_(" --enable-row-security enable row security (dump only
content user has\n"
" access to)\n"));
+ printf(_(" --exclude-extension=PATTERN do NOT dump the specified
extension(s)\n"));
printf(_(" --exclude-table-and-children=PATTERN\n"

--
Regards
Junwang Zhao

#5Ashutosh Bapat
ashutosh.bapat.oss@gmail.com
In reply to: Ayush Vatsa (#1)
Re: Proposal to include --exclude-extension Flag in pg_dump

On Mon, Dec 25, 2023 at 3:48 PM Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

Hi PostgreSQL Community,
Recently I have been working on pg_dump regarding my project and wanted to exclude an extension from the dump generated. I wonder why it doesn't have --exclude-extension type of support whereas --extension exists!
Since I needed that support, I took the initiative to contribute to the community by adding the --exclude-extension flag.

Aren't extensions excluded by default? That's why we have --extension.
Why do we need to explicitly exclude extensions?

--
Best Wishes,
Ashutosh Bapat

#6Ayush Vatsa
ayushvatsa1810@gmail.com
In reply to: Ashutosh Bapat (#5)
Re: Proposal to include --exclude-extension Flag in pg_dump

Hi,

Aren't extensions excluded by default? That's why we have --extension.

According to the documentation of pg_dump when the --extension option is
not specified, all non-system extensions in the target database will get
dumped.

Why do we need to explicitly exclude extensions?

Hence to include only a few we use --extension, but to exclude a few I am
proposing --exclude-extension.

On Mon, 1 Jan 2024 at 18:18, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
wrote:

Show quoted text

On Mon, Dec 25, 2023 at 3:48 PM Ayush Vatsa <ayushvatsa1810@gmail.com>
wrote:

Hi PostgreSQL Community,
Recently I have been working on pg_dump regarding my project and wanted

to exclude an extension from the dump generated. I wonder why it doesn't
have --exclude-extension type of support whereas --extension exists!

Since I needed that support, I took the initiative to contribute to the

community by adding the --exclude-extension flag.

Aren't extensions excluded by default? That's why we have --extension.
Why do we need to explicitly exclude extensions?

--
Best Wishes,
Ashutosh Bapat

#7Dean Rasheed
dean.a.rasheed@gmail.com
In reply to: Ayush Vatsa (#6)
Re: Proposal to include --exclude-extension Flag in pg_dump

On Mon, 1 Jan 2024 at 13:28, Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

According to the documentation of pg_dump when the --extension option is not specified, all non-system extensions in the target database will get dumped.

Why do we need to explicitly exclude extensions?

Hence to include only a few we use --extension, but to exclude a few I am proposing --exclude-extension.

Thanks for working on this. It seems like a useful feature to have.
The code changes look good, and it appears to work as expected.

In my opinion the order of options in pg_dump.sgml and the --help
output is fine. Keeping this new option together with -e/--extension
makes it easier to see, while otherwise it would get lost much further
down. Other opinions on that might differ though.

There are a couple of things missing from the patch, that should be added:

1). The --filter option should be extended to support "exclude
extension pattern" lines in the filter file. That syntax is already
accepted, but it throws a not-supported error, but it's hopefully not
too hard to make that work now.

2). It ought to have some tests in the test script.

Regards,
Dean

#8Ayush Vatsa
ayushvatsa1810@gmail.com
In reply to: Dean Rasheed (#7)
1 attachment(s)
Re: Proposal to include --exclude-extension Flag in pg_dump

Hi,

In my opinion the order of options in pg_dump.sgml and the --help

output is fine. Keeping this new option together with -e/--extension

makes it easier to see, while otherwise it would get lost much further

down.

I agree with your suggestion, so I'll maintain the original order as
proposed.

The --filter option should be extended to support "exclude

extension pattern" lines in the filter file. That syntax is already

accepted, but it throws a not-supported error, but it's hopefully not

too hard to make that work now.

While proposing the --exclude-extension flag in pg_dump, the --filter
option

wasn't there, so it got overlooked. But now that I've familiarized myself
with it

and have tried to enhance its functionality with exclude-extension in the

provided patch. Thank you for bringing this to my attention.

It ought to have some tests in the test script.

Correct, I must have added it in the first patch itself.

As a newcomer to the database, I explored how testing works and tried

to include test cases for the newly added flag. I've confirmed that all
test

cases, including the ones I added, are passing.

Attached is the complete patch with all the required code changes.

Looking forward to your review and feedback.

On Wed, 6 Mar 2024 at 16:04, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:

Show quoted text

On Mon, 1 Jan 2024 at 13:28, Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

According to the documentation of pg_dump when the --extension option is

not specified, all non-system extensions in the target database will get
dumped.

Why do we need to explicitly exclude extensions?

Hence to include only a few we use --extension, but to exclude a few I

am proposing --exclude-extension.

Thanks for working on this. It seems like a useful feature to have.
The code changes look good, and it appears to work as expected.

In my opinion the order of options in pg_dump.sgml and the --help
output is fine. Keeping this new option together with -e/--extension
makes it easier to see, while otherwise it would get lost much further
down. Other opinions on that might differ though.

There are a couple of things missing from the patch, that should be added:

1). The --filter option should be extended to support "exclude
extension pattern" lines in the filter file. That syntax is already
accepted, but it throws a not-supported error, but it's hopefully not
too hard to make that work now.

2). It ought to have some tests in the test script.

Regards,
Dean

Attachments:

v2-0001-Add-support-for-exclude-extension-in-pg_dump.patchapplication/octet-stream; name=v2-0001-Add-support-for-exclude-extension-in-pg_dump.patchDownload
From 8998b050e78b238a346e55f392b17d80eb658d7f Mon Sep 17 00:00:00 2001
From: Ayush Vatsa <ayuvatsa@amazon.com>
Date: Mon, 25 Dec 2023 14:46:05 +0530
Subject: [PATCH] Add support for --exclude-extension in pg_dump

When specified, extensions matching the given pattern are excluded
in dumps.
---
 doc/src/sgml/ref/pg_dump.sgml               | 34 +++++++++++++++++----
 src/bin/pg_dump/pg_dump.c                   | 32 ++++++++++++++++++-
 src/test/modules/test_pg_dump/t/001_base.pl | 26 ++++++++++------
 3 files changed, 76 insertions(+), 16 deletions(-)

diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0caf56e0e0..30a01aa264 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -256,6 +256,27 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>--exclude-extension=<replaceable class="parameter">pattern</replaceable></option></term>
+      <listitem>
+       <para>
+        Do not dump any extensions matching <replaceable
+        class="parameter">pattern</replaceable>.  The pattern is
+        interpreted according to the same rules as for <option>-e</option>.
+        <option>--exclude-extension</option> can be given more than once to exclude extensions
+        matching any of several patterns.
+       </para>
+
+       <para>
+        When both <option>-e</option> and <option>--exclude-extension</option> are given, the behavior
+        is to dump just the extensions that match at least one <option>-e</option>
+        switch but no <option>--exclude-extension</option> switches.  If <option>--exclude-extension</option>
+        appears without <option>-e</option>, then extensions matching <option>--exclude-extension</option> are
+        excluded from what is otherwise a normal dump.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>-E <replaceable class="parameter">encoding</replaceable></option></term>
       <term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term>
@@ -848,10 +869,11 @@ PostgreSQL documentation
         <option>--exclude-table-and-children</option> or
         <option>-T</option> for tables,
         <option>-n</option>/<option>--schema</option> for schemas,
-        <option>--include-foreign-data</option> for data on foreign servers and
+        <option>--include-foreign-data</option> for data on foreign servers,
         <option>--exclude-table-data</option>,
-        <option>--exclude-table-data-and-children</option> for table data,
-        <option>-e</option>/<option>--extension</option> for extensions.
+        <option>--exclude-table-data-and-children</option> for table data and
+        <option>-e</option>/<option>--extension</option> or
+        <option>--exclude-extension</option> for extensions.
         To read from <literal>STDIN</literal>, use <filename>-</filename> as the
         filename.  The <option>--filter</option> option can be specified in
         conjunction with the above listed options for including or excluding
@@ -874,8 +896,7 @@ PostgreSQL documentation
          <listitem>
           <para>
            <literal>extension</literal>: extensions, works like the
-           <option>--extension</option> option. This keyword can only be
-           used with the <literal>include</literal> keyword.
+           <option>-e</option>/<option>--extension</option> option.
           </para>
          </listitem>
          <listitem>
@@ -1278,7 +1299,8 @@ PostgreSQL documentation
        </para>
        <para>
         This option has no effect
-        on <option>-N</option>/<option>--exclude-schema</option>,
+        on <option>--exclude-extension</option>,
+        <option>-N</option>/<option>--exclude-schema</option>,
         <option>-T</option>/<option>--exclude-table</option>,
         or <option>--exclude-table-data</option>.  An exclude pattern failing
         to match any objects is not considered an error.
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 171e591696..56838afcc3 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -136,6 +136,9 @@ static SimpleOidList foreign_servers_include_oids = {NULL, NULL};
 static SimpleStringList extension_include_patterns = {NULL, NULL};
 static SimpleOidList extension_include_oids = {NULL, NULL};
 
+static SimpleStringList extension_exclude_patterns = {NULL, NULL};
+static SimpleOidList extension_exclude_oids = {NULL, NULL};
+
 static const CatalogId nilCatalogId = {0, 0};
 
 /* override for standard extra_float_digits setting */
@@ -437,6 +440,7 @@ main(int argc, char **argv)
 		{"exclude-table-data-and-children", required_argument, NULL, 14},
 		{"sync-method", required_argument, NULL, 15},
 		{"filter", required_argument, NULL, 16},
+		{"exclude-extension", required_argument, NULL, 17},
 
 		{NULL, 0, NULL, 0}
 	};
@@ -672,6 +676,11 @@ main(int argc, char **argv)
 				read_dump_filters(optarg, &dopt);
 				break;
 
+			case 17:			/* exclude extension(s) */
+				simple_string_list_append(&extension_exclude_patterns,
+										  optarg);
+				break;
+
 			default:
 				/* getopt_long already emitted a complaint */
 				pg_log_error_hint("Try \"%s --help\" for more information.", progname);
@@ -890,6 +899,10 @@ main(int argc, char **argv)
 		if (extension_include_oids.head == NULL)
 			pg_fatal("no matching extensions were found");
 	}
+	expand_extension_name_patterns(fout, &extension_exclude_patterns,
+									&extension_exclude_oids,
+									false);
+	/* non-matching exclusion patterns aren't an error */
 
 	/*
 	 * Dumping LOs is the default for dumps where an inclusion switch is not
@@ -1095,6 +1108,7 @@ help(const char *progname)
 	printf(_("  -c, --clean                  clean (drop) database objects before recreating\n"));
 	printf(_("  -C, --create                 include commands to create database in dump\n"));
 	printf(_("  -e, --extension=PATTERN      dump the specified extension(s) only\n"));
+	printf(_("  --exclude-extension=PATTERN  do NOT dump the specified extension(s)\n"));
 	printf(_("  -E, --encoding=ENCODING      dump the data in encoding ENCODING\n"));
 	printf(_("  -n, --schema=PATTERN         dump the specified schema(s) only\n"));
 	printf(_("  -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
@@ -2028,6 +2042,11 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
 			extinfo->dobj.dump = extinfo->dobj.dump_contains =
 				dopt->include_everything ?
 				DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
+
+		if (extension_exclude_oids.head != NULL && 
+				simple_oid_list_member(&extension_exclude_oids,
+									   extinfo->dobj.catId.oid))
+			extinfo->dobj.dump = extinfo->dobj.dump_contains = DUMP_COMPONENT_NONE;
 	}
 }
 
@@ -18262,6 +18281,15 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
 			!simple_oid_list_member(&extension_include_oids,
 									curext->dobj.catId.oid))
 			continue;
+		
+		/*
+		 * Check if this extension is listed as to exclude in the dump.  If
+		 * yes, any table data associated with it is discarded.
+		 */
+		if (extension_exclude_oids.head != NULL &&
+			simple_oid_list_member(&extension_exclude_oids,
+									curext->dobj.catId.oid))
+			continue;
 
 		if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
 		{
@@ -18963,7 +18991,6 @@ read_dump_filters(const char *filename, DumpOptions *dopt)
 				case FILTER_OBJECT_TYPE_FUNCTION:
 				case FILTER_OBJECT_TYPE_INDEX:
 				case FILTER_OBJECT_TYPE_TRIGGER:
-				case FILTER_OBJECT_TYPE_EXTENSION:
 				case FILTER_OBJECT_TYPE_FOREIGN_DATA:
 					pg_log_filter_error(&fstate, _("%s filter for \"%s\" is not allowed"),
 										"exclude",
@@ -18971,6 +18998,9 @@ read_dump_filters(const char *filename, DumpOptions *dopt)
 					exit_nicely(1);
 					break;
 
+				case FILTER_OBJECT_TYPE_EXTENSION:
+					simple_string_list_append(&extension_exclude_patterns, objname);
+					break;
 				case FILTER_OBJECT_TYPE_TABLE_DATA:
 					simple_string_list_append(&tabledata_exclude_patterns,
 											  objname);
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl
index b8c30c2387..23ba81f359 100644
--- a/src/test/modules/test_pg_dump/t/001_base.pl
+++ b/src/test/modules/test_pg_dump/t/001_base.pl
@@ -220,6 +220,12 @@ my %pgdump_runs = (
 			'--extension=test_pg_dump', 'postgres',
 		],
 	},
+	exclude_extension => {
+		dump_cmd => [
+			'pg_dump', '--no-sync', "--file=$tempdir/exclude_extension.sql",
+			'--exclude-extension=test_pg_dump', 'postgres',
+		],
+	},
 
 	# plpgsql in the list blocks the dump of extension test_pg_dump
 	without_extension => {
@@ -299,6 +305,7 @@ my %full_runs = (
 	no_owner => 1,
 	privileged_internals => 1,
 	with_extension => 1,
+	exclude_extension => 1,
 	without_extension => 1);
 
 my %tests = (
@@ -325,7 +332,7 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { binary_upgrade => 1, without_extension => 1 },
+		unlike => { binary_upgrade => 1, exclude_extension => 1, without_extension => 1 },
 	},
 
 	'CREATE ROLE regress_dump_test_role' => {
@@ -434,7 +441,7 @@ my %tests = (
 			section_data => 1,
 			extension_schema => 1,
 		},
-		unlike => { without_extension => 1, },
+		unlike => { exclude_extension => 1, without_extension => 1, },
 	},
 
 	'CREATE TABLE regress_pg_dump_table' => {
@@ -460,6 +467,7 @@ my %tests = (
 		unlike => {
 			binary_upgrade => 1,
 			exclude_table => 1,
+			exclude_extension => 1,
 			without_extension => 1,
 		},
 	},
@@ -483,7 +491,7 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => { no_privs => 1, exclude_extension => 1, without_extension => 1, },
 	},
 
 	'REVOKE GRANT OPTION FOR UPDATE ON SEQUENCE wgo_then_regular' => {
@@ -500,7 +508,7 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => { no_privs => 1, exclude_extension => 1, without_extension => 1, },
 	},
 
 	'CREATE ACCESS METHOD regress_test_am' => {
@@ -520,7 +528,7 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { without_extension => 1, },
+		unlike => { exclude_extension => 1, without_extension => 1, },
 	},
 
 	'GRANT SELECT regress_pg_dump_table_added pre-ALTER EXTENSION' => {
@@ -545,7 +553,7 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => { no_privs => 1, exclude_extension => 1, without_extension => 1, },
 	},
 
 	'GRANT SELECT ON TABLE regress_pg_dump_table' => {
@@ -579,7 +587,7 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1 },
+		unlike => { no_privs => 1, exclude_extension => 1, without_extension => 1 },
 	  },
 
 	'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role'
@@ -595,7 +603,7 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => { no_privs => 1, exclude_extension => 1, without_extension => 1, },
 	  },
 
 	'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => {
@@ -617,7 +625,7 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => { no_privs => 1, exclude_extension => 1, without_extension => 1, },
 	},
 
 	# Objects included in extension part of a schema created by this extension */
-- 
2.39.3 (Apple Git-146)

#9Dean Rasheed
dean.a.rasheed@gmail.com
In reply to: Ayush Vatsa (#8)
1 attachment(s)
Re: Proposal to include --exclude-extension Flag in pg_dump

On Sat, 16 Mar 2024 at 17:36, Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

Attached is the complete patch with all the required code changes.
Looking forward to your review and feedback.

This looks good to me. I tested it and everything worked as expected.

I ran it through pgindent to fix some whitespace issues and added
another test for the filter option, based on the test case you added.

I'm marking this ready-for-commit (which I'll probably do myself in a
day or two, unless anyone else claims it first).

Regards,
Dean

Attachments:

v3-0001-Add-support-for-exclude-extension-in-pg_dump.patchtext/x-patch; charset=US-ASCII; name=v3-0001-Add-support-for-exclude-extension-in-pg_dump.patchDownload
From f757ebe748ab47d1e1ab40b343af2a43a9183287 Mon Sep 17 00:00:00 2001
From: Ayush Vatsa <ayuvatsa@amazon.com>
Date: Mon, 25 Dec 2023 14:46:05 +0530
Subject: [PATCH v3] Add support for --exclude-extension in pg_dump

When specified, extensions matching the given pattern are excluded
in dumps.
---
 doc/src/sgml/ref/pg_dump.sgml               | 34 ++++++--
 src/bin/pg_dump/pg_dump.c                   | 33 +++++++-
 src/test/modules/test_pg_dump/t/001_base.pl | 88 ++++++++++++++++++---
 3 files changed, 139 insertions(+), 16 deletions(-)

diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0caf56e0e0..8edf03a03d 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -256,6 +256,27 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>--exclude-extension=<replaceable class="parameter">pattern</replaceable></option></term>
+      <listitem>
+       <para>
+        Do not dump any extensions matching <replaceable
+        class="parameter">pattern</replaceable>.  The pattern is
+        interpreted according to the same rules as for <option>-e</option>.
+        <option>--exclude-extension</option> can be given more than once to exclude extensions
+        matching any of several patterns.
+       </para>
+
+       <para>
+        When both <option>-e</option> and <option>--exclude-extension</option> are given, the behavior
+        is to dump just the extensions that match at least one <option>-e</option>
+        switch but no <option>--exclude-extension</option> switches.  If <option>--exclude-extension</option>
+        appears without <option>-e</option>, then extensions matching <option>--exclude-extension</option> are
+        excluded from what is otherwise a normal dump.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>-E <replaceable class="parameter">encoding</replaceable></option></term>
       <term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term>
@@ -848,10 +869,11 @@ PostgreSQL documentation
         <option>--exclude-table-and-children</option> or
         <option>-T</option> for tables,
         <option>-n</option>/<option>--schema</option> for schemas,
-        <option>--include-foreign-data</option> for data on foreign servers and
+        <option>--include-foreign-data</option> for data on foreign servers,
         <option>--exclude-table-data</option>,
-        <option>--exclude-table-data-and-children</option> for table data,
-        <option>-e</option>/<option>--extension</option> for extensions.
+        <option>--exclude-table-data-and-children</option> for table data, and
+        <option>-e</option>/<option>--extension</option> or
+        <option>--exclude-extension</option> for extensions.
         To read from <literal>STDIN</literal>, use <filename>-</filename> as the
         filename.  The <option>--filter</option> option can be specified in
         conjunction with the above listed options for including or excluding
@@ -874,8 +896,7 @@ PostgreSQL documentation
          <listitem>
           <para>
            <literal>extension</literal>: extensions, works like the
-           <option>--extension</option> option. This keyword can only be
-           used with the <literal>include</literal> keyword.
+           <option>-e</option>/<option>--extension</option> option.
           </para>
          </listitem>
          <listitem>
@@ -1278,7 +1299,8 @@ PostgreSQL documentation
        </para>
        <para>
         This option has no effect
-        on <option>-N</option>/<option>--exclude-schema</option>,
+        on <option>--exclude-extension</option>,
+        <option>-N</option>/<option>--exclude-schema</option>,
         <option>-T</option>/<option>--exclude-table</option>,
         or <option>--exclude-table-data</option>.  An exclude pattern failing
         to match any objects is not considered an error.
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index a5149ca823..3ab7c6676a 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -136,6 +136,9 @@ static SimpleOidList foreign_servers_include_oids = {NULL, NULL};
 static SimpleStringList extension_include_patterns = {NULL, NULL};
 static SimpleOidList extension_include_oids = {NULL, NULL};
 
+static SimpleStringList extension_exclude_patterns = {NULL, NULL};
+static SimpleOidList extension_exclude_oids = {NULL, NULL};
+
 static const CatalogId nilCatalogId = {0, 0};
 
 /* override for standard extra_float_digits setting */
@@ -437,6 +440,7 @@ main(int argc, char **argv)
 		{"exclude-table-data-and-children", required_argument, NULL, 14},
 		{"sync-method", required_argument, NULL, 15},
 		{"filter", required_argument, NULL, 16},
+		{"exclude-extension", required_argument, NULL, 17},
 
 		{NULL, 0, NULL, 0}
 	};
@@ -672,6 +676,11 @@ main(int argc, char **argv)
 				read_dump_filters(optarg, &dopt);
 				break;
 
+			case 17:			/* exclude extension(s) */
+				simple_string_list_append(&extension_exclude_patterns,
+										  optarg);
+				break;
+
 			default:
 				/* getopt_long already emitted a complaint */
 				pg_log_error_hint("Try \"%s --help\" for more information.", progname);
@@ -890,6 +899,10 @@ main(int argc, char **argv)
 		if (extension_include_oids.head == NULL)
 			pg_fatal("no matching extensions were found");
 	}
+	expand_extension_name_patterns(fout, &extension_exclude_patterns,
+								   &extension_exclude_oids,
+								   false);
+	/* non-matching exclusion patterns aren't an error */
 
 	/*
 	 * Dumping LOs is the default for dumps where an inclusion switch is not
@@ -1095,6 +1108,7 @@ help(const char *progname)
 	printf(_("  -c, --clean                  clean (drop) database objects before recreating\n"));
 	printf(_("  -C, --create                 include commands to create database in dump\n"));
 	printf(_("  -e, --extension=PATTERN      dump the specified extension(s) only\n"));
+	printf(_("  --exclude-extension=PATTERN  do NOT dump the specified extension(s)\n"));
 	printf(_("  -E, --encoding=ENCODING      dump the data in encoding ENCODING\n"));
 	printf(_("  -n, --schema=PATTERN         dump the specified schema(s) only\n"));
 	printf(_("  -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
@@ -2028,6 +2042,12 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
 			extinfo->dobj.dump = extinfo->dobj.dump_contains =
 				dopt->include_everything ?
 				DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
+
+		/* check that the extension is not explicitly excluded */
+		if (extinfo->dobj.dump &&
+			simple_oid_list_member(&extension_exclude_oids,
+								   extinfo->dobj.catId.oid))
+			extinfo->dobj.dump = extinfo->dobj.dump_contains = DUMP_COMPONENT_NONE;
 	}
 }
 
@@ -18265,6 +18285,15 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
 									curext->dobj.catId.oid))
 			continue;
 
+		/*
+		 * Check if this extension is listed as to exclude in the dump.  If
+		 * yes, any table data associated with it is discarded.
+		 */
+		if (extension_exclude_oids.head != NULL &&
+			simple_oid_list_member(&extension_exclude_oids,
+								   curext->dobj.catId.oid))
+			continue;
+
 		if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
 		{
 			int			j;
@@ -18965,7 +18994,6 @@ read_dump_filters(const char *filename, DumpOptions *dopt)
 				case FILTER_OBJECT_TYPE_FUNCTION:
 				case FILTER_OBJECT_TYPE_INDEX:
 				case FILTER_OBJECT_TYPE_TRIGGER:
-				case FILTER_OBJECT_TYPE_EXTENSION:
 				case FILTER_OBJECT_TYPE_FOREIGN_DATA:
 					pg_log_filter_error(&fstate, _("%s filter for \"%s\" is not allowed"),
 										"exclude",
@@ -18973,6 +19001,9 @@ read_dump_filters(const char *filename, DumpOptions *dopt)
 					exit_nicely(1);
 					break;
 
+				case FILTER_OBJECT_TYPE_EXTENSION:
+					simple_string_list_append(&extension_exclude_patterns, objname);
+					break;
 				case FILTER_OBJECT_TYPE_TABLE_DATA:
 					simple_string_list_append(&tabledata_exclude_patterns,
 											  objname);
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl
index b8c30c2387..4266f26c65 100644
--- a/src/test/modules/test_pg_dump/t/001_base.pl
+++ b/src/test/modules/test_pg_dump/t/001_base.pl
@@ -220,6 +220,19 @@ my %pgdump_runs = (
 			'--extension=test_pg_dump', 'postgres',
 		],
 	},
+	exclude_extension => {
+		dump_cmd => [
+			'pg_dump', '--no-sync', "--file=$tempdir/exclude_extension.sql",
+			'--exclude-extension=test_pg_dump', 'postgres',
+		],
+	},
+	exclude_extension_filter => {
+		dump_cmd => [
+			'pg_dump', '--no-sync',
+			"--file=$tempdir/exclude_extension_filter.sql",
+			"--filter=$tempdir/exclude_extension_filter.txt", 'postgres',
+		],
+	},
 
 	# plpgsql in the list blocks the dump of extension test_pg_dump
 	without_extension => {
@@ -299,6 +312,8 @@ my %full_runs = (
 	no_owner => 1,
 	privileged_internals => 1,
 	with_extension => 1,
+	exclude_extension => 1,
+	exclude_extension_filter => 1,
 	without_extension => 1);
 
 my %tests = (
@@ -325,7 +340,12 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { binary_upgrade => 1, without_extension => 1 },
+		unlike => {
+			binary_upgrade => 1,
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
+			without_extension => 1
+		},
 	},
 
 	'CREATE ROLE regress_dump_test_role' => {
@@ -434,7 +454,11 @@ my %tests = (
 			section_data => 1,
 			extension_schema => 1,
 		},
-		unlike => { without_extension => 1, },
+		unlike => {
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
+			without_extension => 1,
+		},
 	},
 
 	'CREATE TABLE regress_pg_dump_table' => {
@@ -460,6 +484,8 @@ my %tests = (
 		unlike => {
 			binary_upgrade => 1,
 			exclude_table => 1,
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
 			without_extension => 1,
 		},
 	},
@@ -483,7 +509,12 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => {
+			no_privs => 1,
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
+			without_extension => 1,
+		},
 	},
 
 	'REVOKE GRANT OPTION FOR UPDATE ON SEQUENCE wgo_then_regular' => {
@@ -500,7 +531,12 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => {
+			no_privs => 1,
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
+			without_extension => 1,
+		},
 	},
 
 	'CREATE ACCESS METHOD regress_test_am' => {
@@ -520,7 +556,11 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { without_extension => 1, },
+		unlike => {
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
+			without_extension => 1,
+		},
 	},
 
 	'GRANT SELECT regress_pg_dump_table_added pre-ALTER EXTENSION' => {
@@ -545,7 +585,12 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => {
+			no_privs => 1,
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
+			without_extension => 1,
+		},
 	},
 
 	'GRANT SELECT ON TABLE regress_pg_dump_table' => {
@@ -579,7 +624,12 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1 },
+		unlike => {
+			no_privs => 1,
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
+			without_extension => 1
+		},
 	  },
 
 	'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role'
@@ -595,7 +645,12 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => {
+			no_privs => 1,
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
+			without_extension => 1,
+		},
 	  },
 
 	'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => {
@@ -617,7 +672,12 @@ my %tests = (
 			schema_only => 1,
 			section_pre_data => 1,
 		},
-		unlike => { no_privs => 1, without_extension => 1, },
+		unlike => {
+			no_privs => 1,
+			exclude_extension => 1,
+			exclude_extension_filter => 1,
+			without_extension => 1,
+		},
 	},
 
 	# Objects included in extension part of a schema created by this extension */
@@ -818,6 +878,16 @@ foreach my $test (
 # Send the combined set of commands to psql
 $node->safe_psql('postgres', $create_sql);
 
+#########################################
+# Create filter file for exclude_extension_filter test
+
+my $filterfile;
+
+open $filterfile, '>', "$tempdir/exclude_extension_filter.txt"
+  or die "unable to open filter file for writing";
+print $filterfile "exclude extension test_pg_dump\n";
+close $filterfile;
+
 #########################################
 # Run all runs
 
-- 
2.35.3

#10Daniel Gustafsson
daniel@yesql.se
In reply to: Dean Rasheed (#9)
Re: Proposal to include --exclude-extension Flag in pg_dump

On 19 Mar 2024, at 12:19, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:

I'm marking this ready-for-commit (which I'll probably do myself in a
day or two, unless anyone else claims it first).

LGTM too from a read through. I did notice a few mistakes in the --filter
documentation portion for other keywords but that's unrelated to this patch,
will fix them once this is in to avoid conflicts.

--
Daniel Gustafsson

#11Ayush Vatsa
ayushvatsa1810@gmail.com
In reply to: Daniel Gustafsson (#10)
Re: Proposal to include --exclude-extension Flag in pg_dump

I ran it through pgindent to fix some whitespace issues and added
another test for the filter option, based on the test case you added.

Thank you for addressing those whitespaces issues and adding more tests. I
appreciate your attention to detail and will certainly be more vigilant in
future.

I'm marking this ready-for-commit (which I'll probably do myself in a
day or two, unless anyone else claims it first).

Thank you very much, this marks my first contribution to the open-source
community, and I'm enthusiastic about making further meaningful
contributions to PostgreSQL in the future.

LGTM too from a read through. I did notice a few mistakes in the --filter
documentation portion for other keywords but that's unrelated to this

patch,

will fix them once this is in to avoid conflicts.

Thanks Daniel for your review. It's gratifying to see that my patch not
only introduced the intended feature but also brought other minor mistakes
to light.

Regards
Ayush Vatsa
Amazon Web services (AWS)

On Tue, 19 Mar 2024 at 17:23, Daniel Gustafsson <daniel@yesql.se> wrote:

Show quoted text

On 19 Mar 2024, at 12:19, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:

I'm marking this ready-for-commit (which I'll probably do myself in a
day or two, unless anyone else claims it first).

LGTM too from a read through. I did notice a few mistakes in the --filter
documentation portion for other keywords but that's unrelated to this
patch,
will fix them once this is in to avoid conflicts.

--
Daniel Gustafsson

#12Dean Rasheed
dean.a.rasheed@gmail.com
In reply to: Ayush Vatsa (#11)
Re: Proposal to include --exclude-extension Flag in pg_dump

On Tue, 19 Mar 2024 at 19:17, Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

I'm marking this ready-for-commit (which I'll probably do myself in a
day or two, unless anyone else claims it first).

Thank you very much, this marks my first contribution to the open-source community, and I'm enthusiastic about making further meaningful contributions to PostgreSQL in the future.

Committed. Congratulations on your first contribution to PostgreSQL!
May it be the first of many to come.

Regards,
Dean

#13Dean Rasheed
dean.a.rasheed@gmail.com
In reply to: Daniel Gustafsson (#10)
1 attachment(s)
Re: Proposal to include --exclude-extension Flag in pg_dump

On Tue, 19 Mar 2024 at 11:53, Daniel Gustafsson <daniel@yesql.se> wrote:

I did notice a few mistakes in the --filter
documentation portion for other keywords but that's unrelated to this patch,
will fix them once this is in to avoid conflicts.

Attached is a patch for the --filter docs, covering the omissions I can see.

Regards,
Dean

Attachments:

pg_dump-filter-docs.patchtext/x-patch; charset=US-ASCII; name=pg_dump-filter-docs.patchDownload
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
new file mode 100644
index 08d7753..b1dfa21
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -866,13 +866,14 @@ PostgreSQL documentation
         same rules as the corresponding options:
         <option>-t</option>/<option>--table</option>,
         <option>--table-and-children</option>,
-        <option>--exclude-table-and-children</option> or
-        <option>-T</option> for tables,
-        <option>-n</option>/<option>--schema</option> for schemas,
+        <option>-T</option>/<option>--exclude-table</option>, and
+        <option>--exclude-table-and-children</option> for tables,
+        <option>-n</option>/<option>--schema</option> and
+        <option>-N</option>/<option>--exclude-schema</option> for schemas,
         <option>--include-foreign-data</option> for data on foreign servers,
-        <option>--exclude-table-data</option>,
+        <option>--exclude-table-data</option> and
         <option>--exclude-table-data-and-children</option> for table data, and
-        <option>-e</option>/<option>--extension</option> or
+        <option>-e</option>/<option>--extension</option> and
         <option>--exclude-extension</option> for extensions.
         To read from <literal>STDIN</literal>, use <filename>-</filename> as the
         filename.  The <option>--filter</option> option can be specified in
@@ -895,34 +896,37 @@ PostgreSQL documentation
         <itemizedlist>
          <listitem>
           <para>
-           <literal>extension</literal>: extensions, works like the
-           <option>-e</option>/<option>--extension</option> option.
+           <literal>extension</literal>: extensions. This works like the
+           <option>-e</option>/<option>--extension</option> and
+           <option>--exclude-extension</option> options.
           </para>
          </listitem>
          <listitem>
           <para>
-           <literal>foreign_data</literal>: data on foreign servers, works like
+           <literal>foreign_data</literal>: data on foreign servers. This works like
            the <option>--include-foreign-data</option> option. This keyword can
            only be used with the <literal>include</literal> keyword.
           </para>
          </listitem>
          <listitem>
           <para>
-           <literal>table</literal>: tables, works like the
-           <option>-t</option>/<option>--table</option> option.
+           <literal>table</literal>: tables. This works like the
+           <option>-t</option>/<option>--table</option> and
+           <option>-T</option>/<option>--exclude-table</option> options.
           </para>
          </listitem>
          <listitem>
           <para>
            <literal>table_and_children</literal>: tables including any partitions
-           or inheritance child tables, works like the
-           <option>--table-and-children</option> option.
+           or inheritance child tables. This works like the
+           <option>--table-and-children</option> and
+           <option>--exclude-table-and-children</option> options.
           </para>
          </listitem>
          <listitem>
           <para>
            <literal>table_data</literal>: table data of any tables matching
-           <replaceable>pattern</replaceable>, works like the
+           <replaceable>pattern</replaceable>. This works like the
            <option>--exclude-table-data</option> option. This keyword can only
            be used with the <literal>exclude</literal> keyword.
           </para>
@@ -931,15 +935,16 @@ PostgreSQL documentation
           <para>
            <literal>table_data_and_children</literal>: table data of any tables
            matching <replaceable>pattern</replaceable> as well as any partitions
-           or inheritance children of the table(s), works like the
+           or inheritance children of the table(s). This works like the
            <option>--exclude-table-data-and-children</option> option. This
            keyword can only be used with the <literal>exclude</literal> keyword.
           </para>
          </listitem>
          <listitem>
           <para>
-           <literal>schema</literal>: schemas, works like the
-           <option>-n</option>/<option>--schema</option> option.
+           <literal>schema</literal>: schemas. This works like the
+           <option>-n</option>/<option>--schema</option> and
+           <option>-N</option>/<option>--exclude-schema</option> options.
           </para>
          </listitem>
         </itemizedlist>
#14Ayush Vatsa
ayushvatsa1810@gmail.com
In reply to: Dean Rasheed (#13)
Re: Proposal to include --exclude-extension Flag in pg_dump

Attached is a patch for the --filter docs, covering the omissions I can

see.
Thanks Dean for working on this.
I have reviewed the changes and they look good to me.

Regards,
Ayush Vatsa
Amazon Web services (AWS)

On Fri, 7 Jun 2024 at 15:50, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:

Show quoted text

On Tue, 19 Mar 2024 at 11:53, Daniel Gustafsson <daniel@yesql.se> wrote:

I did notice a few mistakes in the --filter
documentation portion for other keywords but that's unrelated to this

patch,

will fix them once this is in to avoid conflicts.

Attached is a patch for the --filter docs, covering the omissions I can
see.

Regards,
Dean

#15Dean Rasheed
dean.a.rasheed@gmail.com
In reply to: Ayush Vatsa (#14)
Re: Proposal to include --exclude-extension Flag in pg_dump

On Sat, 8 Jun 2024 at 19:39, Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:

Attached is a patch for the --filter docs, covering the omissions I can see.

Thanks Dean for working on this.
I have reviewed the changes and they look good to me.

Thanks for checking. I have committed this now.

Regards,
Dean