]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
3 years agodocs: add literal strings examples
Daniele Varrazzo [Sun, 3 Jul 2022 02:49:15 +0000 (03:49 +0100)] 
docs: add literal strings examples

Move the PEP 675 section to the typing page.

3 years agodocs: mention LiteralString and related changes in docs
Daniele Varrazzo [Mon, 27 Jun 2022 21:55:57 +0000 (22:55 +0100)] 
docs: mention LiteralString and related changes in docs

3 years agofix: clean internal use of LiteralString
Daniele Varrazzo [Mon, 27 Jun 2022 21:32:20 +0000 (22:32 +0100)] 
fix: clean internal use of LiteralString

Tested one-off using pyre 0.9.13; however it gives too many differences
compared to mypy to use it at the moment.

The pyre run doesn't currently find LiteralString-related problems,
except the todo at psycopg/sql.py:251, because string.Formatter.parse()
doesn't return a LiteralString upon LiteralString input.

3 years agorefactor: restrict Query alias to use Composed or SQL instead of Composable
Daniele Varrazzo [Mon, 27 Jun 2022 21:09:19 +0000 (22:09 +0100)] 
refactor: restrict Query alias to use Composed or SQL instead of Composable

Other Composable subclasses (Identifier, Literal, Placeholder...) don't
make sense as a complete query.

3 years agofeat: use LiteralString for Query and SQL aliases
Daniele Varrazzo [Mon, 27 Jun 2022 21:05:54 +0000 (22:05 +0100)] 
feat: use LiteralString for Query and SQL aliases

Current mypy version probably doesn't do anything with it at the moment.

3 years agoMerge branch 'async-dns'
Daniele Varrazzo [Sun, 3 Jul 2022 02:51:52 +0000 (03:51 +0100)] 
Merge branch 'async-dns'

3 years agotest: use the flakey marker in random weight test, instead of a comment
Daniele Varrazzo [Sun, 3 Jul 2022 01:49:35 +0000 (02:49 +0100)] 
test: use the flakey marker in random weight test, instead of a comment

3 years agorefactor: drop dnspython implementation of resolve_hostaddr_async
Daniele Varrazzo [Sun, 3 Jul 2022 01:44:41 +0000 (02:44 +0100)] 
refactor: drop dnspython implementation of resolve_hostaddr_async

Expose the asyncio function in the _dns module, but mark it deprecated,
because the connection perform async resolution on its own.

3 years agodocs: add documentation about async DNS resolution
Daniele Varrazzo [Sun, 3 Jul 2022 01:19:56 +0000 (02:19 +0100)] 
docs: add documentation about async DNS resolution

Close #259.

3 years agotest: drop ipaddress lazy load test
Daniele Varrazzo [Sun, 3 Jul 2022 01:07:29 +0000 (02:07 +0100)] 
test: drop ipaddress lazy load test

The module is now used by psycopg.

3 years agofeat: don't block on address resolution in async connections
Daniele Varrazzo [Sun, 3 Jul 2022 00:25:19 +0000 (01:25 +0100)] 
feat: don't block on address resolution in async connections

Use the same algorithm implemented in the `_dns` module, but based on
asyncio getaddrinfo: this avoids the need of the external dns package
and works correctly with the /etc/hosts file.

There were problems of resource leaking in Python 3.6, but as psycopg
3.1 is 3.7+ only, let's go for it!

3 years agofix; drop check for libpq < 10 to use hostaddr
Daniele Varrazzo [Sat, 2 Jul 2022 23:21:54 +0000 (00:21 +0100)] 
fix; drop check for libpq < 10 to use hostaddr

Hostaddr has been always available (seen in 7.2 documentation...).

3 years agofix: drop "char" - character alias
Daniele Varrazzo [Mon, 23 May 2022 00:46:42 +0000 (02:46 +0200)] 
fix: drop "char" - character alias

"char", with quotes, is not an alias for character, bpchar is.
Don't rely on regtype to get its alias.

3 years agochore: bump version to release 3.0.15
Daniele Varrazzo [Tue, 14 Jun 2022 23:04:55 +0000 (01:04 +0200)] 
chore: bump version to release 3.0.15

3 years agoMerge branch 'manylinux2014'
Daniele Varrazzo [Tue, 14 Jun 2022 22:56:17 +0000 (00:56 +0200)] 
Merge branch 'manylinux2014'

3 years agotest: test wheel packages using PostgreSQL 14
Daniele Varrazzo [Tue, 14 Jun 2022 15:31:52 +0000 (17:31 +0200)] 
test: test wheel packages using PostgreSQL 14

Now all built packages support SCRAM authentication.

3 years agotest: verify that we distribute the libpq we want to build
Daniele Varrazzo [Tue, 14 Jun 2022 14:57:01 +0000 (16:57 +0200)] 
test: verify that we distribute the libpq we want to build

3 years agobuild: cache libpq build
Daniele Varrazzo [Mon, 13 Jun 2022 07:12:01 +0000 (09:12 +0200)] 
build: cache libpq build

3 years agobuild: build libpq 14 for musllinux packages
Daniele Varrazzo [Mon, 13 Jun 2022 01:15:31 +0000 (03:15 +0200)] 
build: build libpq 14 for musllinux packages

Currently Alpine ships with libpq 12, which wouldn't allow to use the
pipeline mode.

Use the system packages for the other libraries, for the moment.

3 years agobuild: build manylinux2014 packages
Daniele Varrazzo [Mon, 13 Jun 2022 00:04:59 +0000 (02:04 +0200)] 
build: build manylinux2014 packages

manylinux_2_24 is soon EOL and 2_28 will be incompatible with many
distributions to come. See <https://github.com/pypa/manylinux/issues/1332>.

Close #124

3 years agobuild: build the libpq from source when building wheels on centos platform
Daniele Varrazzo [Mon, 13 Jun 2022 00:01:57 +0000 (02:01 +0200)] 
build: build the libpq from source when building wheels on centos platform

3 years agobuild: set expected sysconfdir in libpq shipped with the binary package
Daniele Varrazzo [Sun, 12 Jun 2022 23:58:11 +0000 (01:58 +0200)] 
build: set expected sysconfdir in libpq shipped with the binary package

This affects where the pg_service.conf file is looked for.

See https://github.com/psycopg/psycopg2/issues/1365

3 years agochore: upgrade libraries to build binary packages
Daniele Varrazzo [Sun, 12 Jun 2022 23:26:06 +0000 (01:26 +0200)] 
chore: upgrade libraries to build binary packages

3 years agobuild: add script to build the libpq
Daniele Varrazzo [Sun, 12 Jun 2022 23:25:29 +0000 (01:25 +0200)] 
build: add script to build the libpq

Added as it currently is in the psycopg2 project.

3 years agochore: upgrade cibuildwheel to 2.6.1
Daniele Varrazzo [Sun, 12 Jun 2022 23:01:31 +0000 (01:01 +0200)] 
chore: upgrade cibuildwheel to 2.6.1

3 years agorefactor: drop unused variable
Daniele Varrazzo [Mon, 13 Jun 2022 04:30:18 +0000 (06:30 +0200)] 
refactor: drop unused variable

3 years agotest: skip flakey test on package build
Daniele Varrazzo [Mon, 13 Jun 2022 04:28:33 +0000 (06:28 +0200)] 
test: skip flakey test on package build

Still can't find the reason why this test keeps on failing.

3 years agofix: sync pipeline before rollback()
Daniele Varrazzo [Sun, 12 Jun 2022 09:09:42 +0000 (11:09 +0200)] 
fix: sync pipeline before rollback()

We were syncing it already, but only if we had received a "pipeline
aborted" already. This might be not the case, as probably the tests
test_errors_raised_on_commit which has been failing in CI randomly for
weeks has been trying to say. Other similar branches (e.g. on commit)
don't have the same check for aborted state.

3 years agodocs: fix a typo in infinity date adaptation section
Denis Laxalde [Thu, 9 Jun 2022 06:45:23 +0000 (08:45 +0200)] 
docs: fix a typo in infinity date adaptation section

3 years agoMerge branch 'fix-315'
Daniele Varrazzo [Wed, 8 Jun 2022 23:12:27 +0000 (01:12 +0200)] 
Merge branch 'fix-315'

3 years agofix: raise DataError instead of OverflowError loading intervals too large
Daniele Varrazzo [Wed, 8 Jun 2022 22:12:20 +0000 (00:12 +0200)] 
fix: raise DataError instead of OverflowError loading intervals too large

This happened only for the binary format, not the text format.

3 years agodocs: mention different infinity date adaptation in psycopg2 differences pages
Daniele Varrazzo [Wed, 8 Jun 2022 22:11:52 +0000 (00:11 +0200)] 
docs: mention different infinity date adaptation in psycopg2 differences pages

See #315

3 years agofix: produce consistent error messages on timestamp overflow
Daniele Varrazzo [Wed, 8 Jun 2022 21:26:41 +0000 (23:26 +0200)] 
fix: produce consistent error messages on timestamp overflow

- State if the date is too small or too large, not just "not supported".
- Use similar messages in text and binary format.

See #315

3 years agofix: produce consistent error messages on date overflow
Daniele Varrazzo [Wed, 8 Jun 2022 16:30:13 +0000 (18:30 +0200)] 
fix: produce consistent error messages on date overflow

- State if the date is too small or too large, not just "not supported".
- Use similar messages in text and binary format.
- Avoid an overflow error with the infinity date in Python.

See #315

3 years agotest: move date-related tests to the date tests class
Daniele Varrazzo [Wed, 8 Jun 2022 16:29:35 +0000 (18:29 +0200)] 
test: move date-related tests to the date tests class

3 years agorefactor: rename the no_pqexec param to force_extended
Daniele Varrazzo [Wed, 8 Jun 2022 15:28:43 +0000 (17:28 +0200)] 
refactor: rename the no_pqexec param to force_extended

This refers to using the extended query protocol even in cases where the
singe query protocol might have been chosen instead (e.g. because we
don't have parameters to send).

The negative in the param name is confusing, and the reference to the
PQexec function is wrong, because we never use that function (which is
blocking), but rather we choose PQsendQueryParams instead of
PQsendQuery.

3 years agoMerge branch 'message-0x33'
Daniele Varrazzo [Wed, 8 Jun 2022 14:55:31 +0000 (16:55 +0200)] 
Merge branch 'message-0x33'

3 years agofix: don't use PQsendQuery in pipeline mode
Daniele Varrazzo [Wed, 8 Jun 2022 14:25:28 +0000 (16:25 +0200)] 
fix: don't use PQsendQuery in pipeline mode

There is no reason to use it: the only reason to not use
PQsendQueryParams is to send multiple statements, but this is not
possible in pipeline mode anyway.

Using PQsendQuery seems to produce a spurious Close message, which the
libpq is surprised to receive. Issue reported to pgsql-bugs.

https://www.postgresql.org/message-id/CA%2Bmi_8bvD0_CW3sumgwPvWdNzXY32itoG_16tDYRu_1S2gV2iw%40mail.gmail.com

Close #314

3 years agotest: print notifications received in pipeline demo
Daniele Varrazzo [Wed, 8 Jun 2022 13:18:29 +0000 (15:18 +0200)] 
test: print notifications received in pipeline demo

Investigating on the conditions causing the messages reported in #314.

3 years agofix: use a generic return type to return self
Daniele Varrazzo [Tue, 24 May 2022 10:35:03 +0000 (12:35 +0200)] 
fix: use a generic return type to return self

Standardize the var name to _Self, waiting for PEP 0673.

3 years agoMerge branch 'fix-stream'
Daniele Varrazzo [Tue, 7 Jun 2022 08:47:15 +0000 (10:47 +0200)] 
Merge branch 'fix-stream'

3 years agotest: add test to verify stream+close interaction
Daniele Varrazzo [Tue, 7 Jun 2022 07:41:14 +0000 (09:41 +0200)] 
test: add test to verify stream+close interaction

3 years agofix: restore the connection in usable state after an error in stream()
Daniele Varrazzo [Tue, 7 Jun 2022 07:21:03 +0000 (09:21 +0200)] 
fix: restore the connection in usable state after an error in stream()

3 years agofix: shorter tracebacks on stream() error
Daniele Varrazzo [Tue, 7 Jun 2022 04:46:56 +0000 (06:46 +0200)] 
fix: shorter tracebacks on stream() error

3 years agotest: add test to reveal unexpected message received
Daniele Varrazzo [Sun, 5 Jun 2022 16:58:37 +0000 (18:58 +0200)] 
test: add test to reveal unexpected message received

The test fails because we receive a notification:

    message type 0x33 arrived from server while idle

See issue #314.

3 years agoMerge branch 'fix-copy-escape'
Daniele Varrazzo [Sat, 28 May 2022 01:02:38 +0000 (02:02 +0100)] 
Merge branch 'fix-copy-escape'

3 years agofix(copy): correctly escape non-printable chars
Daniele Varrazzo [Wed, 25 May 2022 21:10:04 +0000 (22:10 +0100)] 
fix(copy): correctly escape non-printable chars

Postgres was doing the right thing with them, but the format was wrong.

3 years agoperf(copy): avoid to call _write with empty buffer
Daniele Varrazzo [Wed, 25 May 2022 17:33:18 +0000 (18:33 +0100)] 
perf(copy): avoid to call _write with empty buffer

There is a call per row we can avoid if the formatter is buffering the
data produced.

3 years agotest: drop unneeded Cursor Row type variable from typing tests
Denis Laxalde [Wed, 25 May 2022 14:55:49 +0000 (16:55 +0200)] 
test: drop unneeded Cursor Row type variable from typing tests

Follow up 2f6e7669f0b32e7a99dd6db0ef41a18af119909f.

3 years agodoc: fix a typo in pipeline examples
Denis Laxalde [Wed, 25 May 2022 08:53:28 +0000 (10:53 +0200)] 
doc: fix a typo in pipeline examples

3 years agoMerge remote-tracking branch 'dlax/pipeline-sync-upon-entering-nested'
Daniele Varrazzo [Wed, 25 May 2022 08:50:11 +0000 (10:50 +0200)] 
Merge remote-tracking branch 'dlax/pipeline-sync-upon-entering-nested'

3 years agotest: fix str(Transaction) test relying on a broken behaviour 310/head
Daniele Varrazzo [Wed, 25 May 2022 05:46:45 +0000 (07:46 +0200)] 
test: fix str(Transaction) test relying on a broken behaviour

It was relying on the need of an extra sync fixed in #309.

3 years agofix: sync nested pipeline with pending commands upon enter
Denis Laxalde [Wed, 25 May 2022 06:51:05 +0000 (08:51 +0200)] 
fix: sync nested pipeline with pending commands upon enter

When entering a nested pipeline and the outer one has pending commands,
we now sync the pipeline. This is probably less surprising at it makes
the implicit transaction from a nested pipeline isolated from the outer
one.

With this, the explicit Sync when entering a transaction is no longer
needed.

Fix #309.

3 years agotest: add test to show lack of generic connect typing info
Daniele Varrazzo [Tue, 24 May 2022 08:39:49 +0000 (10:39 +0200)] 
test: add test to show lack of generic connect typing info

See #308.

3 years agofix: fix ambiguous query to fetch enum details
Daniele Varrazzo [Sun, 22 May 2022 00:10:22 +0000 (02:10 +0200)] 
fix: fix ambiguous query to fetch enum details

The previous query happened to work, but was relying on a joined table
to maintain the order, which is not a documented behaviour.

3 years agofix: don't add a cast to text literals
Daniele Varrazzo [Sun, 22 May 2022 00:08:03 +0000 (02:08 +0200)] 
fix: don't add a cast to text literals

Normally cast is not added to unknown literals, and the text oid is not
usually used. However, when it is, it causes problems. Often Postgres
wants just a literal, not a cast type; for instance, this is not valid:

    NOTIFY foo: 'bar'::text;

3 years agotest: fix binary timedelta dumping text
Daniele Varrazzo [Fri, 20 May 2022 13:43:11 +0000 (15:43 +0200)] 
test: fix binary timedelta dumping text

We were testing text twice.

3 years agotest: define the eur unicode char only once
Daniele Varrazzo [Fri, 20 May 2022 08:01:50 +0000 (10:01 +0200)] 
test: define the eur unicode char only once

3 years agofix: don't emit a comma dumping timedelta objects
Daniele Varrazzo [Fri, 20 May 2022 13:35:31 +0000 (15:35 +0200)] 
fix: don't emit a comma dumping timedelta objects

The format '-1 day, 23:59:59' is understood OK by PostgreSQL but it's
not documented so it seems unwise to rely on it.

3 years agofix: shorter traceback even on COPY statement error
Daniele Varrazzo [Fri, 20 May 2022 08:55:17 +0000 (10:55 +0200)] 
fix: shorter traceback even on COPY statement error

The previous commit only addressed errors raised during transferring
data, not the initial COPY statement.

3 years agofix: shorter traceback on COPY error
Daniele Varrazzo [Thu, 19 May 2022 23:58:01 +0000 (01:58 +0200)] 
fix: shorter traceback on COPY error

3 years agofix: raise a shorter trackeback on interrupted notify connection
Daniele Varrazzo [Wed, 18 May 2022 20:45:48 +0000 (22:45 +0200)] 
fix: raise a shorter trackeback on interrupted notify connection

3 years agoTest: fix mypy 0.941 run
Daniele Varrazzo [Thu, 19 May 2022 21:41:26 +0000 (23:41 +0200)] 
Test: fix mypy 0.941 run

This seems a mypy shortcoming fixed in 0.950 as the CI didn't complain.
The row factory definition was exotic but arguably correct. Not worth
bumping up the min version for it anyway.

3 years agoMerge remote-tracking branch 'dlax/row-covariant'
Daniele Varrazzo [Thu, 19 May 2022 21:07:19 +0000 (23:07 +0200)] 
Merge remote-tracking branch 'dlax/row-covariant'

3 years agofix: only use covariant Row type variable 306/head
Denis Laxalde [Mon, 16 May 2022 17:16:53 +0000 (19:16 +0200)] 
fix: only use covariant Row type variable

The real variance of Row type variable is covariant, per definition of
RowMaker (RowMaker[B] is a subtype of RowMaker[A] if B is a subtype of
A; similar to the Box type in [mypy documentation][]).

By dropping the Row type variable from Cursor argument in RowFactory, we
are now able to only use the covariant Row variable (previously Row_co,
now Row). Indeed, RowFactory does not actually depend on Cursor on being
parametrized on Row; rather it's the other way around (Cursor's Row type
variable comes from its row factory).

[mypy documentation]: https://mypy.readthedocs.io/en/latest/generics.html#variance-of-generic-types

3 years agofix: use a more generic connection type in {Client,Server}Cursor
Denis Laxalde [Sun, 15 May 2022 12:28:36 +0000 (14:28 +0200)] 
fix: use a more generic connection type in {Client,Server}Cursor

This makes them similar to plain Cursor class, i.e. being parametrized
on sync or async connection type, not the row type (which is handled
through the second type variable).

3 years agorefactor: streamline 'type: ignore' in *Cursor.stream()
Denis Laxalde [Sun, 15 May 2022 09:13:38 +0000 (11:13 +0200)] 
refactor: streamline 'type: ignore' in *Cursor.stream()

Make AsyncCursor code similar to Cursor one.

3 years agofix: sync pipeline after tpc_prepare()
Denis Laxalde [Tue, 10 May 2022 19:24:12 +0000 (21:24 +0200)] 
fix: sync pipeline after tpc_prepare()

This is to get the NotSupported raised directly when calling
tpc_prepare() as expected in test_tpc_disabled().

3 years agostyle: import PipelineStatus members in the module like for other pq enums
Daniele Varrazzo [Tue, 17 May 2022 19:24:45 +0000 (21:24 +0200)] 
style: import PipelineStatus members in the module like for other pq enums

3 years agoperf: micro optimise attribute access to PollingStatus
Daniele Varrazzo [Tue, 17 May 2022 19:23:18 +0000 (21:23 +0200)] 
perf: micro optimise attribute access to PollingStatus

3 years agoperf: micro optimise attribute access to ConnStatus
Daniele Varrazzo [Tue, 17 May 2022 19:20:34 +0000 (21:20 +0200)] 
perf: micro optimise attribute access to ConnStatus

3 years agoperf: micro optimise attribute access to TransactionStatus
Daniele Varrazzo [Tue, 17 May 2022 19:14:51 +0000 (21:14 +0200)] 
perf: micro optimise attribute access to TransactionStatus

3 years agoperf: micro optimise attribute access to ExecStatus
Daniele Varrazzo [Tue, 17 May 2022 19:03:22 +0000 (21:03 +0200)] 
perf: micro optimise attribute access to ExecStatus

3 years agoperf: micro optimise attribute access to Format
Daniele Varrazzo [Sun, 15 May 2022 16:43:01 +0000 (18:43 +0200)] 
perf: micro optimise attribute access to Format

3 years agorefactor: while 1 -> while True
Daniele Varrazzo [Sun, 15 May 2022 15:54:14 +0000 (17:54 +0200)] 
refactor: while 1 -> while True

Brain legacy of ancient Python versions where the latter required a
global lookup.

3 years agotest: fix for Python 3.11
Daniele Varrazzo [Mon, 16 May 2022 17:40:11 +0000 (19:40 +0200)] 
test: fix for Python 3.11

The f-string expansion of str enums has changed. All the tests in the
maint-3.0 branch were already fixed; this changeset only fixes the new
ones.

3 years agoMerge branch 'fix-304'
Daniele Varrazzo [Mon, 16 May 2022 02:27:54 +0000 (04:27 +0200)] 
Merge branch 'fix-304'

3 years agofix: add C Float4 binary dumper
Daniele Varrazzo [Mon, 16 May 2022 00:41:53 +0000 (02:41 +0200)] 
fix: add C Float4 binary dumper

This should hopefully work around issue #304, at least when C is used.
When Python is used we raise an error instead.

Close #304

3 years agofix: raise an exception if the struct package is affected by issue #304
Daniele Varrazzo [Mon, 16 May 2022 00:14:56 +0000 (02:14 +0200)] 
fix: raise an exception if the struct package is affected by issue #304

Cowardly refuse to transform ones in zeros.

3 years agotest: Fix implicit f-string conversion to value
Daniele Varrazzo [Sun, 15 May 2022 17:49:14 +0000 (19:49 +0200)] 
test: Fix implicit f-string conversion to value

Behaviour changed in Python 3.11.

3 years agofix: Don't rely on f-string converting str enums in their values
Daniele Varrazzo [Sun, 15 May 2022 17:46:34 +0000 (19:46 +0200)] 
fix: Don't rely on f-string converting str enums in their values

The behaviour seems changed in Python 3.11: now f"%{PyFormat.AUTO}" is
evaluated as `%PyFormat.AUTO` instead of `%s`, for the general hilarity.

3 years agofix: fix typo: ingeger
Daniele Varrazzo [Mon, 16 May 2022 00:58:46 +0000 (02:58 +0200)] 
fix: fix typo: ingeger

3 years agochore: bump version to release 3.0.14
Daniele Varrazzo [Sun, 15 May 2022 15:46:00 +0000 (17:46 +0200)] 
chore: bump version to release 3.0.14

3 years agofix: don't barf on errors with blank sqlstate
Daniele Varrazzo [Sat, 14 May 2022 08:22:44 +0000 (10:22 +0200)] 
fix: don't barf on errors with blank sqlstate

Such messages are not entirely valid (sqlstate is documented to be
always present), however we receive them after a SHOW HELP in the
PgBouncer admin database.

The SHOW HELP actually does generate a sqlstate `00000` but the message
is somehow parsed incorrectly by the libpq, which goes on to report an
error:

    message contents do not agree with length in message type "N"

See #303. PgBouncer issue reported upstream in
https://github.com/pgbouncer/pgbouncer/issues/718

3 years agodocs: drop stray reference to psycopg3
Daniele Varrazzo [Sun, 15 May 2022 10:00:00 +0000 (12:00 +0200)] 
docs: drop stray reference to psycopg3

3 years agoMerge branch 'client-side-cursor'
Daniele Varrazzo [Sun, 15 May 2022 09:59:43 +0000 (11:59 +0200)] 
Merge branch 'client-side-cursor'

3 years agodocs: Subtly suggest to use the psycopg.sql module rather than ClientCursor 302/head
Daniele Varrazzo [Sun, 15 May 2022 09:57:22 +0000 (11:57 +0200)] 
docs: Subtly suggest to use the psycopg.sql module rather than ClientCursor

3 years agodocs: add documentation for client-side binding cursors
Daniele Varrazzo [Fri, 13 May 2022 01:13:05 +0000 (03:13 +0200)] 
docs: add documentation for client-side binding cursors

3 years agotest: test multi-statement parametric queries with client-side binding
Daniele Varrazzo [Fri, 13 May 2022 00:29:38 +0000 (02:29 +0200)] 
test: test multi-statement parametric queries with client-side binding

3 years agofix: set ClientCursor class module to psycopg
Daniele Varrazzo [Fri, 13 May 2022 00:21:10 +0000 (02:21 +0200)] 
fix: set ClientCursor class module to psycopg

3 years agofeat: add params to Cursor.copy()
Daniele Varrazzo [Thu, 12 May 2022 23:18:59 +0000 (01:18 +0200)] 
feat: add params to Cursor.copy()

3 years agotest: disable tests throwing copy to executemany in client-side cursors
Daniele Varrazzo [Thu, 12 May 2022 22:16:13 +0000 (00:16 +0200)] 
test: disable tests throwing copy to executemany in client-side cursors

The async one sometimes gets in an allocation loop. On my laptop it gets
OOM'd quickly. On Github Actions it might be the cause of test taking an
unusually long time.

3 years agofix: don't forbid all PQexec queries in client-side cursors
Daniele Varrazzo [Thu, 12 May 2022 21:47:46 +0000 (23:47 +0200)] 
fix: don't forbid all PQexec queries in client-side cursors

We can still use PQexecParams with an empty list of parameters. This has
advantages, such as the possibility of implementing stream(), and less
faffing with differences between Cursor and ClientCursor.

3 years agofeat: add ClientCursor.mogrify()
Daniele Varrazzo [Thu, 12 May 2022 14:46:28 +0000 (16:46 +0200)] 
feat: add ClientCursor.mogrify()

3 years agofeat: add ClientCursor and AsyncClientCursor classes
Daniele Varrazzo [Thu, 12 May 2022 02:25:51 +0000 (04:25 +0200)] 
feat: add ClientCursor and AsyncClientCursor classes

3 years agotest: skip testing random multirange arrays with empty last elements
Daniele Varrazzo [Sat, 14 May 2022 22:24:17 +0000 (00:24 +0200)] 
test: skip testing random multirange arrays with empty last elements

Previously we were skipping the ones with an empty first element,
because of a known shortcoming in finding the right OID. Now that we
scan the whole array to find all the elements' classes, it's the last
entry which might break dumping.

3 years agoMerge branch 'fix-301'
Daniele Varrazzo [Sat, 14 May 2022 00:02:30 +0000 (02:02 +0200)] 
Merge branch 'fix-301'

3 years agofix: allow dumping mixed types list, as long as they use the same dumper
Daniele Varrazzo [Fri, 13 May 2022 23:29:53 +0000 (01:29 +0200)] 
fix: allow dumping mixed types list, as long as they use the same dumper

Necessary to dump a mix of ipv4/ipv6 addresses, which result in the same
Postgres type, so it's a legit array.

3 years agofix: Raise DataError dumping lists of mixed types
Daniele Varrazzo [Fri, 13 May 2022 22:37:48 +0000 (00:37 +0200)] 
fix: Raise DataError dumping lists of mixed types

This requires more checking dumping lists, but the alternative is to
guard every single dumper, which is painful as well, and more brittle.

3 years agofix: raise DataError if IntDumper tries to dump another type
Daniele Varrazzo [Fri, 13 May 2022 14:54:54 +0000 (16:54 +0200)] 
fix: raise DataError if IntDumper tries to dump another type

Allow to dump int subclasses, but not other numeric type, which can lead
to truncation. As seen in #301, the Python implementation truncates; the
c implementation is reporting failing with a TypeError, but on Python
3.8 it raises a deprecation warning instead.

The condition largely happens dumping array of mixed types. However we
should probably test with array of mixed class in a more generic way.

Close #301.