Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/backend/commands/copyfromparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0";

/* non-export function prototypes */
static bool CopyReadLine(CopyFromState cstate, bool is_csv);
static bool CopyReadLineText(CopyFromState cstate, bool is_csv);
static pg_attribute_always_inline bool CopyReadLineText(CopyFromState cstate,
bool is_csv);
static int CopyReadAttributesText(CopyFromState cstate);
static int CopyReadAttributesCSV(CopyFromState cstate);
static Datum CopyReadBinaryAttribute(CopyFromState cstate, FmgrInfo *flinfo,
Expand Down Expand Up @@ -1173,8 +1174,17 @@ CopyReadLine(CopyFromState cstate, bool is_csv)
resetStringInfo(&cstate->line_buf);
cstate->line_buf_valid = false;

/* Parse data and transfer into line_buf */
result = CopyReadLineText(cstate, is_csv);
/*
* Parse data and transfer into line_buf.
*
* Because this is performance critical, we inline CopyReadLineText() and
* pass the boolean parameters as constants to allow the compiler to emit
* specialized code with fewer branches.
*/
if (is_csv)
result = CopyReadLineText(cstate, true);
else
result = CopyReadLineText(cstate, false);

if (result)
{
Expand Down Expand Up @@ -1241,7 +1251,7 @@ CopyReadLine(CopyFromState cstate, bool is_csv)
/*
* CopyReadLineText - inner loop of CopyReadLine for text mode
*/
static bool
static pg_attribute_always_inline bool
CopyReadLineText(CopyFromState cstate, bool is_csv)
{
char *copy_input_buf;
Expand Down