Commit Graph

2177 Commits

Author SHA1 Message Date
Daniele Varrazzo
9f6bab692d Implement traversal for Diagnostics object
Triyng to fix a reported memory leak with diags, but implementing
traversing doesn't help. Quite the opposite in the example provided in
bug #557, the leak is present even with the `del diag`.

The leak appears with Python 3.5, not with Python 2.7.
2017-05-23 11:37:19 +01:00
Daniele Varrazzo
165449c724 Added doc link to replication commands 2017-05-10 01:55:01 +01:00
Daniele Varrazzo
6e5abf33f2 Merge branch 'fix-547' 2017-04-19 01:34:39 +01:00
Daniele Varrazzo
9d7ff405ee Added news entries for the previous 2 merge requests 2017-04-19 01:16:08 +01:00
Daniele Varrazzo
a7e3f46431 Merge remote-tracking branch 'fix_lobject_factory' 2017-04-19 01:06:24 +01:00
Daniele Varrazzo
bd34c86aba Merge remote-tracking branch 'fix_lobject_mode' 2017-04-19 01:06:08 +01:00
Daniele Varrazzo
248e653c9e Fixed args parsing in ReplicationCursor.consume_stream()
Close #547.
2017-04-19 01:01:59 +01:00
Frazer McLean
9e5621698f Python < 3.2 doesn’t have assertIsInstance 2017-04-16 03:44:21 +02:00
Frazer McLean
7b3ea43e92 Handle lobject mode=None correctly 2017-04-16 03:20:31 +02:00
Frazer McLean
38cd720369 Fix name of lobject keyword argument 2017-04-16 03:12:18 +02:00
Daniele Varrazzo
4b4d2796b7 Merge branch 'fix-410' 2017-04-05 15:16:01 +01:00
Daniele Varrazzo
cd095ef0ee Added test to verify callback errors in named cursors
They work fine.
2017-04-05 14:54:07 +01:00
Daniele Varrazzo
a66c34a6d0 Don't clobber a Python exception with an unknown error
Close #410
2017-04-05 14:54:07 +01:00
Daniele Varrazzo
47f5e97759 Added test to verify #410
The 'unknown error' happens on query.
2017-04-05 14:54:07 +01:00
Daniele Varrazzo
3b48918bef Note that the fast executemany functions don't respect rowcount
See issue #540
2017-03-28 10:37:04 +01:00
Daniele Varrazzo
adf55babe8 Merge remote-tracking branch 'origin/fix-536' 2017-03-22 12:19:31 +00:00
Daniele Varrazzo
b94548f5a3 Fix curl not found on AppVeyor
http://help.appveyor.com/discussions/problems/6312-curl-command-not-found
2017-03-22 03:54:23 +00:00
Daniele Varrazzo
ee9948fa86 Expose *DATETIMETZ* objects in the extensions module 2017-03-22 03:42:12 +00:00
Daniele Varrazzo
57b1093b31 Find again mxDateTime includes in default locations 2017-03-22 03:36:08 +00:00
Daniele Varrazzo
7214c6652e Return objects with timezone parsing infinity timestamptz
Close #536.
2017-03-22 03:03:02 +00:00
Daniele Varrazzo
31f91e033f Dropped info that the features requires libpq >= 9.0
We are currently requiring libpq 9.1 at least, and the feature was
released in 2.7, which could have never been compiled with previos
libpq versions.
2017-03-20 19:08:18 +00:00
Daniele Varrazzo
1e0aef032f Dropped repeated doc links in the same paragraph
And some more sql docs cleanup.
2017-03-16 04:40:22 +00:00
Daniele Varrazzo
f9b36433fb Merge branch 'fix-528' 2017-03-16 04:24:17 +00:00
Daniele Varrazzo
ba0329fb40 replication connection init refactored to use psyco_make_dsn
Some extra bonus refactoring to improve the function readability (don't
reuse names for variables with different refcount rules, don't pass
separate obj/self, async pass-through...)
2017-03-16 03:55:22 +00:00
Daniele Varrazzo
9f160fd820 Obscure the password on url dsn too
Note that we don't leak anymore the password length.

