backend_pid: int = 0
needs_password: bool = False
used_password: bool = False
+ used_gssapi: bool = False
ssl_in_use: bool = False
nonblocking: int = 0
PQconnectionUsedPassword.argtypes = [PGconn_ptr]
PQconnectionUsedPassword.restype = c_int
+if libpq_version >= 160000:
+ PQconnectionUsedGSSAPI = pq.PQconnectionUsedGSSAPI
+ PQconnectionUsedGSSAPI.argtypes = [PGconn_ptr]
+ PQconnectionUsedGSSAPI.restype = c_int
+else:
+ PQconnectionUsedGSSAPI = not_supported_before("PQconnectionUsedGSSAPI", 160000)
+
PQsslInUse = pq.PQsslInUse
PQsslInUse.argtypes = [PGconn_ptr]
PQsslInUse.restype = c_int
def PQbackendPID(arg1: PGconn_struct | None) -> int: ...
def PQconnectionNeedsPassword(arg1: PGconn_struct | None) -> int: ...
def PQconnectionUsedPassword(arg1: PGconn_struct | None) -> int: ...
+def PQconnectionUsedGSSAPI(arg1: PGconn_struct | None) -> int: ...
def PQsslInUse(arg1: PGconn_struct | None) -> int: ...
def PQexec(arg1: PGconn_struct | None, arg2: bytes) -> PGresult_struct: ...
def PQexecParams(arg1: PGconn_struct | None, arg2: bytes, arg3: int, arg4: _Pointer[c_uint], arg5: _Pointer[c_char_p], arg6: _Pointer[c_int], arg7: _Pointer[c_int], arg8: int) -> PGresult_struct: ...
@property
def used_password(self) -> bool: ...
+ @property
+ def used_gssapi(self) -> bool: ...
+
@property
def ssl_in_use(self) -> bool: ...
"""
return bool(impl.PQconnectionUsedPassword(self._pgconn_ptr))
+ @property
+ def used_gssapi(self) -> bool:
+ return bool(impl.PQconnectionUsedGSSAPI(self._pgconn_ptr))
+
@property
def ssl_in_use(self) -> bool:
return self._call_bool(impl.PQsslInUse)
int PQbackendPID(const PGconn *conn)
int PQconnectionNeedsPassword(const PGconn *conn)
int PQconnectionUsedPassword(const PGconn *conn)
+ int PQconnectionUsedGSSAPI(const PGconn *conn)
int PQsslInUse(PGconn *conn) # TODO: const in PG 12 docs - verify/report
# TODO: PQsslAttribute, PQsslAttributeNames, PQsslStruct, PQgetssl
#define PQsetTraceFlags(conn, stream) do {} while (0)
#endif
+#if PG_VERSION_NUM < 160000
+#define PQconnectionUsedGSSAPI(conn) 0
+#endif
+
#if PG_VERSION_NUM < 170000
typedef struct pg_cancel_conn PGcancelConn;
#define PQchangePassword(conn, user, passwd) NULL
def used_password(self) -> bool:
return bool(libpq.PQconnectionUsedPassword(self._pgconn_ptr))
+ @property
+ def used_gssapi(self) -> bool:
+ _check_supported("PQconnectionUsedGSSAPI", 160000)
+ return bool(libpq.PQconnectionUsedGSSAPI(self._pgconn_ptr))
+
@property
def ssl_in_use(self) -> bool:
return bool(_call_int(self, <conn_int_f>libpq.PQsslInUse))
pgconn.used_password
+@pytest.mark.libpq(">= 16")
+def test_used_gssapi(pgconn):
+ assert isinstance(pgconn.used_gssapi, bool)
+
+
+@pytest.mark.libpq("< 16")
+def test_used_gssapi_not_suppored(pgconn):
+ with pytest.raises(psycopg.NotSupportedError):
+ pgconn.used_gssapi
+
+
def test_ssl_in_use(pgconn):
assert isinstance(pgconn.ssl_in_use, bool)