Add GetWALInsertionTimeLine(); also return it via GetFlushRecPtr().
authorRobert Haas <rhaas@postgresql.org>
Fri, 29 Oct 2021 20:03:16 +0000 (16:03 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 29 Oct 2021 21:05:21 +0000 (17:05 -0400)
commitc00f605ab03aec7df21eff0f098751837f2ba935
treef395f1959a987ccb242114cae0f1b5e2e13ec19c
parent082b1b87a32b4690644014bcb43a492551eae01e
Add GetWALInsertionTimeLine(); also return it via GetFlushRecPtr().

Having lots of code that relies on the ThisTimeLineID global variable
is problematic, but to have any chance of fixing that, we must provide
another way for code outside xlog.c to get the relevant value. This
commit adds infrastructure for doing that on a system that is in
normal running, but doesn't do anything about the case where the
system is in recovery.

Here, we provide two different methods for getting the timeline of
a system in normal running. First, a number of the places where we
call GetFlushRecPtr() need the timeline as well, so provide it via
an out parameter. Second, for other places that just need the
timeline and not any LSN, add a GetWALInsertionTimeLine() function.

Future commits will take care of actually removing references to
ThisTimeLineID; this commit is just infrastructure.
src/backend/access/transam/xlog.c
src/backend/access/transam/xlogfuncs.c
src/backend/access/transam/xlogutils.c
src/backend/replication/logical/logicalfuncs.c
src/backend/replication/logical/worker.c
src/backend/replication/slotfuncs.c
src/backend/replication/walsender.c
src/include/access/xlog.h