diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-04-22 16:04:41 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-04-23 13:24:35 +0100 |
| commit | 1edbd16577c337537ee833e593b7579f601328d7 (patch) | |
| tree | 6681d1d81972e17fcbcba1fc4492fbf394abdd40 /psycopg/connection_int.c | |
| parent | a66de9808f89a483347fa32636cb2b63b724851c (diff) | |
| download | psycopg2-1edbd16577c337537ee833e593b7579f601328d7.tar.gz | |
Dropped curs_get_last_result function.
The result is read from a pqpath function and put on the async_cursor by
a function that also checks for is presence and dismiss it after its
usage.
Diffstat (limited to 'psycopg/connection_int.c')
| -rw-r--r-- | psycopg/connection_int.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 0d9da09..ebd710f 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -699,7 +699,8 @@ conn_poll_send(connectionObject *self) /* conn_poll_fetch - poll the connection when reading results from the backend * - * Assume self->async_cursor is not null: use such cursor to store results. + * If self_curs is available, use it to store the result of the last query. + * Also unlink it when finished. */ PyObject * @@ -725,10 +726,23 @@ conn_poll_fetch(connectionObject *self) because of asynchronous NOTIFYs that can be sent by the backend even if the user didn't asked for them */ - if (self->async_status == ASYNC_READ) - last_result = curs_get_last_result((cursorObject *)self->async_cursor); - else + if (self->async_status == ASYNC_READ && self->async_cursor) { + cursorObject *curs = (cursorObject *)self->async_cursor; + IFCLEARPGRES(curs->pgres); + curs->pgres = pq_get_last_result(self); + + /* fetch the tuples (if there are any) and build the result. We don't + * care if pq_fetch return 0 or 1, but if there was an error, we want to + * signal it to the caller. */ + last_result = pq_fetch(curs) == -1 ? -1 : 0; + + /* We have finished with our async_cursor */ + Py_XDECREF(self->async_cursor); + self->async_cursor = NULL; + } + else { last_result = 0; + } if (last_result == 0) { Dprintf("conn_poll_fetch: returning %d", PSYCO_POLL_OK); |
