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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:18:   //!   //! @seealso   //! @[Sql.Sql], @[Sql.postgres]      #pike __REAL_VERSION__      //#define DEBUG 1   //#define DEBUGMORE 1      #ifdef DEBUG - #define PD(X ...) werror(X) + #define PD(X ...) werror(X)   #define UNBUFFEREDIO 1 // Make all IO unbuffered   #else   #undef DEBUGMORE   #define PD(X ...)   #endif -  + //#define NO_LOCKING 1 // This breaks the driver, do not enable, +  // only for benchmarking mutex performance      #define FETCHLIMIT 1024 // Initial upper limit on the    // number of rows to fetch across the    // network at a time    // 0 for no chunking    // Needs to be >0 for interleaved    // portals   #define FETCHLIMITLONGRUN 1 // for long running background queries   #define STREAMEXECUTES 1 // streams executes if defined   #define MINPREPARELENGTH 64 // statements shorter than this will not
pike.git/lib/modules/Sql.pmod/pgsql.pike:45:   #define PGSQL_DEFAULT_PORT 5432   #define PGSQL_DEFAULT_HOST "localhost"   #define PREPSTMTPREFIX "pike_prep_"   #define PORTALPREFIX "pike_portal_"   #define FACTORPLAN 8   #define DRIVERNAME "pgsql"   #define MARKSTART "{""{""{""{\n" // split string to avoid   #define MARKERROR ">>>>" // foldeditors from recognising   #define MARKEND "\n}""}""}""}" // it as a fold    - #define ERROR(X ...) predef::error + #define ERROR(X ...) predef::error(X)      pgsql_result _portal;   int _nextportal;   int _closesent;   int _fetchlimit=FETCHLIMIT;   private int unnamedportalinuse;   private int portalsinflight;      private object conn;   private string SSauthdata,cancelsecret;
pike.git/lib/modules/Sql.pmod/pgsql.pike:1390:   class pgsql_result {      private object pgsqlsession;   private int numrows;   private int eoffound;   private mixed delayederror;   private int copyinprogress;   int _fetchlimit;      private mapping tprepared; + #ifdef NO_LOCKING + int _qmtxkey; + #else   Thread.MutexKey _qmtxkey; -  + #endif      string query;   string _portalname;      int _bytesreceived;   private int rowsreceived;   int _interruptable;   int _inflight;   string _statuscmdcomplete;   array(array(mixed)) _datarows;
pike.git/lib/modules/Sql.pmod/pgsql.pike:1505:    };   }      inline private array(mixed) getdatarow() {    array(mixed) datarow=_datarows[0];    _datarows=_datarows[1..];    return datarow;   }      private void steallock() { + #ifndef NO_LOCKING    PD("Going to steal oldportal %d\n",!!pgsqlsession._portal);    Thread.MutexKey stealmtxkey = stealmutex.lock();    do    if(_qmtxkey = querymutex.current_locking_key()) {    pgsql_result portalb;    if(portalb=pgsqlsession._portal) {    pgsqlsession._nextportal++;    if(portalb->_interruptable)    portalb->fetch_row(2);    else {
pike.git/lib/modules/Sql.pmod/pgsql.pike:1529:    ERROR("Driver bug, please report, "    "conflict while interleaving SQL-operations\n");    }    PD("Got the querymutex\n");    }    pgsqlsession._nextportal--;    }    break;    }    while(!(_qmtxkey=querymutex.trylock())); + #else +  PD("Skipping lock\n"); +  _qmtxkey=1; + #endif    pgsqlsession._portal=this;    PD("Stealing successful\n");   }      int|array(string|int) fetch_row(void|int|string buffer) {    if(copyinprogress) {    if(stringp(buffer)) {    PD("CopyData\n");    pgsqlsession->sendmsg(({"d",plugint32(4+sizeof(buffer)),buffer}));    }    else    releasesession();    return UNDEFINED;    } -  + #ifndef NO_LOCKING    Thread.MutexKey fetchmtxkey = fetchmutex.lock(); -  + #endif    if(!buffer && sizeof(_datarows))    return getdatarow();    mixed err;    if(buffer!=2 && (err=delayederror)) {    delayederror=UNDEFINED;    throw(err);    }    err = catch {    if(_portalname) {    if(buffer!=2 && !_qmtxkey) {