mirror of
https://github.com/bjc/prosody.git
synced 2025-04-04 21:57:45 +03:00
util.sql: Greedily read all rows so we can close queries early (fixes #391)
This commit is contained in:
parent
15ee257b35
commit
c5af3aee3e
1 changed files with 5 additions and 1 deletions
|
@ -175,7 +175,11 @@ function engine:execute_query(sql, ...)
|
||||||
sql = self:prepquery(sql);
|
sql = self:prepquery(sql);
|
||||||
local stmt = assert(self.conn:prepare(sql));
|
local stmt = assert(self.conn:prepare(sql));
|
||||||
assert(stmt:execute(...));
|
assert(stmt:execute(...));
|
||||||
return stmt:rows();
|
local result = {};
|
||||||
|
for row in stmt:rows() do result[#result + 1] = row; end
|
||||||
|
stmt:close();
|
||||||
|
local i = 0;
|
||||||
|
return function() i=i+1; return result[i]; end;
|
||||||
end
|
end
|
||||||
function engine:execute_update(sql, ...)
|
function engine:execute_update(sql, ...)
|
||||||
sql = self:prepquery(sql);
|
sql = self:prepquery(sql);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue