fix: return the compiled port if PQport returns an empty string
Looking at the docs this seems the default value when an empty string is
specified, as opposite as the value in the PGPORT env var. See
<https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-PORT>.
This change is an improvement on top of 40dfa0b, where we allowed PGport
to return NULL. This is likely a libpq bug (reported in
<https://www.postgresql.org/message-id/CA%2Bmi_8YTS8WPZPO0PAb2aaGLwHuQ0DEQRF0ZMnvWss4y9FwDYQ%40mail.gmail.com>)
but now it's in the wild so we better support it rather than dying of
assert or by int()'ing an empty string.
fix: fix return value of `DateFromTicks` and `TimeFromTicks`
These function are based on the return value of `TimestampFromTicks`.
Because this value returned by this function is timezone-aware and
localized to the current timezone, truncating the value (and implicitly
losing the timezone) might return the wrong result.
For example, at tick 0, in NY, it was 1969-12-31T19:00-05:00. By
truncating the timestamp on the date, the date would be the 1969-12-31
instead of the expected 1970-01-01.
This changeset actually changes `TimestampFromTicks` to return an UTC
timestamp instead of a local timestamp. We believe that this change is
not a problem because we don't change neither the type (tz-aware
datetime) nor the value of the returned object (old and new values
compare equal). An alternative would have been to decouple the Timestamp
function from the Date/Time functions, but I think it would be confusing
if the Timestamp function returned a datetime with the date in 1969 but the
Date function returned a date in 1970.
Adjust the tests to be *stricter* than before, making use of the fact
that now the output is not affected by the local timezone.
Fedor Kobak [Sun, 4 May 2025 10:52:23 +0000 (13:52 +0300)]
docs: use "result set" consistently
fix `statusmessage` docs to reflect the fact that it refers to the current result, not the last one, as it was in psycopg2. Improve docs consistency about other attributes which might be affected by current result.
dependabot[bot] [Thu, 1 May 2025 07:13:04 +0000 (07:13 +0000)]
chore(deps): bump the actions group with 2 updates
Bumps the actions group with 2 updates: [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) and [prefix-dev/setup-pixi](https://github.com/prefix-dev/setup-pixi).
Updates `pypa/cibuildwheel` from 2.23.2 to 2.23.3
- [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.23.2...v2.23.3)
Updates `prefix-dev/setup-pixi` from 0.8.4 to 0.8.8
- [Release notes](https://github.com/prefix-dev/setup-pixi/releases)
- [Commits](https://github.com/prefix-dev/setup-pixi/compare/v0.8.4...v0.8.8)
test(pool): verify the overriding of `close()` to act as `putconn()`
We would like to maintain this possibility on a best-effort basis. The
hack has been mentioned in #1046 and upstream in
https://github.com/sqlalchemy/sqlalchemy/discussions/12522 and is useful
to integrate psycopg pool with the SQLAlchemy NullPool.
chore(deps): bump the actions group with 2 updates
Bumps the actions group with 2 updates: [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) and [prefix-dev/setup-pixi](https://github.com/prefix-dev/setup-pixi).
Updates `pypa/cibuildwheel` from 2.22.0 to 2.23.2
- [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.22.0...v2.23.2)
Updates `prefix-dev/setup-pixi` from 0.8.3 to 0.8.4
- [Release notes](https://github.com/prefix-dev/setup-pixi/releases)
- [Commits](https://github.com/prefix-dev/setup-pixi/compare/v0.8.3...v0.8.4)
sobolevn [Thu, 13 Mar 2025 10:40:42 +0000 (13:40 +0300)]
fix: fix `status` annotation in `connection_summary`
Currently enum names are strings, but this is being changed to become
Literal. When this will happen, the type inferred will not be valid
anymore, as we mutate it and manipulate it as string in the function.
Daniele Varrazzo [Mon, 10 Mar 2025 23:26:23 +0000 (00:26 +0100)]
test: skip target_session_attrs with libpw < 14
Only one test fails with the currently "oldest" libpq, which is 10.2,
however the docs in libpq 13 are not explicit in which modes are
supported and, afaics, 'replica' shouldn't work either.
Daniele Varrazzo [Sat, 22 Feb 2025 14:00:38 +0000 (15:00 +0100)]
chore: rename tools/build library "ci"
The name `build` is problematic because we typically want to avoid tools
to go exploring them (mypy, isort, black...) but this leaves this
directory unexplored.
Daniele Varrazzo [Fri, 21 Feb 2025 16:27:29 +0000 (17:27 +0100)]
fix(pool): check that there is some connection in the pool before shrinking
There is a race condition between shrinking the pool and closing an
expired connection which might result in attempting to pop from the
empty _pool deque. Add a check to prevent that.
The bug is not serious as it doesn't compromise the pool working but it causes
noise in the logging.
perf(uuid): speed up UUID creation using a writable subclass
Introduce an object memory-compatible with UUID, but writable. Try to
create this object in the fastest possible way: calling __new__ and
setting its attributes. Then replace the class with the standard UUID.