Allow pg_dump to include/exclude child tables automatically.
authorTom Lane <[email protected]>
Tue, 14 Mar 2023 20:09:03 +0000 (16:09 -0400)
committerTom Lane <[email protected]>
Tue, 14 Mar 2023 20:09:03 +0000 (16:09 -0400)
This patch adds new pg_dump switches
    --table-and-children=pattern
    --exclude-table-and-children=pattern
    --exclude-table-data-and-children=pattern
which act the same as the existing --table, --exclude-table, and
--exclude-table-data switches, except that any partitions or
inheritance child tables of the table(s) matching the pattern
are also included or excluded.

Gilles Darold, reviewed by Stéphane Tachoires

Discussion: https://postgr.es/m/5aa393b5-5f67-8447-b83e-544516990ee2@migops.com

doc/src/sgml/ref/pg_dump.sgml
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/t/002_pg_dump.pl

index 334e4b7fd144e24b62f3cfa900ebae8b6580782e..e6b003bf1041eaf725908c71b25aa1a3932d0bcb 100644 (file)
@@ -775,6 +775,19 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>--exclude-table-and-children=<replaceable class="parameter">pattern</replaceable></option></term>
+      <listitem>
+       <para>
+        This is the same as
+        the <option>-T</option>/<option>--exclude-table</option> option,
+        except that it also excludes any partitions or inheritance child
+        tables of the table(s) matching the
+        <replaceable class="parameter">pattern</replaceable>.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>--exclude-table-data=<replaceable class="parameter">pattern</replaceable></option></term>
       <listitem>
@@ -793,6 +806,18 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>--exclude-table-data-and-children=<replaceable class="parameter">pattern</replaceable></option></term>
+      <listitem>
+       <para>
+        This is the same as the <option>--exclude-table-data</option> option,
+        except that it also excludes data of any partitions or inheritance
+        child tables of the table(s) matching the
+        <replaceable class="parameter">pattern</replaceable>.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>--extra-float-digits=<replaceable class="parameter">ndigits</replaceable></option></term>
       <listitem>
@@ -1142,9 +1167,9 @@ PostgreSQL documentation
         Require that each
         extension (<option>-e</option>/<option>--extension</option>),
         schema (<option>-n</option>/<option>--schema</option>) and
-        table (<option>-t</option>/<option>--table</option>) qualifier
+        table (<option>-t</option>/<option>--table</option>) pattern
         match at least one extension/schema/table in the database to be dumped.
-        Note that if none of the extension/schema/table qualifiers find
+        Note that if none of the extension/schema/table patterns find
         matches, <application>pg_dump</application> will generate an error
         even without <option>--strict-names</option>.
        </para>
@@ -1158,6 +1183,19 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>--table-and-children=<replaceable class="parameter">pattern</replaceable></option></term>
+      <listitem>
+       <para>
+        This is the same as
+        the <option>-t</option>/<option>--table</option> option,
+        except that it also includes any partitions or inheritance child
+        tables of the table(s) matching the
+        <replaceable class="parameter">pattern</replaceable>.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>--use-set-session-authorization</option></term>
       <listitem>
index 4217908f84ab53ac1ea410f8ea1720713e5b75b6..2e068c6620ecb1d8f09421ade567f7e0f6896d2f 100644 (file)
@@ -119,11 +119,15 @@ static SimpleStringList schema_exclude_patterns = {NULL, NULL};
 static SimpleOidList schema_exclude_oids = {NULL, NULL};
 
 static SimpleStringList table_include_patterns = {NULL, NULL};
+static SimpleStringList table_include_patterns_and_children = {NULL, NULL};
 static SimpleOidList table_include_oids = {NULL, NULL};
 static SimpleStringList table_exclude_patterns = {NULL, NULL};
+static SimpleStringList table_exclude_patterns_and_children = {NULL, NULL};
 static SimpleOidList table_exclude_oids = {NULL, NULL};
 static SimpleStringList tabledata_exclude_patterns = {NULL, NULL};
+static SimpleStringList tabledata_exclude_patterns_and_children = {NULL, NULL};
 static SimpleOidList tabledata_exclude_oids = {NULL, NULL};
+
 static SimpleStringList foreign_servers_include_patterns = {NULL, NULL};
 static SimpleOidList foreign_servers_include_oids = {NULL, NULL};
 
