* sends data to a copy command on a specific segment (usually * the hash result of the data value). */
| 239 | * the hash result of the data value). |
| 240 | */ |
| 241 | void |
| 242 | cdbCopySendData(CdbCopy *c, int target_seg, const char *buffer, |
| 243 | int nbytes) |
| 244 | { |
| 245 | SegmentDatabaseDescriptor *q; |
| 246 | Gang *gp; |
| 247 | int result; |
| 248 | |
| 249 | /* |
| 250 | * NOTE!! note that another DELIM was added, for the buf_converted in the |
| 251 | * code above. I didn't do it because it's broken right now |
| 252 | */ |
| 253 | |
| 254 | gp = getCdbCopyPrimaryGang(c); |
| 255 | Assert(gp); |
| 256 | q = getSegmentDescriptorFromGang(gp, target_seg); |
| 257 | |
| 258 | /* transmit the COPY data */ |
| 259 | result = PQputCopyData(q->conn, buffer, nbytes); |
| 260 | |
| 261 | if (result != 1) |
| 262 | { |
| 263 | if (result == 0) |
| 264 | { |
| 265 | /* We don't use blocking mode, so this shouldn't happen */ |
| 266 | ereport(ERROR, |
| 267 | (errcode(ERRCODE_IO_ERROR), |
| 268 | errmsg("could not send COPY data to segment %d, attempt blocked", |
| 269 | target_seg))); |
| 270 | } |
| 271 | else |
| 272 | ereport(ERROR, |
| 273 | (errcode(ERRCODE_IO_ERROR), |
| 274 | errmsg("could not send COPY data to segment %d: %s", |
| 275 | target_seg, PQerrorMessage(q->conn)))); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | /* |
| 280 | * gets a chunk of rows of data from a copy command. |
no test coverage detected