diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c index 0655bf532a05..715279e57598 100644 --- a/contrib/file_fdw/file_fdw.c +++ b/contrib/file_fdw/file_fdw.c @@ -25,6 +25,7 @@ #include "commands/copyfrom_internal.h" #include "commands/defrem.h" #include "commands/explain.h" +#include "commands/progress.h" #include "commands/vacuum.h" #include "foreign/fdwapi.h" #include "foreign/foreign.h" @@ -35,6 +36,7 @@ #include "optimizer/planmain.h" #include "optimizer/restrictinfo.h" #include "utils/acl.h" +#include "utils/backend_progress.h" #include "utils/memutils.h" #include "utils/rel.h" #include "utils/sampling.h" @@ -774,6 +776,10 @@ fileIterateForeignScan(ForeignScanState *node) */ cstate->escontext->error_occurred = false; + /* Report that this tuple was skipped due to ON_ERROR = ignore */ + pgstat_progress_update_param(PROGRESS_COPY_TUPLES_SKIPPED, + cstate->num_errors); + /* Switch back to original memory context */ MemoryContextSwitchTo(oldcontext); @@ -809,6 +815,9 @@ fileIterateForeignScan(ForeignScanState *node) /* Remove error callback. */ error_context_stack = errcallback.previous; + /* Update the processed tuple count for COPY progress reporting */ + pgstat_progress_incr_param(PROGRESS_COPY_TUPLES_PROCESSED, 1); + return slot; } @@ -1261,6 +1270,10 @@ file_acquire_sample_rows(Relation onerel, int elevel, */ cstate->escontext->error_occurred = false; + /* Report that this tuple was skipped due to ON_ERROR = ignore */ + pgstat_progress_update_param(PROGRESS_COPY_TUPLES_SKIPPED, + cstate->num_errors); + /* Repeat NextCopyFrom() until no soft error occurs */ continue; } @@ -1302,6 +1315,9 @@ file_acquire_sample_rows(Relation onerel, int elevel, } *totalrows += 1; + + /* Update the processed tuple count for COPY progress reporting */ + pgstat_progress_update_param(PROGRESS_COPY_TUPLES_PROCESSED, *totalrows); } /* Remove error callback. */