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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:58:   #require constant(Thread.Thread)      #include "pgsql.h"      #define ERROR(X ...) predef::error(X)      final int _fetchlimit=FETCHLIMIT;   final Thread.Mutex _unnamedportalmux;   private Thread.Mutex unnamedstatement;   private Thread.MutexKey termlock; - final int _portalsinflight; - final int _statementsinflight; + private Thread.ResourceCountKey backendreg; + final Thread.ResourceCount _portalsinflight, _statementsinflight;   final int _wasparallelisable;   final int _intransaction;      private .pgsql_util.conxion c;   private string cancelsecret;   private int backendpid, backendstatus;   final mapping(string:mixed) _options;   private array(string) lastmessage=({});   private int clearmessage;   private mapping(string:array(mixed)) notifylist=([]);
pike.git/lib/modules/Sql.pmod/pgsql.pike:101:   private Thread.Queue qportals;   final mixed _delayederror;   private function (:void) readyforquery_cb;      final string _host;   final int _port;   private string database, user, pass;   private string cnonce;   private Thread.Condition waitforauthready;   final Thread.Mutex _shortmux; - final Thread.Condition _readyforcommit; - final int _waittocommit, _readyforquerycount; + final int _readyforquerycount;    - private string _sprintf(int type, void|mapping flags) { + protected string _sprintf(int type) {    string res=UNDEFINED;    switch(type) {    case 'O':    res=sprintf(DRIVERNAME"(%s@%s:%d/%s,%d,%d)",    user,_host,_port,database,c?->socket&&c->socket->query_fd(),backendpid);    break;    }    return res;   }   
pike.git/lib/modules/Sql.pmod/pgsql.pike:206:    this::database = database;    _options = options || ([]);       if(!host) host = PGSQL_DEFAULT_HOST;    if(has_value(host,":") && sscanf(host,"%s:%d",host,_port)!=2)    ERROR("Error in parsing the hostname argument\n");    this::_host = host;       if(!_port)    _port = PGSQL_DEFAULT_PORT; -  .pgsql_util.register_backend(); +  backendreg = .pgsql_util.register_backend();    _shortmux=Thread.Mutex();    PD("Connect\n");    waitforauthready = Thread.Condition();    qportals=Thread.Queue();    _readyforquerycount = 1;    qportals->write(1);    if (!(c = .pgsql_util.conxion(this, qportals, 0)))    ERROR("Couldn't connect to database on %s:%d\n",_host,_port);    _runtimeparameter = ([]);    _unnamedportalmux = Thread.Mutex();    unnamedstatement = Thread.Mutex();    readyforquery_cb = connect_cb; -  _portalsinflight = 0; -  _statementsinflight = 0; +  _portalsinflight = Thread.ResourceCount(); +  _statementsinflight = Thread.ResourceCount();    _wasparallelisable = 0;   }      //! @returns   //! The textual description of the last   //! server-related error. Returns @expr{0@} if no error has occurred   //! yet. It is not cleared upon reading (can be invoked multiple   //! times, will return the same result until a new error occurs).   //!   //! During the execution of a statement, this function accumulates all
pike.git/lib/modules/Sql.pmod/pgsql.pike:1136: Inside #if defined(PG_DEBUG)
  #ifdef PG_DEBUG    PD("%O CopyDone\n",portal._portalname);    msglen-=4;   #endif    portal=0;    break;    case 'E': {   #ifdef PG_DEBUGMORE    showportalstack("ERRORRESPONSE");   #endif -  if (!_portalsinflight && !_readyforquerycount) +  if (_portalsinflight->drained() && !_readyforquerycount)    sendsync();    PD("%O ErrorResponse %O\n",    objectp(portal)&&(portal._portalname||portal._preparedname),    objectp(portal)&&portal._query);    mapping(string:string) msgresponse;    msgresponse=getresponse();    warningsdropcount+=warningscollected;    warningscollected=0;    switch(msgresponse.C) {    case "P0001":
pike.git/lib/modules/Sql.pmod/pgsql.pike:1338:    lock = unnamedstatement->lock(1);    if (c)    destruct(c);    lock = 0;    destruct(waitforauthready);   }      protected void destroy() {    string errstring;    mixed err = catch(close()); -  .pgsql_util.unregister_backend(); +  backendreg = 0;    /*    * Flush out any asynchronously reported errors to stderr; because we are    * inside a destructor, throwing an error will not work anymore.    * Warnings will be silently discarded at this point.    */    lastmessage = filter(lastmessage, lambda(string val) {    return has_prefix(val, "ERROR ") || has_prefix(val, "FATAL "); });    if (err || (err = catch(errstring = error(1))))    werror(describe_backtrace(err));    else if (errstring && sizeof(errstring))