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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:32:   final Regexp createprefix    =Regexp("^[ \t\f\r\n]*[Cc][Rr][Ee][Aa][Tt][Ee][ \t\f\r\n]");   private Regexp dontcacheprefix    =Regexp("^[ \t\f\r\n]*([Ff][Ee][Tt][Cc][Hh]|[Cc][Oo][Pp][Yy])[ \t\f\r\n]");   private Regexp commitprefix=Regexp(    "^[ \t\f\r\n]*([Cc][Oo][Mm][Mm][Ii][Tt]|[Ee][Nn][Dd])([ \t\f\r\n;]|$)");   private Regexp execfetchlimit    =Regexp("^[ \t\f\r\n]*(([Uu][Pp][Dd][Aa]|[Dd][Ee][Ll][Ee])[Tt][Ee]|\   [Ii][Nn][Ss][Ee][Rr][Tt])[ \t\f\r\n]|\   [ \t\f\r\n][Ll][Ii][Mm][Ii][Tt][ \t\f\r\n]+[12][; \t\f\r\n]*$"); + final array(mixed) emptyarray=({});      final void closestatement(bufcon|conxion plugbuffer,string oldprep) {    if(oldprep) {    PD("Close statement %s\n",oldprep);    plugbuffer->add_int8('C')->add_hstring(({'S',oldprep,0}),4,4);    }   }      private void run_local_backend() {    Thread.MutexKey lock;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:553:    trydelayederror();    return eoffound;    }       //! @seealso    //! @[Sql.sql_result()->fetch_fields()]    /*semi*/final array(mapping(string:mixed)) fetch_fields() {    if(!datarowtypes)    waitfordescribe();    trydelayederror(); -  return datarowdesc+({}); +  return datarowdesc+emptyarray;    }      #ifdef PG_DEBUG   #define INTVOID int   #else   #define INTVOID void   #endif    final INTVOID _decodedata(int msglen,string cenc) {    _storetiming();    string serror;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:640:    a[i]="";    }    _processdataready(a);    if(serror)    error(serror);   #ifdef PG_DEBUG    return msglen;   #endif    }    -  final void _setrowdesc(array(mapping(string:mixed)) drowdesc) { +  final void _setrowdesc(array(mapping(string:mixed)) drowdesc, +  array(int) drowtypes) {    Thread.MutexKey lock=_ddescribemux->lock(); -  datarowtypes=map(datarowdesc=drowdesc,lambda(mapping m){return m.type;}); +  datarowdesc=drowdesc; +  datarowtypes=drowtypes;    _ddescribe->broadcast();    lock=0;    }       final void _preparebind(array dtoid) {    array(string|int) paramValues=_params?_params[2]:({});    if(sizeof(dtoid)!=sizeof(paramValues))    SUSERERROR("Invalid number of bindings, expected %d, got %d\n",    sizeof(dtoid),sizeof(paramValues));    Thread.MutexKey lock=_ddescribemux->lock();
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:667:    +(string)(c->socket->query_fd())+"_"   #endif    +int2hex(pgsqlsess._pportalcount++);    lock=0;   #ifdef PG_DEBUGMORE    PD("ParamValues to bind: %O\n",paramValues);   #endif    Stdio.Buffer plugbuffer=Stdio.Buffer();    plugbuffer->add(_portalname)->add_int8(0)    ->add(_preparedname)->add_int8(0)->add_int16(sizeof(dtoid)); -  foreach(dtoid;;int textbin) -  plugbuffer->add_int16(oidformat(textbin)); +  plugbuffer->add_ints(map(dtoid,oidformat),2);    plugbuffer->add_int16(sizeof(dtoid));    string cenc=pgsqlsess._runtimeparameter[CLIENT_ENCODING];    foreach(paramValues;int i;mixed value) {    if(undefinedp(value) || objectp(value)&&value->is_val_null)    plugbuffer->add_int32(-1); // NULL    else if(stringp(value) && !sizeof(value)) {    int k=0;    switch(dtoid[i]) {    default:    k=-1; // cast empty strings to NULL for non-string types
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:793:    if(!datarowtypes) {    if(_tprepared && dontcacheprefix->match(_query))    m_delete(pgsqlsess->_prepareds,_query),_tprepared=0;    waitfordescribe();    }    if(_state>=CLOSING)    lock=_unnamedstatementkey=0;    else {    plugbuffer->add_int16(sizeof(datarowtypes));    if(sizeof(datarowtypes)) -  foreach(datarowtypes;;int typ) -  plugbuffer->add_int16(oidformat(typ)); +  plugbuffer->add_ints(map(datarowtypes,oidformat),2);    else if(commitprefix->match(_query)) {    lock=pgsqlsess->_shortmux->lock();    if(pgsqlsess->_portalsinflight) {    pgsqlsess->_waittocommit++;    PD("Commit waiting for portals to finish\n");    pgsqlsess->_readyforcommit->wait(lock);    pgsqlsess->_waittocommit--;    }    }    lock=0;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:823:    _sendexecute(_fetchlimit    && !(cachealways[_query]    || sizeof(_query)>=MINPREPARELENGTH &&    execfetchlimit->match(_query))    && _fetchlimit,bindbuffer);    }    } else    lock=0;    }    -  final void _processrowdesc(array(mapping(string:mixed)) datarowdesc) { -  _setrowdesc(datarowdesc); -  if(_tprepared) +  final void _processrowdesc(array(mapping(string:mixed)) datarowdesc, +  array(int) datarowtypes) { +  _setrowdesc(datarowdesc,datarowtypes); +  if(_tprepared) {    _tprepared.datarowdesc=datarowdesc; -  +  _tprepared.datarowtypes=datarowtypes;    } -  +  }       final void _openportal() {    pgsqlsess->_portalsinflight++;    Thread.MutexKey lock=closemux->lock();    _state=BOUND;    lock=0;    statuscmdcomplete=UNDEFINED;    }       final void _purgeportal() {
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:922:    PD("<%O _fetchlimit %d, inflight %d, skip execute\n",    _portalname,_fetchlimit,inflight);    lock=0;    }    }       private void releaseconditions() {    pgsqlsess=0;    if(!datarowtypes) {    Thread.MutexKey lock=_ddescribemux->lock(); -  datarowtypes=datarowdesc=({}); +  datarowtypes=emptyarray; +  datarowdesc=emptyarray;    _ddescribe->broadcast();    lock=0;    }    }       final void _releasesession(void|string statusccomplete) {    if(statusccomplete && !statuscmdcomplete)    statuscmdcomplete=statusccomplete;    inflight=0;    conxion plugbuffer=c->start(1);