@@ -180,7 +184,8 @@ static void expand_foreign_server_name_patterns(Archive *fout,
 static void expand_table_name_patterns(Archive *fout,
                                                                           SimpleStringList *patterns,
                                                                           SimpleOidList *oids,
-                                                                          bool strict_names);
+                                                                          bool strict_names,
+                                                                          bool with_child_tables);
 static void prohibit_crossdb_refs(PGconn *conn, const char *dbname,
                                                                  const char *pattern);
 
@@ -421,6 +426,9 @@ main(int argc, char **argv)
                {"on-conflict-do-nothing", no_argument, &dopt.do_nothing, 1},
                {"rows-per-insert", required_argument, NULL, 10},
                {"include-foreign-data", required_argument, NULL, 11},
+               {"table-and-children", required_argument, NULL, 12},
+               {"exclude-table-and-children", required_argument, NULL, 13},
+               {"exclude-table-data-and-children", required_argument, NULL, 14},
 
                {NULL, 0, NULL, 0}
        };
@@ -631,6 +639,22 @@ main(int argc, char **argv)
                                                                                  optarg);
                                break;
 
+                       case 12:                        /* include table(s) and their children */
+                               simple_string_list_append(&table_include_patterns_and_children,
+                                                                                 optarg);
+                               dopt.include_everything = false;
+                               break;
+
+                       case 13:                        /* exclude table(s) and their children */
+                               simple_string_list_append(&table_exclude_patterns_and_children,
+                                                                                 optarg);
+                               break;
+
+                       case 14:                        /* exclude data of table(s) and children */
+                               simple_string_list_append(&tabledata_exclude_patterns_and_children,
+                                                                                 optarg);
+                               break;
+
                        default:
                                /* getopt_long already emitted a complaint */
                                pg_log_error_hint("Try \"%s --help\" for more information.", progname);
@@ -810,21 +834,30 @@ main(int argc, char **argv)
        /* non-matching exclusion patterns aren't an error */
 
        /* Expand table selection patterns into OID lists */
-       if (table_include_patterns.head != NULL)
-       {
-               expand_table_name_patterns(fout, &table_include_patterns,
-                                                                  &table_include_oids,
-                                                                  strict_names);
-               if (table_include_oids.head == NULL)
-                       pg_fatal("no matching tables were found");
-       }
+       expand_table_name_patterns(fout, &table_include_patterns,
+                                                          &table_include_oids,
+                                                          strict_names, false);
+       expand_table_name_patterns(fout, &table_include_patterns_and_children,
+                                                          &table_include_oids,
+                                                          strict_names, true);
+       if ((table_include_patterns.head != NULL ||
+                table_include_patterns_and_children.head != NULL) &&
+               table_include_oids.head == NULL)
+               pg_fatal("no matching tables were found");
+
        expand_table_name_patterns(fout, &table_exclude_patterns,
                                                           &table_exclude_oids,
-                                                          false);
+                                                          false, false);
+       expand_table_name_patterns(fout, &table_exclude_patterns_and_children,
+                                                          &table_exclude_oids,
+                                                          false, true);
 
        expand_table_name_patterns(fout, &tabledata_exclude_patterns,
                                                           &tabledata_exclude_oids,
-                                                          false);
+                                                          false, false);
+       expand_table_name_patterns(fout, &tabledata_exclude_patterns_and_children,
+                                                          &tabledata_exclude_oids,
+                                                          false, true);
 
        expand_foreign_server_name_patterns(fout, &foreign_servers_include_patterns,
                                                                                &foreign_servers_include_oids);
@@ -1051,7 +1084,7 @@ help(const char *progname)
                         "                               plain-text format\n"));
        printf(_("  -s, --schema-only            dump only the schema, no data\n"));
        printf(_("  -S, --superuser=NAME         superuser user name to use in plain-text format\n"));
-       printf(_("  -t, --table=PATTERN          dump the specified table(s) only\n"));
+       printf(_("  -t, --table=PATTERN          dump only the specified table(s)\n"));
        printf(_("  -T, --exclude-table=PATTERN  do NOT dump the specified table(s)\n"));
        printf(_("  -x, --no-privileges          do not dump privileges (grant/revoke)\n"));
        printf(_("  --binary-upgrade             for use by upgrade utilities only\n"));
