]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Avoid syscache lookup while building a WAIT FOR tuple descriptor
authorAlexander Korotkov <akorotkov@postgresql.org>
Mon, 6 Apr 2026 19:27:36 +0000 (22:27 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Mon, 6 Apr 2026 19:47:26 +0000 (22:47 +0300)
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 <xunengzhou@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
src/backend/commands/wait.c

index e64e3be628565e3e600de2859dd12bb7b828089b..85fcd463b4c59431ab0a0236a4335a58caada459 100644 (file)
@@ -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;
 }