]>
git.ipfire.org Git - thirdparty/psycopg.git/log
Daniele Varrazzo [Mon, 1 Apr 2024 23:18:50 +0000 (23:18 +0000)]
fix: lock the connection during a 'notifies()' call
With the previous implementation, it was possible to sneak an execute()
while the generator is consumed. This gives the false impression that
it's possible to use the connection while listening (see #756), which is
false for reason better explored in #757.
Therefore, lock the connection while listening to notifications. If
someone wants to mix commands with listening on the same connection,
they should do it collaboratively with an adequately short notifies()
timeout.
Daniele Varrazzo [Mon, 10 Jun 2024 14:50:43 +0000 (16:50 +0200)]
chore: drop pq enums aliases on connection and cursor
Unused in the codebase, and not documented. Only used in the test suite.
Daniele Varrazzo [Thu, 13 Jun 2024 14:06:23 +0000 (16:06 +0200)]
Merge pull request #794 from dlax/cursor-stream-chunks
Denis Laxalde [Wed, 17 Apr 2024 09:38:43 +0000 (11:38 +0200)]
feat: add a size parameter to Cursor.stream()
This triggers results retrieval by chunks from the server, if > 1,
leveraging the "chunked rows mode" from libpq 17.
A new has_stream_chunked() capability is added.
Daniele Varrazzo [Thu, 13 Jun 2024 14:04:49 +0000 (16:04 +0200)]
Merge pull request #834 from psycopg/cancel-conn-encoding
Daniele Varrazzo [Thu, 13 Jun 2024 09:09:44 +0000 (10:09 +0100)]
fix: typo
Co-authored-by: Denis Laxalde <denis.laxalde@dalibo.com>
Daniele Varrazzo [Wed, 12 Jun 2024 10:38:04 +0000 (12:38 +0200)]
feat: add get_error_message() methods
The method is available on PGconn, PGconnCancel, PGresult.
The generic function error_message() is retained only because it was
documented so we don't want to drop it. Internally only the
get_error_message() method is used.
Daniele Varrazzo [Mon, 10 Jun 2024 15:42:17 +0000 (17:42 +0200)]
refactor: make PGcancelConn.error_message return bytes
This is more consistent with PGconn and PGresult.
There doesn't seem to be the need of extending pq.misc.error_message as
we never pass it a PGcancelConn object.
Close #781
Daniele Varrazzo [Wed, 12 Jun 2024 17:02:58 +0000 (19:02 +0200)]
fix: fix PQclosePortal not supported error message
Daniele Varrazzo [Mon, 10 Jun 2024 14:24:21 +0000 (16:24 +0200)]
refactor(tests/crdb): generate sync from async
Daniele Varrazzo [Tue, 4 Jun 2024 19:05:43 +0000 (21:05 +0200)]
Merge branch 'pyupgrade'
Denis Laxalde [Tue, 4 Jun 2024 07:39:14 +0000 (09:39 +0200)]
refactor: remove more types as strings
I.e. all those suggested by pyupgrade --py38-plus.
Denis Laxalde [Tue, 4 Jun 2024 07:40:30 +0000 (09:40 +0200)]
refactor: use set literals
As suggested by pyupgrade --py38-plus.
Denis Laxalde [Tue, 4 Jun 2024 07:33:34 +0000 (09:33 +0200)]
chore: upgrade usage lru_cache decorator for Python 3.8+
Daniele Varrazzo [Tue, 4 Jun 2024 19:03:28 +0000 (21:03 +0200)]
Merge pull request #832 from psycopg/uniform-annotations
Upgrade annotation syntax to Python 3.8
Daniele Varrazzo [Thu, 30 May 2024 03:28:59 +0000 (05:28 +0200)]
fix: fix type annotation for Python 3.8
Daniele Varrazzo [Thu, 30 May 2024 02:14:17 +0000 (04:14 +0200)]
refactor: avoid using types as strings where possible
Daniele Varrazzo [Thu, 30 May 2024 01:36:33 +0000 (03:36 +0200)]
chore: drop unused import
Daniele Varrazzo [Thu, 30 May 2024 01:35:10 +0000 (03:35 +0200)]
refactor: drop use of typing.Set
Daniele Varrazzo [Thu, 30 May 2024 01:34:17 +0000 (03:34 +0200)]
refactor: drop use of typing.Tuple
Daniele Varrazzo [Thu, 30 May 2024 01:23:56 +0000 (03:23 +0200)]
refactor: drop use of typing.Type
Daniele Varrazzo [Thu, 30 May 2024 01:14:03 +0000 (03:14 +0200)]
refactor: drop use of typing.Dict
Daniele Varrazzo [Thu, 30 May 2024 01:03:57 +0000 (03:03 +0200)]
refactor: drop use of typing.List
Daniele Varrazzo [Thu, 30 May 2024 00:40:30 +0000 (02:40 +0200)]
refactor: drop use of typing.Union
Daniele Varrazzo [Wed, 29 May 2024 23:58:04 +0000 (01:58 +0200)]
refactor: drop use of typing.Optional
Daniele Varrazzo [Thu, 30 May 2024 00:03:44 +0000 (02:03 +0200)]
chore: drop vim syntax marker for interface files
Daniele Varrazzo [Mon, 3 Jun 2024 16:43:28 +0000 (18:43 +0200)]
Merge pull request #642 from psycopg/none-returning-dumper
Allow dumpers to return None
Daniele Varrazzo [Sat, 1 Jun 2024 11:06:38 +0000 (13:06 +0200)]
docs: add documentation about none-returning dumpers
Daniele Varrazzo [Wed, 4 Jan 2023 16:06:35 +0000 (16:06 +0000)]
docs: add news entry about none support in dumpers
Daniele Varrazzo [Wed, 29 May 2024 19:43:09 +0000 (21:43 +0200)]
fix(c): allow dumpers to return none in copy
Daniele Varrazzo [Mon, 19 Sep 2022 10:47:23 +0000 (11:47 +0100)]
test: verify that dumpers returning None are used correctly in copy
Daniele Varrazzo [Mon, 19 Sep 2022 01:20:38 +0000 (02:20 +0100)]
fix: manage dumpers returning None in nested dumpers
Daniele Varrazzo [Mon, 19 Sep 2022 00:54:44 +0000 (01:54 +0100)]
test: verify that dumpers returning None are used correctly in queries
Daniele Varrazzo [Mon, 19 Sep 2022 00:42:34 +0000 (01:42 +0100)]
fix: annotate every dumper to return Optional[Buffer]
Even if these classes never return None, this allows to create
subclasses returning None without making Mypy unhappy.
Similarly, annotate quote() methods as returning Buffer to allow
subclasses to return other types.
Daniele Varrazzo [Mon, 19 Sep 2022 00:08:19 +0000 (01:08 +0100)]
fix: manage None as return value of Dumper.dump()
These are only the changes suggested by Mypy; no test added to verify
that the code paths actually work.
Only Python test fixed, no C yet.
Daniele Varrazzo [Sun, 18 Sep 2022 23:36:35 +0000 (00:36 +0100)]
feat: extend signature of Dumper.dump() to allow returning None
Daniele Varrazzo [Sat, 1 Jun 2024 11:05:54 +0000 (13:05 +0200)]
docs: extend on the type info note
Denis Laxalde [Wed, 17 Apr 2024 08:35:45 +0000 (10:35 +0200)]
feat: add libpq interface to change a password
See https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=
a7be2a6c262d5352756d909b29c419ea5e5fa1d9 :
> drivers built on top of libpq should expose this function and its
> use should be generally encouraged over doing ALTER USER directly for
> password changes.
The test case assumes that the role connected to postgres has CREATEROLE
rights. If this is not true, the test is skipped.
Daniele Varrazzo [Wed, 29 May 2024 19:45:57 +0000 (21:45 +0200)]
fix(copy): fix count of chars to escape
We missed to reset the number of chars to escape at every field. As a
consequence, we end up resizing and scanning all the fields after the
first one requiring an escape and allocating a bit more memory than
needed.
dependabot[bot] [Thu, 30 May 2024 20:33:57 +0000 (20:33 +0000)]
chore(deps): bump pypa/cibuildwheel in the actions group
Bumps the actions group with 1 update: [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel).
Updates `pypa/cibuildwheel` from 2.17.0 to 2.18.1
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.17.0...v2.18.1)
---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: actions
...
Signed-off-by: dependabot[bot] <support@github.com>
Daniele Varrazzo [Thu, 30 May 2024 20:33:15 +0000 (22:33 +0200)]
Merge pull request #824
Updates action versions and add dependabot to check monthly for updates
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
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
Daniele Varrazzo [Mon, 27 May 2024 14:20:38 +0000 (16:20 +0200)]
chore: fix typo in comment
Daniele Varrazzo [Fri, 17 May 2024 00:42:32 +0000 (02:42 +0200)]
docs: improve docs about query protocols and PgBouncer
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.
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
Daniele Varrazzo [Thu, 9 May 2024 01:49:24 +0000 (03:49 +0200)]
test: adapt type representation tests to crdb and postgres < 15
Daniele Varrazzo [Thu, 9 May 2024 01:27:29 +0000 (03:27 +0200)]
feat: add Column.type_display
Daniele Varrazzo [Thu, 9 May 2024 00:02:08 +0000 (02:02 +0200)]
fix: fix representation of bit/varbit columns
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.
Daniele Varrazzo [Wed, 8 May 2024 21:57:11 +0000 (23:57 +0200)]
refactor(column): remove ColumnData internal object
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
Daniele Varrazzo [Fri, 3 May 2024 19:45:24 +0000 (21:45 +0200)]
style(typeinfo): more modern type annotations
Ruben Laguna [Tue, 14 May 2024 13:48:08 +0000 (15:48 +0200)]
Add instructions for pgbouncer simple query protocol
Daniele Varrazzo [Tue, 14 May 2024 12:03:45 +0000 (14:03 +0200)]
docs: add README to build the docs
Close #821.
Daniele Varrazzo [Fri, 10 May 2024 00:05:25 +0000 (02:05 +0200)]
chore: bump psycopg_pool package version to 3.2.2
Daniele Varrazzo [Fri, 10 May 2024 00:01:14 +0000 (02:01 +0200)]
chore: bump psycopg package version to 3.1.19
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.
Daniele Varrazzo [Wed, 8 May 2024 20:12:01 +0000 (22:12 +0200)]
Merge pull request #791
Replace SELECT 1 with an empty query
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
Eyal Halpern Shalev [Sat, 4 May 2024 12:57:56 +0000 (15:57 +0300)]
refactor(pool): replace --ping with empty string
Eyal Halpern Shalev [Mon, 15 Apr 2024 23:09:45 +0000 (02:09 +0300)]
perf(pool): replace SELECT 1 with an empty query
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
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.
Daniele Varrazzo [Fri, 3 May 2024 11:08:11 +0000 (13:08 +0200)]
test(copy): add minimal copy benchmark framework
Andrew Kane [Mon, 4 Mar 2024 22:34:56 +0000 (14:34 -0800)]
Improve performance of copy
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.
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.
Daniele Varrazzo [Sat, 20 Apr 2024 21:46:46 +0000 (23:46 +0200)]
Merge branch 'fix-734'
Daniele Varrazzo [Sun, 11 Feb 2024 01:34:20 +0000 (02:34 +0100)]
fix(c): solve undefined behaviour caused by unaligned access
Close #734
Daniele Varrazzo [Wed, 10 Apr 2024 23:24:02 +0000 (01:24 +0200)]
ci: add test to check for misaligned memory access
Daniele Varrazzo [Thu, 18 Apr 2024 01:38:17 +0000 (03:38 +0200)]
fix: fix handling of floating point values for connect_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()
Denis Laxalde [Tue, 16 Apr 2024 07:11:30 +0000 (09:11 +0200)]
refactor: set the meaningful timeout for _try_cancel() as a default
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.
Daniele Varrazzo [Sat, 13 Apr 2024 10:23:38 +0000 (12:23 +0200)]
docs: adjust cancel_safe() docstring
Daniele Varrazzo [Sat, 13 Apr 2024 10:23:38 +0000 (12:23 +0200)]
docs: reword notes on cancellation
Daniele Varrazzo [Fri, 12 Apr 2024 22:51:22 +0000 (00:51 +0200)]
test: more uniform treatment of timeout approx check
Daniele Varrazzo [Fri, 12 Apr 2024 22:36:36 +0000 (00:36 +0200)]
refactor: check if cancel safe is implemented via capabilities
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.
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.
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
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 |
| ^
Daniele Varrazzo [Fri, 12 Apr 2024 22:11:15 +0000 (00:11 +0200)]
Merge branch 'cancel-exceptions-swallow'
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
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.
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.
Daniele Varrazzo [Fri, 12 Apr 2024 22:09:23 +0000 (00:09 +0200)]
Merge branch 'capabilities'
Daniele Varrazzo [Fri, 12 Apr 2024 12:04:57 +0000 (14:04 +0200)]
refactor(capabilities): add caching to capabilities check
Daniele Varrazzo [Tue, 9 Apr 2024 22:13:18 +0000 (00:13 +0200)]
refactor(pipeline): use Capabilities to implement is_supported
Daniele Varrazzo [Tue, 9 Apr 2024 21:41:28 +0000 (23:41 +0200)]
docs: add capabilities documentation
Daniele Varrazzo [Tue, 9 Apr 2024 20:30:43 +0000 (22:30 +0200)]
feat: add psycopg.capability
Close #772
Daniele Varrazzo [Tue, 9 Apr 2024 20:15:39 +0000 (22:15 +0200)]
refactor: use consistently the version_pretty() function
Daniele Varrazzo [Tue, 9 Apr 2024 13:54:55 +0000 (15:54 +0200)]
feat: add pq.version_pretty() function
Daniele Varrazzo [Fri, 12 Apr 2024 22:07:29 +0000 (00:07 +0200)]
Merge branch 'async-to-sync-refactor'
Daniele Varrazzo [Fri, 12 Apr 2024 22:05:00 +0000 (00:05 +0200)]
refactor(async-to-sync): rename --convert-all option to --all
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.
Daniele Varrazzo [Fri, 12 Apr 2024 00:47:05 +0000 (02:47 +0200)]
refactor(async-to-sync): use pattern matching for more compact tests
Daniele Varrazzo [Thu, 11 Apr 2024 23:32:18 +0000 (01:32 +0200)]
refactor(async-to-sync): simpler pattern to convert string literals