]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
3 years agochore: update cibuildwheel to 2.5.0
Daniele Varrazzo [Mon, 2 May 2022 01:01:11 +0000 (03:01 +0200)] 
chore: update cibuildwheel to 2.5.0

3 years agoMerge branch 'fix-293' into maint-3.0
Daniele Varrazzo [Sun, 8 May 2022 19:11:04 +0000 (21:11 +0200)] 
Merge branch 'fix-293' into maint-3.0

3 years agoFix array oid dumping lists of integer
Daniele Varrazzo [Sun, 8 May 2022 14:29:32 +0000 (16:29 +0200)] 
Fix array oid dumping lists of integer

The problem was only in the list text dumper, which was trying to do more
than what needed. The list binary dumper worked alright.

Drop mixed array test, which don't really represent anything Postgres
can work with.

Close #293

3 years agotest: add test to verify the wrong array oid with numbers
Daniele Varrazzo [Thu, 5 May 2022 21:04:10 +0000 (23:04 +0200)] 
test: add test to verify the wrong array oid with numbers

The array binary dumper does the right thing; the text one picks
numeric[] unconditionally. It was clearly made on purpose, but #293
shows that it's a bad idea.

3 years agofix: allow to use cancel() on a closed connection
Daniele Varrazzo [Mon, 2 May 2022 00:45:21 +0000 (02:45 +0200)] 
fix: allow to use cancel() on a closed connection

3 years agodocs: add hint about using add_signal_handler() to interrupt async queries
Daniele Varrazzo [Mon, 2 May 2022 00:37:00 +0000 (02:37 +0200)] 
docs: add hint about using add_signal_handler() to interrupt async queries

Courtesy @gjcarneiro, thank you!

3 years agoMerge branch 'fix-286' into maint-3.0
Daniele Varrazzo [Mon, 2 May 2022 00:46:32 +0000 (02:46 +0200)] 
Merge branch 'fix-286' into maint-3.0

3 years agoperf: avoid unnecessary recvfrom() in cursor.stream()
Daniele Varrazzo [Sun, 1 May 2022 22:56:42 +0000 (00:56 +0200)] 
perf: avoid unnecessary recvfrom() in cursor.stream()

Call PQisBusy() before PQconsumeInput() on fetching results. If not
busy, don't call PQconsumeInput() at all but just go to fetching results
and notifications.

This is especially useful in single-row mode because most of the times
the libpq can produce several results after a single network fetch.
Previously we were calling PQconsumeInput() also when results were
already on the client and there was nothing new to read, which forced
the libpq to run a select() to tell apart a lack of data from an EOF,
see `the grumble`_, and caused the overhead reported in #286.

Close #286.

.. _the grumble: https://github.com/postgres/postgres/blob/ed57cac84d1c5642737dab1e4c4b8cb4f0c4305f/src/interfaces/libpq/fe-misc.c#L681

3 years agotest: add cursor.stream() test for empty result sets
Daniele Varrazzo [Sun, 1 May 2022 20:45:24 +0000 (22:45 +0200)] 
test: add cursor.stream() test for empty result sets

Also add a missing async test for results with no column.

3 years agorefactor: replace an assert with a type: ignore
Daniele Varrazzo [Sun, 1 May 2022 20:44:37 +0000 (22:44 +0200)] 
refactor: replace an assert with a type: ignore

It's not like we give away opcodes for free here.

3 years agorefactor: send only once per stream
Daniele Varrazzo [Sun, 1 May 2022 12:35:02 +0000 (14:35 +0200)] 
refactor: send only once per stream

No need to do it at every row, probably entirely wrong. However this is
not the cause of the slowness reported in #286.

3 years agorefactor: only clean up the wait() timeout if needed
Daniele Varrazzo [Sun, 1 May 2022 12:30:20 +0000 (14:30 +0200)] 
refactor: only clean up the wait() timeout if needed

Often we terminate the iteration at the first item, so no need to select
at all.

3 years agotest: fix variable scope in ctrl-c test
Daniele Varrazzo [Sat, 30 Apr 2022 13:18:14 +0000 (15:18 +0200)] 
test: fix variable scope in ctrl-c test

3 years agotest: verify ctrl-c in async mode using get_event_loop
Daniele Varrazzo [Fri, 29 Apr 2022 23:16:02 +0000 (01:16 +0200)] 
test: verify ctrl-c in async mode using get_event_loop

