]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
2 years agoci: merge all produced artifacts into a single artifact for ease of downloading 824/head
Trenton Holmes [Sat, 18 May 2024 20:21:04 +0000 (13:21 -0700)] 
ci: merge all produced artifacts into a single artifact for ease of downloading

2 years agoci: updates action versions and add dependabot to check monthly for updates
Trenton Holmes [Sat, 18 May 2024 01:41:51 +0000 (18:41 -0700)] 
ci: updates action versions and add dependabot to check monthly for updates

2 years agochore: fix typo in comment
Daniele Varrazzo [Mon, 27 May 2024 14:20:38 +0000 (16:20 +0200)] 
chore: fix typo in comment

2 years agodocs: improve docs about query protocols and PgBouncer
Daniele Varrazzo [Fri, 17 May 2024 00:42:32 +0000 (02:42 +0200)] 
docs: improve docs about query protocols and PgBouncer

2 years agofix: use the simple query protocol to execute BEGIN/COMMIT out of pipeline
Daniele Varrazzo [Tue, 14 May 2024 11:18:40 +0000 (13:18 +0200)] 
fix: use the simple query protocol to execute BEGIN/COMMIT out of pipeline

We started using the extended protocol in e5079184 to fix #350, but,
probably to keep symmetry, we also changed the behaviour out of the
pipeline.

This turns out to be a problem for people connecting to the PgBouncer
admin console. They can use the `ClientCursor`, which tries to use the
simple protocol as much as it can, but they currently have to use
autocommit. With this changeset autocommit shouldn't be needed anymore.
See #808.

2 years agoMerge pull request #811 from psycopg/refactor-typeinfo
Daniele Varrazzo [Wed, 15 May 2024 16:29:30 +0000 (18:29 +0200)] 
Merge pull request #811 from psycopg/refactor-typeinfo

Remove type modifier decoding from Column object

2 years agotest: adapt type representation tests to crdb and postgres < 15 811/head
Daniele Varrazzo [Thu, 9 May 2024 01:49:24 +0000 (03:49 +0200)] 
test: adapt type representation tests to crdb and postgres < 15

2 years agofeat: add Column.type_display
Daniele Varrazzo [Thu, 9 May 2024 01:27:29 +0000 (03:27 +0200)] 
feat: add Column.type_display

2 years agofix: fix representation of bit/varbit columns
Daniele Varrazzo [Thu, 9 May 2024 00:02:08 +0000 (02:02 +0200)] 
fix: fix representation of bit/varbit columns

2 years agofix: improve column type display
Daniele Varrazzo [Wed, 8 May 2024 23:39:30 +0000 (01:39 +0200)] 
fix: improve column type display

Make sure that what displayed is the same displayed by postgres for all
supported types.

2 years agorefactor(column): remove ColumnData internal object
Daniele Varrazzo [Wed, 8 May 2024 21:57:11 +0000 (23:57 +0200)] 
refactor(column): remove ColumnData internal object

2 years agorefactor: dispatch type modifier parsing to type-specific objects
Daniele Varrazzo [Wed, 8 May 2024 21:49:19 +0000 (23:49 +0200)] 
refactor: dispatch type modifier parsing to type-specific objects

This changeset is enough to pass the current test suite, but probably it
might require some cleanup.

Close #450

2 years agostyle(typeinfo): more modern type annotations
Daniele Varrazzo [Fri, 3 May 2024 19:45:24 +0000 (21:45 +0200)] 
style(typeinfo): more modern type annotations

2 years agoAdd instructions for pgbouncer simple query protocol
Ruben Laguna [Tue, 14 May 2024 13:48:08 +0000 (15:48 +0200)] 
Add instructions for pgbouncer simple query protocol

2 years agodocs: add README to build the docs
Daniele Varrazzo [Tue, 14 May 2024 12:03:45 +0000 (14:03 +0200)] 
docs: add README to build the docs

Close #821.

2 years agochore: bump psycopg_pool package version to 3.2.2
Daniele Varrazzo [Fri, 10 May 2024 00:05:25 +0000 (02:05 +0200)] 
chore: bump psycopg_pool package version to 3.2.2

2 years agochore: bump psycopg package version to 3.1.19
Daniele Varrazzo [Fri, 10 May 2024 00:01:14 +0000 (02:01 +0200)] 
chore: bump psycopg package version to 3.1.19

2 years agoci(macos): test and build macOS packages on M1 runners
Daniele Varrazzo [Tue, 9 Apr 2024 23:57:50 +0000 (01:57 +0200)] 
ci(macos): test and build macOS packages on M1 runners

Separate macos runners because:

The macos-14 runner can build amd64 images, but doesn't have Python <
3.10.

The macos-12 runner can only build x86_64 images.

Run Postgres from CI rather than from cibuildwheel, as cibw won't use a
docker image on macOS anyway. It makes it more uniform w.r.t. other
runners and doesn't require a "before" script.

2 years agoMerge pull request #791
Daniele Varrazzo [Wed, 8 May 2024 20:12:01 +0000 (22:12 +0200)] 
Merge pull request #791

Replace SELECT 1 with an empty query

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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.

2 years 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

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

2 years 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.

2 years 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.

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

2 years 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

2 years 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

2 years 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

2 years 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()

2 years 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

2 years 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.

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

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

2 years 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

2 years 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

2 years 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.

2 years 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.

2 years 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

2 years 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 |
          | ^

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

2 years 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

2 years 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.

2 years 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.

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

2 years 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

2 years 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

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

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

Close #772

2 years 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

2 years 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

2 years 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'

2 years 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

2 years 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.

2 years 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

2 years 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

2 years 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.

2 years 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).

2 years 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.

2 years 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.

2 years 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

2 years 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

2 years 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.

2 years 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

2 years 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

2 years 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()

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

2 years 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.

2 years 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.

2 years 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.

2 years 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.

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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.

2 years 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

2 years 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.

2 years 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.

2 years 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

2 years 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

2 years 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

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

2 years 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

2 years 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.

2 years 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.

2 years 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).

2 years 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

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

2 years 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'

2 years 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.

2 years 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.

2 years 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

2 years 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.

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

2 years 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

2 years 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