mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-15 09:10:32 +00:00
Implement DBAPI2's `executemany`, which Synapse uses for batched writes. The statement is prepared once and run for each parameter set inside the connection's (lazily opened) transaction, so a failure part-way aborts the whole batch. The per-set executions are pipelined — their futures are driven concurrently so tokio_postgres streams the batch onto the connection in one round-trip rather than one per statement. Afterwards `rowcount` reports the total rows affected across all executions (as psycopg2 does) via a new fetchless "command complete" cursor state; there is no result set to fetch or describe. An empty parameter sequence is a no-op that leaves rowcount at -1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>