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

Commitbacbc48

Browse files
Refactor Copy{From|To}GetRoutine() to use pass-by-reference argument.
The change improves efficiency by eliminating unnecessary copying ofCopyFormatOptions.The coverity also complained about inefficiencies caused bypass-by-value.Oversight in7717f63 and2e4127b.Reported-by: Junwang Zhao <zhjwpku@gmail.com>Reported-by: Tom Lane <tgl@sss.pgh.pa.us> (per reports from coverity)Author: Sutou Kouhei <kou@clear-code.com>Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>Discussion:https://postgr.es/m/CAEG8a3L6YCpPksTQMzjD_CvwDEhW3D_t=5md9BvvdOs5k+TA=Q@mail.gmail.com
1 parent0b2a45a commitbacbc48

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

‎src/backend/commands/copyfrom.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ static const CopyFromRoutine CopyFromRoutineBinary = {
153153

154154
/* Return a COPY FROM routine for the given options */
155155
staticconstCopyFromRoutine*
156-
CopyFromGetRoutine(CopyFormatOptionsopts)
156+
CopyFromGetRoutine(constCopyFormatOptions*opts)
157157
{
158-
if (opts.csv_mode)
158+
if (opts->csv_mode)
159159
return&CopyFromRoutineCSV;
160-
elseif (opts.binary)
160+
elseif (opts->binary)
161161
return&CopyFromRoutineBinary;
162162

163163
/* default is text */
@@ -1574,7 +1574,7 @@ BeginCopyFrom(ParseState *pstate,
15741574
ProcessCopyOptions(pstate,&cstate->opts, true/* is_from */ ,options);
15751575

15761576
/* Set the format routine */
1577-
cstate->routine=CopyFromGetRoutine(cstate->opts);
1577+
cstate->routine=CopyFromGetRoutine(&cstate->opts);
15781578

15791579
/* Process the target relation */
15801580
cstate->rel=rel;

‎src/backend/commands/copyto.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ static const CopyToRoutine CopyToRoutineBinary = {
174174

175175
/* Return a COPY TO routine for the given options */
176176
staticconstCopyToRoutine*
177-
CopyToGetRoutine(CopyFormatOptionsopts)
177+
CopyToGetRoutine(constCopyFormatOptions*opts)
178178
{
179-
if (opts.csv_mode)
179+
if (opts->csv_mode)
180180
return&CopyToRoutineCSV;
181-
elseif (opts.binary)
181+
elseif (opts->binary)
182182
return&CopyToRoutineBinary;
183183

184184
/* default is text */
@@ -700,7 +700,7 @@ BeginCopyTo(ParseState *pstate,
700700
ProcessCopyOptions(pstate,&cstate->opts, false/* is_from */ ,options);
701701

702702
/* Set format routine */
703-
cstate->routine=CopyToGetRoutine(cstate->opts);
703+
cstate->routine=CopyToGetRoutine(&cstate->opts);
704704

705705
/* Process the source/target relation or query */
706706
if (rel)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp