* 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. */
| 1195 | * Replaces the "<SEGID>" token in the filename with this segment's ID. |
| 1196 | */ |
| 1197 | void |
| 1198 | MangleCopyFileName(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 | |
| 1229 | static uint64 |
| 1230 | CopyToQueryOnSegment(CopyToState cstate) |
no test coverage detected