Fix #528
2017-03-16 03:53:40 +00:00
Daniele Varrazzo
c7f5690426 Added docs about the usability of sql objects with copy_expert()
See issue #529.
2017-03-16 00:55:20 +00:00
Daniele Varrazzo
3bfbd3a0a5 Added test to verify sql objects work with copy_expert()
I'll be honest: I lucked out, I didn't think about this combination. But
maybe sheer luck, maybe using common code paths, it just works. Let's
make it stays so.
2017-03-16 00:55:20 +00:00
Daniele Varrazzo
103655d670 Password scrubbing refactored in a separate function 2017-03-15 16:04:45 +00:00
Daniele Varrazzo
cc047a445a Added tests to verify the password is obscured
The url test fails: see issue #528
2017-03-15 16:00:40 +00:00
Daniele Varrazzo
7187d6408a Merge branch 'fix-443' 2017-03-14 14:41:48 +00:00
Daniele Varrazzo
3626e961f8 Reported bug #443 fixed *again*
Also see ticket #527.
2017-03-14 14:16:02 +00:00
Daniele Varrazzo
8e28444897 Bunch of test tweaks to make the test grid green 2017-03-14 14:15:52 +00:00
Daniele Varrazzo
7c2333dd81 Connection state fixed noted in the news 2017-03-14 14:15:52 +00:00
Greg Ward
12317557da Always raise OperationalError when connection was closed externally.
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.
2017-03-14 12:14:00 +00:00
Greg Ward
b203a7c775 Always detect when a connection is closed behind psycopg2's back.
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.
2017-03-14 12:08:03 +00:00
Daniele Varrazzo
3c124a0b87 Flake8 complaints 2017-03-14 12:06:46 +00:00
Daniele Varrazzo
ef9f9f5fff Improved notes to release psycopg packages 2017-03-13 16:50:57 +00:00
Daniele Varrazzo
5730aa9a40 Less stuff in the readme, more in the docs 2017-03-13 12:13:47 +00:00
Daniele Varrazzo
8ed0196d02 Bump to next dev release 2017-03-13 11:50:34 +00:00
Daniele Varrazzo
09c48c76c3 Bump to version 2.7.1 2017-03-11 17:03:22 +00:00
Daniele Varrazzo
b075c7169c Report ticket 518 fixed
The fix is actually implemented in the openssl1 branch of
https://github.com/psycopg/psycopg2-wheels
2017-03-11 17:00:58 +00:00
Jon Nelson
c661695b28 correct minor grammatical issue with deprecation warning 2017-03-03 13:54:22 +00:00
Daniele Varrazzo
06fbd0ee02 Dropped "what's new in 2.7.1" from docs index 2017-03-03 13:50:57 +00:00
Daniele Varrazzo
e3f56718d2 Added install section to specify how to skip wheels 2017-03-03 13:49:19 +00:00
Daniele Varrazzo
d007dc3249 Merge branch 'fix-520' 2017-03-02 19:36:45 +00:00
Daniele Varrazzo
a5382d7b72 Skip the tests according to the earliest of libpq built/linked. 2017-03-02 19:32:44 +00:00
Daniele Varrazzo
26bd5df048 Don't use PG_INT64_TYPE
Only defined in Postgres 9.3

Should close #520, but let's wait for the CI response (build on
Windows etc.)
2017-03-02 19:32:39 +00:00
Daniele Varrazzo
3a441467c0 Merge branch 'no-unittest2'
Close #516
2017-03-02 12:41:33 +00:00
Daniele Varrazzo
6be94f1927 Merge branch 'fix-517' 2017-03-02 12:22:27 +00:00
Daniele Varrazzo
5a65ff5cf4 Don't try to use unittest2
Modules importing unittest directly would miss the monkeypatch: see
ticket #516.
2017-03-01 20:44:04 +00:00