# TODO: PQsslAttribute, PQsslAttributeNames, PQsslStruct, PQgetssl
# 33.3. Command Execution Functions
- PGresult *PQexec(PGconn *conn, const char *command)
+ PGresult *PQexec(PGconn *conn, const char *command) nogil
PGresult *PQexecParams(PGconn *conn,
const char *command,
int nParams,
const char * const *paramValues,
const int *paramLengths,
const int *paramFormats,
- int resultFormat)
+ int resultFormat) nogil
PGresult *PQprepare(PGconn *conn,
const char *stmtName,
const char *query,
int nParams,
- const Oid *paramTypes)
+ const Oid *paramTypes) nogil
PGresult *PQexecPrepared(PGconn *conn,
const char *stmtName,
int nParams,
const char * const *paramValues,
const int *paramLengths,
const int *paramFormats,
- int resultFormat)
+ int resultFormat) nogil
PGresult *PQdescribePrepared(PGconn *conn, const char *stmtName)
PGresult *PQdescribePortal(PGconn *conn, const char *portalName)
ExecStatusType PQresultStatus(const PGresult *res)
# 33.4. Asynchronous Command Processing
- int PQsendQuery(PGconn *conn, const char *command)
+ int PQsendQuery(PGconn *conn, const char *command) nogil
int PQsendQueryParams(PGconn *conn,
const char *command,
int nParams,
const char * const *paramValues,
const int *paramLengths,
const int *paramFormats,
- int resultFormat)
+ int resultFormat) nogil
int PQsendPrepare(PGconn *conn,
const char *stmtName,
const char *query,
int nParams,
- const Oid *paramTypes)
+ const Oid *paramTypes) nogil
int PQsendQueryPrepared(PGconn *conn,
const char *stmtName,
int nParams,
const char * const *paramValues,
const int *paramLengths,
const int *paramFormats,
- int resultFormat)
+ int resultFormat) nogil
int PQsendDescribePrepared(PGconn *conn, const char *stmtName)
int PQsendDescribePortal(PGconn *conn, const char *portalName)
PGresult *PQgetResult(PGconn *conn)
def exec_(self, command: bytes) -> PGresult:
self._ensure_pgconn()
- cdef libpq.PGresult *pgresult = libpq.PQexec(self.pgconn_ptr, command)
+ cdef const char *ccommand = command
+ cdef libpq.PGresult *pgresult
+ with nogil:
+ pgresult = libpq.PQexec(self.pgconn_ptr, ccommand)
if pgresult is NULL:
raise MemoryError("couldn't allocate PGresult")
def send_query(self, command: bytes) -> None:
self._ensure_pgconn()
- if not libpq.PQsendQuery(self.pgconn_ptr, command):
+ cdef const char *ccommand = command
+ cdef int rv
+ with nogil:
+ rv = libpq.PQsendQuery(self.pgconn_ptr, ccommand)
+ if not rv:
raise PQerror(f"sending query failed: {error_message(self)}")
def exec_params(
cdef char *const *cvalues
cdef int *clengths
cdef int *cformats
+ cdef const char *ccommand = command
+ cdef int cresformat = result_format
cnparams, ctypes, cvalues, clengths, cformats = _query_params_args(
param_values, param_types, param_formats)
- cdef libpq.PGresult *pgresult = libpq.PQexecParams(
- self.pgconn_ptr, command, cnparams, ctypes,
- <const char *const *>cvalues, clengths, cformats, result_format)
+ cdef libpq.PGresult *pgresult
+ with nogil:
+ pgresult = libpq.PQexecParams(
+ self.pgconn_ptr, ccommand, cnparams, ctypes,
+ <const char *const *>cvalues, clengths, cformats, cresformat)
_clear_query_params(ctypes, cvalues, clengths, cformats)
if pgresult is NULL:
raise MemoryError("couldn't allocate PGresult")
cdef char *const *cvalues
cdef int *clengths
cdef int *cformats
+ cdef const char *ccommand = command
+ cdef int cresformat = result_format
cnparams, ctypes, cvalues, clengths, cformats = _query_params_args(
param_values, param_types, param_formats)
- cdef int rv = libpq.PQsendQueryParams(
- self.pgconn_ptr, command, cnparams, ctypes,
- <const char *const *>cvalues,
- clengths, cformats, result_format)
+ cdef int rv
+ with nogil:
+ rv = libpq.PQsendQueryParams(
+ self.pgconn_ptr, ccommand, cnparams, ctypes,
+ <const char *const *>cvalues, clengths, cformats, cresformat)
_clear_query_params(ctypes, cvalues, clengths, cformats)
if not rv:
raise PQerror(
for i in range(nparams):
atypes[i] = param_types[i]
- cdef int rv = libpq.PQsendPrepare(
- self.pgconn_ptr, name, command, nparams, atypes
- )
+ cdef int rv
+ cdef const char *cname = name
+ cdef const char *ccommand = command
+ with nogil:
+ rv = libpq.PQsendPrepare(
+ self.pgconn_ptr, cname, ccommand, nparams, atypes
+ )
PyMem_Free(atypes)
if not rv:
raise PQerror(
cdef char *const *cvalues
cdef int *clengths
cdef int *cformats
+ cdef const char *cname = name
+ cdef int cresformat = result_format
cnparams, ctypes, cvalues, clengths, cformats = _query_params_args(
param_values, None, param_formats)
- cdef int rv = libpq.PQsendQueryPrepared(
- self.pgconn_ptr, name, cnparams,
- <const char *const *>cvalues,
- clengths, cformats, result_format)
+ cdef int rv
+ with nogil:
+ rv = libpq.PQsendQueryPrepared(
+ self.pgconn_ptr, cname, cnparams, <const char *const *>cvalues,
+ clengths, cformats, cresformat)
_clear_query_params(ctypes, cvalues, clengths, cformats)
if not rv:
raise PQerror(
for i in range(nparams):
atypes[i] = param_types[i]
- cdef libpq.PGresult *rv = libpq.PQprepare(
- self.pgconn_ptr, name, command, nparams, atypes)
+ cdef const char *cname = name
+ cdef const char *ccommand = command
+ cdef libpq.PGresult *rv
+ with nogil:
+ rv = libpq.PQprepare(
+ self.pgconn_ptr, cname, ccommand, nparams, atypes)
PyMem_Free(atypes)
if rv is NULL:
raise MemoryError("couldn't allocate PGresult")
cnparams, ctypes, cvalues, clengths, cformats = _query_params_args(
param_values, None, param_formats)
- cdef libpq.PGresult *rv = libpq.PQexecPrepared(
- self.pgconn_ptr, name, cnparams,
- <const char *const *>cvalues,
- clengths, cformats, result_format)
+ cdef const char *cname = name
+ cdef int cresformat = result_format
+ cdef libpq.PGresult *rv
+ with nogil:
+ rv = libpq.PQexecPrepared(
+ self.pgconn_ptr, cname, cnparams,
+ <const char *const *>cvalues,
+ clengths, cformats, cresformat)
_clear_query_params(ctypes, cvalues, clengths, cformats)
if rv is NULL: