Skip to content

Commit 5ecf985

Browse files
committed
Use pg_last_wal_replay_lsn and pg_last_wal_receive_lsn for PostgreSQL 10
1 parent bea0469 commit 5ecf985

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/backup.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -959,15 +959,27 @@ wait_replica_wal_lsn(XLogRecPtr lsn, bool is_start_backup)
959959
* data.
960960
*/
961961
if (is_start_backup)
962-
res = pgut_execute(backup_conn, "SELECT pg_last_xlog_replay_location()",
963-
0, NULL);
962+
{
963+
if (server_version >= 100000)
964+
res = pgut_execute(backup_conn, "SELECT pg_last_wal_replay_lsn()",
965+
0, NULL);
966+
else
967+
res = pgut_execute(backup_conn, "SELECT pg_last_xlog_replay_location()",
968+
0, NULL);
969+
}
964970
/*
965971
* For lsn from pg_stop_backup() we need it only to be received by
966972
* replica and fsync()'ed on WAL segment.
967973
*/
968974
else
969-
res = pgut_execute(backup_conn, "SELECT pg_last_xlog_receive_location()",
970-
0, NULL);
975+
{
976+
if (server_version >= 100000)
977+
res = pgut_execute(backup_conn, "SELECT pg_last_wal_receive_lsn()",
978+
0, NULL);
979+
else
980+
res = pgut_execute(backup_conn, "SELECT pg_last_xlog_receive_location()",
981+
0, NULL);
982+
}
971983

972984
/* Extract timeline and LSN from result */
973985
XLogDataFromLSN(PQgetvalue(res, 0, 0), &xlogid, &xrecoff);

0 commit comments

Comments
 (0)