mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-10 19:16:34 +03:00
Dropped redundant call to conn_notice_process().
If the connection is sync, notices will be processed by pq_fetch() downstream. If the connection is async, here we have only sent the query: no result is ready yet, and neither notices have had a chance to arrive: they will be retrieved later by pq_is_busy(). Added tests to check the above statement don't break.
This commit is contained in:
parent
bcfcea4b49
commit
12ef826d50
|
@ -761,8 +761,6 @@ pq_execute(cursorObject *curs, const char *query, int async)
|
|||
pthread_mutex_unlock(&(curs->conn->lock));
|
||||
Py_END_ALLOW_THREADS;
|
||||
|
||||
conn_notice_process(curs->conn);
|
||||
|
||||
/* if the execute was sync, we call pq_fetch() immediately,
|
||||
to respect the old DBAPI-2.0 compatible behaviour */
|
||||
if (async == 0) {
|
||||
|
|
|
@ -388,6 +388,15 @@ class AsyncTests(unittest.TestCase):
|
|||
self.wait(cur2)
|
||||
self.assertEquals(cur2.fetchone()[0], 1)
|
||||
|
||||
def test_notices(self):
|
||||
del self.conn.notices[:]
|
||||
cur = self.conn.cursor()
|
||||
cur.execute("create temp table chatty (id serial primary key);")
|
||||
self.wait(cur)
|
||||
self.assertEqual("CREATE TABLE", cur.statusmessage)
|
||||
self.assert_(self.conn.notices)
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
||||
|
|
|
@ -37,6 +37,13 @@ class ConnectionTests(unittest.TestCase):
|
|||
# now the isolation level should be equal to saved one
|
||||
self.assertEqual(conn.isolation_level, level)
|
||||
|
||||
def test_notices(self):
|
||||
conn = self.connect()
|
||||
cur = conn.cursor()
|
||||
cur.execute("create temp table chatty (id serial primary key);")
|
||||
self.assertEqual("CREATE TABLE", cur.statusmessage)
|
||||
self.assert_(conn.notices)
|
||||
conn.close()
|
||||
|
||||
def test_suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
Loading…
Reference in New Issue
Block a user