pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Refactor XLogReadRecord(), adding XLogBeginRead() function.
Date: Sun, 26 Jan 2020 09:39:48 +0000
Message-ID: <E1iveOS-0007si-1M@gemulon.postgresql.org> (raw)

Refactor XLogReadRecord(), adding XLogBeginRead() function.

The signature of XLogReadRecord() required the caller to pass the starting
WAL position as argument, or InvalidXLogRecPtr to continue reading at the
end of previous record. That's slightly awkward to the callers, as most
of them don't want to randomly jump around in the WAL stream, but start
reading at one position and then read everything from that point onwards.
Remove the 'RecPtr' argument and add a new function XLogBeginRead() to
specify the starting position instead. That's more convenient for the
callers. Also, xlogreader holds state that is reset when you change the
starting position, so having a separate function for doing that feels like
a more natural fit.

This changes XLogFindNextRecord() function so that it doesn't reset the
xlogreader's state to what it was before the call anymore. Instead, it
positions the xlogreader to the found record, like XLogBeginRead().

Reviewed-by: Kyotaro Horiguchi, Alvaro Herrera
Discussion: https://www.postgresql.org/message-id/5382a7a3-debe-be31-c860-cb810c08f366%40iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/38a957316d7e46d4b00de40f43966984a463d80a

Modified Files
--------------
src/backend/access/transam/twophase.c          |  3 +-
src/backend/access/transam/xlog.c              | 36 ++++++------
src/backend/access/transam/xlogreader.c        | 79 ++++++++++++++++----------
src/backend/replication/logical/logical.c      |  7 +--
src/backend/replication/logical/logicalfuncs.c | 14 +----
src/backend/replication/slotfuncs.c            | 13 +----
src/backend/replication/walsender.c            |  8 +--
src/bin/pg_rewind/parsexlog.c                  | 15 +++--
src/bin/pg_waldump/pg_waldump.c                |  5 +-
src/include/access/xlogreader.h                | 19 ++++---
10 files changed, 102 insertions(+), 97 deletions(-)



Message-ID: <E1iveOS-0007si-1M@gemulon.postgresql.org>
Permalink:  ../E1iveOS-0007si-1M@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iveOS-0007si-1M@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Refactor XLogReadRecord(), adding XLogBeginRead() function.
  In-Reply-To: <E1iveOS-0007si-1M@gemulon.postgresql.org>
  References: <E1iveOS-0007si-1M@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox