pike.git / lib / modules / Sql.pmod / pgsql.pike

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:29:   private int unnamedportalinuse;   private int portalsinflight;      object _c;   private string SSauthdata,cancelsecret;   private int backendpid;   private int backendstatus;   private mapping(string:mixed) options;   private string lastmessage;   private int clearmessage; + private int earlyclose;   private mapping(string:array(mixed)) notifylist=([]);   private mapping(string:string) msgresponse;   private mapping(string:string) runtimeparameter;   state _mstate;   private enum querystate {queryidle,inquery,cancelpending,canceled};   private querystate qstate;   private mapping(string:mapping(string:mixed)) prepareds=([]);   private int pstmtcount;   private int pportalcount;   private int totalhits;
pike.git/lib/modules/Sql.pmod/pgsql.pike:699:    plugbuf+=({"user\0",user,"\0"});    if(database)    plugbuf+=({"database\0",database,"\0"});    foreach(sessiondefaults;string name;string value)    plugbuf+=({name,"\0",value,"\0"});    plugbuf+=({"\0"});    int len=4;    foreach(plugbuf;;string s)    len+=sizeof(s);    plugbuf[0]=_c.plugint32(len); -  _c.sendcmd(plugbuf); +  _c.write(plugbuf);    PD("%O\n",plugbuf);    _decodemsg(readyforquery);    PD("%O\n",runtimeparameter);   }      //! @decl void reload()   //!   //! Resets the connection to the database. Can be used for   //! a variety of reasons, for example to detect the status of a connection.   void reload(void|int special) {    mixed err;    int didsync;    if(err = catch { -  sendclose(); +  sendclose(1);    PD("Portalsinflight: %d\n",portalsinflight);    if(!portalsinflight) { -  +  if(!earlyclose) {    PD("Sync\n"); -  _c.sendcmd(({"S",_c.plugint32(4)})); +  _c.sendcmd(({"S",_c.plugint32(4)}),2); +  }    didsync=1;    if(!special) {    _decodemsg(readyforquery);    foreach(prepareds;;mapping tprepared) {    m_delete(tprepared,"datatypeoid");    m_delete(tprepared,"datarowdesc");    }    }    } -  +  earlyclose=0;    }) { -  +  earlyclose=0;    PD("%O\n",err);    reconnect(1);    }    else if(didsync && special==2)    _decodemsg(readyforquery);   #ifndef UNBUFFEREDIO    _c.set_read_callback(read_cb);   #endif   }   
pike.git/lib/modules/Sql.pmod/pgsql.pike:1025:    case UUIDOID:    return 1; //binary    }    return 0; // text   }      final void _sendexecute(int fetchlimit) {    string portalname=_c.portal->_portalname;    PD("Execute portal %s fetchlimit %d\n",portalname,fetchlimit);    _c.sendcmd(({"E",_c.plugint32(4+sizeof(portalname)+1+4),portalname, -  "\0",_c.plugint32(fetchlimit)}),1); +  "\0",_c.plugint32(fetchlimit)}),!!fetchlimit);    _c.portal->_inflight+=fetchlimit; -  +  if(!fetchlimit) { +  earlyclose=1; +  if(sizeof(portalname)) { +  PD("Close portal %s & Sync\n",portalname); +  _c.sendcmd(({"C",_c.plugint32(4+1+sizeof(portalname)+1), +  "P",portalname,"\0"}));    } -  +  _c.sendcmd(({"S",_c.plugint32(4)}),2); +  } + }    - final private void sendclose() { + final private void sendclose(void|int hold) {    string portalname;    portalsinflight--;    if(_c.portal && (portalname=_c.portal->_portalname)) {    _c.portal->_portalname = UNDEFINED;    _c.setportal();   #ifdef DEBUGMORE    PD("Closetrace %O\n",backtrace());   #endif    if(!sizeof(portalname))    unnamedportalinuse--; -  +  if(sizeof(portalname)) { +  if(!earlyclose) {    PD("Close portal %s\n",portalname);    _c.sendcmd(({"C",_c.plugint32(4+1+sizeof(portalname)+1), -  "P",portalname,"\0"}),1); +  "P",portalname,"\0"}),!hold||portalsinflight?1:0); +  }    _closesent=1;    }    } -  + }      final private string trbackendst(int c) {    switch(c) {    case 'I':return "idle";    case 'T':return "intransaction";    case 'E':return "infailedtransaction";    }    return "unknown";   }   
pike.git/lib/modules/Sql.pmod/pgsql.pike:1178:    if(unnamedportalinuse)    portalname=PORTALPREFIX+(string)pportalcount++;    else    unnamedportalinuse++;    _c.portal->_portalname=portalname;    qstate=inquery;    portalsinflight++;    clearmessage=1;    mixed err;    if(err = catch { +  _c.set_read_callback(0);    if(!sizeof(preparedname) || !tprepared || !tprepared->preparedname) {    PD("Parse statement %s\n",preparedname);    // Even though the protocol doesn't require the Parse command to be    // followed by a flush, it makes a VERY noticeable difference in    // performance if it is omitted; seems like a flaw in the PostgreSQL    // server    _c.sendcmd(({"P",_c.plugint32(4+sizeof(preparedname)+1+sizeof(q)+1+2), -  preparedname,"\0",q,"\0",_c.plugint16(0)}),1); +  preparedname,"\0",q,"\0",_c.plugint16(0)}),3);    PD("Query: %O\n",q); -  } // sends Parameter- and RowDescription for 'S' -  _c.set_read_callback(0); +  } // sends Parameter- and RowDescription for 'S'    if(!tprepared || !tprepared->datatypeoid) {    PD("Describe statement %s\n",preparedname);    _c.sendcmd(({"D",_c.plugint32(4+1+sizeof(preparedname)+1),    "S",preparedname,"\0"}),1);    }    else {    _c.portal->_datatypeoid=tprepared->datatypeoid;    _c.portal->_datarowdesc=tprepared->datarowdesc;    }    { array(string) plugbuf=({"B",UNDEFINED});