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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:86:   private int sessionblocked; // Number of times the session blocked on network   private int skippeddescribe; // Number of times we skipped Describe phase   private int portalsopened; // Number of portals opened   int _msgsreceived; // Number of protocol messages received   int _bytesreceived; // Number of bytes received   int _packetssent; // Number of packets sent   int _bytessent; // Number of bytes sent   private int warningsdropcount; // Number of uncollected warnings   private int prepstmtused; // Number of times prepared statements were used   private int warningscollected; + private int invalidatecache;      private string host, database, user, pass;   private int port;   private object createprefix    =Regexp("^[ \t\f\r\n]*[Cc][Rr][Ee][Aa][Tt][Ee][ \t\f\r\n]");   private object fetchprefix    =Regexp("^[ \t\f\r\n]*[Ff][Ee][Tt][Cc][Hh][ \t\f\r\n]");   private object limitpostfix    =Regexp("[ \t\f\r\n][Ll][Ii][Mm][Ii][Tt][ \t\f\r\n]+[12][; \t\f\r\n]*$");   Thread.Mutex _querymutex;
pike.git/lib/modules/Sql.pmod/pgsql.pike:843:    msgresponse=getresponse();    warningsdropcount+=warningscollected;    warningscollected=0;    switch(msgresponse->C) {   #define USERERROR(msg) throw(({msg, backtrace()[..<1]}))    case "P0001":    lastmessage=sprintf("%s: %s",msgresponse->S,msgresponse->M);    USERERROR(lastmessage    +"\n"+pinpointerror(_c.portal->query,msgresponse->P));    break; +  case "08P01":case "42P05": +  errtype=protocolerror; +  case "XX000":case "42883":case "42P01": +  invalidatecache=1;    default:    lastmessage=sprintf("%s %s:%s %s\n (%s:%s:%s)\n%s%s%s%s\n%s",    msgresponse->S,msgresponse->C,msgresponse->P||"",msgresponse->M,    msgresponse->F||"",msgresponse->R||"",msgresponse->L||"",    addnlifpresent(msgresponse->D),addnlifpresent(msgresponse->H),    pinpointerror(_c.portal&&_c.portal->query,msgresponse->P),    pinpointerror(msgresponse->q,msgresponse->p),    addnlifpresent(msgresponse->W));    switch(msgresponse->S) {    case "PANIC":werror(lastmessage);
pike.git/lib/modules/Sql.pmod/pgsql.pike:1428:   //! idle   //! intransaction   //! infailedtransaction   //!   //! This function is PostgreSQL-specific, and thus it is not available   //! through the generic SQL-interface.   final string status_commit() {    return trbackendst(backendstatus);   }    + final private void closestatement(array(string) plugbuf,mapping tp) { +  string oldprep=tp->preparedname; +  if(oldprep) { +  PD("Close statement %s\n",oldprep); +  plugbuf+=({"C",_c.plugint32(4+1+sizeof(oldprep)+1), +  "S",oldprep,"\0"}); +  } + } +    //! This is the only provided interface which allows you to query the   //! database. If you wish to use the simpler "query" function, you need to   //! use the @[Sql.Sql] generic SQL-object.   //!   //! It returns a pgsql_result object (which conforms to the   //! @[Sql.sql_result] standard interface for accessing data). I   //! recommend using @[query()] for simpler queries (because it is   //! easier to handle, but stores all the result in memory), and   //! @[big_query()] for queries you expect to return huge amounts of   //! data (it's harder to handle, but fetches results on demand).
pike.git/lib/modules/Sql.pmod/pgsql.pike:1507:    }    if(rep--)    q=replace(q,from[..rep],to[..rep]);    paramValues= pi ? paramValues[..pi-1] : ({});    }    else    paramValues = ({});    mapping(string:mixed) tp;    int tstart;    if(forcecache==1 || forcecache!=0 && sizeof(q)>=MINPREPARELENGTH) { +  array(string) plugbuf=({});    if(tp=prepareds[q]) {    if(tp->preparedname)    prepstmtused++, preparedname=tp->preparedname;    else if((tstart=tp->trun)    && tp->tparse*FACTORPLAN>=tstart)    preparedname=PREPSTMTPREFIX+(string)pstmtcount++;    }    else { -  int flushcache=0; -  if(forcecache!=1 && createprefix->match(q)) // Flush cache on CREATE -  flushcache=1; -  if(totalhits>=cachedepth || flushcache) { -  array(string) plugbuf=({}); +  if(totalhits>=cachedepth) {    foreach(prepareds;string ind;tp) {    int oldhits=tp->hits;    totalhits-=oldhits-(tp->hits=oldhits>>1); -  if(oldhits<=1 || flushcache) { -  string oldprep=tp->preparedname; -  if(oldprep) { -  PD("Close statement %s\n",oldprep); -  plugbuf+=({"C",_c.plugint32(4+1+sizeof(oldprep)+1), -  "S",oldprep,"\0"}); -  } +  if(oldhits<=1) { +  closestatement(plugbuf,tp);    m_delete(prepareds,ind);    }    } -  if(sizeof(plugbuf)) -  _c.sendcmd(plugbuf,1); // close expireds -  PD("%O\n",plugbuf); +     } -  if(!flushcache) +  if(forcecache!=1 && createprefix->match(q)) // Flush cache on CREATE +  invalidatecache=1; +  else    prepareds[q]=tp=([]);    } -  +  if(invalidatecache) { +  invalidatecache=0; +  foreach(prepareds;;mapping np) { +  closestatement(plugbuf,np); +  m_delete(np,"preparedname"); +  } +  } +  if(sizeof(plugbuf)) { +  _c.sendcmd(plugbuf,1); // close expireds +  PD("%O\n",plugbuf); +  }    tstart=gethrtime();    } // pgsql_result autoassigns to portal    else    tp=UNDEFINED;    .pgsql_util.pgsql_result(this,q,_fetchlimit,portalbuffersize,_alltyped);    if(unnamedportalinuse)    portalname=PORTALPREFIX+(string)pportalcount++;    else    unnamedportalinuse++;    _c.portal->_portalname=portalname;