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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:80:   #endif      //! The instance of the pgsql dedicated backend.   final Pike.Backend local_backend;      private Pike.Backend cb_backend;   private Result qalreadyprinted;   private Thread.Mutex backendmux = Thread.Mutex();   final multiset(proxy) clients = set_weak_flag((<>), Pike.WEAK);    - constant emptyarray = ({}); - constant describenodata -  = (["datarowdesc":emptyarray, "datarowtypes":emptyarray, -  "datatypeoid":emptyarray]); - private constant censoroptions = (<"use_ssl", "force_ssl", + mapping describenodata +  = (["datarowdesc":({}), "datarowtypes":({}), "datatypeoid":({})]); + private multiset censoroptions = (<"use_ssl", "force_ssl",    "cache_autoprepared_statements", "reconnect", "text_query", "is_superuser",    "server_encoding", "server_version", "integer_datetimes",    "session_authorization">);       /* Statements matching createprefix cause the prepared statement cache    * to be flushed to prevent stale references to (temporary) tables    */   final Regexp createprefix = iregexp("^\a*(CREATE|DROP)\a");       /* Statements matching dontcacheprefix never enter the cache
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:664:    int|Result portal;    if (qportals) // CancelRequest does not use qportals    while (portal = qportals->try_read())    if (objectp(portal))    portal->_purgeportal();    if (nostash) {    while (sizeof(runningportals))    catch {    foreach (runningportals; Result result; )    if (!result.datarowtypes) { -  result.datarowtypes = emptyarray; +  result.datarowtypes = ({});    if (result._state != PURGED && !result.delayederror)    result.delayederror = LOSTERROR;    result._ddescribe->broadcast();    runningportals[result] = 0;    } else    destruct(result);    };    destruct(nostash);    if (socket->set_non_blocking)    socket->set_non_blocking(); // Drop all callbacks
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:910:    _forcetext = forcetext;    _state = PORTALINIT;    timeout = _timeout;    syncparse = _syncparse;    gottimeout = _pgsqlsess->cancelquery;    c->runningportals[this] = 1;    transtype = _transtype;    }       final array(string) _showbindings() { -  array(string) msgs = emptyarray; +  array(string) msgs = ({});    if (_params) {    array from, to, paramValues;    [from, to, paramValues] = _params;    if (sizeof(paramValues)) {    int i;    string val, fmt = sprintf("%%%ds %%3s %%.61s", max(@map(from, sizeof)));    foreach (paramValues; i; val)    msgs += ({sprintf(fmt, from[i], to[i], sprintf("%O", val))});    }    }
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1037:    return eoffound;    }       //! @seealso    //! @[Sql.Result()->fetch_fields()]    /*semi*/final array(mapping(string:mixed)) fetch_fields() {    if (!datarowtypes)    waitfordescribe();    if (!datarowdesc)    error(LOSTERROR); -  return datarowdesc + emptyarray; +  return datarowdesc + ({});    }      #ifdef PG_DEBUG   #define INTVOID int   #else   #define INTVOID void   #endif    final INTVOID _decodedata(int msglen, string cenc) {    _storetiming(); _releasestatement();    string serror;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1252:       final void _setrowdesc(array(mapping(string:mixed)) drowdesc,    array(int) drowtypes) {    Thread.MutexKey lock = _ddescribemux->lock();    datarowdesc = drowdesc;    datarowtypes = drowtypes;    _ddescribe->broadcast();    }       final void _preparebind(array dtoid) { -  array(string|int) paramValues = _params ? _params[2] : emptyarray; +  array(string|int) paramValues = _params ? _params[2] : ({});    if (sizeof(dtoid) != sizeof(paramValues))    SUSERERROR("Invalid number of bindings, expected %d, got %d\n",    sizeof(dtoid), sizeof(paramValues));    Thread.MutexKey lock = _ddescribemux->lock();    if (!_portalname) {    _portalname    = (_unnamedportalkey = pgsqlsess.unnamedportalmux->trylock(1))    ? "" : PORTALPREFIX   #ifdef PG_DEBUG    + (string)(c->socket->query_fd()) + "_"
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1694:    _fetchlimit, (portalbuffersize >> 1) * index / bytesreceived,    pgsqlsess._fetchlimit, inflight);    replenishrows();    }       private void releaseconditions() {    _unnamedportalkey = _unnamedstatementkey = 0;    if (!datarowtypes) {    if (_state != PURGED && !delayederror)    delayederror = LOSTERROR; -  datarowtypes = emptyarray; +  datarowtypes = ({});    _ddescribe->broadcast();    }    if (delayederror && pgsqlsess && !pgsqlsess.delayederror)    pgsqlsess.delayederror = delayederror; // Preserve error upstream    pgsqlsess = 0;    }       final void _releasesession(void|string statusccomplete) {    c->runningportals[this] = 0;    if (statusccomplete && !statuscmdcomplete) {
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1933:    private Thread.MutexKey termlock;    final Thread.ResourceCount portalsinflight, statementsinflight;    final int(0..1) wasparallelisable;    final int(0..1) intransaction;       final conxion c;    private string cancelsecret;    private int backendpid;    final int(-128..127) backendstatus;    final mapping(string:mixed) options; -  private array(string) lastmessage = emptyarray; +  private array(string) lastmessage = ({});    final int(0..1) clearmessage;    final int(0..1) untolderror;    private mapping(string:array(mixed)) notifylist = ([]);    final mapping(string:string) runtimeparameter;    final mapping(string:mapping(string:mixed)) prepareds = ([]);    final int pportalcount;    final int totalhits;    final int msgsreceived; // Number of protocol messages received    final int bytesreceived; // Number of bytes received    final int warningsdropcount; // Number of uncollected warnings
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:2014:    }       final int is_open() {    return c && c->socket && c->socket->is_open();    }       final string geterror(void|int clear) {    untolderror = 0;    string s = lastmessage * "\n";    if (clear) -  lastmessage = emptyarray; +  lastmessage = ({});    warningscollected = 0;    return sizeof(s) && s;    }       final string host_info() {    return sprintf("fd:%d TCP/IP %s:%d PID %d",    c ? c->socket->query_fd() : -1, host, port, backendpid);    }       final void cancelquery() {
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:2064:    return MARKSTART + query + MARKEND;    return MARKSTART + (k > 1 ? query[..k-2] : "")    + MARKERROR + query[k - 1..] + MARKEND;    }       private void connect_cb() {    PD("%O\n", runtimeparameter);    }       private array(string) showbindings(Result portal) { -  return portal ? portal._showbindings() : emptyarray; +  return portal ? portal._showbindings() : ({});    }       private void preplastmessage(mapping(string:string) msgresponse) {    lastmessage = ({    sprintf("%s %s:%s %s\n (%s:%s:%s)",    msgresponse.S, msgresponse.C, msgresponse.P || "",    msgresponse.M, msgresponse.F || "", msgresponse.R || "",    msgresponse.L||"")});    }   
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:2196:   #else    cr->consume(cols << 1);   #endif // Discard column info, and make it line oriented    return ({ ({(["name":"line"])}), ({bintext?BYTEAOID:TEXTOID}) });    };    array(string) reads() {   #ifdef PG_DEBUG    if (msglen < 1)    errtype = PROTOCOLERROR;   #endif -  array ret = emptyarray, aw = ({0}); +  array ret = ({}), aw = ({0});    do {    string w = cr->read_cstring();    msglen -= sizeof(w) + 1; aw[0] = w; ret += aw;    } while (msglen);    return ret;    };    mapping(string:string) getresponse() {    mapping(string:string) msgresponse = ([]);    msglen -= 4;    foreach (reads(); ; string f)
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:2493:    portal = 0;    }    break;    }    case 'n': {   #ifdef PG_DEBUG    msglen -= 4;    PD("NoData %O\n", portal._query);   #endif    portal._fetchlimit = 0; // disables subsequent Executes -  portal->_processrowdesc(emptyarray, emptyarray); +  portal->_processrowdesc(({}), ({}));    portal = 0;    break;    }    case 'H':    portal->_processrowdesc(@getcols());    PD("CopyOutResponse %O\n", portal. _query);    break;    case '2': {    mapping tp;   #ifdef PG_DEBUG
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:2670:    USERERROR(a2nls(lastmessage)); // Implicitly closed portal    }    break;    }    case 'N': {    PD("NoticeResponse\n");    mapping(string:string) msgresponse = getresponse();    if (clearmessage) {    warningsdropcount += warningscollected;    clearmessage = warningscollected = 0; -  lastmessage = emptyarray; +  lastmessage = ({});    }    warningscollected++;    lastmessage = ({sprintf("%s %s: %s",    msgresponse.S, msgresponse.C, msgresponse.M)});    int val;    if (val = msgisfatal(msgresponse)) { // Some warnings are fatal    preplastmessage(msgresponse);    PD(a2nls(lastmessage)); throw(val);    }    break;