* Delete unresolved-ref rows by row id — the precise cleanup for refs a * resolution pass actually processed. The key-tuple variant above also * deletes SIBLING rows (same caller calling the same callee at other lines) * that a later batch hasn't attempted yet, so when a batch boundary spli
(rowIds: number[])
| 4920 | * created (#1269). |
| 4921 | */ |
| 4922 | deleteReferencesByRowIds(rowIds: number[]): number { |
| 4923 | if (rowIds.length === 0) return 0; |
| 4924 | // One transaction for all chunks (each chunk was previously its own |
| 4925 | // implicit transaction = its own WAL commit — measurable on 100k+-ref |
| 4926 | // resolution persists), and the full-size chunk statement is cached so |
| 4927 | // repeat calls skip the re-prepare; only the final partial chunk (if any) |
| 4928 | // prepares ad hoc. Returns rows actually removed (summed `changes`) for |
| 4929 | // the batched loop's non-progress guard (§7a.2). |
| 4930 | let changed = 0; |
| 4931 | this.db.transaction(() => { |
| 4932 | for (let i = 0; i < rowIds.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 4933 | const chunk = rowIds.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 4934 | if (chunk.length === SQLITE_PARAM_CHUNK_SIZE) { |
| 4935 | if (!this.stmts.deleteRefsByRowIdsFull) { |
| 4936 | const placeholders = new Array(SQLITE_PARAM_CHUNK_SIZE).fill('?').join(','); |
| 4937 | this.stmts.deleteRefsByRowIdsFull = this.db.prepare( |
| 4938 | `DELETE FROM unresolved_refs WHERE id IN (${placeholders})` |
| 4939 | ); |
| 4940 | } |
| 4941 | changed += this.stmts.deleteRefsByRowIdsFull.run(...chunk).changes; |
| 4942 | } else { |
| 4943 | const placeholders = chunk.map(() => '?').join(','); |
| 4944 | changed += this.db.prepare(`DELETE FROM unresolved_refs WHERE id IN (${placeholders})`).run(...chunk).changes; |
| 4945 | } |
| 4946 | } |
| 4947 | })(); |
| 4948 | return changed; |
| 4949 | } |
| 4950 | |
| 4951 | /** |
| 4952 | * Mark refs a completed resolution pass could not resolve as status='failed' |
no test coverage detected