]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
14 months agodocs(pool): mention running an empty query on check in news file 791/head
Daniele Varrazzo [Wed, 8 May 2024 16:49:41 +0000 (18:49 +0200)] 
docs(pool): mention running an empty query on check in news file

14 months agorefactor(pool): replace --ping with empty string
Eyal Halpern Shalev [Sat, 4 May 2024 12:57:56 +0000 (15:57 +0300)] 
refactor(pool): replace --ping with empty string

14 months agoperf(pool): replace SELECT 1 with an empty query
Eyal Halpern Shalev [Mon, 15 Apr 2024 23:09:45 +0000 (02:09 +0300)] 
perf(pool): replace SELECT 1 with an empty query

14 months agoMerge pull request #746 from ankane/copy-performance
Daniele Varrazzo [Wed, 8 May 2024 16:35:58 +0000 (18:35 +0200)] 
Merge pull request #746 from ankane/copy-performance

Improve performance of copy

14 months agoperf(copy): only flush at every row on copy on macOS 746/head
Daniele Varrazzo [Mon, 6 May 2024 16:43:10 +0000 (18:43 +0200)] 
perf(copy): only flush at every row on copy on macOS

With some benchmark, it seems that on Linux and Windows performances are worse.
See #746 for details.

14 months agotest(copy): add minimal copy benchmark framework
Daniele Varrazzo [Fri, 3 May 2024 11:08:11 +0000 (13:08 +0200)] 
test(copy): add minimal copy benchmark framework

14 months agoImprove performance of copy
Andrew Kane [Mon, 4 Mar 2024 22:34:56 +0000 (14:34 -0800)] 
Improve performance of copy

14 months agofix(pool): avoid possible deadlock (until timeout) on pool closing
Daniele Varrazzo [Mon, 6 May 2024 09:21:33 +0000 (11:21 +0200)] 
fix(pool): avoid possible deadlock (until timeout) on pool closing

With the previous change to avoid finding open connections in the pool
(#784), stopping the worker was moved into the critical section. This
can create a deadlock in case a worker is in the process of obtaining a
new connection, because putting it to the pool requires the lock. The
deadlock only last for the default 5s timeout passed to _stop_workers().

Solve the problem by guarding _add_to_pool() to avoid it to try to add
the connection if the pool is closed.

However, refactor the pool closing sequence too and close the workers
and other resources that now out of the state outside the critical
section to keep the operation running under lock to a minimum.

14 months agotest: fix running pool tests using Psycopg 3.1
Daniele Varrazzo [Sat, 20 Apr 2024 22:03:56 +0000 (00:03 +0200)] 
test: fix running pool tests using Psycopg 3.1

Avoid using Capabilities at import time in the test suite.

14 months agoMerge branch 'fix-734'
Daniele Varrazzo [Sat, 20 Apr 2024 21:46:46 +0000 (23:46 +0200)] 
Merge branch 'fix-734'

14 months agofix(c): solve undefined behaviour caused by unaligned access 735/head
Daniele Varrazzo [Sun, 11 Feb 2024 01:34:20 +0000 (02:34 +0100)] 
fix(c): solve undefined behaviour caused by unaligned access

Close #734

14 months agoci: add test to check for misaligned memory access
Daniele Varrazzo [Wed, 10 Apr 2024 23:24:02 +0000 (01:24 +0200)] 
ci: add test to check for misaligned memory access

14 months agofix: fix handling of floating point values for connect_timeout 796/head
Daniele Varrazzo [Thu, 18 Apr 2024 01:38:17 +0000 (03:38 +0200)] 
fix: fix handling of floating point values for connect_timeout

14 months agoMerge pull request #780 from dlax/cancel-safe-timeout
Daniele Varrazzo [Wed, 17 Apr 2024 21:52:02 +0000 (23:52 +0200)] 
Merge pull request #780 from dlax/cancel-safe-timeout

feat: add a timeout parameter to Connection.cancel_safe()

14 months agorefactor: set the meaningful timeout for _try_cancel() as a default 780/head
Denis Laxalde [Tue, 16 Apr 2024 07:11:30 +0000 (09:11 +0200)] 
refactor: set the meaningful timeout for _try_cancel() as a default

14 months agofix: avoid to swallow exceptions in public cancel methods
Daniele Varrazzo [Sat, 13 Apr 2024 10:23:38 +0000 (12:23 +0200)] 
fix: avoid to swallow exceptions in public cancel methods

Only ignore errors in every internal usage, in order to cancel as a best
effort and don't clobber a likely more meaningful exception.

14 months agodocs: adjust cancel_safe() docstring
Daniele Varrazzo [Sat, 13 Apr 2024 10:23:38 +0000 (12:23 +0200)] 
docs: adjust cancel_safe() docstring

14 months agodocs: reword notes on cancellation
Daniele Varrazzo [Sat, 13 Apr 2024 10:23:38 +0000 (12:23 +0200)] 
docs: reword notes on cancellation

14 months agotest: more uniform treatment of timeout approx check
Daniele Varrazzo [Fri, 12 Apr 2024 22:51:22 +0000 (00:51 +0200)] 
test: more uniform treatment of timeout approx check

14 months agorefactor: check if cancel safe is implemented via capabilities
Daniele Varrazzo [Fri, 12 Apr 2024 22:36:36 +0000 (00:36 +0200)] 
refactor: check if cancel safe is implemented via capabilities

14 months agotest(proxy): use 127.0.0.1 rather than localhost
Daniele Varrazzo [Fri, 12 Apr 2024 12:46:49 +0000 (14:46 +0200)] 
test(proxy): use 127.0.0.1 rather than localhost

Try to fix the flakiness shown by deaf_listen() in CI. Maybe there is a
race condition in listen()/connect() but I have also seen problems
related with localhost in the /etc/hosts file and ipv6, so let's first
try this.

14 months agofeat: add a timeout parameter to Connection.cancel_safe()
Denis Laxalde [Mon, 8 Apr 2024 13:00:17 +0000 (15:00 +0200)] 
feat: add a timeout parameter to Connection.cancel_safe()

This will only work for PGcancelConn, i.e. libpq >= 17, or thanks to
added waiting logic in AsyncConnection's implementation; so we add a
note about the limitation in Connection's documentation.

14 months agofeat: add libpq interface for retrieving results in chunks 793/head
Denis Laxalde [Wed, 17 Apr 2024 08:35:45 +0000 (10:35 +0200)] 
feat: add libpq interface for retrieving results in chunks

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=4643a2b265e967cc5f13ffa0c7c6912dbb3466d0

14 months agofix(c): fix the goto label in the HAVE_POLL branch of wait_c_impl()
Denis Laxalde [Tue, 16 Apr 2024 14:21:16 +0000 (16:21 +0200)] 
fix(c): fix the goto label in the HAVE_POLL branch of wait_c_impl()

This resolves the following warning when building the extension module:

    $ python psycopg_c/setup.py build_ext -i
    [...]
    building 'psycopg_c._psycopg' extension
    x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/denis/.local/pgsql/include -I/home/denis/src/psycopg3/.venv/include -I/usr/include/python3.11 -c psycopg_c/_psycopg.c -o build/temp.linux-x86_64-cpython-311/psycopg_c/_psycopg.o
    psycopg_c/_psycopg.c: In function ‘wait_c_impl’:
    psycopg_c/_psycopg.c:1649:1: warning: label ‘error’ defined but not used [-Wunused-label]
     1649 |
          | ^

15 months agoMerge branch 'cancel-exceptions-swallow'
Daniele Varrazzo [Fri, 12 Apr 2024 22:11:15 +0000 (00:11 +0200)] 
Merge branch 'cancel-exceptions-swallow'

15 months agofix: avoid explicit str() call when logging exception 785/head
Daniele Varrazzo [Fri, 12 Apr 2024 12:11:22 +0000 (14:11 +0200)] 
fix: avoid explicit str() call when logging exception

This was done as paranoia check for Sentry which might uses the repr of
the exception even if we asked for `%s` and therefore might leak
secrets, but frankly it's not our responsibility.

https://github.com/getsentry/sentry-python/issues/2417

15 months agorefactor: clearer cancel_safe implementation
Daniele Varrazzo [Wed, 10 Apr 2024 20:37:24 +0000 (22:37 +0200)] 
refactor: clearer cancel_safe implementation

Avoid catching NotSupported, just check for the libpq version.

Also avoid the half exception handler in `_cancel_gen()`: as in the
legacy branch, warn and ignore any error happening in the outermost
method, without adding an ignore exception policy in an implementation
method.

Close #778.

15 months agorefactor: drop _try_cancel internal method.
Daniele Varrazzo [Wed, 10 Apr 2024 20:16:47 +0000 (22:16 +0200)] 
refactor: drop _try_cancel internal method.

This method was useful before introducing cancel_safe, which is now the
function of choice for internal cancelling.

Also refactor the exception handling to account for possible errors in
`PGcancel.cancel()`, not only in `PGconn.get_cancel()`, to make sure to
not clobber an exception bubbling up with ours, whatever happens to the
underlying connection.

15 months agoMerge branch 'capabilities'
Daniele Varrazzo [Fri, 12 Apr 2024 22:09:23 +0000 (00:09 +0200)] 
Merge branch 'capabilities'

15 months agorefactor(capabilities): add caching to capabilities check 782/head
Daniele Varrazzo [Fri, 12 Apr 2024 12:04:57 +0000 (14:04 +0200)] 
refactor(capabilities): add caching to capabilities check

15 months agorefactor(pipeline): use Capabilities to implement is_supported
Daniele Varrazzo [Tue, 9 Apr 2024 22:13:18 +0000 (00:13 +0200)] 
refactor(pipeline): use Capabilities to implement is_supported

15 months agodocs: add capabilities documentation
Daniele Varrazzo [Tue, 9 Apr 2024 21:41:28 +0000 (23:41 +0200)] 
docs: add capabilities documentation

15 months agofeat: add psycopg.capability
Daniele Varrazzo [Tue, 9 Apr 2024 20:30:43 +0000 (22:30 +0200)] 
feat: add psycopg.capability

Close #772

15 months agorefactor: use consistently the version_pretty() function
Daniele Varrazzo [Tue, 9 Apr 2024 20:15:39 +0000 (22:15 +0200)] 
refactor: use consistently the version_pretty() function

15 months agofeat: add pq.version_pretty() function
Daniele Varrazzo [Tue, 9 Apr 2024 13:54:55 +0000 (15:54 +0200)] 
feat: add pq.version_pretty() function

15 months agoMerge branch 'async-to-sync-refactor'
Daniele Varrazzo [Fri, 12 Apr 2024 22:07:29 +0000 (00:07 +0200)] 
Merge branch 'async-to-sync-refactor'

15 months agorefactor(async-to-sync): rename --convert-all option to --all 787/head
Daniele Varrazzo [Fri, 12 Apr 2024 22:05:00 +0000 (00:05 +0200)] 
refactor(async-to-sync): rename --convert-all option to --all

15 months agochore(async-to-sync): drop --all argument
Daniele Varrazzo [Fri, 12 Apr 2024 17:37:25 +0000 (19:37 +0200)] 
chore(async-to-sync): drop --all argument

Working on all inputs is a meaningful default.

15 months agorefactor(async-to-sync): use pattern matching for more compact tests
Daniele Varrazzo [Fri, 12 Apr 2024 00:47:05 +0000 (02:47 +0200)] 
refactor(async-to-sync): use pattern matching for more compact tests

15 months agorefactor(async-to-sync): simpler pattern to convert string literals
Daniele Varrazzo [Thu, 11 Apr 2024 23:32:18 +0000 (01:32 +0200)] 
refactor(async-to-sync): simpler pattern to convert string literals

15 months agofix(pool): make sure there are no connection in the pool after close()
Daniele Varrazzo [Wed, 10 Apr 2024 21:58:24 +0000 (23:58 +0200)] 
fix(pool): make sure there are no connection in the pool after close()

The case has been reported in #784. While not easy to reproduce, it
seems that it might be caused by the pool being closed while a worker is
still trying to create a connection, which will be put in the _pool
state after supposedly no other operation should have been performed.

Stop the workers and then empty the pool only after they have stopped to
run.

Also refactor the cleanup of the pool and waiting queue, moving them
to close(). There is no reason why a method called "stop workers" should
empty them, and there is no other code path that use such feature.

Close #784.

15 months agotest: replace deaf_port fixture with deaf_listen method on proxy 783/head
Daniele Varrazzo [Wed, 10 Apr 2024 19:40:00 +0000 (21:40 +0200)] 
test: replace deaf_port fixture with deaf_listen method on proxy

This allows to replace the listening proxy port with a port that blocks
connection and to write more easily cancel timeout tests (as in #780).

15 months agotests: fix allow to skip running the pool tests again
Daniele Varrazzo [Thu, 11 Apr 2024 23:15:34 +0000 (01:15 +0200)] 
tests: fix allow to skip running the pool tests again

`pytest -m not pool` should allow to skip the pool test. However,
because of the attribute access at import time to define the test
marker, import failed as well.

Convert the marker to strings which will be used in a getattr by the
fixture. Extend async-to-sync to convert the pool classes names from the
string too.

15 months agotest: add missing prepared async tests
Daniele Varrazzo [Thu, 11 Apr 2024 22:44:42 +0000 (00:44 +0200)] 
test: add missing prepared async tests

Sync and async sides diverged because the async-to-sync check in CI was
pretty much disabled by the lack of the -B.

15 months agoci: restore async-to-sync check to check all the files
Daniele Varrazzo [Thu, 11 Apr 2024 22:34:21 +0000 (00:34 +0200)] 
ci: restore async-to-sync check to check all the files

15 months agotest(pool): more lenient timeout in reconnect test timings
Daniele Varrazzo [Wed, 10 Apr 2024 22:03:33 +0000 (00:03 +0200)] 
test(pool): more lenient timeout in reconnect test timings

15 months agochore: ignore spelling in html files
Daniele Varrazzo [Tue, 9 Apr 2024 22:33:27 +0000 (00:33 +0200)] 
chore: ignore spelling in html files

These files are generated by cython to display the C code generated...
and are a mess.

15 months agoMerge pull request #763 from dlax/pg17/non-blocking-pqcancel
Daniele Varrazzo [Tue, 9 Apr 2024 10:49:33 +0000 (11:49 +0100)] 
Merge pull request #763 from dlax/pg17/non-blocking-pqcancel

Add encrypted and non-blocking cancellation

15 months agofix: fix type signature of to_thread() compat 763/head
Denis Laxalde [Tue, 9 Apr 2024 07:19:27 +0000 (09:19 +0200)] 
fix: fix type signature of to_thread() compat

15 months agodocs: shorten news entry about Connection.cancel_safe()
Denis Laxalde [Tue, 9 Apr 2024 07:18:07 +0000 (09:18 +0200)] 
docs: shorten news entry about Connection.cancel_safe()

15 months agodocs: improve cancel_safe documentation
Daniele Varrazzo [Mon, 8 Apr 2024 22:57:53 +0000 (00:57 +0200)] 
docs: improve cancel_safe documentation

15 months agofeat: use non-blocking cancellation upon Copy termination
Denis Laxalde [Fri, 24 Mar 2023 13:55:18 +0000 (14:55 +0100)] 
feat: use non-blocking cancellation upon Copy termination

The logic of Copy termination, in finish(), is reworked so that
connection cancellation is invoked from there directly instead of from
_end_copy_out_gen() as we cannot call async code from the generator.

15 months agofeat: fall back to cancel() in cancel_safe() for libpq < 17
Denis Laxalde [Mon, 8 Apr 2024 08:00:04 +0000 (10:00 +0200)] 
feat: fall back to cancel() in cancel_safe() for libpq < 17

We run this in a thread executor in the AsyncConnection.
As asyncio's to_thread() is not available in Python 3.8, so we add a
compat layer.

15 months agofeat: add encrypted and non-blocking cancellation
Denis Laxalde [Fri, 24 Mar 2023 13:55:18 +0000 (14:55 +0100)] 
feat: add encrypted and non-blocking cancellation

We introduce Connection.cancel_safe() which uses the encrypted and
non-blocking libpq cancellation API available with PostgreSQL 17. As a
non-blocking entry point, cancel_safe() delegates to a generator function,
namely _cancel_gen(). If the libpq version is too old, the method raises
a NotSupportedError.

CTRL+C handling (in Connection.wait() or Cursor.stream()) also uses the
non-blocking cancellation but falls back to old method if the former is
not supported.

The behavior of cancel() method (either on Connection or
AsyncConnection) is kept unchanged to use the old cancellation API.

15 months agofeat: add generators.cancel()
Denis Laxalde [Fri, 24 Mar 2023 13:08:20 +0000 (14:08 +0100)] 
feat: add generators.cancel()

This is a PQGenConn generator as the socket for the PGcancelConn needs
to be retrieved after (at least) the first poll() call.

15 months agoMerge pull request #773 from psycopg/pgbouncer-prepare
Daniele Varrazzo [Tue, 9 Apr 2024 09:34:38 +0000 (10:34 +0100)] 
Merge pull request #773 from psycopg/pgbouncer-prepare

Make prepared statements compatible with PgBouncer

15 months agofeat(prepare): allow setting connection.prepare_max to None 773/head
Daniele Varrazzo [Mon, 8 Apr 2024 20:22:02 +0000 (20:22 +0000)] 
feat(prepare): allow setting connection.prepare_max to None

15 months agodocs(prepare): add note about PgBouncer max prepared statements setting
Daniele Varrazzo [Mon, 8 Apr 2024 20:13:37 +0000 (22:13 +0200)] 
docs(prepare): add note about PgBouncer max prepared statements setting

15 months agodocs(prepare): add notes about the PgBouncer and prepared statements
Daniele Varrazzo [Sat, 6 Apr 2024 20:54:21 +0000 (20:54 +0000)] 
docs(prepare): add notes about the PgBouncer and prepared statements

15 months agofeat(prepare): send Close messages to deallocate when possible
Daniele Varrazzo [Sat, 6 Apr 2024 19:26:18 +0000 (19:26 +0000)] 
feat(prepare): send Close messages to deallocate when possible

This allows for compatibility with PgBouncer, but requires libpq v17 at
least.

15 months agorefactor(prepare): queue statement names, not SQL commands
Daniele Varrazzo [Sat, 6 Apr 2024 17:36:54 +0000 (17:36 +0000)] 
refactor(prepare): queue statement names, not SQL commands

15 months agorefactor(prepare): make maintenance operation a PQGen generator
Daniele Varrazzo [Sat, 6 Apr 2024 16:36:16 +0000 (16:36 +0000)] 
refactor(prepare): make maintenance operation a PQGen generator

This will allow us to replace the SQL commands with protocol messages.

15 months agodocs(readme): fix hyperlink in bullet list
Daniele Varrazzo [Mon, 8 Apr 2024 19:21:42 +0000 (19:21 +0000)] 
docs(readme): fix hyperlink in bullet list

The problem was reported in #775, but the file is not wrong, and
rst2html renders correctly without warnings.

The problem is that the Github reST implementation doesn't get the
hyperlinks indented at bullet list level right.

My preference is to move the links out of the list rather than inserting
the URLs in the flow of the text and get awkward newlines or long lines.

15 months agodocs: drop spurious word in readme
Daniele Varrazzo [Mon, 8 Apr 2024 19:14:25 +0000 (19:14 +0000)] 
docs: drop spurious word in readme

Close #775

15 months agotest: fix test suite import on master with Python 3.1
Daniele Varrazzo [Sun, 7 Apr 2024 12:25:52 +0000 (12:25 +0000)] 
test: fix test suite import on master with Python 3.1

15 months agotest: fix cancel connection status test on Unix socket connection
Daniele Varrazzo [Sat, 6 Apr 2024 19:29:37 +0000 (19:29 +0000)] 
test: fix cancel connection status test on Unix socket connection

15 months agoMerge branch 'libpq-cancel-nonblocking'
Daniele Varrazzo [Fri, 5 Apr 2024 19:49:09 +0000 (19:49 +0000)] 
Merge branch 'libpq-cancel-nonblocking'

15 months agodocs: document the ALLOCATED ConnStatus value 754/head
Denis Laxalde [Fri, 5 Apr 2024 10:42:01 +0000 (12:42 +0200)] 
docs: document the ALLOCATED ConnStatus value

15 months agofix: prevent usage of finished PGcancelConn
Denis Laxalde [Fri, 5 Apr 2024 08:47:47 +0000 (10:47 +0200)] 
fix: prevent usage of finished PGcancelConn

Similarly to PGconn, PGcancelConn must not be used after .finish(); we
raise an OperationalError to prevent segfault when the connection
pointer is NULL.

15 months agotests: simplify PGcancelConn tests
Denis Laxalde [Fri, 5 Apr 2024 08:18:41 +0000 (10:18 +0200)] 
tests: simplify PGcancelConn tests

We split the previous (misnamed) test_cancel_nonblocking() into
test_cancel_conn_blocking() and test_cancel_conn_nonblocking()
respectively checking PQcancelBlocking() and
PQcancelStart()/PQcancelPoll().

The cancellable_query() is now responsible for creating the monitor_conn
and uses a PGconn value, coming from the pgconn fixture in tests.

15 months agofeat: add libpq interface for encrypted and non-blocking cancellation
Denis Laxalde [Thu, 23 Mar 2023 12:51:16 +0000 (13:51 +0100)] 
feat: add libpq interface for encrypted and non-blocking cancellation

Encrypted and non-blocking cancellation should be part PostgreSQL 17:
- https://commitfest.postgresql.org/37/3511/
- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=61461a300c1cb5d53955ecd792ad0ce75a104736

We here add the interface for libpq functions for this feature.

An extra test is introduced, it closely reproduces
src/test/modules/libpq_pipeline/libpq_pipeline::test_cancel() in
PostgreSQL test suite.

The error_message property of PGcancelConn is directly an str and
PGcancelConn has no encoding specified and all messages come from the
client (libpq).

15 months agotests: introduce a wait() helper function pq.PGconn tests
Denis Laxalde [Fri, 5 Apr 2024 10:25:10 +0000 (12:25 +0200)] 
tests: introduce a wait() helper function pq.PGconn tests

15 months agoMerge branch 'conn-generator-refactoring'
Daniele Varrazzo [Fri, 5 Apr 2024 15:22:01 +0000 (15:22 +0000)] 
Merge branch 'conn-generator-refactoring'

15 months agorefactor: rename wait functions 'timeout' parameter to 'interval' 766/head
Daniele Varrazzo [Fri, 26 Jan 2024 11:49:23 +0000 (11:49 +0000)] 
refactor: rename wait functions 'timeout' parameter to 'interval'

15 months agorefactor: handle timeout in the connection generator, not the waiting function
Daniele Varrazzo [Fri, 26 Jan 2024 09:47:31 +0000 (09:47 +0000)] 
refactor: handle timeout in the connection generator, not the waiting function

The waiting function is supposed to be generic, the timeout is a policy
decision of the generator.

This change aligns the semantics of the `timeout` parameter of `wait_conn()`
to the one of the other wait functions: the timeout is actually an
interval. It will be renamed to clarify that in a followup commit.

15 months agostyle: use literals instead of the concatenation operator for long strings
Daniele Varrazzo [Thu, 4 Apr 2024 21:37:57 +0000 (21:37 +0000)] 
style: use literals instead of the concatenation operator for long strings

The reason we were using operators was to stop async_to_sync to generate
a line too long and incur in the flake8 ires.

MR #764 suggests to disable line length check altogether, but we can use
per-file ignore, as there will not be many cases to manage.

15 months agodocs: add a note to remember why flake8 configuration is repeated
Daniele Varrazzo [Thu, 4 Apr 2024 21:37:10 +0000 (21:37 +0000)] 
docs: add a note to remember why flake8 configuration is repeated

15 months agochore: regenerate _pq_ctypes.pyi
Denis Laxalde [Fri, 5 Apr 2024 10:35:53 +0000 (12:35 +0200)] 
chore: regenerate _pq_ctypes.pyi

Following commit a7f280227923ccb5de8928f7335e092531eedea1.

15 months agoMerge branch 'mypy-love'
Daniele Varrazzo [Fri, 5 Apr 2024 09:20:24 +0000 (09:20 +0000)] 
Merge branch 'mypy-love'

15 months agorefactor(c): mor compact guard for unsupported libpq versions 768/head
Daniele Varrazzo [Thu, 4 Apr 2024 23:20:12 +0000 (23:20 +0000)] 
refactor(c): mor compact guard for unsupported libpq versions

15 months agorefactor: less verbose pattern to manage optional libpq functions
Daniele Varrazzo [Thu, 4 Apr 2024 23:03:11 +0000 (23:03 +0000)] 
refactor: less verbose pattern to manage optional libpq functions

15 months agolint: avoid mypy warning in _pq_ctypes.py
Daniele Varrazzo [Thu, 4 Apr 2024 22:23:23 +0000 (22:23 +0000)] 
lint: avoid mypy warning in _pq_ctypes.py

I can't find how my editor is set up, but it doesn't complain on this
file, and yet calling mypy on this file only will find several error.

Having seen @dlax adding `type: ignore[no-any-return]` comments makes me
want to fix this.

15 months agodocs: let the 'pq' role possibly link to "devel" PostgreSQL docs
Denis Laxalde [Tue, 2 Apr 2024 09:35:23 +0000 (11:35 +0200)] 
docs: let the 'pq' role possibly link to "devel" PostgreSQL docs

If we now set libpq_docs_version to 'devel', the pq Sphinx role will use
the master branch when looking libpq.sgml and the 'devel' URL component
when linking to libpq online documentation.

15 months agofix: more careful stripping of error prefixes
Daniele Varrazzo [Sun, 31 Mar 2024 20:57:42 +0000 (20:57 +0000)] 
fix: more careful stripping of error prefixes

Only strip the known prefixes, both in English and in the currently
known localizations.

Added script to generate regexp to match every backend localization. The
script was executed on PostgreSQL commit f4ad0021af (on master branch,
before v17).

Close #752.

15 months agoMerge pull request #744 from dlax/async-to-sync-jobs
Daniele Varrazzo [Mon, 1 Apr 2024 23:03:10 +0000 (00:03 +0100)] 
Merge pull request #744 from dlax/async-to-sync-jobs

feat(tools): possibly run async_to_sync.py concurrently

15 months agofeat(tools): check last modification times in async_to_sync.py 744/head
Denis Laxalde [Mon, 4 Mar 2024 07:37:58 +0000 (08:37 +0100)] 
feat(tools): check last modification times in async_to_sync.py

We now only process _async.py files with a modification time higher than
their sync counterpart. A -B,--convert-all option is added to force
conversion of all (specified) input files and skip last-modification
time check.

15 months agofeat(tools): add a -L,--log-level option to async_to_sync.py
Denis Laxalde [Mon, 4 Mar 2024 07:27:14 +0000 (08:27 +0100)] 
feat(tools): add a -L,--log-level option to async_to_sync.py

We'll use DEBUG messages in the next commit.

15 months agofeat(tools): run async_to_sync.py concurrently
Denis Laxalde [Fri, 1 Mar 2024 13:21:35 +0000 (14:21 +0100)] 
feat(tools): run async_to_sync.py concurrently

Multi-processing is used by default (using all available processors),
but can be disabled or limited with the -j/--jobs option.

15 months agotest: add pool package to django tests
Daniele Varrazzo [Sun, 31 Mar 2024 22:22:07 +0000 (22:22 +0000)] 
test: add pool package to django tests

It seems needed in the current main branch.

15 months agodocs: fix a typo in FinishedPGconn docstring
Denis Laxalde [Fri, 8 Mar 2024 10:00:34 +0000 (11:00 +0100)] 
docs: fix a typo in FinishedPGconn docstring

16 months agodocs: fix missing `async` in example
Daniele Varrazzo [Mon, 26 Feb 2024 10:52:21 +0000 (11:52 +0100)] 
docs: fix missing `async` in example

Close #740.

16 months agodocs(pool): reorder sections in a way that makes more sense 738/head
Daniele Varrazzo [Sun, 18 Feb 2024 00:04:34 +0000 (01:04 +0100)] 
docs(pool): reorder sections in a way that makes more sense

16 months agodocs(pool): add box warning against opening async pools on init
Daniele Varrazzo [Sun, 18 Feb 2024 00:03:20 +0000 (01:03 +0100)] 
docs(pool): add box warning against opening async pools on init

16 months agofix(pool): make opening an async connection pool in the constructor a runtime warning
Daniele Varrazzo [Fri, 16 Feb 2024 13:02:17 +0000 (14:02 +0100)] 
fix(pool): make opening an async connection pool in the constructor a runtime warning

Deprecation warnings are ignored by default and easy to miss.

Close #737.

16 months agoci: skip refcount tests on scheduled jobs
Daniele Varrazzo [Tue, 13 Feb 2024 10:45:27 +0000 (11:45 +0100)] 
ci: skip refcount tests on scheduled jobs

17 months agofix: avoid to create reference loops in datetime adapters
Daniele Varrazzo [Wed, 7 Feb 2024 01:16:06 +0000 (01:16 +0000)] 
fix: avoid to create reference loops in datetime adapters

Setting the reference to a bound method in the state creates a reference
loop.

The issue is minimal because the gc will be able to break these loops
anyway and because it mostly happens with exotic or unsupported
date/interval styles.

17 months agodocs: fix typo in release notes
Daniele Varrazzo [Mon, 5 Feb 2024 16:34:36 +0000 (16:34 +0000)] 
docs: fix typo in release notes

17 months agochore: bump psycopg package version to 3.1.18
Daniele Varrazzo [Sun, 4 Feb 2024 17:42:54 +0000 (17:42 +0000)] 
chore: bump psycopg package version to 3.1.18

17 months agofix(c): drop spurious loop break in pipeline_communicate
Daniele Varrazzo [Fri, 4 Nov 2022 22:17:13 +0000 (23:17 +0100)] 
fix(c): drop spurious loop break in pipeline_communicate

This makes the Python and the C implementation more similar. The
difference was unexpected but apparently harmless. See #431

17 months agotests: don't depend on ConnDict
Daniele Varrazzo [Sun, 4 Feb 2024 12:07:24 +0000 (12:07 +0000)] 
tests: don't depend on ConnDict

Added in 3.2, so can't run the pool tests using Psycopg 3.1