Streaming replication and pg_xlogfile_name()
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>, Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Date: 2010-01-19T09:35:06Z
Lists: pgsql-hackers
Hi, In relation to the functions added recently, I found an annoying problem; pg_xlogfile_name(pg_last_xlog_receive/replay_location()) might report the wrong name because pg_xlogfile_name() always uses the current timeline, and a backend doesn't know the actual timeline related to the location which pg_last_xlog_receive/replay_location() reports. Even if a backend knows that, pg_xlogfile_name() would be unable to determine which timeline should be used. To solve this problem, I'm thiking to add the following functions: * pg_current_timeline() reports the current timeline ID. * pg_last_receive_timeline() reports the timeline ID which is related to the last WAL receive location. * pg_last_replay_timeline() reports the timeline ID which is related to the last WAL replay location. * pg_xlogfile_name(location text [, timeline bigint ]) reports the WAL file name using the given timeline. By default, the current timeline is used. * pg_xlogfile_name_offset(location text [, timeline bigint]) reports the WAL file name and offset using the given timeline. By default, the current timeline is used. If the second parameter is omitted, pg_xlogfile_name() would behave as it does now. We can get the right WAL file name by giving it the result of pg_last_receive/replay_timeline(). Thought? Or we should just drop the support of pg_xlogfile_name() for pg_last_xlog_receive/replay_locadtion()? Regards, -- Fujii Masao NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center