At Wed, 18 Nov 2020 15:05:00 +0300, a.pervushina@postgrespro.ru wrote in > I've changed the BEGIN WAIT FOR LSN statement to core functions > pg_waitlsn, pg_waitlsn_infinite and pg_waitlsn_no_wait. > Currently the functions work inside repeatable read transactions, but > waitlsn creates a snapshot if called first in a transaction block, > which can possibly lead the transaction to working incorrectly, so the > function gives a warning.
According to the discuttion here, implementing as functions is not optimal. As a Poc, I made it as a procedure. However I'm not sure it is the correct implement as a native procedure but it seems working as expected.
The first and second usage is coverd by a single procedure. The last function is equivalent to pg_last_wal_replay_lsn(). As the result, the following procedure is provided in the attached.