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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1332:    * before the close was initiated.    * It's a bit of a tricky race, but this check should be sufficient.    */    pgsqlsess->readyforquerycount++, retval = SYNCSEND;    pgsqlsess->pportalcount = 0;    }    }    return retval;    }    -  final void _processdataready(array datarow, void|int msglen) { -  bytesreceived += msglen; -  inflight--; -  if (_state<CLOSED) -  datarows->write(datarow); -  if (++index == 1) -  PD("<%O _fetchlimit %d=min(%d||1,%d), inflight %d\n", _portalname, -  _fetchlimit, (portalbuffersize >> 1) * index / bytesreceived, -  pgsqlsess._fetchlimit, inflight); -  if (_fetchlimit) { +  private void replenishrows() { +  if (_fetchlimit && sizeof(datarows) <= _fetchlimit >> 1) {    _fetchlimit =    min((portalbuffersize >> 1) * index / bytesreceived || 1,    pgsqlsess._fetchlimit);    Thread.MutexKey lock = closemux->lock();    if (_fetchlimit && inflight <= (_fetchlimit - 1) >> 1)    _sendexecute(_fetchlimit);    else if (!_fetchlimit)    PD("<%O _fetchlimit %d, inflight %d, skip execute\n",    _portalname, _fetchlimit, inflight);    }    }    -  +  final void _processdataready(array datarow, void|int msglen) { +  bytesreceived += msglen; +  inflight--; +  if (_state<CLOSED) +  datarows->write(datarow); +  if (++index == 1) +  PD("<%O _fetchlimit %d=min(%d||1,%d), inflight %d\n", _portalname, +  _fetchlimit, (portalbuffersize >> 1) * index / bytesreceived, +  pgsqlsess._fetchlimit, inflight); +  replenishrows(); +  } +     private void releaseconditions() {    _unnamedportalkey = _unnamedstatementkey = 0;    if (!datarowtypes) {    if (_state != PURGED && !delayederror)    delayederror = LOSTERROR;    datarowtypes = emptyarray;    _ddescribe->broadcast();    }    if (delayederror && !pgsqlsess.delayederror)    pgsqlsess.delayederror = delayederror; // Preserve error upstream
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1419:    //! @returns    //! One result row at a time.    //!    //! When using COPY FROM STDOUT, this method returns one row at a time    //! as a single string containing the entire row.    //!    //! @seealso    //! @[eof()], @[send_row()]    /*semi*/final array(mixed) fetch_row() {    int|array datarow; +  replenishrows();    if (arrayp(datarow = datarows->try_read()))    return datarow;    if (!eoffound) {    if (!datarow) {    PD("%O Block for datarow\n", _portalname);    array cid = setuptimeout();    PT(datarow = datarows->read());    local_backend->remove_call_out(cid);    if (arrayp(datarow))    return datarow;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1448:    //! Multiple result rows at a time (at least one).    //!    //! When using COPY FROM STDOUT, this method returns one row at a time    //! as a single string containing the entire row.    //!    //! @seealso    //! @[eof()], @[fetch_row()]    /*semi*/final array(array(mixed)) fetch_row_array() {    if (eoffound)    return 0; +  replenishrows();    array(array|int) datarow = datarows->try_read_array();    if (!sizeof(datarow)) {    array cid = setuptimeout();    PT(datarow = datarows->read_array());    local_backend->remove_call_out(cid);    } -  +  replenishrows();    if (arrayp(datarow[-1]))    return datarow;    do datarow = datarow[..<1]; // Swallow EOF mark(s)    while (sizeof(datarow) && !arrayp(datarow[-1]));    trydelayederror();    eoffound = 1;    datarows->write(1); // Signal EOF for other threads    return datarow;    }