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

Commitc532d15

Browse files
committed
Split copy.c into four files.
Copy.c has grown really large. Split it into more manageable parts:- copy.c now contains only a few functions that are common to COPY FROM and COPY TO.- copyto.c contains code for COPY TO.- copyfrom.c contains code for initializing COPY FROM, and inserting the tuples to the correct table.- copyfromparse.c contains code for reading from the client/file/program, and parsing the input text/CSV/binary format into tuples.All of these parts are fairly complicated, and fairly independent of eachother. There is a patch being discussed to implement parallel COPY FROM,which will add a lot of new code to the COPY FROM path, and another patchwhich would allow INSERTs to use the same multi-insert machinery as COPYFROM, both of which will require refactoring that code. With those twopatches, there's going to be a lot of code churn in copy.c anyway, so nowseems like a good time to do this refactoring.The CopyStateData struct is also split. All the formatting options, likeFORMAT, QUOTE, ESCAPE, are put in a new CopyFormatOption struct, whichis used by both COPY FROM and TO. Other state data are kept in separateCopyFromStateData and CopyToStateData structs.Reviewed-by: Soumyadeep Chakraborty, Erik Rijkers, Vignesh C, Andres FreundDiscussion:https://www.postgresql.org/message-id/8e15b560-f387-7acc-ac90-763986617bfb%40iki.fi
1 parent1795897 commitc532d15

File tree

9 files changed

+4841
-4529
lines changed

9 files changed

+4841
-4529
lines changed

‎contrib/file_fdw/file_fdw.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ typedef struct FileFdwExecutionState
105105
boolis_program;/* true if filename represents an OS command */
106106
List*options;/* merged COPY options, excluding filename and
107107
* is_program */
108-
CopyStatecstate;/* COPY execution state */
108+
CopyFromStatecstate;/* COPY execution state */
109109
}FileFdwExecutionState;
110110

111111
/*
@@ -655,7 +655,7 @@ fileBeginForeignScan(ForeignScanState *node, int eflags)
655655
char*filename;
656656
boolis_program;
657657
List*options;
658-
CopyStatecstate;
658+
CopyFromStatecstate;
659659
FileFdwExecutionState*festate;
660660

661661
/*
@@ -677,6 +677,7 @@ fileBeginForeignScan(ForeignScanState *node, int eflags)
677677
*/
678678
cstate=BeginCopyFrom(NULL,
679679
node->ss.ss_currentRelation,
680+
NULL,
680681
filename,
681682
is_program,
682683
NULL,
@@ -752,6 +753,7 @@ fileReScanForeignScan(ForeignScanState *node)
752753

753754
festate->cstate=BeginCopyFrom(NULL,
754755
node->ss.ss_currentRelation,
756+
NULL,
755757
festate->filename,
756758
festate->is_program,
757759
NULL,
@@ -1107,7 +1109,7 @@ file_acquire_sample_rows(Relation onerel, int elevel,
11071109
char*filename;
11081110
boolis_program;
11091111
List*options;
1110-
CopyStatecstate;
1112+
CopyFromStatecstate;
11111113
ErrorContextCallbackerrcallback;
11121114
MemoryContextoldcontext=CurrentMemoryContext;
11131115
MemoryContexttupcontext;
@@ -1125,7 +1127,7 @@ file_acquire_sample_rows(Relation onerel, int elevel,
11251127
/*
11261128
* Create CopyState from FDW options.
11271129
*/
1128-
cstate=BeginCopyFrom(NULL,onerel,filename,is_program,NULL,NIL,
1130+
cstate=BeginCopyFrom(NULL,onerel,NULL,filename,is_program,NULL,NIL,
11291131
options);
11301132

11311133
/*

‎src/backend/commands/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ OBJS = \
2424
constraint.o\
2525
conversioncmds.o\
2626
copy.o\
27+
copyfrom.o\
28+
copyfromparse.o\
29+
copyto.o\
2730
createas.o\
2831
dbcommands.o\
2932
define.o\

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp