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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:140:    * in the majority of the real-world cases, it would be considered a good    * tradeoff.    */   private Regexp execfetchlimit    = iregexp("^\a*((UPDA|DELE)TE|INSERT)\a|\aLIMIT\a+[1-9][; \t\f\r\n]*$");      private void default_backend_runs() { // Runs as soon as the    cb_backend = Pike.DefaultBackend; // DefaultBackend has started   }    - private void create() { + protected void create() {    atexit(_destruct);    // Run callbacks from our local_backend until DefaultBackend has started    cb_backend = local_backend = Pike.SmallBackend();    call_out(default_backend_runs, 0);   }    - private void _destruct() { + protected void _destruct() {    foreach (clients; proxy client; )    destruct(client);   }      private Regexp iregexp(string expr) {    Stdio.Buffer ret = Stdio.Buffer();    foreach (expr; ; int c)    if (c >= 'A' && c <= 'Z')    ret->add('[', c, c + 'a' - 'A', ']');    else if (c == '\a') // Replace with generic whitespace
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:335:    private Thread.ResourceCountKey dirty;      #ifdef PG_DEBUGRACE    final bufcon `chain() {    return this;    }   #endif       private conxion realbuffer;    -  private void create(conxion _realbuffer) { +  protected void create(conxion _realbuffer) {    realbuffer = _realbuffer;    }       final Thread.ResourceCount `stashcount() {    return realbuffer->stashcount;    }       final bufcon start(void|int waitforreal) {    dirty = realbuffer->stashcount->acquire();   #ifdef PG_DEBUG
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:441:   #endif    );    Thread.MutexKey lock = fillreadmux->lock();    if (procmsg && id)    procmsg = 0, lock = 0, Thread.Thread(id);    else if (fillread)    didreadcb = 1, fillread.signal();    return 0;    }    -  private void create() { +  protected void create() {    i::create();    fillreadmux = MUTEX();    fillread = Thread.Condition();    }   };      class sfile {    inherit Stdio.File;    final int query_fd() {    return is_open() ? ::query_fd() : -1;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:679:    };    destruct(nostash);    socket->set_non_blocking(); // Drop all callbacks    PD("%d>Close socket\n", socket->query_fd());    socket->close(); // This will be an asynchronous close    }    destruct(this);    }    }    -  private void _destruct() { +  protected void _destruct() {    PD("%d>Close conxion %d\n", socket ? socket->query_fd() : -1, !!nostash);    catch(purge());    }       final void connectloop(proxy pgsqlsess, int nossl) {   #ifdef PG_DEBUG    mixed err =   #endif    catch {    for (; ; clear()) {
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:739:    socket->set_nonblocking(i->read_cb, write_cb, close);    if (nossl != 2)    Thread.Thread(pgsqlsess->processloop, this);    return;    };    PD("Connect error %s\n", describe_backtrace(err));    catch(destruct(pgsqlsess->waitforauthready));    destruct(this);    }    -  private string _sprintf(int type) { +  protected string _sprintf(int type) {    string res;    switch (type) {    case 'O':    int fd = -1;    if (socket)    catch(fd = socket->query_fd());    res = predef::sprintf("conxion fd: %d input queue: %d/%d "    "queued portals: %d output queue: %d/%d\n"    "started: %d\n",    fd, sizeof(i), i->_size_object(),    qportals && qportals->size(), sizeof(this), _size_object(),    !!started);    break;    }    return res;    }    -  private void create(proxy pgsqlsess, Thread.Queue _qportals, int nossl) { +  protected void create(proxy pgsqlsess, Thread.Queue _qportals, int nossl) {    o::create();    qportals = _qportals;    synctransact = 1;    socket = sfile();    i = conxiin();    shortmux = MUTEX();    nostash = MUTEX();    closenext = 0;    stashavail = Thread.Condition();    stashqueue = Thread.Queue();    stash = Stdio.Buffer();    stashcount = Thread.ResourceCount();    Thread.Thread(connectloop, pgsqlsess, nossl);    }   };      #ifdef PG_DEBUGRACE   class conxsess {    final conxion chain;    -  private void create(conxion parent) { +  protected void create(conxion parent) {    if (parent->started)    werror("Overwriting conxsess %s %s\n",    describe_backtrace(({"new ", backtrace()[..<1]})),    describe_backtrace(({"old ", parent->nostrack})));    parent->nostrack = backtrace();    chain = parent;    }       final void sendcmd(int mode, void|Result portal) {    chain->sendcmd(mode, portal);    chain = 0;    }    -  private void _destruct() { +  protected void _destruct() {    if (chain)    werror("Untransmitted conxsess %s\n",    describe_backtrace(({"", backtrace()[..<1]})));    }   };   #endif      //! The result object returned by @[Sql.pgsql()->big_query()], except for   //! the noted differences it behaves the same as @[Sql.Result].   //!
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1932:    final function (:void) readyforquery_cb;       final string host;    final int(0..65535) port;    final string database, user, pass;    private Crypto.Hash.SCRAM SASLcontext;    final Thread.Condition waitforauthready;    final MUTEX shortmux;    final int readyforquerycount;    -  private string _sprintf(int type) { +  protected string _sprintf(int type) {    string res;    switch (type) {    case 'O':    res = sprintf(DRIVERNAME".proxy(%s@%s:%d/%s,%d,%d)",    user, host, port, database, c && c->socket && c->socket->query_fd(),    backendpid);    break;    }    return res;    }    -  private void create(void|string host, void|string database, +  protected void create(void|string host, void|string database,    void|string user, void|string pass,    void|mapping(string:mixed) options) {    if (this::pass = pass) {    String.secure(pass);    pass = "CENSORED";    }    this::user = user;    this::database = database;    this::options = options;   
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:2788:    if (c) // Prevent trivial backtraces    c->close();    if (unnamedstatement)    lock = unnamedstatement->lock(1);    if (c)    c->purge();    }    destruct(waitforauthready);    }    -  private void _destruct() { +  protected void _destruct() {    string errstring;    mixed err = catch(close());    clients[this] = 0;    if (untolderror) {    /*    * 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) {