diff --git a/ts/sql/main.ts b/ts/sql/main.ts index 49dc6fb59..b34802e25 100644 --- a/ts/sql/main.ts +++ b/ts/sql/main.ts @@ -254,10 +254,11 @@ export class MainSQL { }>; // pageMessages runs over several queries and needs to have access to - // the same temporary table. + // the same temporary table, it also creates temporary insert/update + // triggers so it has to run on the same connection that updates the tables const isPaging = PAGING_QUERIES.has(method); - const entry = isPaging ? this.#pool.at(-1) : this.#getWorker(); + const entry = isPaging ? this.#pool[0] : this.#getWorker(); strictAssert(entry != null, 'Must have a pool entry'); const { result, duration } = await this.#send(entry, {