From c90f2fd5bc7b187838e3576f60a2b91b5ea37ac2 Mon Sep 17 00:00:00 2001 From: Alexander Korotkov Date: Sun, 12 Jul 2026 20:07:40 +0300 Subject: [PATCH v4 6/6] Remove unreachable error check in JSON_TABLE plan transform transformJsonTableNestedColumns() looked up the nested column named by a JSON_TABLE PLAN node and raised "invalid JSON_TABLE plan clause / PATH name was %s not found in nested columns list" if none was found. That lookup cannot fail: validateJsonTableChildPlan() runs first, at every plan level, and already matches the plan's sibling path names one-to-one against the nested columns (reporting any uncovered nested path or any extra or duplicate sibling node). The check has been unreachable since the PLAN clause code was first written. Replace it with an Assert documenting the invariant, which also removes a user-facing message that could never be emitted. Reported-by: Thom Brown Discussion: https://postgr.es/m/CAA-aLv5_9%3DzgA_Y7aoFp-%2BQSeh0kx4dfbAas9Wx%3DyrweQSqa6Q%40mail.gmail.com --- src/backend/parser/parse_jsontable.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/backend/parser/parse_jsontable.c b/src/backend/parser/parse_jsontable.c index 3fb6a511230..d86c6946ee9 100644 --- a/src/backend/parser/parse_jsontable.c +++ b/src/backend/parser/parse_jsontable.c @@ -647,13 +647,12 @@ transformJsonTableNestedColumns(JsonTableParseContext *cxt, else elog(ERROR, "invalid JSON_TABLE plan type %d", planspec->plan_type); - if (!jtc) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid JSON_TABLE plan clause"), - errdetail("PATH name was %s not found in nested columns list.", - planspec->pathname), - parser_errposition(cxt->pstate, planspec->location))); + /* + * The plan's path names were already matched one-to-one against the + * nested columns by validateJsonTableChildPlan(), so a nested column with + * this path name must exist. + */ + Assert(jtc != NULL); return transformJsonTableColumns(cxt, planspec, jtc->columns, passingArgs, -- 2.50.1 (Apple Git-155)