Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite55f025

Browse files
committed
Refactor CopyFrom() in copyfrom.c.
This commit simplifies CopyFrom() by removing the unnecessary local variable'skipped', which tracked the number of rows skipped due to on_error = 'ignore'.That count is already handled by cstate->num_errors, so the 'skipped' variablewas redundant.Additionally, the condition on_error != COPY_ON_ERROR_STOP is removed.Since on_error == COPY_ON_ERROR_IGNORE is already checked, and on_erroronly has two values (ignore and stop), the additional check was redundantand made the logic harder to read. Seemingly this was introducedin preparation for a future patch, but the current checks don’t offerclear value and have been removed to improve readability.Author: Atsushi TorikoshiReviewed-by: Masahiko Sawada, Fujii MasaoDiscussion:https://postgr.es/m/ab59dad10490ea3734cf022b16c24cfd@oss.nttdata.com
1 parenta1c4c8a commite55f025

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

‎src/backend/commands/copyfrom.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ CopyFrom(CopyFromState cstate)
657657
CopyMultiInsertInfomultiInsertInfo= {0};/* pacify compiler */
658658
int64processed=0;
659659
int64excluded=0;
660-
int64skipped=0;
661660
boolhas_before_insert_row_trig;
662661
boolhas_instead_insert_row_trig;
663662
boolleafpart_use_multi_insert= false;
@@ -1004,26 +1003,22 @@ CopyFrom(CopyFromState cstate)
10041003
if (!NextCopyFrom(cstate,econtext,myslot->tts_values,myslot->tts_isnull))
10051004
break;
10061005

1007-
if (cstate->opts.on_error!=COPY_ON_ERROR_STOP&&
1006+
if (cstate->opts.on_error==COPY_ON_ERROR_IGNORE&&
10081007
cstate->escontext->error_occurred)
10091008
{
10101009
/*
1011-
* Soft error occurred, skip this tuple and deal with error
1012-
* information according to ON_ERROR.
1010+
* Soft error occurred, skip this tuple and just make
1011+
* ErrorSaveContext ready for the next NextCopyFrom. Since we
1012+
* don't set details_wanted and error_data is not to be filled,
1013+
* just resetting error_occurred is enough.
10131014
*/
1014-
if (cstate->opts.on_error==COPY_ON_ERROR_IGNORE)
1015-
1016-
/*
1017-
* Just make ErrorSaveContext ready for the next NextCopyFrom.
1018-
* Since we don't set details_wanted and error_data is not to
1019-
* be filled, just resetting error_occurred is enough.
1020-
*/
1021-
cstate->escontext->error_occurred= false;
1015+
cstate->escontext->error_occurred= false;
10221016

10231017
/* Report that this tuple was skipped by the ON_ERROR clause */
10241018
pgstat_progress_update_param(PROGRESS_COPY_TUPLES_SKIPPED,
1025-
++skipped);
1019+
cstate->num_errors);
10261020

1021+
/* Repeat NextCopyFrom() until no soft error occurs */
10271022
continue;
10281023
}
10291024

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp