Thank you for the detailed explanation! I doubt many people from -general would actually be able to provide such info since the spirit of that list is to find work-arounds for problems and questions at user level rather than dig into the details on how something actually works.
It's worth adding to the documentation, with that exact example BTW: https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-BACKUP-TABLE (I can try submitting a docs PR if you think it's a good idea). Also, when I said that we use PQexec, I did it just for an illustration: in practice we use the node-postgres JS library which sends multi-statement protocol messages. So - transaction wise - it works the same way as PQexec with multiple queries, but it returns responses for ALL queries in the batch, not just for the last one (very convenient BTW, saves on network round-trip latency). This mode is fully supported by PG wire protocol: https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT On Wed, Aug 3, 2022 at 12:32 AM Kyotaro Horiguchi <horikyota....@gmail.com> wrote: > > <snip> > =# select pg_current_wal_insert_lsn(); > pg_current_wal_insert_lsn > --------------------------- > 0/*68E5038* > (1 row) > =# insert into t values(0)\; select pg_current_wal_lsn(); > INSERT 0 1 > pg_current_wal_lsn > -------------------- > 0/*68E5038* > (1 row) > =# select pg_current_wal_insert_lsn(); > pg_current_wal_insert_lsn > --------------------------- > 0/68E50A0 > (1 row) <snip> > > =# select pg_current_wal_insert_lsn(); > pg_current_wal_insert_lsn > --------------------------- > 0/*68E75C8* > (1 row) > =# begin\;insert into t values(0)\;commit\; select pg_current_wal_lsn(); > pg_current_wal_lsn > -------------------- > 0/*68E7958* >