<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/python-packages/psycopg2.git/tests/test_cursor.py, branch py37</title>
<subtitle>github.com: psycopg/psycopg2.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/'/>
<entry>
<title>Bump tests for selective closure of named cursor to pg 8.2</title>
<updated>2018-07-24T18:02:13+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2018-07-24T18:02:13+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=ba54f1194ad591f96acd5bacdc03524e54f7897b'/>
<id>ba54f1194ad591f96acd5bacdc03524e54f7897b</id>
<content type='text'>
Previous versions don't support the features as they don't have the
pg_cursors view. But they are too old to care.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previous versions don't support the features as they don't have the
pg_cursors view. But they are too old to care.
</pre>
</div>
</content>
</entry>
<entry>
<title>Close named cursor if exist, even if we didn't run execute</title>
<updated>2018-07-21T17:32:02+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2018-07-21T17:32:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=43e35db988625dcb32c8fd410e856b6a543f1376'/>
<id>43e35db988625dcb32c8fd410e856b6a543f1376</id>
<content type='text'>
Close #746
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Close #746
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't raise an exception closing an unused named cursor</title>
<updated>2018-05-20T13:05:58+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2018-05-20T12:56:59+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=7aea6b846ef755b8cc0a67e42467e1923aba92cc'/>
<id>7aea6b846ef755b8cc0a67e42467e1923aba92cc</id>
<content type='text'>
Close #716
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Close #716
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix use of "async" in test_cursor.py</title>
<updated>2018-05-18T10:18:24+00:00</updated>
<author>
<name>Jon Dufresne</name>
<email>jon.dufresne@gmail.com</email>
</author>
<published>2017-12-04T02:47:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=42efb739d8610a1f11840002f7def545e165ace7'/>
<id>42efb739d8610a1f11840002f7def545e165ace7</id>
<content type='text'>
"async" will be a keyword starting with Python 3.7. On Python 3.6, use
of "async" causes a deprecation warning. Use the alias "async_" instead.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
"async" will be a keyword starting with Python 3.7. On Python 3.6, use
of "async" causes a deprecation warning. Use the alias "async_" instead.
</pre>
</div>
</content>
</entry>
<entry>
<title>'cursor.mogrify()' can be called on closed cursors</title>
<updated>2018-01-10T23:26:11+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2018-01-10T23:06:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=9c5bf367917698c058c2bc16c9b447d5e0b7e8e1'/>
<id>9c5bf367917698c058c2bc16c9b447d5e0b7e8e1</id>
<content type='text'>
Fix #579.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix #579.
</pre>
</div>
</content>
</entry>
<entry>
<title>Collect rowcount in executemany even when discarding results</title>
<updated>2017-11-29T15:38:02+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2017-11-29T15:28:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=a5fd594ea428e3e8c11a632b1e3fd47df0cec2ab'/>
<id>a5fd594ea428e3e8c11a632b1e3fd47df0cec2ab</id>
<content type='text'>
Closes #633.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Closes #633.
</pre>
</div>
</content>
</entry>
<entry>
<title>Bunch of test tweaks to make the test grid green</title>
<updated>2017-03-14T14:15:52+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2016-07-04T20:49:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=8e28444897de74b9137f00c60a41f676058cc751'/>
<id>8e28444897de74b9137f00c60a41f676058cc751</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Always raise OperationalError when connection was closed externally.</title>
<updated>2017-03-14T12:14:00+00:00</updated>
<author>
<name>Greg Ward</name>
<email>gward@dyn.com</email>
</author>
<published>2016-06-28T22:03:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=12317557da20d84baf12054d8dfce11ba8976cb6'/>
<id>12317557da20d84baf12054d8dfce11ba8976cb6</id>
<content type='text'>
From the DB-API (https://www.python.org/dev/peps/pep-0249/):

  OperationalError

  Exception raised for errors that are related to the database's
  operation and not necessarily under the control of the programmer,
  e.g. an unexpected disconnect occurs, [...]

Additionally, psycopg2 was inconsistent, at least in the async case:
depending on how the "connection closed" error was reported from the
kernel to libpq, it would sometimes raise OperationalError and
sometimes DatabaseError. Now it always raises OperationalError.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
From the DB-API (https://www.python.org/dev/peps/pep-0249/):

  OperationalError

  Exception raised for errors that are related to the database's
  operation and not necessarily under the control of the programmer,
  e.g. an unexpected disconnect occurs, [...]

Additionally, psycopg2 was inconsistent, at least in the async case:
depending on how the "connection closed" error was reported from the
kernel to libpq, it would sometimes raise OperationalError and
sometimes DatabaseError. Now it always raises OperationalError.
</pre>
</div>
</content>
</entry>
<entry>
<title>Always detect when a connection is closed behind psycopg2's back.</title>
<updated>2017-03-14T12:08:03+00:00</updated>
<author>
<name>Greg Ward</name>
<email>gward@dyn.com</email>
</author>
<published>2016-06-28T21:46:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=b203a7c775c5f81f59c6b4205c3c33455ceeec3d'/>
<id>b203a7c775c5f81f59c6b4205c3c33455ceeec3d</id>
<content type='text'>
There's a race condition that only seems to happen over Unix-domain
sockets. Sometimes, the closed socket is reported by the kernel to
libpq like this (captured with strace):

  sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = 29
  recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110
  recvfrom(3, 0x12d0330, 16384, 0, 0, 0)  = -1 ECONNRESET (Connection reset by peer)

That is, psycopg2/libpq sees no error when sending the first query
after the connection is closed, but gets an error reading the result.
In that case, everything worked fine.

But sometimes, the error manifests like this:

  sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = -1 EPIPE (Broken pipe)
  recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110
  recvfrom(3, "", 16274, 0, NULL, NULL)   = 0
  recvfrom(3, "", 16274, 0, NULL, NULL)   = 0

i.e. libpq received an error when sending the query. This manifests as
a slightly different exception from a slightly different place. More
importantly, in this case connection.closed is left at 0 rather than
being set to 2, and that is the bug I'm fixing here.

Note that we see almost identical behaviour for sync and async
connections, and the fixes are the same. So I added extremely similar
test cases.

Finally, there is still a bug here: for async connections, we
sometimes raise DatabaseError (incorrect) and sometimes raise
OperationalError (correct). Will fix that next.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There's a race condition that only seems to happen over Unix-domain
sockets. Sometimes, the closed socket is reported by the kernel to
libpq like this (captured with strace):

  sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = 29
  recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110
  recvfrom(3, 0x12d0330, 16384, 0, 0, 0)  = -1 ECONNRESET (Connection reset by peer)

That is, psycopg2/libpq sees no error when sending the first query
after the connection is closed, but gets an error reading the result.
In that case, everything worked fine.

But sometimes, the error manifests like this:

  sendto(3, "Q\0\0\0\34select pg_backend_pid()\0", 29, MSG_NOSIGNAL, NULL, 0) = -1 EPIPE (Broken pipe)
  recvfrom(3, "E\0\0\0mSFATAL\0C57P01\0Mterminating "..., 16384, 0, NULL, NULL) = 110
  recvfrom(3, "", 16274, 0, NULL, NULL)   = 0
  recvfrom(3, "", 16274, 0, NULL, NULL)   = 0

i.e. libpq received an error when sending the query. This manifests as
a slightly different exception from a slightly different place. More
importantly, in this case connection.closed is left at 0 rather than
being set to 2, and that is the bug I'm fixing here.

Note that we see almost identical behaviour for sync and async
connections, and the fixes are the same. So I added extremely similar
test cases.

Finally, there is still a bug here: for async connections, we
sometimes raise DatabaseError (incorrect) and sometimes raise
OperationalError (correct). Will fix that next.
</pre>
</div>
</content>
</entry>
<entry>
<title>Flake8 complaints</title>
<updated>2017-03-14T12:06:46+00:00</updated>
<author>
<name>Daniele Varrazzo</name>
<email>daniele.varrazzo@gmail.com</email>
</author>
<published>2017-03-14T12:06:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/python-packages/psycopg2.git/commit/?id=3c124a0b87a7bde51519cd0eb98980f04eed1595'/>
<id>3c124a0b87a7bde51519cd0eb98980f04eed1595</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
