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

Commit8a1012b

Browse files
Re-export NextCopyFromRawFields() to copy.h.
Commit7717f63 removed NextCopyFromRawFields() from copy.h. Whileit was hoped that NextCopyFrom() could serve as an alternative,certain use cases still require NextCopyFromRawFields(). For instance,extensions like file_text_array_fdw, which process source data with anunknown number of columns, rely on this function.Per buildfarm member crake.Reported-by: Andrew Dunstan <andrew@dunslane.net>Reviewed-by: Andrew Dunstan <andrew@dunslane.net>Reviewed-by: Sutou Kouhei <kou@clear-code.com>Discussion:https://postgr.es/m/5c7e1ac8-5083-4c08-af19-cb9ade2f16ce@dunslane.net
1 parente636da9 commit8a1012b

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

‎src/backend/commands/copyfromparse.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ static pg_attribute_always_inline bool CopyFromTextLikeOneRow(CopyFromState csta
152152
Datum*values,
153153
bool*nulls,
154154
boolis_csv);
155+
staticpg_attribute_always_inlineboolNextCopyFromRawFieldsInternal(CopyFromStatecstate,
156+
char***fields,
157+
int*nfields,
158+
boolis_csv);
155159

156160

157161
/* Low-level communications functions */
@@ -736,8 +740,21 @@ CopyReadBinaryData(CopyFromState cstate, char *dest, int nbytes)
736740
}
737741

738742
/*
739-
* Read raw fields in the next line for COPY FROM in text or csv mode.
740-
* Return false if no more lines.
743+
* This function is exposed for use by extensions that read raw fields in the
744+
* next line. See NextCopyFromRawFieldsInternal() for details.
745+
*/
746+
bool
747+
NextCopyFromRawFields(CopyFromStatecstate,char***fields,int*nfields)
748+
{
749+
returnNextCopyFromRawFieldsInternal(cstate,fields,nfields,
750+
cstate->opts.csv_mode);
751+
}
752+
753+
/*
754+
* Workhorse for NextCopyFromRawFields().
755+
*
756+
* Read raw fields in the next line for COPY FROM in text or csv mode. Return
757+
* false if no more lines.
741758
*
742759
* An internal temporary buffer is returned via 'fields'. It is valid until
743760
* the next call of the function. Since the function returns all raw fields
@@ -747,10 +764,11 @@ CopyReadBinaryData(CopyFromState cstate, char *dest, int nbytes)
747764
* NOTE: force_not_null option are not applied to the returned fields.
748765
*
749766
* We use pg_attribute_always_inline to reduce function call overhead
750-
* and to help compilers to optimize away the 'is_csv' condition.
767+
* and to help compilers to optimize away the 'is_csv' condition when called
768+
* by internal functions such as CopyFromTextLikeOneRow().
751769
*/
752770
staticpg_attribute_always_inlinebool
753-
NextCopyFromRawFields(CopyFromStatecstate,char***fields,int*nfields,boolis_csv)
771+
NextCopyFromRawFieldsInternal(CopyFromStatecstate,char***fields,int*nfields,boolis_csv)
754772
{
755773
intfldct;
756774
booldone;
@@ -934,7 +952,7 @@ CopyFromTextLikeOneRow(CopyFromState cstate, ExprContext *econtext,
934952
attr_count=list_length(cstate->attnumlist);
935953

936954
/* read raw fields in the next line */
937-
if (!NextCopyFromRawFields(cstate,&field_strings,&fldct,is_csv))
955+
if (!NextCopyFromRawFieldsInternal(cstate,&field_strings,&fldct,is_csv))
938956
return false;
939957

940958
/* check for overflowing fields */

‎src/include/commands/copy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ extern CopyFromState BeginCopyFrom(ParseState *pstate, Relation rel, Node *where
107107
externvoidEndCopyFrom(CopyFromStatecstate);
108108
externboolNextCopyFrom(CopyFromStatecstate,ExprContext*econtext,
109109
Datum*values,bool*nulls);
110+
externboolNextCopyFromRawFields(CopyFromStatecstate,
111+
char***fields,int*nfields);
110112
externvoidCopyFromErrorCallback(void*arg);
111113
externchar*CopyLimitPrintoutLength(constchar*str);
112114

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp