refactor(crdb): drop crdb_version; use server_version instead
The server_version returned by CRDB is a misleading dummy. The version
tested is reported as 13.0 but certain features are more akin to
different versions (e.g. lack of range support and different behaviour
w.r.t. unknown/text adaptation).
- Keep into account the different supported interval range
- Allow for float representation rounding (pre-PG 12 behaviour)
- Run leak tests in transactions to allow to recreate the tables
Daniele Varrazzo [Wed, 25 May 2022 08:45:29 +0000 (10:45 +0200)]
feat: allow to customize the oid to dump None
On Postgres >= 10, INVALID_OID is ok, because it has a fallback text
cast. CRDB doesn't have such cast, but can convert implicitly from text
to other types, so TEXT_OID is a better choice.
Daniele Varrazzo [Tue, 24 May 2022 13:05:13 +0000 (15:05 +0200)]
test: fix skipping versions in parametrized tests
In the previous implementation, all the tests were skipped, because
annotations were added to the function and ended up affecting all
generated tests, not the marked ones only.
Daniele Varrazzo [Sun, 22 May 2022 00:44:17 +0000 (02:44 +0200)]
fix(crdb): fix json adaptation
The function set_json_dumps() now adapts the currently registered
adapter, not the default one, to be able to customize the Json dumper on
CRDB, without resetting its oid to the PostgreSQL standard one, which
CRDB doesn't know.
Daniele Varrazzo [Fri, 20 May 2022 00:32:19 +0000 (02:32 +0200)]
test(crdb): add copy tests
Skip tests from psycopg, because there is no support for copy out and
copy in syntax is different. Data types are different too (int/serial
mean int8) so the binary data samples don't match the format.
Daniele Varrazzo [Tue, 17 May 2022 00:28:53 +0000 (02:28 +0200)]
feat(crdb): cusomize CockroachDB connection
- Add ConnectionInfo.vendor
- Add ConnectionInfo subclassing
- Add CrdbConnectionInfo subclass with crdb_version attribute
- Add 'psycopg.crdb' module with adapters
- Dump strings using the text oid by default on CockroachDB
The latter change might have wider consequences, however crdb casts
strings to other types more easily than what Postgres does. At a glance
it might work; porting the rest of the test suite will tell.
test_adapt tests ported. Tests showing a difference moved to
crdb/test_adapt.
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.
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!
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.
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.
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.
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.