MCPcopy Create free account
hub / github.com/apache/cloudberry / SendCopyFromForwardedError

Function SendCopyFromForwardedError

src/backend/commands/copyfrom.c:4035–4066  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4033}
4034
4035static void
4036SendCopyFromForwardedError(CopyFromState cstate, CdbCopy *cdbCopy, char *errormsg)
4037{
4038 copy_from_dispatch_error *errframe;
4039 StringInfo msgbuf;
4040 int target_seg;
4041 int errormsg_len = strlen(errormsg);
4042
4043 msgbuf = cstate->dispatch_msgbuf;
4044 resetStringInfo(msgbuf);
4045 enlargeStringInfo(msgbuf, SizeOfCopyFromDispatchError);
4046 /* allocate space for the header (we'll fill it in last). */
4047 msgbuf->len = SizeOfCopyFromDispatchError;
4048
4049 appendBinaryStringInfo(msgbuf, errormsg, errormsg_len);
4050 appendBinaryStringInfo(msgbuf, cstate->line_buf.data, cstate->line_buf.len);
4051
4052 errframe = (copy_from_dispatch_error *) msgbuf->data;
4053
4054 errframe->error_marker = -1;
4055 errframe->lineno = cstate->cur_lineno;
4056 errframe->line_len = cstate->line_buf.len;
4057 errframe->errmsg_len = errormsg_len;
4058
4059 /* send the bad data row to a random QE (via roundrobin) */
4060 if (cstate->lastsegid == cdbCopy->total_segs)
4061 cstate->lastsegid = 0; /* start over from first segid */
4062
4063 target_seg = (cstate->lastsegid++ % cdbCopy->total_segs);
4064
4065 cdbCopySendData(cdbCopy, target_seg, msgbuf->data, msgbuf->len);
4066}
4067
4068static void
4069EndCopyFromDirectoryTable(CopyFromState cstate)

Callers 1

HandleCopyErrorFunction · 0.85

Calls 4

resetStringInfoFunction · 0.85
enlargeStringInfoFunction · 0.85
appendBinaryStringInfoFunction · 0.85
cdbCopySendDataFunction · 0.85

Tested by

no test coverage detected