pike.git
/
lib
/
modules
/
Sql.pmod
/
pgsql_util.pmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:795:
private function(:void) gottimeout; private int timeout; protected string _sprintf(int type) { string res; switch (type) { case 'O': int fd = -1; if (c && c->socket) catch(fd = c->socket->query_fd());
-
res = sprintf("sql_result state: %d numrows: %d eof: %d inflight: %d\n"
-
"
query
: %O\n"
+
res = sprintf(
+
"sql_result state: %d numrows: %d eof: %d inflight: %d\n"
+
"
fd
: %
O portalname: %O coltypes: %d"
+
" synctransact: %d laststatus: %s\n"
+
"stash: %
O\n"
#if PG_DEBUGHISTORY > 0 "history: %O\n"
-
"stash: %O\n"
+
#endif
-
"fd:
%O
portalname: %O datarows: %d
"
-
" synctransact
: %
d laststatus:
%s\n",
+
"
query
: %
O\n
%s\n",
_state, index, eoffound, inflight,
-
qalreadyprinted == this ? "..." : _query,
-
#if PG_DEBUGHISTORY > 0
-
qalreadyprinted == this ? 0 : c && c->i->history,
-
qalreadyprinted == this ? 0
-
: c && (string)c->stash,
-
#endif
+
fd, _portalname, datarowtypes && sizeof(datarowtypes), _synctransact, statuscmdcomplete
-
|| (_unnamedstatementkey ? "*parsing*" : ""));
+
|| (_unnamedstatementkey ? "*parsing*" : "")
,
+
qalreadyprinted == this ? 0
+
: c && (string
)
c->stash,
+
#if PG_DEBUGHISTORY > 0
+
qalreadyprinted == this ? 0 : c && c->i->history,
+
#endif
+
qalreadyprinted == this
+
? "..." : replace(_query, "xxxx\n", "\\n"),
+
qalreadyprinted == this ? "..." : _showbindings()*"\n")
;
qalreadyprinted = this; break; } return res; } protected void create(proxy _pgsqlsess, conxion _c, string query, int _portalbuffersize, int alltyped, array params, int forcetext, int _timeout, int _syncparse, int _transtype) { pgsqlsess = _pgsqlsess;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:845:
_params = params; _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;
+
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))});
+
}
+
}
+
return msgs;
+
}
+
//! Returns the command-complete status for this query. //! //! @note //! This function is PostgreSQL-specific. //! //! @seealso //! @[affected_rows()] /*semi*/final string status_command_complete() { if (!statuscmdcomplete) { if (!datarowtypes)
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1103:
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] : emptyarray;
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:1846:
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(sql_result portal) {
-
array(string)
msgs = emptyarray;
-
array from;
-
if (
portal
&&
(from =
portal._
params)) {
-
array to, paramValues;
-
[from, to, paramValues] = from;
-
if
(
sizeof(paramValues
)
)
{
-
string val
;
-
int i;
-
string fmt = sprintf("%%%ds %%3s %%.61s", max(@map(from, sizeof)));
-
foreach (paramValues; i; val)
-
msgs += ({sprintf(fmt, from[i], to[i], sprintf("%O", val))});
+
return
portal
?
portal._
showbindings
()
:
emptyarray
;
}
-
}
-
return msgs;
-
}
+
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||"")}); } private int|sql_result portal; // state information procmessage
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1908:
cs->sendcmd(SENDOUT); } } // Do not flush at this point, PostgreSQL 9.4 disapproves procmessage(); } private void procmessage() { mixed err; int terminating = 0; err = catch {
-
conxion ci = c; // cache value
FIXME sensible?
-
conxiin cr = ci->i; // cache value
FIXME sensible?
+
conxion ci = c; // cache value
+
conxiin cr = ci->i; // cache value
#ifdef PG_DEBUG PD("Processloop\n"); #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"); };