Hi, I noticed that PGconn.ssl_handshake_started is a write-only field and can be safely removed. The patch is attached.
-- Best regards, Aleksander Alekseev
From d14035e62ac2206e3caaa767e9f59745b20b8b75 Mon Sep 17 00:00:00 2001 From: Aleksander Alekseev <[email protected]> Date: Tue, 11 Aug 2026 14:58:25 +0300 Subject: [PATCH v1] libpq: remove unused PGconn.ssl_handshake_started field The field was added by d39a49c1e45 to let connection_failed() skip retrying with a different SSL negotiation method once the server had reported an error after the TLS handshake had already started. That logic was dropped by fb5718f35ff, which removed the ability to fall back from direct to negotiated SSL, and with it the only reader of the field. Since then pgconn_bio_read() and pgtls_close() have kept maintaining a value that nobody looks at. Oversight in fb5718f35ff. Author: Aleksander Alekseev <[email protected]> Reviewed-by: TODO FIXME Discussion: TODO FIXME --- src/interfaces/libpq/fe-secure-openssl.c | 4 ---- src/interfaces/libpq/libpq-int.h | 1 - 2 files changed, 5 deletions(-) diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index 91c1fa9bb95..3ef12987fee 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -1547,7 +1547,6 @@ pgtls_close(PGconn *conn) SSL_free(conn->ssl); conn->ssl = NULL; conn->ssl_in_use = false; - conn->ssl_handshake_started = false; } if (conn->peer) @@ -1795,9 +1794,6 @@ pgconn_bio_read(BIO *h, char *buf, int size) } } - if (res > 0) - conn->ssl_handshake_started = true; - return res; } diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index 8a729b1e748..a737d1db457 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -619,7 +619,6 @@ struct pg_conn /* SSL structures */ bool ssl_in_use; - bool ssl_handshake_started; bool ssl_cert_requested; /* Did the server ask us for a cert? */ bool ssl_cert_sent; /* Did we send one in reply? */ bool last_read_was_eof; -- 2.43.0
