@@ -115,6 +115,8 @@ static SimpleStringList table_include_patterns = {NULL, NULL};
115115static SimpleOidList table_include_oids = {NULL , NULL };
116116static SimpleStringList table_exclude_patterns = {NULL , NULL };
117117static SimpleOidList table_exclude_oids = {NULL , NULL };
118+ static SimpleStringList tabledata_exclude_patterns = {NULL , NULL };
119+ static SimpleOidList tabledata_exclude_oids = {NULL , NULL };
118120
119121/* default, if no "inclusion" switches appear, is to dump everything */
120122static bool include_everything = true;
@@ -324,6 +326,7 @@ main(int argc, char **argv)
324326 {"column-inserts" , no_argument , & column_inserts , 1 },
325327 {"disable-dollar-quoting" , no_argument , & disable_dollar_quoting , 1 },
326328 {"disable-triggers" , no_argument , & disable_triggers , 1 },
329+ {"exclude-table-data" , required_argument , NULL , 4 },
327330 {"inserts" , no_argument , & dump_inserts , 1 },
328331 {"lock-wait-timeout" , required_argument , NULL , 2 },
329332 {"no-tablespaces" , no_argument , & outputNoTablespaces , 1 },
@@ -487,6 +490,10 @@ main(int argc, char **argv)
487490 use_role = optarg ;
488491 break ;
489492
493+ case 4 : /* exclude table(s) data */
494+ simple_string_list_append (& tabledata_exclude_patterns , optarg );
495+ break ;
496+
490497 default :
491498 fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ), progname );
492499 exit (1 );
@@ -715,6 +722,10 @@ main(int argc, char **argv)
715722 }
716723 expand_table_name_patterns (& table_exclude_patterns ,
717724 & table_exclude_oids );
725+
726+ expand_table_name_patterns (& tabledata_exclude_patterns ,
727+ & tabledata_exclude_oids );
728+
718729 /* non-matching exclusion patterns aren't an error */
719730
720731 /*
@@ -854,6 +865,7 @@ help(const char *progname)
854865 printf (_ (" --column-inserts dump data as INSERT commands with column names\n" ));
855866 printf (_ (" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n" ));
856867 printf (_ (" --disable-triggers disable triggers during data-only restore\n" ));
868+ printf (_ (" --exclude-table-data=TABLE do NOT dump data for the named table(s)\n" ));
857869 printf (_ (" --inserts dump data as INSERT commands, rather than COPY\n" ));
858870 printf (_ (" --no-security-labels do not dump security label assignments\n" ));
859871 printf (_ (" --no-tablespaces do not dump tablespace assignments\n" ));
@@ -1087,6 +1099,15 @@ selectDumpableTable(TableInfo *tbinfo)
10871099 simple_oid_list_member (& table_exclude_oids ,
10881100 tbinfo -> dobj .catId .oid ))
10891101 tbinfo -> dobj .dump = false;
1102+
1103+ /* If table is to be dumped, check that the data is not excluded */
1104+ if (tbinfo -> dobj .dump && !
1105+ simple_oid_list_member (& tabledata_exclude_oids ,
1106+ tbinfo -> dobj .catId .oid ))
1107+ tbinfo -> dobj .dumpdata = true;
1108+ else
1109+ tbinfo -> dobj .dumpdata = false;
1110+
10901111}
10911112
10921113/*
@@ -1518,6 +1539,10 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
15181539 DataDumperPtr dumpFn ;
15191540 char * copyStmt ;
15201541
1542+ /* don't do anything if the data isn't wanted */
1543+ if (!tbinfo -> dobj .dumpdata )
1544+ return ;
1545+
15211546 if (!dump_inserts )
15221547 {
15231548 /* Dump/restore using COPY */
0 commit comments