mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
isready/prefetch fix.
This commit is contained in:
parent
06ef93271a
commit
08a4965342
|
@ -1,5 +1,10 @@
|
|||
2004-12-14 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* psycopg/cursor_type.c (_psyco_curs_prefetch): fixed bug in
|
||||
interaction between the .isready() method and
|
||||
_psyco_curs_prefetch: isready now store away the pgres but leave
|
||||
prefetch do its work.
|
||||
|
||||
* psycopg/*.c: changed the names of most of the psycopg's built-in
|
||||
types to replect their position in the psycopg._psycopg module.
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef struct {
|
|||
|
||||
int closed:1; /* 1 if the cursor is closed */
|
||||
int notuples:1; /* 1 if the command was not a SELECT query */
|
||||
int needsfetch:1; /* 1 if a call to pq_fetch is pending */
|
||||
|
||||
long int rowcount; /* number of rows affected by last execute */
|
||||
long int columns; /* number of columns fetched from the db */
|
||||
|
|
|
@ -511,7 +511,8 @@ _psyco_curs_prefetch(cursorObject *self)
|
|||
}
|
||||
pthread_mutex_unlock(&(self->conn->lock));
|
||||
|
||||
if (self->pgres == NULL) {
|
||||
if (self->pgres == NULL || self->needsfetch) {
|
||||
self->needsfetch = 0;
|
||||
Dprintf("_psyco_curs_prefetch: trying to fetch data");
|
||||
do {
|
||||
i = pq_fetch(self);
|
||||
|
@ -978,6 +979,7 @@ psyco_curs_isready(cursorObject *self, PyObject *args)
|
|||
self->pgres = PQgetResult(self->conn->pgconn);
|
||||
self->conn->async_cursor = NULL;
|
||||
pthread_mutex_unlock(&(self->conn->lock));
|
||||
self->needsfetch = 1;
|
||||
Py_INCREF(Py_True);
|
||||
return Py_True;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,13 @@ def sleep(curs):
|
|||
# FOR READ ONLY;""", async = 1)
|
||||
curs.execute("SELECT now() AS foo", async=1);
|
||||
sleep(curs)
|
||||
print curs.fetchall()
|
||||
|
||||
#curs.execute("""
|
||||
# FETCH FORWARD 1 FROM zz;""", async = 1)
|
||||
curs.execute("SELECT now() AS bar", async=1);
|
||||
print curs.fetchall()
|
||||
|
||||
curs.execute("SELECT now() AS bar");
|
||||
sleep(curs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user