Push operation rows in a loop, not a spread

Spreading a large RETURNING * result into push() overflowed the call
stack on scale, recode and clone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Paul Trowbridge 2026-10-05 21:11:21 -04:00
parent f8b935d03f
commit 1c40e5b7b0

View File

@ -905,7 +905,7 @@ module.exports = function(pool) {
for (const unit of units) {
const incr = await resolveIncrs(client, ctx, unit.where, excludeClause, req.body);
// no rows, or already at the target — nothing to write for this slice
if (incr.value === 0 && incr.units === 0) { skipped.push(...unit.slices); continue; }
if (incr.value === 0 && incr.units === 0) { for (const s of unit.slices) skipped.push(s); continue; }
applied++;
const loggedSlice = unit.slices.length === 1 ? unit.slices[0] : unit.slices;
@ -933,7 +933,7 @@ module.exports = function(pool) {
for (const r of result.rows) {
if (r.pf_logid != null) sqlByLogId.set(r.pf_logid, sql);
}
allRows.push(...result.rows);
for (const r of result.rows) allRows.push(r);
}
if (allRows.length === 0) {
@ -1041,7 +1041,7 @@ module.exports = function(pool) {
for (const r of result.rows) {
if (r.pf_logid != null) sqlByLogId.set(r.pf_logid, sql);
}
allRows.push(...result.rows);
for (const r of result.rows) allRows.push(r);
}
// Every coordinate in the selection nets to zero -- nothing to move.
// Refused like scale's no-op rather than committing an empty log
@ -1161,7 +1161,7 @@ module.exports = function(pool) {
for (const r of result.rows) {
if (r.pf_logid != null) sqlByLogId.set(r.pf_logid, sql);
}
allRows.push(...result.rows);
for (const r of result.rows) allRows.push(r);
}
await client.query('COMMIT');
committed = true;