]>
git.ipfire.org Git - thirdparty/psycopg.git/log
Daniele Varrazzo [Fri, 18 Mar 2022 16:00:51 +0000 (17:00 +0100)]
docs: specify that ANY() is available in psycopg2 too
poulpe [Thu, 17 Mar 2022 13:18:46 +0000 (14:18 +0100)]
doc: give more context to disconnection detection recipe
Daniele Varrazzo [Sun, 13 Mar 2022 00:29:09 +0000 (00:29 +0000)]
doc: fix duplications in class exceptions table titles
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
Daniele Varrazzo [Thu, 3 Mar 2022 01:53:41 +0000 (01:53 +0000)]
chore: bump version number to 3.0.10
Daniele Varrazzo [Wed, 2 Mar 2022 23:48:15 +0000 (23:48 +0000)]
doc: fix typo in comment
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.
Daniele Varrazzo [Wed, 2 Mar 2022 02:53:06 +0000 (02:53 +0000)]
Merge branch 'fix-231'
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".
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
Daniele Varrazzo [Sat, 19 Feb 2022 18:04:28 +0000 (19:04 +0100)]
chore(pool): bump to next rev release
Daniele Varrazzo [Sat, 19 Feb 2022 17:52:18 +0000 (18:52 +0100)]
docs: declare psycopg 3.0.9 released
Daniele Varrazzo [Sat, 19 Feb 2022 17:23:48 +0000 (18:23 +0100)]
chore(pool): Bump pool version to 3.1.1
Daniele Varrazzo [Sat, 19 Feb 2022 17:19:31 +0000 (18:19 +0100)]
refactor(pool): update some debug logging
Drop debug logging on `MaintenanceTask.init()`, which is not
particularly useful. Add debug entries on tasks `run()` early bailout,
which is a more interesting condition to follow (and would have allowed
to spot #230 more easily).
Daniele Varrazzo [Sat, 19 Feb 2022 17:03:55 +0000 (18:03 +0100)]
Merge branch 'fix-230'
Close #230.
Daniele Varrazzo [Sat, 19 Feb 2022 16:34:37 +0000 (17:34 +0100)]
fix(pool): set the open flag before starting the maintenance tasks
Failing to do so we might trigger the test in `MaintenanceTask.run()`
and find the pool closed, so discard the operation. It usually doesn't
happen, but with a few combination of IO operation it does happen: see
https://github.com/psycopg/psycopg/issues/230 for details.
Daniele Varrazzo [Sat, 19 Feb 2022 14:39:37 +0000 (15:39 +0100)]
test(pool): add test to show deadlock on logging
This deadlock seems reproducible at least on Python 3.8 and 3.10 on
Linux. It is caused by the logging statement in
``MaintenanceTask.__init__``: even just a ``print()`` there causes the lock.
See https://github.com/psycopg/psycopg/issues/230 for more details.
Daniele Varrazzo [Sat, 19 Feb 2022 14:38:48 +0000 (15:38 +0100)]
chore(pool): bump to next pool version
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.
Daniele Varrazzo [Fri, 11 Feb 2022 22:16:51 +0000 (23:16 +0100)]
Set up the sqlstate-exception mapping using init_subclass
Daniele Varrazzo [Fri, 11 Feb 2022 20:33:14 +0000 (21:33 +0100)]
Merge branch 'fix-225'
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.
Daniele Varrazzo [Fri, 11 Feb 2022 19:27:40 +0000 (20:27 +0100)]
Set Error.sqlcode when unknown codes are received
Close #225.
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
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
Daniele Varrazzo [Fri, 11 Feb 2022 00:10:36 +0000 (01:10 +0100)]
Merge pull request #224 from The-One-And-Only-H/asyncio-fix
Fix failures caused by the pytest-asyncio now raising a warning when a sync
function is marked asyncio.
H [Thu, 10 Feb 2022 23:50:41 +0000 (23:50 +0000)]
Move Windows test to separate file to avoid applying the asyncio mark
H [Thu, 10 Feb 2022 23:07:18 +0000 (23:07 +0000)]
Make synchronous test async to avoid asyncio error
Daniele Varrazzo [Sun, 6 Feb 2022 00:24:17 +0000 (01:24 +0100)]
Configure codespell to run on a dirty working directory
Daniele Varrazzo [Sun, 6 Feb 2022 00:23:09 +0000 (01:23 +0100)]
Add doc section about server messages handling
Daniele Varrazzo [Sat, 5 Feb 2022 22:43:13 +0000 (23:43 +0100)]
Fix typo/improve errors docs
Daniele Varrazzo [Sat, 5 Feb 2022 22:31:51 +0000 (23:31 +0100)]
Fix docs typo
Daniele Varrazzo [Sat, 5 Feb 2022 19:25:02 +0000 (20:25 +0100)]
Note Python 3.6 dropped support in pool release notes
Daniele Varrazzo [Sat, 5 Feb 2022 15:50:37 +0000 (16:50 +0100)]
Prepare psycopg_pool 3.1 for release
Chris Roberts [Fri, 4 Feb 2022 21:52:07 +0000 (15:52 -0600)]
Fix typo in prepared statements+pooling warning
Joe Freeman [Wed, 2 Feb 2022 21:22:35 +0000 (21:22 +0000)]
Fix pool docs typo
Daniele Varrazzo [Mon, 31 Jan 2022 10:37:10 +0000 (10:37 +0000)]
Merge branch 'black-stable'
Daniele Varrazzo [Sun, 30 Jan 2022 16:57:45 +0000 (16:57 +0000)]
Apply string manipulations from black --preview
They are stable under the current black and look an improvement.
Daniele Varrazzo [Sun, 30 Jan 2022 16:40:19 +0000 (16:40 +0000)]
Restore black max line length to its default
Trying black --preview, it performs several aggressive changes that are
made worse by the stricter margin, so relax it to the default.
Daniele Varrazzo [Sun, 30 Jan 2022 13:38:47 +0000 (13:38 +0000)]
Move to using the stable black version 22.1.0
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.
Benji York [Sat, 22 Jan 2022 14:35:06 +0000 (08:35 -0600)]
Fix typo
Toilets are not to be taken lightly.
Daniele Varrazzo [Thu, 20 Jan 2022 14:37:13 +0000 (14:37 +0000)]
Typo fixed
Daniele Varrazzo [Wed, 19 Jan 2022 22:17:44 +0000 (22:17 +0000)]
Merge pull request #211 from The-One-And-Only-H/codespell
H [Wed, 19 Jan 2022 20:56:18 +0000 (20:56 +0000)]
Add codespell to pipeline
H [Wed, 19 Jan 2022 20:57:35 +0000 (20:57 +0000)]
Configure codespell in tox.ini
H [Wed, 19 Jan 2022 20:57:35 +0000 (20:57 +0000)]
Fix spelling errors found by codespell
H [Wed, 19 Jan 2022 20:57:34 +0000 (20:57 +0000)]
Rename noe function to no_e
Christian Clauss [Sun, 16 Jan 2022 09:32:20 +0000 (10:32 +0100)]
abc.rst: Fix typos discovered by codespell
https://pypi.org/project/codespell/
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.
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.
Daniele Varrazzo [Fri, 14 Jan 2022 01:31:07 +0000 (02:31 +0100)]
Drop dataclasses package from constraints file
It is part of the stdlib in all supported Python versions, so it is no
more an external dependency.
Daniele Varrazzo [Fri, 14 Jan 2022 01:01:48 +0000 (02:01 +0100)]
Add compatibility macro for PQsetTraceFlags
Avoid a warning of implicit declaration compiling with libpq < 14.
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.
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.
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
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.
Daniele Varrazzo [Thu, 13 Jan 2022 21:56:44 +0000 (22:56 +0100)]
Retry automatically flakey tests in tox runs
Daniele Varrazzo [Thu, 13 Jan 2022 19:00:14 +0000 (20:00 +0100)]
Bump min version required for pytest-asyncio to 0.17.0
Older versions fail for the presence of asyncio_mode in pytest config,
which is required from 0.17 on instead.
Daniele Varrazzo [Thu, 13 Jan 2022 16:17:37 +0000 (17:17 +0100)]
Configure the async loop at test session start
Doing it in a fixture is too late: event_loop might have already been
called if the first test running is async, and it would fail on Windows.
This started to be needed after pytest-asyncio 0.17.0 was released.
See <https://github.com/pytest-dev/pytest-asyncio/issues/256>.
Daniele Varrazzo [Thu, 13 Jan 2022 15:17:41 +0000 (16:17 +0100)]
Set asyncio mode in pytest configuration
Remove the warning raised in pytest-async >= 0.17.0 if the setting is
missing.
Daniele Varrazzo [Thu, 13 Jan 2022 14:07:52 +0000 (15:07 +0100)]
Merge branch 'null-pool'
Daniele Varrazzo [Sat, 8 Jan 2022 18:37:14 +0000 (19:37 +0100)]
More robust null pool tests
Fix race conditions of tasks completing before a concurrent client is
queued.
Fix test relying on fixed broken behaviour of copy().
Use connection.info rather than connection.pgconn to obtain higher level
results (e.g. Enum instead of int).
Daniele Varrazzo [Sat, 8 Jan 2022 17:35:41 +0000 (18:35 +0100)]
Refactor pools to reduce code duplication
Use common getconn/putconn implementations and implement only the
different behaviours in subclasses.
Daniele Varrazzo [Thu, 6 Jan 2022 02:39:42 +0000 (03:39 +0100)]
Add null-pools documentation
Daniele Varrazzo [Mon, 3 Jan 2022 19:20:29 +0000 (20:20 +0100)]
Add NullPool and AsyncNullPool
Close #148
Daniele Varrazzo [Sun, 9 Jan 2022 17:46:58 +0000 (18:46 +0100)]
Minor changes to pool docs
Daniele Varrazzo [Sun, 9 Jan 2022 14:04:55 +0000 (15:04 +0100)]
Improve pool docs, especially pools and connections life cycle
Daniele Varrazzo [Sun, 9 Jan 2022 13:14:14 +0000 (14:14 +0100)]
Add wait parameter to pool.open()
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.
Daniele Varrazzo [Sat, 8 Jan 2022 20:57:14 +0000 (21:57 +0100)]
Drop support for Python 3.6
Daniele Varrazzo [Sat, 8 Jan 2022 18:57:04 +0000 (19:57 +0100)]
Bump version numbers for release
Daniele Varrazzo [Sat, 8 Jan 2022 01:16:57 +0000 (02:16 +0100)]
Leave start year only in docs footer
Daniele Varrazzo [Sat, 8 Jan 2022 01:09:05 +0000 (02:09 +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..//'
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.
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.
Daniele Varrazzo [Fri, 7 Jan 2022 01:07:02 +0000 (02:07 +0100)]
Add prepare_threshold connection parameter
This can help configuring connections to use PgBouncer. It is possible
to use the attribute in the pool kwargs, for instance, instead of using
the more complex configure callback.
Close #200.
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.
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.
Daniele Varrazzo [Fri, 7 Jan 2022 01:54:25 +0000 (02:54 +0100)]
Add example about DDL statement with quoted parameter
See #199.
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.
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...
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.
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.
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).
Daniele Varrazzo [Wed, 5 Jan 2022 22:13:52 +0000 (23:13 +0100)]
Merge branch 'pool-checks'
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.
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.
Daniele Varrazzo [Mon, 3 Jan 2022 18:40:11 +0000 (19:40 +0100)]
Move some common checks to the pool base class
Daniele Varrazzo [Wed, 5 Jan 2022 19:23:25 +0000 (20:23 +0100)]
Use caplog.set_level instead of manual filtering in tests
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
Daniele Varrazzo [Wed, 5 Jan 2022 00:53:07 +0000 (01:53 +0100)]
Add deaf_port fixture and base timeout tests on it
Daniele Varrazzo [Mon, 3 Jan 2022 18:47:38 +0000 (19:47 +0100)]
Merge branch 'pool-open'
Daniele Varrazzo [Mon, 3 Jan 2022 15:59:29 +0000 (16:59 +0100)]
Use the present tense in PoolClosed error messages
Thank you John Aldis! https://twitter.com/johnaldis/status/
1478016200634425348
Daniele Varrazzo [Mon, 3 Jan 2022 14:37:54 +0000 (15:37 +0100)]
Report if the pool was closed, or never opened, in getconn() error message
Daniele Varrazzo [Mon, 3 Jan 2022 14:10:54 +0000 (15:10 +0100)]
Add API docs for pool open method/param.
Daniele Varrazzo [Mon, 3 Jan 2022 15:03:48 +0000 (16:03 +0100)]
AsyncConnectionPool.open() made async.
This makes it symmetrical with close(). However it doesn't really do any
async work as it's awkward to call it from init. Something we might do,
if that will be needed, could be to start the scheduler only and use it
to schedule immediately a call to an async _open().
In the future, an anyio-based pool might instead disallow open=True on
init.
See https://github.com/psycopg/psycopg/pull/151 for some discussion
about the topic.
Daniele Varrazzo [Mon, 3 Jan 2022 12:09:38 +0000 (13:09 +0100)]
Add open param to pool init
Denis Laxalde [Tue, 16 Nov 2021 09:55:26 +0000 (10:55 +0100)]
Disallow pool re-opening
There seems to be no use case for re-opening a closed pool, so disable
this now (until we find a real use-case).
Denis Laxalde [Mon, 15 Nov 2021 08:43:04 +0000 (09:43 +0100)]
Factor out a _stop_workers() method on connection pool classes
The method is symmetrical with open().
In particular, we take advantage of this method in
ConnectionPool.__del__() to remove some duplication.