diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-10-10 23:56:05 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-10-10 23:56:05 +0100 |
commit | d251d51b34e1d00218fe293d8f90d526c1b5f6ce (patch) | |
tree | e91b1b4fa3041b4823ed21dc62e61afe69b20132 /psycopg/pqpath.c | |
parent | c97266921c900345085b8beffa298ecb3746baa4 (diff) | |
parent | 5abbcb23cae335341a19fcddf81328d977dfd8b6 (diff) | |
download | psycopg2-d251d51b34e1d00218fe293d8f90d526c1b5f6ce.tar.gz |
Merge branch 'fix-copy-async-hangs' into maint_2_7
Diffstat (limited to 'psycopg/pqpath.c')
-rw-r--r-- | psycopg/pqpath.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 204a6b0..b490d4f 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -1106,12 +1106,13 @@ pq_send_query(connectionObject *conn, const char *query) * The function will block only if a command is active and the * necessary response data has not yet been read by PQconsumeInput. * - * The result should be disposed using PQclear() + * The result should be disposed of using PQclear() */ PGresult * pq_get_last_result(connectionObject *conn) { PGresult *result = NULL, *res; + ExecStatusType status; /* Read until PQgetResult gives a NULL */ while (NULL != (res = PQgetResult(conn->pgconn))) { @@ -1124,11 +1125,15 @@ pq_get_last_result(connectionObject *conn) PQclear(result); } result = res; + status = PQresultStatus(result); + Dprintf("pq_get_last_result: got result %s", PQresStatus(status)); - /* After entering copy both mode, libpq will make a phony + /* After entering copy mode, libpq will make a phony * PGresult for us every time we query for it, so we need to * break out of this endless loop. */ - if (PQresultStatus(result) == PGRES_COPY_BOTH) { + if (status == PGRES_COPY_BOTH + || status == PGRES_COPY_OUT + || status == PGRES_COPY_IN) { break; } } |