Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 91ecb5e

Browse files
committed
Add regression tests for pg_stat_progress_copy.tuples_skipped.
This commit adds tests to verify that tuples_skipped in pg_stat_progress_copy works as expected. While existing tests checked other fields, tuples_skipped was previously untested. This improves test coverage and ensures accurate tracking of skipped tuples. Author: Jian He <jian.universality@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Reviewed-by: Josef Šimánek <josef.simanek@gmail.com> Discussion: https://postgr.es/m/CACJufxFazq-bfyhiO0KBojR=yOr84E25Rqf6mHB0Ow0KPidkKw@mail.gmail.com
1 parent d2e7068 commit 91ecb5e

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/test/regress/expected/copy.out

+8-3
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ begin
181181
bytes_processed > 0 as has_bytes_processed,
182182
bytes_total > 0 as has_bytes_total,
183183
tuples_processed,
184-
tuples_excluded
184+
tuples_excluded,
185+
tuples_skipped
185186
from pg_stat_progress_copy
186187
where pid = pg_backend_pid())
187188
select into report (to_jsonb(r)) as value
@@ -197,13 +198,17 @@ create trigger check_after_tab_progress_reporting
197198
execute function notice_after_tab_progress_reporting();
198199
-- Generate COPY FROM report with PIPE.
199200
copy tab_progress_reporting from stdin;
200-
INFO: progress: {"type": "PIPE", "command": "COPY FROM", "relname": "tab_progress_reporting", "has_bytes_total": false, "tuples_excluded": 0, "tuples_processed": 3, "has_bytes_processed": true}
201+
INFO: progress: {"type": "PIPE", "command": "COPY FROM", "relname": "tab_progress_reporting", "tuples_skipped": 0, "has_bytes_total": false, "tuples_excluded": 0, "tuples_processed": 3, "has_bytes_processed": true}
201202
-- Generate COPY FROM report with FILE, with some excluded tuples.
202203
truncate tab_progress_reporting;
203204
\set filename :abs_srcdir '/data/emp.data'
204205
copy tab_progress_reporting from :'filename'
205206
where (salary < 2000);
206-
INFO: progress: {"type": "FILE", "command": "COPY FROM", "relname": "tab_progress_reporting", "has_bytes_total": true, "tuples_excluded": 1, "tuples_processed": 2, "has_bytes_processed": true}
207+
INFO: progress: {"type": "FILE", "command": "COPY FROM", "relname": "tab_progress_reporting", "tuples_skipped": 0, "has_bytes_total": true, "tuples_excluded": 1, "tuples_processed": 2, "has_bytes_processed": true}
208+
-- Generate COPY FROM report with PIPE, with some skipped tuples.
209+
copy tab_progress_reporting from stdin(on_error ignore);
210+
NOTICE: 2 rows were skipped due to data type incompatibility
211+
INFO: progress: {"type": "PIPE", "command": "COPY FROM", "relname": "tab_progress_reporting", "tuples_skipped": 2, "has_bytes_total": false, "tuples_excluded": 0, "tuples_processed": 1, "has_bytes_processed": true}
207212
drop trigger check_after_tab_progress_reporting on tab_progress_reporting;
208213
drop function notice_after_tab_progress_reporting();
209214
drop table tab_progress_reporting;

src/test/regress/sql/copy.sql

+9-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ begin
193193
bytes_processed > 0 as has_bytes_processed,
194194
bytes_total > 0 as has_bytes_total,
195195
tuples_processed,
196-
tuples_excluded
196+
tuples_excluded,
197+
tuples_skipped
197198
from pg_stat_progress_copy
198199
where pid = pg_backend_pid())
199200
select into report (to_jsonb(r)) as value
@@ -222,6 +223,13 @@ truncate tab_progress_reporting;
222223
copy tab_progress_reporting from :'filename'
223224
where (salary < 2000);
224225

226+
-- Generate COPY FROM report with PIPE, with some skipped tuples.
227+
copy tab_progress_reporting from stdin(on_error ignore);
228+
sharon x (15,12) x sam
229+
sharon 25 (15,12) 1000 sam
230+
sharon y (15,12) x sam
231+
\.
232+
225233
drop trigger check_after_tab_progress_reporting on tab_progress_reporting;
226234
drop function notice_after_tab_progress_reporting();
227235
drop table tab_progress_reporting;

0 commit comments

Comments
 (0)