3 years agochore: bump to next dev release
Daniele Varrazzo [Sat, 30 Apr 2022 00:46:44 +0000 (02:46 +0200)] 
chore: bump to next dev release

3 years agochore: bump to version 3.0.12 3.0.12
Daniele Varrazzo [Fri, 29 Apr 2022 22:38:49 +0000 (00:38 +0200)] 
chore: bump to version 3.0.12

3 years agoMerge branch 'fix-254' into maint-3.0
Daniele Varrazzo [Fri, 29 Apr 2022 22:31:40 +0000 (00:31 +0200)] 
Merge branch 'fix-254' into maint-3.0

3 years agotest: add tests to verify copy across tables works
Daniele Varrazzo [Fri, 29 Apr 2022 21:39:36 +0000 (23:39 +0200)] 
test: add tests to verify copy across tables works

3 years agofeat(copy): allow bytearray/memoryview as copy.write() input
Daniele Varrazzo [Sat, 26 Mar 2022 00:56:49 +0000 (01:56 +0100)] 
feat(copy): allow bytearray/memoryview as copy.write() input

The C implementation can deal with these types efficiently and it may
save a memcopy if that's what the user has available.

Close #254

3 years agofix: fix dumping int enums in text mode, python implementation
Daniele Varrazzo [Thu, 21 Apr 2022 01:29:05 +0000 (03:29 +0200)] 
fix: fix dumping int enums in text mode, python implementation

The error was hidden by a broken test, failing to test the text mode.

3 years agofix: drop debug logging left over
Daniele Varrazzo [Thu, 7 Apr 2022 17:57:07 +0000 (19:57 +0200)] 
fix: drop debug logging left over

3 years agoci: print versions of depending packages on psycopg-binary build
Daniele Varrazzo [Thu, 31 Mar 2022 19:34:27 +0000 (21:34 +0200)] 
ci: print versions of depending packages on psycopg-binary build

Only on manylinux and musllinux images for the moment.

See #262

3 years agochore: upgrade cibuildwheel to 2.3.1
Daniele Varrazzo [Wed, 30 Mar 2022 15:08:43 +0000 (17:08 +0200)] 
chore: upgrade cibuildwheel to 2.3.1

3 years agobuild: upgrade system packages before building psycopg-binary
Daniele Varrazzo [Wed, 30 Mar 2022 14:53:30 +0000 (16:53 +0200)] 
build: upgrade system packages before building psycopg-binary

See #262

3 years agochore: bump to next dev version
Daniele Varrazzo [Wed, 30 Mar 2022 14:51:54 +0000 (16:51 +0200)] 
chore: bump to next dev version

3 years agochore: bump version number to 3.0.11 3.0.11
Daniele Varrazzo [Tue, 29 Mar 2022 21:06:52 +0000 (23:06 +0200)] 
chore: bump version number to 3.0.11

3 years agoci: upgrade black
Daniele Varrazzo [Tue, 29 Mar 2022 01:21:40 +0000 (03:21 +0200)] 
ci: upgrade black

This version is not affected by https://github.com/psf/black/issues/2964
and doesn't require pinning click.

3 years agotest: display the version of the server tests are run against
Daniele Varrazzo [Sun, 27 Mar 2022 18:52:57 +0000 (20:52 +0200)] 
test: display the version of the server tests are run against

3 years agodocs: add back lost comment and extend it with new knowledge
Daniele Varrazzo [Sat, 26 Mar 2022 01:32:31 +0000 (02:32 +0100)] 
docs: add back lost comment and extend it with new knowledge

3 years agoperf: release the GIL in copy-related libpq functions
Daniele Varrazzo [Sat, 26 Mar 2022 00:18:05 +0000 (01:18 +0100)] 
perf: release the GIL in copy-related libpq functions

Tests have shown that these functions may do a considerable amount of
work, although purely CPU.

3 years agofix(copy): chunk large buffers before queuing, not after
Daniele Varrazzo [Fri, 25 Mar 2022 15:57:28 +0000 (16:57 +0100)] 
fix(copy): chunk large buffers before queuing, not after

This is conceptually a better place to do it, because the queue has the
function of applying backpressure on the data generator. Splitting large
buffers later would flood the libpq without effectively slowing down the
producer.

Also, reduce the size of the chunks appended to the libpq from 1Mb to
128K. This makes an *immense* difference: the too large chunk probably
triggers some quadraticity in the libpq. The test script found in #255,
piped in `ts -s`, shows that pushing a block of data of about 1Gb size
(which will fail in Postgres anyway), with the smaller size, will take
about 9s. With the larger size, it takes 4.10m to get to waiting for
PQputCopyEnd, and other almost 6 minutes to receive the error message
from the server.

    00:00:47 putting 1048576 (or less) bytes in queue size 1023
    00:00:47 writing copy end
    00:00:47 got 1048576 bytes from queue size 1023
    ...
    00:01:25 got 1048576 bytes from queue size 640
    ...
    00:01:54 got 1048576 bytes from queue size 512
    ...
    00:03:00 got 1048576 bytes from queue size 256
    ...
    00:04:12 got 0 bytes from queue size 0
    00:04:12 wait for copy end
    00:09:59 Traceback (most recent call last):
    ...

Adding a few prints (see #255 for details) also shows that the time
spent in PQputCopyData increases, going from ~15 entries/sec processed
when the writer has just finished pushing data in the queue, down to ~4
items/sec towards the end.

Considering that a reduction of 10-20% of the input size causes a
decrease of the processing time of about 50%, there is definitely
something quadratic going on there. It might be possible to improve the
libpq, but for the moment it's better to try and coexist nicely with the
current state.

3 years agofix(copy): split large buffers before sending them to PQputCopyData
Daniele Varrazzo [Thu, 24 Mar 2022 13:01:58 +0000 (14:01 +0100)] 
fix(copy): split large buffers before sending them to PQputCopyData

Sending excessively large data doesn't allow the libpq to flush its
content to the server, ending up in an infinite loop.

Close #255

3 years agofix(copy): propagate errors raised in the worker thread
Daniele Varrazzo [Thu, 24 Mar 2022 15:52:05 +0000 (16:52 +0100)] 
fix(copy): propagate errors raised in the worker thread

Previously, an error in the worker thread was printed to stderr, but
processing continued, for no result but no exception.

Problem found in #255, but unrelated to it.

3 years agofix: fix loading of text arrays with dimension information
Daniele Varrazzo [Sun, 20 Mar 2022 00:32:25 +0000 (01:32 +0100)] 
fix: fix loading of text arrays with dimension information

The dimension information is a prefix such as ``[0:2]=`` in front of the
array. We just discard it when loading to lists, because for Python they
are always 0-based.

https://www.postgresql.org/docs/14/arrays.html#ARRAYS-IO

Close #253.

3 years agochore: bump to next dev release
Daniele Varrazzo [Sun, 13 Mar 2022 00:34:14 +0000 (00:34 +0000)] 
chore: bump to next dev release

3 years agodoc: fix duplications in class exceptions table titles
Daniele Varrazzo [Sun, 13 Mar 2022 00:29:09 +0000 (00:29 +0000)] 
doc: fix duplications in class exceptions table titles

3 years agofix(c): fix portable endian aliases on different BSD flavours 3.0.10
Daniele Varrazzo [Fri, 11 Mar 2022 20:07:03 +0000 (20:07 +0000)] 
fix(c): fix portable endian aliases on different BSD flavours

See the commit at:
https://github.com/linux-sunxi/sunxi-tools/commit/384ff6473455da1a24b5037b358591f44f3bbf57

Close #241

3 years agochore: bump version number to 3.0.10
Daniele Varrazzo [Thu, 3 Mar 2022 01:53:41 +0000 (01:53 +0000)] 
chore: bump version number to 3.0.10

3 years agofix: don't raise error accessing Cursor.description after COPY_OUT
Daniele Varrazzo [Wed, 2 Mar 2022 00:48:30 +0000 (00:48 +0000)] 
fix: don't raise error accessing Cursor.description after COPY_OUT

COPY_OUT result advertises the number of columns but not their names (or
types). Use a surrogate name for description (which is more useful than
returning `None`, because at lest it tells how many columns were
emitted).

Close #235.

3 years agoMerge branch 'fix-231' into maint-3.0
Daniele Varrazzo [Wed, 2 Mar 2022 01:56:25 +0000 (01:56 +0000)] 
Merge branch 'fix-231' into maint-3.0

3 years agotest(win32): skip Ctrl-C test on Windows
Daniele Varrazzo [Wed, 2 Mar 2022 00:57:51 +0000 (00:57 +0000)] 
test(win32): skip Ctrl-C test on Windows

As much as I've tried, haven't been able to send a Ctrl-C. Tests fail on
"ctrl-c not received".

3 years agofix: Cancel query on Ctrl-C
Daniele Varrazzo [Tue, 22 Feb 2022 03:02:13 +0000 (04:02 +0100)] 
fix: Cancel query on Ctrl-C

On KeyboardInterrupt, send a cancel to the server and keep waiting for
the result of the cancel, which is expected to raise a QueryCanceled,
then re-raise KeyboardInterrupt.

Before this, the connection was left in ACTIVE state, so it couldn't be rolled
back.

Only fixed on sync connections. Left a failing test for async
connections; the test fails with an output from the script such as:

    error ignored in rollback on <psycopg.AsyncConnection [ACTIVE] ...>:
    sending query failed: another command is already in progress
    Traceback (most recent call last):
      File "<string>", line 27, in <module>
      File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
        return loop.run_until_complete(main)
      File "/usr/lib/python3.8/asyncio/base_events.py", line 603, in run_until_complete
        self.run_forever()
      File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
        self._run_once()
      File "/usr/lib/python3.8/asyncio/base_events.py", line 1823, in _run_once
        event_list = self._selector.select(timeout)
      File "/usr/lib/python3.8/selectors.py", line 468, in select
        fd_event_list = self._selector.poll(timeout, max_ev)
    KeyboardInterrupt

And the except branch in `AsyncConnection.wait()` is not reached.

See #231

3 years agochore: bump to next dev release
Daniele Varrazzo [Sat, 19 Feb 2022 18:05:31 +0000 (19:05 +0100)] 
chore: bump to next dev release

3 years agochore: bump version number to 3.0.9 3.0.9
Daniele Varrazzo [Sat, 19 Feb 2022 17:48:24 +0000 (18:48 +0100)] 
chore: bump version number to 3.0.9

3 years agoMore regular and compact auto-generated exceptions
Daniele Varrazzo [Sat, 12 Feb 2022 17:55:09 +0000 (18:55 +0100)] 
More regular and compact auto-generated exceptions

Also drop unneeded flake8 config file.

3 years agoSet up the sqlstate-exception mapping using init_subclass
Daniele Varrazzo [Fri, 11 Feb 2022 22:16:51 +0000 (23:16 +0100)] 
Set up the sqlstate-exception mapping using init_subclass

3 years agoMerge branch 'fix-225' into maint-3.0
Daniele Varrazzo [Fri, 11 Feb 2022 20:33:59 +0000 (21:33 +0100)] 
Merge branch 'fix-225' into maint-3.0

3 years agoAdd doc section to refer to the exceptions list
Daniele Varrazzo [Fri, 11 Feb 2022 19:32:55 +0000 (20:32 +0100)] 
Add doc section to refer to the exceptions list

Also clarify Error.sqlstate and further errors doc cleanup.

3 years agoSet Error.sqlcode when unknown codes are received
Daniele Varrazzo [Fri, 11 Feb 2022 19:27:40 +0000 (20:27 +0100)] 
Set Error.sqlcode when unknown codes are received

Close #225.

3 years agoMake the tzdata package a dependency on Windows
Daniele Varrazzo [Wed, 9 Feb 2022 21:03:35 +0000 (22:03 +0100)] 
Make the tzdata package a dependency on Windows

The package replaces the missing system tz database and allows to avoid
the warning and return timestamps in the client timezone instead of in
UTC.

Close #223

3 years agoSet workflows to cancel jobs on the same branch
Daniele Varrazzo [Fri, 11 Feb 2022 00:41:09 +0000 (01:41 +0100)] 
Set workflows to cancel jobs on the same branch

Docs at https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency

3 years agoMove Windows test to separate file to avoid applying the asyncio mark
H [Thu, 10 Feb 2022 23:50:41 +0000 (23:50 +0000)] 
Move Windows test to separate file to avoid applying the asyncio mark

3 years agoMake synchronous test async to avoid asyncio error
H [Thu, 10 Feb 2022 23:07:18 +0000 (23:07 +0000)] 
Make synchronous test async to avoid asyncio error

3 years agoAdd doc section about server messages handling
Daniele Varrazzo [Sun, 6 Feb 2022 00:23:09 +0000 (01:23 +0100)] 
Add doc section about server messages handling

3 years agoFix typo/improve errors docs
Daniele Varrazzo [Sat, 5 Feb 2022 22:43:13 +0000 (23:43 +0100)] 
Fix typo/improve errors docs

3 years agoAllow running tests with psycopg-pool 3.1
Daniele Varrazzo [Sat, 5 Feb 2022 19:15:48 +0000 (20:15 +0100)] 
Allow running tests with psycopg-pool 3.1

A few internal attributes changed but they are only poked at for
testing, they are not part of the interface.

3 years agoReconfigure black/flake8 as on master branch and re-blacken
Daniele Varrazzo [Mon, 31 Jan 2022 10:44:08 +0000 (10:44 +0000)] 
Reconfigure black/flake8 as on master branch and re-blacken

3 years agofix: confusing named parameters in example query
Jules Sagot--Gentil [Sat, 29 Jan 2022 17:25:45 +0000 (18:25 +0100)] 
fix: confusing named parameters in example query

In the named parameters example query, the name of the parameters are
Python built in data types: int and str.

This is confusing because it looks like we are casting values passed
as arguments instead of passing named arguments.

3 years agoFix typo
Benji York [Sat, 22 Jan 2022 14:35:06 +0000 (08:35 -0600)] 
Fix typo

Toilets are not to be taken lightly.

3 years agoTypo fixed
Daniele Varrazzo [Thu, 20 Jan 2022 14:37:13 +0000 (14:37 +0000)] 
Typo fixed

3 years agoAllow one test to fail on Windows C implementation
Daniele Varrazzo [Fri, 14 Jan 2022 03:44:56 +0000 (04:44 +0100)] 
Allow one test to fail on Windows C implementation

This test doesn't run in tox, so it doesn't benefit from repeats, and it
fails often indeed on flakey tests.

Add pytest option to tolerate a number of failures, and use it.

3 years agoDon't reset the random seed re-running failed tests
Daniele Varrazzo [Fri, 14 Jan 2022 03:17:15 +0000 (04:17 +0100)] 
Don't reset the random seed re-running failed tests

We don't want to make them pass because we didn't like the random draw.
It's not best of three.

3 years agoFix definitions for pipeline replacements macros
Daniele Varrazzo [Fri, 14 Jan 2022 00:48:12 +0000 (01:48 +0100)] 
Fix definitions for pipeline replacements macros

The previous definition caused a warning for implicit conversion from
void* to int.

3 years agoAllow passing the PIP_CONSTRAINT env var to tox
Daniele Varrazzo [Fri, 14 Jan 2022 01:23:51 +0000 (02:23 +0100)] 
Allow passing the PIP_CONSTRAINT env var to tox

This allows to run tests using the oldest, rather than the newest,
dependency packages, by passing it the tests/constraints.txt file.

3 years agoUse wheel 0.37 as minimum version
Daniele Varrazzo [Fri, 14 Jan 2022 00:07:03 +0000 (01:07 +0100)] 
Use wheel 0.37 as minimum version

It is the first version officially supporting Python 3.10
https://wheel.readthedocs.io/en/stable/news.html

3 years agoDrop explicit tests retries
Daniele Varrazzo [Thu, 13 Jan 2022 21:57:45 +0000 (22:57 +0100)] 
Drop explicit tests retries

Now we just retry all failing tests automatically.

3 years agoRetry automatically flakey tests in tox runs
Daniele Varrazzo [Thu, 13 Jan 2022 21:56:44 +0000 (22:56 +0100)] 
Retry automatically flakey tests in tox runs

3 years agoPin pytest-asyncio package in Psycopg 3.0.x maint branch
Daniele Varrazzo [Thu, 13 Jan 2022 18:49:59 +0000 (19:49 +0100)] 
Pin pytest-asyncio package in Psycopg 3.0.x maint branch

We cannot upgrade to 0.17.0 because it requires a config entry that then
makes 0.16.x fail.

3 years agoRelax some timing tests tolerances
Daniele Varrazzo [Sat, 8 Jan 2022 22:37:55 +0000 (23:37 +0100)] 
Relax some timing tests tolerances

Seeing them failing regularly in Github workflows.

3 years agoBump to next maint releases
Daniele Varrazzo [Sat, 8 Jan 2022 19:50:26 +0000 (20:50 +0100)] 
Bump to next maint releases

3 years agoSeparate pool packages building into a different workflow
Daniele Varrazzo [Mon, 3 Jan 2022 15:37:37 +0000 (16:37 +0100)] 
Separate pool packages building into a different workflow

Psycopg and pool releases are separate.

3 years agoBump version numbers for release 3.0.8 pool-3.0.3
Daniele Varrazzo [Sat, 8 Jan 2022 18:57:04 +0000 (19:57 +0100)] 
Bump version numbers for release

3 years agoLeave start year only in docs footer
Daniele Varrazzo [Sat, 8 Jan 2022 01:16:57 +0000 (02:16 +0100)] 
Leave start year only in docs footer

3 years agoUpdate, once and for good, the copyright year
Daniele Varrazzo [Sat, 8 Jan 2022 01:18:57 +0000 (02:18 +0100)] 
Update, once and for good, the copyright year

After getting more information about the matter and having convinced
myself that there is no need, except FOMO, to extend the copyright year
on source code, change all our entries to leave only the start year.

    git ls-tree -r HEAD --name-only \
        | xargs sed -i '/Copyright.*\(Varrazzo\|Psycopg\)/ s/-20..//'

3 years agoDon't leave the connection ACTIVE on error in COPY_OUT
Daniele Varrazzo [Fri, 7 Jan 2022 21:06:20 +0000 (22:06 +0100)] 
Don't leave the connection ACTIVE on error in COPY_OUT

Cancel the active COPY operation if the server has not finished sending
the data yet.

Close #203.

Also fix the tests which were based on this broken behaviour. A case of
self-administered Hyrum's law.

3 years agoUse info instead of pgconn in copy tests
Daniele Varrazzo [Fri, 7 Jan 2022 21:05:02 +0000 (22:05 +0100)] 
Use info instead of pgconn in copy tests

It displays better information in case of assert failed.

3 years agoExclude mypy 0.931 too from tests
Daniele Varrazzo [Fri, 7 Jan 2022 18:35:03 +0000 (19:35 +0100)] 
Exclude mypy 0.931 too from tests

It seems still affected by https://github.com/python/mypy/issues/11820.

3 years agoDon't overwrite the module of the psycopg.pq.pq_ctypes objects
Daniele Varrazzo [Fri, 7 Jan 2022 17:32:47 +0000 (18:32 +0100)] 
Don't overwrite the module of the psycopg.pq.pq_ctypes objects

It might be useful to tell apart the C version from the python versions
for debugging. The C versions don't do it, so they repr as:

    <psycopg_binary.pq.PGconn [IDLE] (database=piro) at 0x7f8556deb040>

See #201.

3 years agoAdd example about DDL statement with quoted parameter
Daniele Varrazzo [Fri, 7 Jan 2022 01:54:25 +0000 (02:54 +0100)] 
Add example about DDL statement with quoted parameter

See #199.

3 years agoAdd mark for pool tests
Daniele Varrazzo [Thu, 6 Jan 2022 23:23:46 +0000 (00:23 +0100)] 
Add mark for pool tests

Don't auto-skip pool test if import fails. This would miss serious
problems leading to the pool not being importable. If someone wants to
skip the pool tests they can use `-m 'not pool'` now.

3 years agoDrop broken test about setting prepare attributes on the class
Daniele Varrazzo [Fri, 7 Jan 2022 01:11:29 +0000 (02:11 +0100)] 
Drop broken test about setting prepare attributes on the class

I'm just clobbering the property here. It doesn't work. Thankfully it
wasn't documented to work...

3 years agoDon't look up other modules objects in __del__ methods
Daniele Varrazzo [Thu, 6 Jan 2022 16:09:22 +0000 (17:09 +0100)] 
Don't look up other modules objects in __del__ methods

The modules might have been already cleaned up during interpreted
shutdown. See <https://bugs.python.org/issue46256#msg409847> for an
explanation.

The stdlib guards against the same thing happening too. However they
take a reference in the function closure, which is stronger than what we
do. Doing so, on our strictly typed codebase, is a tedious chore, so, if
this is enough (it should be, according to the OP), I'm happy this way.

Close #198.

3 years agoAllow pools to have min_size = 0 as long as they can grow
Daniele Varrazzo [Thu, 6 Jan 2022 21:16:09 +0000 (22:16 +0100)] 
Allow pools to have min_size = 0 as long as they can grow

Add tests to verify they can grow from 0 no problem.

3 years agoAdd ConnectionTimeout subclass of OperationalError
Daniele Varrazzo [Wed, 5 Jan 2022 01:50:25 +0000 (02:50 +0100)] 
Add ConnectionTimeout subclass of OperationalError

To be used in the connection pool to detect timeout on connection.

Backported to Psycopg 3.0.8 to allow the pool 3.1 to work with it, at
least on diminished capacity (NullPool.connection() would time out only
for clients in the queue, not in case of new connection timeout).

3 years agoMerge branch 'pool-checks' into maint-3.0
Daniele Varrazzo [Wed, 5 Jan 2022 22:10:56 +0000 (23:10 +0100)] 
Merge branch 'pool-checks' into maint-3.0

3 years agoRaise PoolClosed on wait() on a closed pool
Daniele Varrazzo [Wed, 5 Jan 2022 02:24:52 +0000 (03:24 +0100)] 
Raise PoolClosed on wait() on a closed pool

Previously it might have raised an assert, if, for instance, wait would
have failed and retried.

3 years agoRaise ValueError if the pool min_size is <= 0
Daniele Varrazzo [Mon, 3 Jan 2022 18:52:44 +0000 (19:52 +0100)] 
Raise ValueError if the pool min_size is <= 0

Before it would have created a broken pool, blocking forever on getconn.

3 years agoMove some common checks to the pool base class
Daniele Varrazzo [Mon, 3 Jan 2022 18:40:11 +0000 (19:40 +0100)] 
Move some common checks to the pool base class

3 years agoUse caplog.set_level instead of manual filtering in tests
Daniele Varrazzo [Wed, 5 Jan 2022 19:23:25 +0000 (20:23 +0100)] 
Use caplog.set_level instead of manual filtering in tests

3 years agoSkip tests using the deaf_port fixture on macOS and Windows
Daniele Varrazzo [Wed, 5 Jan 2022 20:52:55 +0000 (21:52 +0100)] 
Skip tests using the deaf_port fixture on macOS and Windows

They fail some 50% of the time, looks like the port is not really
listening, the fact that the function is called listen() is just a
practical joke.

https://github.com/psycopg/psycopg/runs/4719288041?check_suite_focus=true

3 years agoAdd deaf_port fixture and base timeout tests on it
Daniele Varrazzo [Wed, 5 Jan 2022 00:53:07 +0000 (01:53 +0100)] 
Add deaf_port fixture and base timeout tests on it

3 years agoHopefully more robust test to identify a closed connection
Daniele Varrazzo [Sun, 2 Jan 2022 21:19:15 +0000 (22:19 +0100)] 
Hopefully more robust test to identify a closed connection

3 years agoDrop unneeded method signatures in docs
Daniele Varrazzo [Sun, 2 Jan 2022 20:02:26 +0000 (21:02 +0100)] 
Drop unneeded method signatures in docs

3 years agoRename a couple of internal cursor methods for clarity
Daniele Varrazzo [Sun, 2 Jan 2022 18:47:37 +0000 (19:47 +0100)] 
Rename a couple of internal cursor methods for clarity

3 years agoRefactor cur._raise_from_results() into _raise_for_result()
Daniele Varrazzo [Sun, 2 Jan 2022 18:46:32 +0000 (19:46 +0100)] 
Refactor cur._raise_from_results() into _raise_for_result()

The case of raising with different statuses doesn't practically happen.

3 years agoDrop Cursor._set_results()
Daniele Varrazzo [Sun, 2 Jan 2022 18:22:34 +0000 (19:22 +0100)] 
Drop Cursor._set_results()

Split it into a _check_results() and leave the caller manage the cursor state.

3 years agoShorten traceback on executemany
Daniele Varrazzo [Sun, 2 Jan 2022 19:06:45 +0000 (20:06 +0100)] 
Shorten traceback on executemany

3 years agoFix typo in comment
Daniele Varrazzo [Sun, 2 Jan 2022 18:59:02 +0000 (19:59 +0100)] 
Fix typo in comment

3 years agoFix test suite to run on database in locales different from English
Daniele Varrazzo [Sun, 2 Jan 2022 17:58:17 +0000 (18:58 +0100)] 
Fix test suite to run on database in locales different from English

3 years agoNote in news file that 3.0.8 is still unreleased
Daniele Varrazzo [Sun, 2 Jan 2022 17:03:08 +0000 (18:03 +0100)] 
Note in news file that 3.0.8 is still unreleased