@@ -1060,7 +1093,13 @@ help(const char *progname)
        printf(_("  --disable-triggers           disable triggers during data-only restore\n"));
        printf(_("  --enable-row-security        enable row security (dump only content user has\n"
                         "                               access to)\n"));
+       printf(_("  --exclude-table-and-children=PATTERN\n"
+                        "                               do NOT dump the specified table(s),\n"
+                        "                               including child and partition tables\n"));
        printf(_("  --exclude-table-data=PATTERN do NOT dump data for the specified table(s)\n"));
+       printf(_("  --exclude-table-data-and-children=PATTERN\n"
+                        "                               do NOT dump data for the specified table(s),\n"
+                        "                               including child and partition tables\n"));
        printf(_("  --extra-float-digits=NUM     override default setting for extra_float_digits\n"));
        printf(_("  --if-exists                  use IF EXISTS when dropping objects\n"));
        printf(_("  --include-foreign-data=PATTERN\n"
@@ -1084,6 +1123,8 @@ help(const char *progname)
        printf(_("  --snapshot=SNAPSHOT          use given snapshot for the dump\n"));
        printf(_("  --strict-names               require table and/or schema include patterns to\n"
                         "                               match at least one entity each\n"));
+       printf(_("  --table-and-children=PATTERN dump only the specified table(s),\n"
+                        "                               including child and partition tables\n"));
        printf(_("  --use-set-session-authorization\n"
                         "                               use SET SESSION AUTHORIZATION commands instead of\n"
                         "                               ALTER OWNER commands to set ownership\n"));
@@ -1497,7 +1538,7 @@ expand_foreign_server_name_patterns(Archive *fout,
 static void
 expand_table_name_patterns(Archive *fout,
                                                   SimpleStringList *patterns, SimpleOidList *oids,
-                                                  bool strict_names)
+                                                  bool strict_names, bool with_child_tables)
 {
        PQExpBuffer query;
        PGresult   *res;
@@ -1523,7 +1564,15 @@ expand_table_name_patterns(Archive *fout,
                 * Query must remain ABSOLUTELY devoid of unqualified names.  This
                 * would be unnecessary given a pg_table_is_visible() variant taking a
                 * search_path argument.
+                *
+                * For with_child_tables, we start with the basic query's results and
+                * recursively search the inheritance tree to add child tables.
                 */
+               if (with_child_tables)
+               {
+                       appendPQExpBuffer(query, "WITH RECURSIVE partition_tree (relid) AS (\n");
+               }
+
                appendPQExpBuffer(query,
                                                  "SELECT c.oid"
                                                  "\nFROM pg_catalog.pg_class c"
@@ -1546,6 +1595,17 @@ expand_table_name_patterns(Archive *fout,
                        prohibit_crossdb_refs(GetConnection(fout), dbbuf.data, cell->val);
                termPQExpBuffer(&dbbuf);
 
+               if (with_child_tables)
+               {
+                       appendPQExpBuffer(query, "UNION"
+                                                         "\nSELECT i.inhrelid"
+                                                         "\nFROM partition_tree p"
+                                                         "\n     JOIN pg_catalog.pg_inherits i"
+                                                         "\n     ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
+                                                         "\n)"
+                                                         "\nSELECT relid FROM partition_tree");
+               }
+
                ExecuteSqlStatement(fout, "RESET search_path");
                res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
                PQclear(ExecuteSqlQueryForSingleRow(fout,
index 9c354213cebc75c40a9500d7346ec8e5f19c2f33..a22f27f300f06bf186f6c96807421aa9aa1f51d9 100644 (file)
@@ -393,6 +393,24 @@ my %pgdump_runs = (
                        '--exclude-table=dump_test.test_table', 'postgres',
                ],
        },
+       exclude_measurement => {
+               dump_cmd => [
+                       'pg_dump', '--no-sync',
+                       "--file=$tempdir/exclude_measurement.sql",
+                       '--exclude-table-and-children=dump_test.measurement',
+                       'postgres',
+               ],
+       },
+       exclude_measurement_data => {
+               dump_cmd => [
+                       'pg_dump',
+                       '--no-sync',
+                       "--file=$tempdir/exclude_measurement_data.sql",
+                       '--exclude-table-data-and-children=dump_test.measurement',
+                       '--no-unlogged-table-data',
+                       'postgres',
+               ],
+       },
        exclude_test_table_data => {
                dump_cmd => [
                        'pg_dump',
@@ -487,6 +505,17 @@ my %pgdump_runs = (
                        'postgres',
                ],
        },
+       only_dump_measurement => {
+               dump_cmd => [
+                       'pg_dump',
+                       '--no-sync',
+                       "--file=$tempdir/only_dump_measurement.sql",
+                       '--table-and-children=dump_test.measurement',
+                       '--lock-wait-timeout='
+                         . (1000 * $PostgreSQL::Test::Utils::timeout_default),
+                       'postgres',
+               ],
+       },
        role => {
                dump_cmd => [
                        'pg_dump',
@@ -604,6 +633,7 @@ my %pgdump_runs = (
 # Tests which target the 'dump_test' schema, specifically.
 my %dump_test_schema_runs = (
        only_dump_test_schema  => 1,
+       only_dump_measurement  => 1,
        test_schema_plus_large_objects => 1,);
 
 # Tests which are considered 'full' dumps by pg_dump, but there
@@ -618,6 +648,8 @@ my %full_runs = (
        exclude_dump_test_schema => 1,
        exclude_test_table       => 1,
        exclude_test_table_data  => 1,
+       exclude_measurement      => 1,
+       exclude_measurement_data => 1,
        no_toast_compression     => 1,
        no_large_objects         => 1,
        no_owner                 => 1,
@@ -644,6 +676,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_privs                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -663,6 +696,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_privs                 => 1,
+                       only_dump_measurement    => 1,
                },
          },
 
@@ -741,6 +775,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_owner                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -754,6 +789,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_owner                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -786,7 +822,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'ALTER OPERATOR CLASS dump_test.op_class OWNER TO' => {
@@ -799,6 +838,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_owner                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -838,6 +878,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_owner                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -884,6 +925,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -901,6 +943,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -920,6 +963,7 @@ my %tests = (
                },
                unlike => {
                        exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -939,6 +983,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -958,6 +1003,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -977,6 +1023,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -996,6 +1043,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1010,6 +1058,10 @@ my %tests = (
                        role             => 1,
                        section_pre_data => 1,
                        binary_upgrade   => 1,
+                       only_dump_measurement => 1,
+               },
+               unlike => {
+                       exclude_measurement => 1,
                },
          },
 
@@ -1029,6 +1081,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1050,7 +1103,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'ALTER TABLE test_table OWNER TO' => {
@@ -1064,6 +1120,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                        no_owner                 => 1,
                },
        },
@@ -1083,6 +1140,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1094,16 +1152,22 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_owner                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
        'ALTER TABLE measurement OWNER TO' => {
                regexp => qr/^\QALTER TABLE dump_test.measurement OWNER TO \E.+;/m,
-               like =>
-                 { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
+               like => {
+                       %full_runs,
+                       %dump_test_schema_runs,
+                       section_pre_data => 1,
+                       only_dump_measurement => 1,
+               },
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_owner                 => 1,
+                       exclude_measurement      => 1,
                },
        },
 
@@ -1114,8 +1178,12 @@ my %tests = (
                        %full_runs,
                        role             => 1,
                        section_pre_data => 1,
+                       only_dump_measurement => 1,
+               },
+               unlike => {
+                       no_owner => 1,
+                       exclude_measurement => 1,
                },
-               unlike => { no_owner => 1, },
        },
 
        'ALTER FOREIGN TABLE foreign_table OWNER TO' => {
@@ -1126,6 +1194,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_owner                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1137,6 +1206,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_owner                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1150,6 +1220,7 @@ my %tests = (
                        only_dump_test_table     => 1,
                        no_owner                 => 1,
                        role                     => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1240,6 +1311,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1259,6 +1331,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1271,7 +1344,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON COLUMN dump_test.test_second_table.col1' => {
@@ -1283,7 +1359,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON COLUMN dump_test.test_second_table.col2' => {
@@ -1295,7 +1374,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON CONVERSION dump_test.test_conversion' => {
@@ -1306,7 +1388,10 @@ my %tests = (
                  qr/^\QCOMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversion';\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON COLLATION test0' => {
@@ -1372,7 +1457,10 @@ my %tests = (
                  qr/^\QCOMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 IS 'comment on text search configuration';\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1' => {
@@ -1384,7 +1472,10 @@ my %tests = (
                  qr/^\QCOMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 IS 'comment on text search dictionary';\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1' => {
@@ -1395,7 +1486,10 @@ my %tests = (
                  qr/^\QCOMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1 IS 'comment on text search parser';\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1' => {
@@ -1406,7 +1500,10 @@ my %tests = (
                  qr/^\QCOMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 IS 'comment on text search template';\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON TYPE dump_test.planets - ENUM' => {
@@ -1417,7 +1514,10 @@ my %tests = (
                  qr/^\QCOMMENT ON TYPE dump_test.planets IS 'comment on enum type';\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON TYPE dump_test.textrange - RANGE' => {
@@ -1428,7 +1528,10 @@ my %tests = (
                  qr/^\QCOMMENT ON TYPE dump_test.textrange IS 'comment on range type';\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON TYPE dump_test.int42 - Regular' => {
@@ -1439,7 +1542,10 @@ my %tests = (
                  qr/^\QCOMMENT ON TYPE dump_test.int42 IS 'comment on regular type';\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COMMENT ON TYPE dump_test.undefined - Undefined' => {
@@ -1450,7 +1556,10 @@ my %tests = (
                  qr/^\QCOMMENT ON TYPE dump_test.undefined IS 'comment on undefined type';\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'COPY test_table' => {
@@ -1474,6 +1583,7 @@ my %tests = (
                        exclude_test_table       => 1,
                        exclude_test_table_data  => 1,
                        schema_only              => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1497,6 +1607,7 @@ my %tests = (
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
                        schema_only              => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1532,6 +1643,7 @@ my %tests = (
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
                        schema_only              => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1553,6 +1665,7 @@ my %tests = (
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
                        schema_only              => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1575,6 +1688,7 @@ my %tests = (
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
                        schema_only              => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1596,6 +1710,7 @@ my %tests = (
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
                        schema_only              => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1617,6 +1732,7 @@ my %tests = (
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
                        schema_only              => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -1796,7 +1912,10 @@ my %tests = (
                        exclude_test_table => 1,
                        section_pre_data   => 1,
                },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE CONVERSION dump_test.test_conversion' => {
@@ -1807,7 +1926,10 @@ my %tests = (
                  qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;\E/xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE DOMAIN dump_test.us_postal_code' => {
@@ -1829,7 +1951,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE FUNCTION dump_test.pltestlang_call_handler' => {
@@ -1846,7 +1971,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE FUNCTION dump_test.trigger_func' => {
@@ -1862,7 +1990,10 @@ my %tests = (
                        \$\$;/xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE FUNCTION dump_test.event_trigger_func' => {
@@ -1878,7 +2009,10 @@ my %tests = (
                        \$\$;/xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE OPERATOR FAMILY dump_test.op_family' => {
@@ -1890,7 +2024,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE OPERATOR CLASS dump_test.op_class' => {
@@ -1920,7 +2057,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        # verify that a custom operator/opclass/range type is dumped in right order
@@ -1950,7 +2090,10 @@ my %tests = (
                        /xms,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement => 1,
+               },
        },
 
        'CREATE OPERATOR CLASS dump_test.op_class_empty' => {
@@ -1965,7 +2108,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE EVENT TRIGGER test_event_trigger' => {
@@ -2001,6 +2147,7 @@ my %tests = (
                unlike => {
                        exclude_test_table       => 1,
                        exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -2019,6 +2166,7 @@ my %tests = (
                unlike => {
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -2047,7 +2195,10 @@ my %tests = (
                        \n\);/xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TYPE dump_test.int42' => {
@@ -2056,7 +2207,10 @@ my %tests = (
                regexp       => qr/^\QCREATE TYPE dump_test.int42;\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1' => {
@@ -2068,7 +2222,10 @@ my %tests = (
                        \s+\QPARSER = pg_catalog."default" );\E/xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'ALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 ...' => {
@@ -2133,7 +2290,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1' => {
@@ -2145,7 +2305,10 @@ my %tests = (
                        \s+\QLEXIZE = dsimple_lexize );\E/xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TEXT SEARCH PARSER dump_test.alt_ts_prs1' => {
@@ -2161,7 +2324,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1' => {
@@ -2174,7 +2340,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE FUNCTION dump_test.int42_in' => {
@@ -2189,7 +2358,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE FUNCTION dump_test.int42_out' => {
@@ -2204,7 +2376,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE FUNCTION ... SUPPORT' => {
@@ -2218,7 +2393,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE PROCEDURE dump_test.ptest1' => {
@@ -2232,7 +2410,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TYPE dump_test.int42 populated' => {
@@ -2256,7 +2437,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TYPE dump_test.composite' => {
@@ -2273,7 +2457,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TYPE dump_test.undefined' => {
@@ -2282,7 +2469,10 @@ my %tests = (
                regexp       => qr/^\QCREATE TYPE dump_test.undefined;\E/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE FOREIGN DATA WRAPPER dummy' => {
@@ -2315,7 +2505,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE USER MAPPING FOR regress_dump_test_role SERVER s1' => {
@@ -2360,7 +2553,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE MATERIALIZED VIEW matview_second' => {
@@ -2376,7 +2572,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE MATERIALIZED VIEW matview_third' => {
@@ -2392,7 +2591,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE MATERIALIZED VIEW matview_fourth' => {
@@ -2408,7 +2610,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE MATERIALIZED VIEW matview_compression' => {
@@ -2429,8 +2634,11 @@ my %tests = (
                lz4 => 1,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike =>
-                 { exclude_dump_test_schema => 1, no_toast_compression => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       no_toast_compression     => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE POLICY p1 ON test_table' => {
@@ -2451,6 +2659,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -2471,6 +2680,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -2491,6 +2701,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -2511,6 +2722,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -2531,6 +2743,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -2551,6 +2764,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -2746,7 +2960,10 @@ my %tests = (
                regexp       => qr/^CREATE SCHEMA dump_test;/m,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE SCHEMA dump_test_second_schema' => {
@@ -2791,6 +3008,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -2806,7 +3024,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_second_table' => {
@@ -2823,7 +3044,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_compression' => {
@@ -2843,8 +3067,11 @@ my %tests = (
                lz4 => 1,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike =>
-                 { exclude_dump_test_schema => 1, no_toast_compression => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       no_toast_compression => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE measurement PARTITIONED BY' => {
@@ -2867,11 +3094,16 @@ my %tests = (
                        \)\n
                        \QPARTITION BY RANGE (logdate);\E\n
                        /xm,
-               like =>
-                 { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
+               like => {
+                       %full_runs,
+                       %dump_test_schema_runs,
+                       section_pre_data => 1,
+                       only_dump_measurement => 1,
+               },
                unlike => {
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
+                       exclude_measurement => 1,
                },
        },
 
@@ -2898,6 +3130,10 @@ my %tests = (
                        section_pre_data => 1,
                        role             => 1,
                        binary_upgrade   => 1,
+                       only_dump_measurement => 1,
+               },
+               unlike => {
+                       exclude_measurement => 1,
                },
        },
 
@@ -2913,9 +3149,40 @@ my %tests = (
                        /xm,
                like => {
                        %full_runs, %dump_test_schema_runs, section_post_data => 1,
+                       only_dump_measurement => 1,
                },
                unlike => {
                        exclude_dump_test_schema => 1,
+                       exclude_measurement => 1,
+               },
+       },
+
+       'COPY measurement' => {
+               create_order => 93,
+               create_sql   => 'INSERT INTO dump_test.measurement (city_id, logdate, peaktemp, unitsales) '
+                 . "VALUES (1, '2006-02-12', 35, 1);",
+               regexp => qr/^
+                       \QCOPY dump_test_second_schema.measurement_y2006m2 (city_id, logdate, peaktemp, unitsales) FROM stdin;\E
+                       \n(?:1\t2006-02-12\t35\t1\n)\\\.\n
+                       /xm,
+               like => {
+                       %full_runs,
+                       %dump_test_schema_runs,
+                       data_only            => 1,
+                       only_dump_measurement => 1,
+                       section_data         => 1,
+                       only_dump_test_schema => 1,
+                       role_parallel => 1,
+                       role => 1,
+               },
+               unlike => {
+                       binary_upgrade           => 1,
+                       schema_only              => 1,
+                       exclude_measurement      => 1,
+                       only_dump_test_schema    => 1,
+                       test_schema_plus_large_objects => 1,
+                       exclude_measurement      => 1,
+                       exclude_measurement_data => 1,
                },
        },
 
@@ -2943,6 +3210,10 @@ my %tests = (
                        section_post_data => 1,
                        role              => 1,
                        binary_upgrade    => 1,
+                       only_dump_measurement => 1,
+               },
+               unlike => {
+                       exclude_measurement => 1,
                },
        },
 
@@ -2955,6 +3226,10 @@ my %tests = (
                        section_post_data => 1,
                        role              => 1,
                        binary_upgrade    => 1,
+                       only_dump_measurement => 1,
+               },
+               unlike => {
+                       exclude_measurement => 1,
                },
        },
 
@@ -2967,6 +3242,10 @@ my %tests = (
                        section_post_data => 1,
                        role              => 1,
                        binary_upgrade    => 1,
+                       only_dump_measurement => 1,
+               },
+               unlike => {
+                       exclude_measurement => 1,
                },
        },
 
@@ -3002,7 +3281,11 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { binary_upgrade => 1, exclude_dump_test_schema => 1, },
+               unlike => {
+                       binary_upgrade => 1,
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement => 1,
+               },
        },
 
        'CREATE TABLE test_fourth_table_zero_col' => {
@@ -3015,7 +3298,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_fifth_table' => {
@@ -3038,7 +3324,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_sixth_table' => {
@@ -3057,7 +3346,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_seventh_table' => {
@@ -3076,7 +3368,10 @@ my %tests = (
                        /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_table_identity' => {
@@ -3102,7 +3397,10 @@ my %tests = (
                        /xms,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_table_generated' => {
@@ -3119,7 +3417,10 @@ my %tests = (
                        /xms,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_table_generated_child1 (without local columns)' => {
@@ -3136,6 +3437,7 @@ my %tests = (
                unlike => {
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3165,6 +3467,7 @@ my %tests = (
                unlike => {
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3187,7 +3490,10 @@ my %tests = (
                        /xms,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_inheritance_parent' => {
@@ -3205,7 +3511,10 @@ my %tests = (
                /xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE TABLE test_inheritance_child' => {
@@ -3227,6 +3536,7 @@ my %tests = (
                unlike => {
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3239,7 +3549,10 @@ my %tests = (
                    /xms,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE STATISTICS extended_stats_options' => {
@@ -3251,7 +3564,10 @@ my %tests = (
                    /xms,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'ALTER STATISTICS extended_stats_options' => {
@@ -3263,7 +3579,10 @@ my %tests = (
                    /xms,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE STATISTICS extended_stats_expression' => {
@@ -3275,7 +3594,10 @@ my %tests = (
                    /xms,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE SEQUENCE test_table_col1_seq' => {
@@ -3294,7 +3616,10 @@ my %tests = (
                        only_dump_test_table => 1,
                        section_pre_data     => 1,
                },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE INDEX ON ONLY measurement' => {
@@ -3324,6 +3649,8 @@ my %tests = (
                        schema_only             => 1,
                        section_post_data       => 1,
                        test_schema_plus_large_objects => 1,
+                       only_dump_measurement   => 1,
+                       exclude_measurement_data => 1,
                },
                unlike => {
                        exclude_dump_test_schema => 1,
@@ -3332,6 +3659,7 @@ my %tests = (
                        pg_dumpall_globals_clean => 1,
                        role                     => 1,
                        section_pre_data         => 1,
+                       exclude_measurement      => 1,
                },
        },
 
@@ -3345,9 +3673,16 @@ my %tests = (
                        \QALTER TABLE ONLY dump_test.measurement\E \n^\s+
                        \QADD CONSTRAINT measurement_pkey PRIMARY KEY (city_id, logdate);\E
                /xm,
-               like =>
-                 { %full_runs, %dump_test_schema_runs, section_post_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               like => {
+                       %full_runs,
+                       %dump_test_schema_runs,
+                       section_post_data => 1,
+                       only_dump_measurement => 1,
+               },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       exclude_measurement      => 1,
+               },
        },
 
        'CREATE INDEX ... ON measurement_y2006_m2' => {
@@ -3358,6 +3693,10 @@ my %tests = (
                        %full_runs,
                        role              => 1,
                        section_post_data => 1,
+                       only_dump_measurement => 1,
+               },
+               unlike => {
+                       exclude_measurement      => 1,
                },
        },
 
@@ -3369,6 +3708,11 @@ my %tests = (
                        %full_runs,
                        role              => 1,
                        section_post_data => 1,
+                       only_dump_measurement => 1,
+                       exclude_measurement_data => 1,
+               },
+               unlike => {
+                       exclude_measurement      => 1,
                },
        },
 
@@ -3398,6 +3742,8 @@ my %tests = (
                        role                     => 1,
                        schema_only              => 1,
                        section_post_data        => 1,
+                       only_dump_measurement    => 1,
+                       exclude_measurement_data => 1,
                },
                unlike => {
                        only_dump_test_schema    => 1,
@@ -3406,6 +3752,7 @@ my %tests = (
                        pg_dumpall_globals_clean => 1,
                        section_pre_data         => 1,
                        test_schema_plus_large_objects => 1,
+                       exclude_measurement      => 1,
                },
        },
 
@@ -3421,7 +3768,10 @@ my %tests = (
                        \n\s+\QWITH LOCAL CHECK OPTION;\E/xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'ALTER VIEW test_view SET DEFAULT' => {
@@ -3432,7 +3782,10 @@ my %tests = (
                        \QALTER TABLE ONLY dump_test.test_view ALTER COLUMN col1 SET DEFAULT 1;\E/xm,
                like =>
                  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
-               unlike => { exclude_dump_test_schema => 1, },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        # FIXME
@@ -3604,6 +3957,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_privs                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3619,6 +3973,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_privs                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3634,6 +3989,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_privs                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3649,6 +4005,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_privs                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3678,6 +4035,7 @@ my %tests = (
                        exclude_dump_test_schema => 1,
                        exclude_test_table       => 1,
                        no_privs                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3688,11 +4046,16 @@ my %tests = (
                                                   TO regress_dump_test_role;',
                regexp =>
                  qr/^\QGRANT SELECT ON TABLE dump_test.measurement TO regress_dump_test_role;\E/m,
-               like =>
-                 { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
+               like => {
+                       %full_runs,
+                       %dump_test_schema_runs,
+                       section_pre_data => 1,
+                       only_dump_measurement => 1,
+               },
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_privs                 => 1,
+                       exclude_measurement      => 1,
                },
        },
 
@@ -3710,8 +4073,12 @@ my %tests = (
                        %full_runs,
                        role             => 1,
                        section_pre_data => 1,
+                       only_dump_measurement => 1,
+               },
+               unlike => {
+                       no_privs => 1,
+                       exclude_measurement      => 1,
                },
-               unlike => { no_privs => 1, },
        },
 
        'GRANT ALL ON LARGE OBJECT ...' => {
@@ -3755,6 +4122,7 @@ my %tests = (
                unlike => {
                        exclude_dump_test_schema => 1,
                        no_privs                 => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3856,6 +4224,7 @@ my %tests = (
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
                        schema_only              => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3871,6 +4240,7 @@ my %tests = (
                        binary_upgrade           => 1,
                        exclude_dump_test_schema => 1,
                        schema_only              => 1,
+                       only_dump_measurement    => 1,
                },
        },
 
@@ -3958,6 +4328,7 @@ my %tests = (
                        only_dump_test_table => 1,
                        role                 => 1,
                        section_pre_data     => 1,
+                       only_dump_measurement => 1,
                },
                unlike => { no_privs => 1, },
        },
@@ -3996,8 +4367,11 @@ my %tests = (
                like => {
                        %full_runs, %dump_test_schema_runs, section_pre_data => 1,
                },
-               unlike =>
-                 { exclude_dump_test_schema => 1, no_table_access_method => 1 },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       no_table_access_method => 1,
+                       only_dump_measurement    => 1,
+               },
        },
 
        'CREATE MATERIALIZED VIEW regress_pg_dump_matview_am' => {
@@ -4017,8 +4391,11 @@ my %tests = (
                like => {
                        %full_runs, %dump_test_schema_runs, section_pre_data => 1,
                },
-               unlike =>
-                 { exclude_dump_test_schema => 1, no_table_access_method => 1 },
+               unlike => {
+                       exclude_dump_test_schema => 1,
+                       no_table_access_method => 1,
+                       only_dump_measurement    => 1,
+               },
        });
 
 #########################################