public inbox for [email protected]  
help / color / mirror / Atom feed
From: =?gb18030?B?uvq0q87E?= <[email protected]>
To: =?gb18030?B?cGdzcWwtaGFja2Vycw==?= <[email protected]>
Subject: [PATCH] Fix wrong comment in JsonTablePlanJoinNextRow()
Date: Wed, 15 Apr 2026 16:28:44 +0800
Message-ID: <[email protected]> (raw)

Hi,

Found a misleading comment in JsonTablePlanJoinNextRow() while reading
the JSON_TABLE execution code.

The function returns false when both siblings are exhausted (meaning no
more rows), but the comment says "there are more rows" — the exact
opposite of what's happening. The code itself is correct.






if (!JsonTablePlanNextRow(planstate-&gt;right))
{
    /* Right sibling ran out of row, so there are more rows. */  /* wrong */
    return false;
}





A reader might reasonably treat this as a bug and flip the return value,
which would cause JSON_TABLE UNION plans to loop indefinitely.

Patch attached.

Regards,
Chuanwen Hu

Attachments:

  [application/octet-stream] fix-jsontable-comment.patch (510B, 3-fix-jsontable-comment.patch)
  download | inline diff:
diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c
index 770840a..0ec9b4d 100644
--- a/src/backend/utils/adt/jsonpath_exec.c
+++ b/src/backend/utils/adt/jsonpath_exec.c
@@ -4729,7 +4729,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;
 		}
 	}


view thread (4+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: [PATCH] Fix wrong comment in JsonTablePlanJoinNextRow()
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox