]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix incorrect comment in JsonTablePlanJoinNextRow()
authorAmit Langote <amitlan@postgresql.org>
Thu, 16 Apr 2026 02:52:16 +0000 (11:52 +0900)
committerAmit Langote <amitlan@postgresql.org>
Thu, 16 Apr 2026 03:12:15 +0000 (12:12 +0900)
The comment on the return-false path when both UNION siblings are
exhausted said "there are more rows," which is the opposite of what
the code does. The code itself is correct, returning false to signal
no more rows, but the misleading comment could tempt a reader into
"fixing" the return value, which would cause UNION plans to loop
indefinitely.

Back-patch to 17, where JSON_TABLE was introduced.

Author: Chuanwen Hu <463945512@qq.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/tencent_4CC6316F02DECA61ACCF22F933FEA5C12806@qq.com
Backpatch-through: 17

src/backend/utils/adt/jsonpath_exec.c

index dbab24737ef1fa030ff62be707bab47de3aabdda..eedc5c87b05f37461927281fef4c1bacc5fcf1ce 100644 (file)
@@ -4419,7 +4419,7 @@ JsonTablePlanJoinNextRow(JsonTablePlanState *planstate)
                 */
                if (!JsonTablePlanNextRow(planstate->right))
                {
-                       /* Right sibling ran out of row, so there are more rows. */
+                       /* Right sibling ran out of rows too, so there are no more rows. */
                        return false;
                }
        }