• Michael Paquier's avatar
    Add pg_relation_check_pages() to check on-disk pages of a relation · f2b88396
    Michael Paquier authored
    This makes use of CheckBuffer() introduced in c780a7a9, adding a SQL
    wrapper able to do checks for all the pages of a relation.  By default,
    all the fork types of a relation are checked, and it is possible to
    check only a given relation fork.  Note that if the relation given in
    input has no physical storage or is temporary, then no errors are
    generated, allowing full-database checks when coupled with a simple scan
    of pg_class for example.  This is not limited to clusters with data
    checksums enabled, as clusters without data checksums can still apply
    checks on pages using the page headers or for the case of a page full of
    zeros.
    
    This function returns a set of tuples consisting of:
    - The physical file where a broken page has been detected (without the
    segment number as that can be AM-dependent, which can be guessed from
    the block number for heap).  A relative path from PGPATH is used.
    - The block number of the broken page.
    
    By default, only superusers have an access to this function but
    execution rights can be granted to other users.
    
    The feature introduced here is still minimal, and more improvements
    could be done, like:
    - Addition of a start and end block number to run checks on a range
    of blocks, which would apply only if one fork type is checked.
    - Addition of some progress reporting.
    - Throttling, with configuration parameters in function input or
    potentially some cost-based GUCs.
    
    Regression tests are added for positive cases in the main regression
    test suite, and TAP tests are added for cases involving the emulation of
    page corruptions.
    
    Bump catalog version.
    
    Author: Julien Rouhaud, Michael Paquier
    Reviewed-by: Masahiko Sawada, Justin Pryzby
    Discussion: https://postgr.es/m/CAOBaU_aVvMjQn=ge5qPiJOPMmOj5=ii3st5Q0Y+WuLML5sR17w@mail.gmail.com
    f2b88396
system_views.sql 55.3 KB