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

Function MangleCopyFileName

src/backend/commands/copy.c:1197–1227  ·  view source on GitHub ↗

* Modify the filename in cstate->filename, and cstate->cdbsreh if any, * for COPY ON SEGMENT. * * Replaces the " " token in the filename with this segment's ID. */

Source from the content-addressed store, hash-verified

1195 * Replaces the "<SEGID>" token in the filename with this segment's ID.
1196 */
1197void
1198MangleCopyFileName(char **filenameptr, CdbSreh *cdbsreh)
1199{
1200 Assert(filenameptr && *filenameptr);
1201
1202 char *filename = *filenameptr;
1203 StringInfoData filepath;
1204
1205 initStringInfo(&filepath);
1206 appendStringInfoString(&filepath, filename);
1207
1208 replaceStringInfoString(&filepath, "<SEG_DATA_DIR>", DataDir);
1209
1210 if (strstr(filename, "<SEGID>") == NULL)
1211 ereport(ERROR,
1212 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1213 errmsg("<SEGID> is required for file name")));
1214
1215 char segid_buf[8];
1216 snprintf(segid_buf, 8, "%d", GpIdentity.segindex);
1217 replaceStringInfoString(&filepath, "<SEGID>", segid_buf);
1218
1219 *filenameptr = filepath.data;
1220 /* Rename filename if error log needed */
1221 if (NULL != cdbsreh)
1222 {
1223 snprintf(cdbsreh->filename,
1224 sizeof(cdbsreh->filename), "%s",
1225 filepath.data);
1226 }
1227}
1228
1229static uint64
1230CopyToQueryOnSegment(CopyToState cstate)

Callers 3

BeginCopyToFunction · 0.85
BeginCopyToOnSegmentFunction · 0.85
BeginCopyFromFunction · 0.85

Calls 5

initStringInfoFunction · 0.85
appendStringInfoStringFunction · 0.85
replaceStringInfoStringFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected