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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:791:    _state = PORTALINIT;    timeout = _timeout;    syncparse = _syncparse;    gottimeout = _pgsqlsess->cancelquery;    c->runningportals[this] = 1;    transtype = _transtype;    }       //! Returns the command-complete status for this query.    //! -  //! @note -  //! This method should normally be called after EOF has been reached. -  //! If it is called before, all unfetched result rows will be discarded. -  //! +     //! @seealso -  //! @[affected_rows()], @[eof()] +  //! @[Sql.Result()->status_command_complete()]    /*semi*/final string status_command_complete() { -  +  if (!statuscmdcomplete) { +  if (!datarowtypes) +  waitfordescribe(); +  { +  Thread.MutexKey lock = closemux->lock(); +  if (_fetchlimit) +  _sendexecute(_fetchlimit = 0); +  lock = _ddescribemux->lock();    if (!statuscmdcomplete) -  while (fetch_row_array()); +  PT(_ddescribe->wait(lock)); +  } +  if (this) // If object already destructed, skip the next call +  trydelayederror(); // since you cannot call functions anymore +  else +  error(LOSTERROR); +  }    return statuscmdcomplete;    }       //! Returns the number of affected rows by this query.    //! -  //! @note -  //! This method should normally be called after EOF has been reached. -  //! If it is called before, all unfetched result rows will be discarded. -  //! +     //! @seealso -  //! @[status_command_complete()], @[eof()] +  //! @[Sql.Result()->affected_rows()]    /*semi*/final int affected_rows() {    int rows; -  sscanf(status_command_complete(), "%*s %d %d", rows, rows); +  sscanf(status_command_complete() || "", "%*s %d %d", rows, rows);    return rows;    }       final void _storetiming() {    if (_tprepared) {    _tprepared.trun = gethrtime() - _tprepared.trunstart;    m_delete(_tprepared, "trunstart");    _tprepared = 0;    }    }
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1556:    datarowtypes = emptyarray;    _ddescribe->broadcast();    }    if (delayederror && !pgsqlsess.delayederror)    pgsqlsess.delayederror = delayederror; // Preserve error upstream    pgsqlsess = 0;    }       final void _releasesession(void|string statusccomplete) {    c->runningportals[this] = 0; -  if (statusccomplete && !statuscmdcomplete) +  if (statusccomplete && !statuscmdcomplete) { +  Thread.MutexKey lock = _ddescribemux->lock();    statuscmdcomplete = statusccomplete; -  +  _ddescribe->broadcast(); +  }    inflight = 0;    conxsess plugbuffer;    if (!catch(plugbuffer = c->start()))    plugbuffer->sendcmd(_closeportal(plugbuffer));    if (_state < CLOSED)    _state = CLOSED;    datarows->write(1); // Signal EOF    releaseconditions();    }   
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:2634:    delayederror = err;    }    destruct(waitforauthready);    c->purge();    };    }       final void close() {    throwdelayederror(this);    { -  Thread.MutexKey lock; -  while (qportals && qportals->size()) -  sleep(0.1, 1); // Drain portal queue to completion +  Thread.MutexKey lock = shortmux->lock(); +  portalsinflight->wait_till_drained(lock); // Drain portal queue to completion +  lock = 0;    if (unnamedstatement)    termlock = unnamedstatement->lock(1);    if (c) // Prevent trivial backtraces    c->close();    if (unnamedstatement)    lock = unnamedstatement->lock(1);    if (c)    c->purge();    }    destruct(waitforauthready);