Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add libpq interface for encrypted and non-blocking cancellation #754

Merged
merged 5 commits into from Apr 5, 2024

Conversation

dlax
Copy link
Contributor

@dlax dlax commented Mar 29, 2024

First step for #534

@dlax dlax force-pushed the libpq-cancel-nonblocking branch 7 times, most recently from 1c0c20e to 66d010f Compare April 2, 2024 09:02
docs/api/pq.rst Show resolved Hide resolved
psycopg/psycopg/pq/_pq_ctypes.py Outdated Show resolved Hide resolved
tests/pq/test_pgconn.py Show resolved Hide resolved
tests/pq/test_pgconn.py Outdated Show resolved Hide resolved
tests/pq/test_pgconn.py Outdated Show resolved Hide resolved
tests/pq/test_pgconn.py Show resolved Hide resolved
@dlax dlax force-pushed the libpq-cancel-nonblocking branch 3 times, most recently from 55177e5 to 621b010 Compare April 5, 2024 11:02
@dlax dlax mentioned this pull request Apr 5, 2024
@dlax dlax requested a review from dvarrazzo April 5, 2024 12:32
dlax added 5 commits April 5, 2024 18:35
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).
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.
Similarly to PGconn, PGcancelConn must not be used after .finish(); we
raise an OperationalError to prevent segfault when the connection
pointer is NULL.
Copy link
Member

@dvarrazzo dvarrazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Rebasing and merging, thank you very much!

@dvarrazzo dvarrazzo merged commit 028fef4 into psycopg:master Apr 5, 2024
42 checks passed
@dvarrazzo
Copy link
Member

Merged now 🙂

@dlax dlax deleted the libpq-cancel-nonblocking branch April 6, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants