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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:61:   #include "pgsql.h"      #define ERROR(X ...) predef::error(X)      inherit __builtin.Sql.Connection;      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:105:   private int invalidatecache;   private Thread.Queue qportals;   final mixed _delayederror;   private function (:void) readyforquery_cb;      final string _host;   final int _port;   private string database, user, pass;   private Thread.Condition waitforauthready;   final Thread.Mutex _shortmux; - final Thread.Condition _readyforcommit; - final int _waittocommit, _readyforquerycount; + final int _readyforquerycount;    - private string _sprintf(int type) { + 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:216:    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();    reconnect();   }      //! @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).   //!
pike.git/lib/modules/Sql.pmod/pgsql.pike:439:    "current_prepared_statement_hits":totalhits,    "prepared_statement_count":pstmtcount,   #ifdef PG_STATS    "used_prepared_statements":prepstmtused,    "skipped_describe_count":skippeddescribe,    "portals_opened_count":portalsopened,   #endif    "messages_received":_msgsreceived,    "bytes_received":_bytesreceived,    "reconnect_count":reconnected, -  "portals_in_flight":_portalsinflight, -  "statements_in_flight":_statementsinflight, +     ]);    return stats;   }      //! @param newdepth   //! Sets the new cachedepth for automatic caching of prepared statements.   //!   //! @returns   //! The previous cachedepth.   //!
pike.git/lib/modules/Sql.pmod/pgsql.pike:1063: 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:1262:    lock = unnamedstatement->lock(1);    if (c)    destruct(c);    lock = 0;    destruct(waitforauthready);   }      protected void _destruct() {    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, has_prefix, "ERROR ");    if (err || (err = catch(errstring = error(1))))    werror(describe_backtrace(err));    else if (errstring && sizeof(errstring))    werror("%s\n", errstring); // Add missing terminating newline
pike.git/lib/modules/Sql.pmod/pgsql.pike:1334:    termlock = 0;    catch(destruct(c));    PD("Flushing old cache\n");    foreach(_prepareds;;mapping tp)    m_delete(tp,"preparedname");    if(!_options.reconnect)    ERROR("Lost connection to database %s:%d\n",_host,_port);    }    PD("Actually start to connect\n");    qportals=Thread.Queue(); -  _readyforcommit=Thread.Condition(); +     _readyforquerycount=1; -  _waittocommit=0; +     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=recon?reconnect_cb:connect_cb; -  _portalsinflight=0; -  _statementsinflight = 0; +  _portalsinflight = Thread.ResourceCount(); +  _statementsinflight = Thread.ResourceCount();    _wasparallelisable = 0;    return 1;   }      //! For PostgreSQL this function performs the same function as @[resync()].   //!   //! @seealso   //! @[resync()], @[cancelquery()]   /*semi*/final void reload() {    resync();