pike.git/
lib/
modules/
Sql.pmod/
pgsql_util.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2018-05-26
2018-05-26 13:51:31 by Stephen R. van den Berg <srb@cuci.nl>
b901be1634dc884d60c42d020b432f225d6876ba (
74
lines) (+
40
/-
34
)
[
Show
|
Annotate
]
Branch:
8.0
pgsql: Improve _sprintf() formatting.
802:
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; }
852:
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
1110:
} 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));
1853:
} 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 = ({
1915:
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");