From b52ad537c39f27e06dc931b14c88facb142fe9a1 Mon Sep 17 00:00:00 2001 From: "Stephen R. van den Berg" <srb@cuci.nl> Date: Sat, 20 Jan 2018 13:52:48 +0100 Subject: [PATCH] Whitespace and doc fixes. --- lib/modules/Sql.pmod/pgsql_util.pmod | 225 +++++++++++++-------------- 1 file changed, 112 insertions(+), 113 deletions(-) diff --git a/lib/modules/Sql.pmod/pgsql_util.pmod b/lib/modules/Sql.pmod/pgsql_util.pmod index cb03aa8afb..f5cd54fac3 100644 --- a/lib/modules/Sql.pmod/pgsql_util.pmod +++ b/lib/modules/Sql.pmod/pgsql_util.pmod @@ -26,7 +26,6 @@ #define CLOSING 5 #define CLOSED 6 #define PURGED 7 -// If this is extended, change the type of _state #define NOERROR 0 // Error states networkparser #define PROTOCOLERROR 1 @@ -362,11 +361,9 @@ class conxion { final Thread.Queue stashqueue; final Thread.Condition stashavail; final Stdio.Buffer stash; - /* FIXME actually: int(KEEP..SYNCSEND) stashflushmode - * but the PikeParser does not approve, and refdoc - * generation aborts - */ - final int(0..4) stashflushmode; + //! @ignore + final int(KEEP..SYNCSEND) stashflushmode; + //! @endignore final Thread.ResourceCount stashcount; final int synctransact; #ifdef PG_DEBUGRACE @@ -670,7 +667,9 @@ class sql_result { private conxiin cr; final int(0..1) untolderror; final mixed delayederror; - final int(0..7) _state; // FIXME actually: int(PORTALINIT..PURGED) + //! @ignore + final int(PORTALINIT..PURGED) _state; + //! @endignore final int _fetchlimit; private int(0..1) alltext; final int(0..1) _forcetext; @@ -1639,10 +1638,10 @@ class proxy { } private int|sql_result portal; // state information procmessage - #ifdef PG_DEBUG +#ifdef PG_DEBUG private string datarowdebug; private int datarowdebugcount; - #endif +#endif final void processloop(conxion ci) { (c = ci)->socket->set_id(procmessage); @@ -1678,17 +1677,17 @@ class proxy { err = catch { conxion ci = c; // cache value FIXME sensible? conxiin cr = ci->i; // cache value FIXME sensible? - #ifdef PG_DEBUG +#ifdef PG_DEBUG PD("Processloop\n"); - #ifdef PG_DEBUGMORE +#ifdef PG_DEBUGMORE void showportalstack(string label) { PD(sprintf(">>>>>>>>>>> Portalstack %s: %O\n", label, portal)); foreach (qportals->peek_array(); ; int|sql_result qp) PD(" =========== Portal: %O\n", qp); PD("<<<<<<<<<<<<<< Portalstack end\n"); }; - #endif +#endif void showportal(int msgtype) { if (objectp(portal)) PD("%d<%O %d %c switch portal\n", @@ -1697,7 +1696,7 @@ class proxy { PD("%d<Sync %d %d %c portal\n", ci->socket->query_fd(), ++ci->queueinidx, portal, msgtype); }; - #endif +#endif int msgisfatal(mapping(string:string) msgresponse) { if (!terminating) // Run the callback once per lost connection runcallback(backendpid,"_lost",""); @@ -1707,15 +1706,15 @@ class proxy { }; for (;;) { err = catch { - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (!portal && datarowdebug) { PD("%s rows %d\n", datarowdebug, datarowdebugcount); datarowdebug = 0; datarowdebugcount = 0; } - #endif - #ifdef PG_DEBUGMORE +#endif +#ifdef PG_DEBUGMORE showportalstack("LOOPTOP"); - #endif +#endif if (!sizeof(cr)) { // Preliminary check, fast path Thread.MutexKey lock = cr->fillreadmux->lock(); if (!sizeof(cr)) { // Check for real @@ -1730,9 +1729,9 @@ class proxy { int msgtype = cr->read_int8(); if (!portal) { portal = qportals->try_read(); - #ifdef PG_DEBUG +#ifdef PG_DEBUG showportal(msgtype); - #endif +#endif } int msglen = cr->read_int32(); msgsreceived++; @@ -1743,21 +1742,21 @@ class proxy { array getcols() { int bintext = cr->read_int8(); int cols = cr->read_int16(); - #ifdef PG_DEBUG +#ifdef PG_DEBUG array a; msglen -= 4 + 1 + 2 + 2 * cols; foreach (a = allocate(cols, ([])); ; mapping m) m.type = cr->read_int16(); - #else +#else cr->consume(cols << 1); - #endif // Discard column info, and make it line oriented +#endif // Discard column info, and make it line oriented return ({ ({(["name":"line"])}), ({bintext?BYTEAOID:TEXTOID}) }); }; array(string) reads() { - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (msglen < 1) errtype = PROTOCOLERROR; - #endif +#endif array ret = emptyarray, aw = ({0}); do { string w = cr->read_cstring(); @@ -1806,16 +1805,16 @@ class proxy { break; case 5: PD("MD5Password\n"); - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (msglen < 4) errtype = PROTOCOLERROR; - #endif - #define md5hex(x) String.string2hex(Crypto.MD5.hash(x)) +#endif +#define md5hex(x) String.string2hex(Crypto.MD5.hash(x)) authresponse(({"md5", md5hex(md5hex(pass + user) + cr->read(msglen)), 0})); - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen = 0; - #endif +#endif break; case 6: PD("SCMCredential\n"); @@ -1833,11 +1832,11 @@ class proxy { PD("GSSContinue\n"); errtype = PROTOCOLUNSUPPORTED; cr->read(msglen); // SSauthdata - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (msglen<1) errtype = PROTOCOLERROR; msglen = 0; - #endif +#endif break; case 10: { string word; @@ -1848,11 +1847,11 @@ class proxy { case "SCRAM-SHA-256": k = 1; } - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen -= sizeof(word) + 1; if (msglen < 1) break; - #endif +#endif } if (k) { SASLcontext = Crypto.SHA256.SCRAM(); @@ -1862,11 +1861,11 @@ class proxy { })); } else errtype = PROTOCOLUNSUPPORTED; - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (msglen != 1) errtype = PROTOCOLERROR; msglen = 0; - #endif +#endif break; } case 11: { @@ -1877,9 +1876,9 @@ class proxy { authresponse(response); else errtype = PROTOCOLERROR; - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen = 0; - #endif +#endif break; } case 12: @@ -1888,9 +1887,9 @@ class proxy { SASLcontext = 0; // Clears context and approves server else errtype = PROTOCOLERROR; - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen = 0; - #endif +#endif break; default: PD("Unknown Authentication Method %c\n", authtype); @@ -1909,49 +1908,49 @@ class proxy { case 'K': msglen -= 4 + 4; backendpid = cr->read_int32(); cancelsecret = cr->read(msglen); - #ifdef PG_DEBUG +#ifdef PG_DEBUG PD("BackendKeyData %O\n", cancelsecret); msglen = 0; - #endif +#endif break; case 'S': { PD("ParameterStatus "); msglen -= 4; array(string) ts = reads(); - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (sizeof(ts) == 2) { - #endif +#endif runtimeparameter[ts[0]] = ts[1]; - #ifdef PG_DEBUG +#ifdef PG_DEBUG PD("%O=%O\n", ts[0], ts[1]); } else errtype = PROTOCOLERROR; - #endif +#endif break; } case '3': - #ifdef PG_DEBUG +#ifdef PG_DEBUG PD("CloseComplete\n"); msglen -= 4; - #endif +#endif break; case 'Z': { backendstatus = cr->read_int8(); - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen -= 4 + 1; PD("ReadyForQuery %c\n", backendstatus); - #endif - #ifdef PG_DEBUGMORE +#endif +#ifdef PG_DEBUGMORE showportalstack("READYFORQUERY"); - #endif +#endif int keeplooking; do for (keeplooking = 0; objectp(portal); portal = qportals->read()) { - #ifdef PG_DEBUG +#ifdef PG_DEBUG showportal(msgtype); - #endif +#endif if (backendstatus == 'I' && intransaction && portal->transtype != TRANSEND) keeplooking = 1; @@ -1969,9 +1968,9 @@ class proxy { } } portal = 0; - #ifdef PG_DEBUGMORE +#ifdef PG_DEBUGMORE showportalstack("AFTER READYFORQUERY"); - #endif +#endif readyforquerycount--; if (readyforquery_cb) readyforquery_cb(), readyforquery_cb = 0; @@ -1979,24 +1978,24 @@ class proxy { break; } case '1': - #ifdef PG_DEBUG +#ifdef PG_DEBUG PD("ParseComplete portal %O\n", portal); msglen -= 4; - #endif +#endif break; case 't': { array a; - #ifdef PG_DEBUG +#ifdef PG_DEBUG int cols = cr->read_int16(); PD("%O ParameterDescription %d values\n", portal._query, cols); msglen -= 4 + 2 + 4 * cols; a = cr->read_ints(cols, 4); - #else +#else a = cr->read_ints(cr->read_int16(), 4); - #endif - #ifdef PG_DEBUGMORE +#endif +#ifdef PG_DEBUGMORE PD("%O\n", a); - #endif +#endif if (portal._tprepared) portal._tprepared.datatypeoid = a; Thread.Thread(portal->_preparebind, a); @@ -2005,23 +2004,23 @@ class proxy { case 'T': { array a, at; int cols = cr->read_int16(); - #ifdef PG_DEBUG +#ifdef PG_DEBUG PD("RowDescription %d columns %O\n", cols, portal._query); msglen -= 4 + 2; - #endif +#endif at = allocate(cols); foreach (a = allocate(cols); int i; ) { string s = cr->read_cstring(); mapping(string:mixed) res = (["name":s]); - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen -= sizeof(s) + 1 + 4 + 2 + 4 + 2 + 4 + 2; res.tableoid = cr->read_int32() || UNDEFINED; res.tablecolattr = cr->read_int16() || UNDEFINED; - #else +#else cr->consume(6); - #endif +#endif at[i] = cr->read_int32(); - #ifdef PG_DEBUG +#ifdef PG_DEBUG res.type = at[i]; { int len = cr->read_sint(2); @@ -2033,14 +2032,14 @@ class proxy { * at query time */ res.formatcode = cr->read_int16(); - #else +#else cr->consume(8); - #endif +#endif a[i] = res; } - #ifdef PG_DEBUGMORE +#ifdef PG_DEBUGMORE PD("%O\n", a); - #endif +#endif if (portal._forcetext) portal->_setrowdesc(a, at); // Do not consume queued portal else { @@ -2050,10 +2049,10 @@ class proxy { break; } case 'n': { - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen -= 4; PD("NoData %O\n", portal._query); - #endif +#endif portal._fetchlimit = 0; // disables subsequent Executes portal->_processrowdesc(emptyarray, emptyarray); portal = 0; @@ -2065,10 +2064,10 @@ class proxy { break; case '2': { mapping tp; - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen -= 4; PD("%O BindComplete\n", portal._portalname); - #endif +#endif if (tp = portal._tprepared) { int tend = gethrtime(); int tstart = tp.trun; @@ -2094,58 +2093,58 @@ class proxy { } case 'D': msglen -= 4; - #ifdef PG_DEBUG - #ifdef PG_DEBUGMORE +#ifdef PG_DEBUG +#ifdef PG_DEBUGMORE PD("%O DataRow %d bytes\n", portal._portalname, msglen); - #endif +#endif datarowdebugcount++; if (!datarowdebug) datarowdebug = sprintf( "%O DataRow %d bytes", portal._portalname, msglen); - #endif - #ifdef PG_DEBUG +#endif +#ifdef PG_DEBUG msglen= - #endif +#endif portal->_decodedata(msglen, runtimeparameter[CLIENT_ENCODING]); break; case 's': - #ifdef PG_DEBUG +#ifdef PG_DEBUG PD("%O PortalSuspended\n", portal._portalname); msglen -= 4; - #endif +#endif portal = 0; break; case 'C': { msglen -= 4; - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (msglen < 1) errtype = PROTOCOLERROR; - #endif +#endif string s = cr->read(msglen - 1); portal->_storetiming(); PD("%O CommandComplete %O\n", portal._portalname, s); - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (cr->read_int8()) errtype = PROTOCOLERROR; msglen = 0; - #else +#else cr->consume(1); - #endif - #ifdef PG_DEBUGMORE +#endif +#ifdef PG_DEBUGMORE showportalstack("COMMANDCOMPLETE"); - #endif +#endif portal->_releasesession(s); portal = 0; break; } case 'I': - #ifdef PG_DEBUG +#ifdef PG_DEBUG PD("EmptyQueryResponse %O\n", portal._portalname); msglen -= 4; - #endif - #ifdef PG_DEBUGMORE +#endif +#ifdef PG_DEBUGMORE showportalstack("EMPTYQUERYRESPONSE"); - #endif +#endif portal->_releasesession(); portal = 0; break; @@ -2153,14 +2152,14 @@ class proxy { PD("%O CopyData\n", portal._portalname); portal->_storetiming(); msglen -= 4; - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (msglen < 0) errtype = PROTOCOLERROR; - #endif +#endif portal->_processdataready(({cr->read(msglen)}), msglen); - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen = 0; - #endif +#endif break; case 'G': portal->_releasestatement(); @@ -2169,16 +2168,16 @@ class proxy { portal._state = COPYINPROGRESS; break; case 'c': - #ifdef PG_DEBUG +#ifdef PG_DEBUG PD("%O CopyDone\n", portal._portalname); msglen -= 4; - #endif +#endif portal = 0; break; case 'E': { - #ifdef PG_DEBUGMORE +#ifdef PG_DEBUGMORE showportalstack("ERRORRESPONSE"); - #endif +#endif if (portalsinflight->drained() && !readyforquerycount) sendsync(); PD("%O ErrorResponse %O\n", @@ -2251,13 +2250,13 @@ class proxy { { array(string) ts = reads(); switch (sizeof(ts)) { - #if PG_DEBUG +#if PG_DEBUG case 0: errtype = PROTOCOLERROR; break; default: errtype = PROTOCOLERROR; - #endif +#endif case 2: extrainfo = ts[1]; case 1: @@ -2273,9 +2272,9 @@ class proxy { string s; PD("Unknown message received %c\n", msgtype); s = cr->read(msglen -= 4); PD("%O\n", s); - #ifdef PG_DEBUG +#ifdef PG_DEBUG msglen = 0; - #endif +#endif errtype = PROTOCOLUNSUPPORTED; } else { lastmessage += ({ @@ -2288,10 +2287,10 @@ class proxy { } break; } - #ifdef PG_DEBUG +#ifdef PG_DEBUG if (msglen) errtype = PROTOCOLERROR; - #endif +#endif { string msg; switch (errtype) { @@ -2322,9 +2321,9 @@ class proxy { or = this; if (!or.delayederror) or.delayederror = err; - #ifdef PG_DEBUGMORE +#ifdef PG_DEBUGMORE showportalstack("THROWN"); - #endif +#endif if (objectp(portal)) portal->_releasesession(); portal = 0; @@ -2336,9 +2335,9 @@ class proxy { PD("Closing database processloop %s\n", err ? describe_backtrace(err) : ""); delayederror = err; if (objectp(portal)) { - #ifdef PG_DEBUG +#ifdef PG_DEBUG showportal(0); - #endif +#endif portal->_purgeportal(); } destruct(waitforauthready); -- GitLab