Changeset 844 for trunk/pgmodule.c


Ignore:
Timestamp:
Feb 8, 2016, 6:15:53 PM (4 years ago)
Author:
cito
Message:

New connection attribute "closed" in pgdb

This can be useful when implementing connection pools, e.g. in SQLAlchemy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pgmodule.c

    r824 r844  
    14421442check_cnx_obj(connObject *self)
    14431443{
    1444         if (!self->valid)
     1444        if (!self || !self->valid || !self->cnx)
    14451445        {
    14461446                set_error_msg(OperationalError, "Connection has been closed");
     
    36303630                return NULL;
    36313631
    3632         /* make sure that the connection object is valid */
    3633         if (!self->pgcnx->cnx)
    3634                 return NULL;
    3635 
    36363632        encoding = PQclientEncoding(self->pgcnx->cnx);
    36373633
     
    37723768
    37733769        /* checks validity */
    3774         if (!check_source_obj(self, CHECK_RESULT | CHECK_DQL))
     3770        if (!check_source_obj(self, CHECK_RESULT | CHECK_DQL | CHECK_CNX))
    37753771                return NULL;
    37763772
     
    39813977        /* checks validity */
    39823978        if (!check_source_obj(self, CHECK_CNX | CHECK_RESULT) ||
    3983                         !self->pgcnx->cnx ||
    39843979                        PQresultStatus(self->result) != PGRES_COPY_IN)
    39853980        {
     
    40694064        /* checks validity */
    40704065        if (!check_source_obj(self, CHECK_CNX | CHECK_RESULT) ||
    4071                         !self->pgcnx->cnx ||
    40724066                        PQresultStatus(self->result) != PGRES_COPY_OUT)
    40734067        {
Note: See TracChangeset for help on using the changeset viewer.