postgres.git / summary / log / commit / refs
commit 3c5a4dcaaa8d5bef429bd8143d1a6e9f92fa0b74
Author: Michael Paquier <michael@paquier.xyz>
Date: Fri Nov 06 05:01:31 2026 +0000
pgrowlocks: Reject unlogged and temp tables during recovery
Unlogged and temporary tables have no data on a standby, and attempting
to use pgrowlocks() in this case led to this failure:
ERROR: could not open file "base/MMM/NNN": No such file or directory
These cases are now checked, failing with a proper failure. Temporary
tables from other sessions cannot be accessed, as the streaming read
APIs prevent that already.
Author: Jim Jones <jim.jones@uni-muenster.de>
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Discussion: https://postgr.es/m/82ba0876-6127-4770-b900-aa1bd52abfed@uni-muenster.de
contrib/pgrowlocks/pgrowlocks.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 87bbde59937..71d67254d65 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -29,6 +29,7 @@
#include "access/relscan.h"
#include "access/tableam.h"
#include "access/xact.h"
+#include "access/xlog.h"
#include "catalog/namespace.h"
#include "catalog/pg_am_d.h"
#include "catalog/pg_authid.h"
@@ -114,6 +115,11 @@ pgrowlocks(PG_FUNCTION_ARGS)
aclcheck_error(aclresult, get_relkind_objtype(rel->rd_rel->relkind),
RelationGetRelationName(rel));
+ if (!RelationIsPermanent(rel) && RecoveryInProgress())
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot access temporary or unlogged relations during recovery")));
+
/* Scan the relation */
scan = table_beginscan(rel, GetActiveSnapshot(), 0, NULL, SO_NONE);
hscan = (HeapScanDesc) scan;
[parent: 46ed1b831fa1]