pgsql: Extend PageIsVerified() to handle more custom options

Started by Michael Paquieralmost 6 years ago5 messagescomitters
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t220217
psql -h localhost -U postgres

Built from patchset v3 (message #3), July 29, 2026 at 12:53 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t220217_3 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t220217_3 && git checkout t220217_3

Patchset v3 (message #3) is on t220217_3

Jump to latest
#1Michael Paquier
michael@paquier.xyz

Extend PageIsVerified() to handle more custom options

This is useful for checks of relation pages without having to load the
pages into the shared buffers, and two cases can make use of that: page
verification in base backups and the online, lock-safe, flavor.

Compatibility is kept with past versions using a macro that calls the
new extended routine with the set of options compatible with the
original version.

Extracted from a larger patch by the same author.

Author: Anastasia Lubennikova
Reviewed-by: Michael Paquier, Julien Rouhaud
Discussion: /messages/by-id/608f3476-0598-2514-2c03-e05c7d2b0cbd@postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d401c5769ef6aeef0a28c147f3fb5afedcd59984

Modified Files
--------------
src/backend/catalog/storage.c | 3 ++-
src/backend/storage/buffer/bufmgr.c | 6 ++++--
src/backend/storage/page/bufpage.c | 22 +++++++++++++++-------
src/include/storage/bufpage.h | 22 ++++++++++++++++------
4 files changed, 37 insertions(+), 16 deletions(-)

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Michael Paquier (#1)
Re: pgsql: Extend PageIsVerified() to handle more custom options

On 2020-Oct-26, Michael Paquier wrote:

Extend PageIsVerified() to handle more custom options

This is useful for checks of relation pages without having to load the
pages into the shared buffers, and two cases can make use of that: page
verification in base backups and the online, lock-safe, flavor.

Compatibility is kept with past versions using a macro that calls the
new extended routine with the set of options compatible with the
original version.

Please remember that in the macro definition, the arguments should be
enclosed in parens. No bug here at present, but it seems better to be
cautious.

#3Michael Paquier
michael@paquier.xyz
In reply to: Alvaro Herrera (#2)
Re: pgsql: Extend PageIsVerified() to handle more custom options

On Mon, Oct 26, 2020 at 11:39:33AM -0300, Alvaro Herrera wrote:

Please remember that in the macro definition, the arguments should be
enclosed in parens. No bug here at present, but it seems better to be
cautious.

Indeed, I can see similar changes in the history of the tree. Do you
think that doing something like the attached is sufficient?
--
Michael

Attachments:

t220217_3
bufpage-macro.patchtext/x-diff; charset=us-asciiDownload+1-1
#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Paquier (#3)
Re: pgsql: Extend PageIsVerified() to handle more custom options

Michael Paquier <michael@paquier.xyz> writes:

On Mon, Oct 26, 2020 at 11:39:33AM -0300, Alvaro Herrera wrote:

Please remember that in the macro definition, the arguments should be
enclosed in parens. No bug here at present, but it seems better to be
cautious.

Indeed, I can see similar changes in the history of the tree. Do you
think that doing something like the attached is sufficient?

Hm, I suspect what Alvaro meant was

 #define PageIsVerified(page, blkno) \
- 	PageIsVerifiedExtended(page, blkno, \
+ 	PageIsVerifiedExtended((page), (blkno), \

But IMV that's not necessary: if the argument parsed as a single
function/macro argument before, it still will do so. The places
where you have to be careful to add parentheses are where the
macro argument is used as part of a larger expression that is
not just a function/macro argument.

regards, tom lane

#5Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#4)
Re: pgsql: Extend PageIsVerified() to handle more custom options

On Mon, Oct 26, 2020 at 09:29:46PM -0400, Tom Lane wrote:

Hm, I suspect what Alvaro meant was

#define PageIsVerified(page, blkno) \
- 	PageIsVerifiedExtended(page, blkno, \
+ 	PageIsVerifiedExtended((page), (blkno), \

But IMV that's not necessary: if the argument parsed as a single
function/macro argument before, it still will do so. The places
where you have to be careful to add parentheses are where the
macro argument is used as part of a larger expression that is
not just a function/macro argument.

Thanks. I really thought that this remark was for the bit-flag
argument for readability reasons, not the two others as we don't do
that in other places (varbit.h, bufpage.h, timestamp.h, brin_page.h,
etc.). Perhaps I just missed the point.
--
Michael