From: Alexander Korotkov Date: Mon, 6 Apr 2026 19:27:36 +0000 (+0300) Subject: Avoid syscache lookup while building a WAIT FOR tuple descriptor X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=834038c1f8d52f51666c60ec774bbbf590f4e8c6;p=thirdparty%2Fpostgresql.git Avoid syscache lookup while building a WAIT FOR tuple descriptor Use TupleDescInitBuiltinEntry instead of TupleDescInitEntry when building the result tuple descriptor for the WAIT FOR command. This avoids a syscache access that could re-establish a catalog snapshot after we've explicitly released all snapshots before the wait. Discussion: https://postgr.es/m/CABPTF7U%2BSUnJX_woQYGe%3D%3DR9Oz%2B-V6X0VO2stBLPGfJmH_LEhw%40mail.gmail.com Author: Xuneng Zhou Reviewed-by: Alexander Korotkov --- diff --git a/src/backend/commands/wait.c b/src/backend/commands/wait.c index e64e3be6285..85fcd463b4c 100644 --- a/src/backend/commands/wait.c +++ b/src/backend/commands/wait.c @@ -335,10 +335,17 @@ WaitStmtResultDesc(WaitStmt *stmt) { TupleDesc tupdesc; - /* Need a tuple descriptor representing a single TEXT column */ + /* + * Need a tuple descriptor representing a single TEXT column. + * + * We use TupleDescInitBuiltinEntry instead of TupleDescInitEntry to avoid + * syscache access. This is important because WaitStmtResultDesc may be + * called after snapshots have been released, and we must not re-establish + * a catalog snapshot which could cause recovery conflicts on a standby. + */ tupdesc = CreateTemplateTupleDesc(1); - TupleDescInitEntry(tupdesc, (AttrNumber) 1, "status", - TEXTOID, -1, 0); + TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, "status", + TEXTOID, -1, 0); TupleDescFinalize(tupdesc); return tupdesc; }