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

Function getCopyResult

src/interfaces/libpq/fe-exec.c:2193–2217  ·  view source on GitHub ↗

* getCopyResult * Helper for PQgetResult: generate result for COPY-in-progress cases */

Source from the content-addressed store, hash-verified

2191 * Helper for PQgetResult: generate result for COPY-in-progress cases
2192 */
2193static PGresult *
2194getCopyResult(PGconn *conn, ExecStatusType copytype)
2195{
2196 /*
2197 * If the server connection has been lost, don't pretend everything is
2198 * hunky-dory; instead return a PGRES_FATAL_ERROR result, and reset the
2199 * asyncStatus to idle (corresponding to what we'd do if we'd detected I/O
2200 * error in the earlier steps in PQgetResult). The text returned in the
2201 * result is whatever is in conn->errorMessage; we hope that was filled
2202 * with something relevant when the lost connection was detected.
2203 */
2204 if (conn->status != CONNECTION_OK)
2205 {
2206 pqSaveErrorResult(conn);
2207 conn->asyncStatus = PGASYNC_IDLE;
2208 return pqPrepareAsyncResult(conn);
2209 }
2210
2211 /* If we have an async result for the COPY, return that */
2212 if (conn->result && conn->result->resultStatus == copytype)
2213 return pqPrepareAsyncResult(conn);
2214
2215 /* Otherwise, invent a suitable PGresult */
2216 return PQmakeEmptyPGresult(conn, copytype);
2217}
2218
2219
2220/*

Callers 1

PQgetResultFunction · 0.85

Calls 3

pqSaveErrorResultFunction · 0.85
pqPrepareAsyncResultFunction · 0.85
PQmakeEmptyPGresultFunction · 0.85

Tested by

no test coverage detected