* Common code for PQexec and sibling routines: wait for command result */
| 2376 | * Common code for PQexec and sibling routines: wait for command result |
| 2377 | */ |
| 2378 | static PGresult * |
| 2379 | PQexecFinish(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 |
no test coverage detected