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

Function PQexecFinish

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

* Common code for PQexec and sibling routines: wait for command result */

Source from the content-addressed store, hash-verified

2376 * Common code for PQexec and sibling routines: wait for command result
2377 */
2378static PGresult *
2379PQexecFinish(PGconn *conn)
2380{
2381 PGresult *result;
2382 PGresult *lastResult;
2383
2384 /*
2385 * For backwards compatibility, return the last result if there are more
2386 * than one. (We used to have logic here to concatenate successive error
2387 * messages, but now that happens automatically, since conn->errorMessage
2388 * will continue to accumulate errors throughout this loop.)
2389 *
2390 * We have to stop if we see copy in/out/both, however. We will resume
2391 * parsing after application performs the data transfer.
2392 *
2393 * Also stop if the connection is lost (else we'll loop infinitely).
2394 */
2395 lastResult = NULL;
2396 while ((result = PQgetResult(conn)) != NULL)
2397 {
2398 if (lastResult)
2399 PQclear(lastResult);
2400 lastResult = result;
2401 if (result->resultStatus == PGRES_COPY_IN ||
2402 result->resultStatus == PGRES_COPY_OUT ||
2403 result->resultStatus == PGRES_COPY_BOTH ||
2404 conn->status == CONNECTION_BAD)
2405 break;
2406 }
2407
2408 return lastResult;
2409}
2410
2411/*
2412 * PQdescribePrepared

Callers 6

PQexecFunction · 0.85
PQexecParamsFunction · 0.85
PQprepareFunction · 0.85
PQexecPreparedFunction · 0.85
PQdescribePreparedFunction · 0.85
PQdescribePortalFunction · 0.85

Calls 2

PQgetResultFunction · 0.85
PQclearFunction · 0.85

Tested by

no test coverage detected