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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:89:   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 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;   Thread.Mutex _stealmutex;      protected string _sprintf(int type, void|mapping flags) {    string res=UNDEFINED;    switch(type) {
pike.git/lib/modules/Sql.pmod/pgsql.pike:1511:    int tstart;    if(forcecache==1 || forcecache!=0 && sizeof(q)>=MINPREPARELENGTH) {    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 { -  if(totalhits>=cachedepth) { +  int flushcache=0; +  if(forcecache!=1 && createprefix->match(q)) // Flush cache on CREATE +  flushcache=1; +  if(totalhits>=cachedepth || flushcache) {    array(string) plugbuf=({});    foreach(prepareds;string ind;tp) {    int oldhits=tp->hits;    totalhits-=oldhits-(tp->hits=oldhits>>1); -  if(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"});    }    m_delete(prepareds,ind);    }    }    if(sizeof(plugbuf))    _c.sendcmd(plugbuf,1); // close expireds    PD("%O\n",plugbuf);    } -  +  if(!flushcache)    prepareds[q]=tp=([]);    }    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