postgres.git / summary / log / commit / refs

commit    391fded1e563692f0ca14b9bd53d33e2e72783a6
Author:   Masahiko Sawada <msawada@postgresql.org>
Date:     Wed Oct 21 18:10:46 2026 +0000
First released in: 14.25, 15.20, 16.16, 17.12, 18.7, 19.0

    Reject currtid2() on unlogged tables during recovery.
    
    Commit 1e707d32564 made COPY TO report a proper error for unlogged
    tables during recovery. currtid2() has the same problem: it reads the
    table directly without going through the planner, so on a standby it
    failed with a low-level error for an unlogged table:
    
    ERROR:  could not open file "base/5/16384": No such file or directory
    
    Check for this case and report the same error as SELECT. No test is
    added, as currtid2() is an undocumented internal function.
    
    Backpatch to all supported versions, like commit 1e707d32564.
    
    Reported-by: Masahiko Sawada <sawada.mshk@gmail.com>
    Author: Jim Jones <jim.jones@uni-muenster.de>
    Discussion: https://postgr.es/m/CAD21AoDNa7pL760_23AN_wYPMkWXCt+Kw0_vJAcci4R5DoCQGg@mail.gmail.com
    Backpatch-through: 14


src/backend/utils/adt/tid.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index 77fb74ab0c1..11ffeb4c685 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -23,6 +23,7 @@ #include "access/heapam.h" #include "access/sysattr.h" #include "access/tableam.h" +#include "access/xlog.h" #include "catalog/namespace.h" #include "catalog/pg_type.h" #include "common/hashfn.h" @@ -316,6 +317,12 @@ currtid_internal(Relation rel, ItemPointer tid) get_namespace_name(RelationGetNamespace(rel)), RelationGetRelationName(rel)); + /* Temporary and unlogged relations are inaccessible during recovery. */ + if (!RelationIsPermanent(rel) && RecoveryInProgress()) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot access temporary or unlogged relations during recovery"))); + ItemPointerCopy(tid, result); snapshot = RegisterSnapshot(GetLatestSnapshot()); [parent: 044887b60812]