pike.git/
lib/
modules/
Sql.pmod/
pgsql_util.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2018-05-07
2018-05-07 08:44:10 by Stephen R. van den Berg <srb@cuci.nl>
42dcee42d66b82af82c52f666a2085e16d33574d (
44
lines) (+
27
/-
17
)
[
Show
|
Annotate
]
Branch:
master
pgsql: affected_rows() now preserves as of yet unfetched rows.
798:
//! Returns the command-complete status for this query. //!
-
//! @note
-
//! This method should normally be called after EOF has been reached.
-
//! If it is called before, all unfetched result rows will be discarded.
-
//!
+
//! @seealso
-
//! @[
affected_rows
()
], @[eof
()]
+
//! @[
Sql.Result
()
->status_command_complete
()]
/*semi*/final string status_command_complete() {
-
+
if (!statuscmdcomplete) {
+
if (!datarowtypes)
+
waitfordescribe();
+
{
+
Thread.MutexKey lock = closemux->lock();
+
if (_fetchlimit)
+
_sendexecute(_fetchlimit = 0);
+
lock = _ddescribemux->lock();
if (!statuscmdcomplete)
-
while
(
fetch
_
row_array
());
+
PT
(_
ddescribe->wait
(
lock
));
+
}
+
if (this) // If object already destructed, skip the next call
+
trydelayederror(); // since you cannot call functions anymore
+
else
+
error(LOSTERROR);
+
}
return statuscmdcomplete; } //! Returns the number of affected rows by this query. //!
-
//! @note
-
//! This method should normally be called after EOF has been reached.
-
//! If it is called before, all unfetched result rows will be discarded.
-
//!
+
//! @seealso
-
//! @[
status_command_complete
()
], @[eof
()]
+
//! @[
Sql.Result
()
->affected_rows
()]
/*semi*/final int affected_rows() { int rows;
-
sscanf(status_command_complete(), "%*s %d %d", rows, rows);
+
sscanf(status_command_complete()
|| ""
, "%*s %d %d", rows, rows);
return rows; }
1563:
final void _releasesession(void|string statusccomplete) { c->runningportals[this] = 0;
-
if (statusccomplete && !statuscmdcomplete)
+
if (statusccomplete && !statuscmdcomplete)
{
+
Thread.MutexKey lock = _ddescribemux->lock();
statuscmdcomplete = statusccomplete;
-
+
_ddescribe->broadcast();
+
}
inflight = 0; conxsess plugbuffer; if (!catch(plugbuffer = c->start()))
2641:
final void close() { throwdelayederror(this); {
-
Thread.MutexKey lock
;
-
while (qportals && qportals
->
size
()
)
-
sleep
(
0.1, 1
);
// Drain portal queue to completion
+
Thread.MutexKey lock
=
shortmux
->
lock
()
;
+
portalsinflight->wait_till_drained
(
lock
);
//
Drain
portal
queue
to
completion
+
lock
=
0;
if (unnamedstatement) termlock = unnamedstatement->lock(1); if (c) // Prevent trivial backtraces