Re: [PATCH] Reject duplicate SQL/JSON PASSING argument names

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Dewei Dai <daidewei1970(at)163(dot)com>
Cc: Pgsql Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Reject duplicate SQL/JSON PASSING argument names
Date: 2026-11-18 23:51:07
Message-ID: B37E54B2-63C3-4DB4-A300-D2EAACCB86C0@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Nov 18, 2026, at 17:50, Dewei Dai <daidewei1970(at)163(dot)com> wrote:
>
> Thanks for the review.
>
> On 2026-11-18 14:31:33, Chao Li wrote:
>> 1
>> --- a/src/backend/parser/parse_expr.c
>> +++ b/src/backend/parser/parse_expr.c
>> ...
>> The result of transformJsonValueExpr() doesn't matter for the dup name check, so we can do the check before calling transformJsonValueExpr().
>
> Fixed. I moved the duplicate name check before calling transformJsonValueExpr().
>
>> 2
>> ...
>> Modern ereport() style doesn't require the extra parentheses around errcode(), errmsg(), etc. Since this file already has a mix of old and new styles, I think we should use the modern style for new code.
>
> Fixed. I updated the new ereport() call to use the modern style without extra parentheses.
>
>> 3. The current doc in func-json.sgml doesn't explicitly say anything about duplicate PASSING argument names:
>> ...
>> So, I think this patch should update the doc accordingly, for example, adding a simple sentence saying that duplicate PASSING argument names are not allowed.
>
> Fixed. I added a sentence to func-json.sgml stating that the names of the variables in the PASSING clause must be unique.
>
>> 4. The tests cover JSON_QUERY and JSON_TABLE, but as you explained in the patch email, JSON_EXISTS and JSON_VALUE are also affected. Maybe add test cases for JSON_EXISTS and JSON_VALUE as well.
>
> Fixed. I added regression tests for JSON_EXISTS and JSON_VALUE.
>
>> 5. Maybe also mention JSON_EXISTS, JSON_QUERY, and JSON_VALUE in the commit message, as they are fixed by this patch as well.
>
> Fixed. I updated the commit message to mention all affected functions.
>
>
> Best regards,
> Dewei Dai
>
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
> <v2-0001-Reject-duplicate-SQL-JSON-PASSING-argument-names.patch>

Thanks for updating the patch. V2 looks good to me.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Joao Rito 2026-11-18 23:58:32 Re: Backend crash in expanded_record_info functions
Previous Message Joao Rito 2026-11-18 23:46:39 [PATCH] Add hint to wal_level errors for replication slots and pg_log_standby_snapshot