Parse all the columns on QD if binary mode COPY
@@ -5357,7 +5357,7 @@ NextCopyFromX(CopyState cstate, ExprContext *econtext,
Assert(fieldno == nfields);
}
- else
+ else if (attr_count)
{
/* binary */
int16 fld_count;
@@ -7683,11 +7683,22 @@ static void
InitCopyFromDispatchSplit(CopyState cstate, GpDistributionData *distData,
EState *estate)
{
- int first_qe_processed_field;
+ int first_qe_processed_field = 0;
Bitmapset *needed_cols = NULL;
ListCell *lc;
- int fieldno;
+ if (cstate->binary)
+ {
+ foreach(lc, cstate->attnumlist)
+ {
+ AttrNumber attnum = lfirst_int(lc);
+ needed_cols = bms_add_member(needed_cols, attnum);
+ first_qe_processed_field++;
+ }
+ }
+ else
+ {
+ int fieldno;
/*
* We need all the columns that form the distribution key.
*/
@@ -7707,7 +7718,6 @@ InitCopyFromDispatchSplit(CopyState cstate, GpDistributionData *distData,
distData->policy == NULL, estate);
/* Get the max fieldno that contains one of the needed attributes. */
- first_qe_processed_field = 0;
fieldno = 0;
foreach(lc, cstate->attnumlist)
{
@@ -7717,6 +7727,7 @@ InitCopyFromDispatchSplit(CopyState cstate, GpDistributionData *distData,
first_qe_processed_field = fieldno + 1;
fieldno++;
}
+ }
/* If the file contains OIDs, it's the first field. */
if (cstate->file_has_oids)
