mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-03-03 23:55:46 +03:00
Make pq_clear_async clear the whole pending result and export it
This commit is contained in:
parent
e0d789466a
commit
53748443d8
|
@ -283,19 +283,25 @@ pq_resolve_critical(connectionObject *conn, int close)
|
|||
note that this function does block because it needs to wait for the full
|
||||
result sets of the previous query to clear them.
|
||||
|
||||
|
||||
this function does not call any Py_*_ALLOW_THREADS macros */
|
||||
|
||||
static void
|
||||
void
|
||||
pq_clear_async(connectionObject *conn)
|
||||
{
|
||||
PGresult *pgres;
|
||||
|
||||
do {
|
||||
/* this will get all pending results (if the submitted query consisted of
|
||||
many parts, i.e. "select 1; select 2", there will be many) and also
|
||||
finalize asynchronous processing so the connection will be ready to
|
||||
accept another query */
|
||||
for (;;) {
|
||||
pgres = PQgetResult(conn->pgconn);
|
||||
Dprintf("pq_clear_async: clearing PGresult at %p", pgres);
|
||||
IFCLEARPGRES(pgres);
|
||||
} while (pgres != NULL);
|
||||
if (pgres == NULL)
|
||||
break;
|
||||
CLEARPGRES(pgres);
|
||||
}
|
||||
conn->async_cursor = NULL;
|
||||
}
|
||||
|
||||
/* pg_execute_command_locked - execute a no-result query on a locked connection.
|
||||
|
|
|
@ -45,6 +45,7 @@ HIDDEN int pq_abort_locked(connectionObject *conn, PGresult **pgres,
|
|||
HIDDEN int pq_abort(connectionObject *conn);
|
||||
HIDDEN int pq_reset(connectionObject *conn);
|
||||
HIDDEN int pq_is_busy(connectionObject *conn);
|
||||
HIDDEN void pq_clear_async(connectionObject *conn);
|
||||
|
||||
HIDDEN void pq_set_critical(connectionObject *conn, const char *msg);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user