* PQgetCopyData - read a row of data from the backend during COPY OUT * or COPY BOTH * * If successful, sets *buffer to point to a malloc'd row of data, and * returns row length (always > 0) as result. * Returns 0 if no row available yet (only possible if async is true), * -1 if end of copy (consult PQgetResult), or -2 if error (consult * PQerrorMessage). */
| 2704 | * PQerrorMessage). |
| 2705 | */ |
| 2706 | int |
| 2707 | PQgetCopyData(PGconn *conn, char **buffer, int async) |
| 2708 | { |
| 2709 | *buffer = NULL; /* for all failure cases */ |
| 2710 | if (!conn) |
| 2711 | return -2; |
| 2712 | if (conn->asyncStatus != PGASYNC_COPY_OUT && |
| 2713 | conn->asyncStatus != PGASYNC_COPY_BOTH) |
| 2714 | { |
| 2715 | appendPQExpBufferStr(&conn->errorMessage, |
| 2716 | libpq_gettext("no COPY in progress\n")); |
| 2717 | return -2; |
| 2718 | } |
| 2719 | return pqGetCopyData3(conn, buffer, async); |
| 2720 | } |
| 2721 | |
| 2722 | /* |
| 2723 | * PQgetline - gets a newline-terminated string from the backend. |
no test coverage detected