Re: updates for handling optional argument in system functions

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Mark Wong <markwkm(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: updates for handling optional argument in system functions
Date: 2026-01-21 08:45:35
Message-ID: 0604F7D7-EABE-47CA-A58A-231CBD0DA659@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Jan 21, 2026, at 02:15, Mark Wong <markwkm(at)gmail(dot)com> wrote:
>
> Hi everyone,
>
> On Tue, Dec 09, 2025 at 03:28:59PM -0800, Mark Wong wrote:
>> Hi everyone,
>>
>> I noticed how it was preferred to define optional arguments with the
>> system functions in system_functions.sql instead of defining them in
>> pg_proc.dat.
>>
>> I took a gross stab at updating the ones that ended in _ext, which
>> turned out to be 7 declarations across 6 system functions, and created a
>> patch per system function, hoping it would be easier to review.
>>
>> Perhaps the most interesting thing to share is the total reduction of
>> the lines of code, although system_functions.sql only grows:
>>
>> src/backend/catalog/system_functions.sql | 49 ++++++++
>> src/backend/utils/adt/ruleutils.c | 130 ----------------------
>> src/include/catalog/pg_proc.dat | 36 ++----
>> 3 files changed, 56 insertions(+), 159 deletions(-)
>>
>>
>> Is that something we want?
>
> I fixed an error caught by the address sanitizer in CI [1] and am uploading a
> new patchset. The only change is to 2 lines in
> v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch to update a
> call to pg_get_expr with the correct number of arguments in tablecmds.c.
>
> Regards,
> Mark
>
> [1] https://cirrus-ci.com/task/6109065824174080
> --
> Mark Wong <markwkm(at)gmail(dot)com>
> EDB https://enterprisedb.com
> <v2-0001-Handle-pg_get_ruledef-default-args-in-system_func.patch><v2-0002-Handle-pg_get_viewdef-default-args-in-system_func.patch><v2-0003-Handle-pg_get_indexdef-default-args-in-system_fun.patch><v2-0004-Handle-pg_get_constraintdef-default-args-in-syste.patch><v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch><v2-0006-Handle-pg_get_triggerdef-default-args-in-system_f.patch>

Hi Mark,

Thanks for the patch. After reviewing it, I have mixed feelings. From one side, it removes some redundant code, which is good. In the other side, I doubt if we should delete proc entries from pg_proc.c? Say, there is a view that uses a proc to be deleted, the proc OID is stored with the view, then after an upgrade, the view would be broken. From this perspective, should we retain the old proc entries and only point them to the new functions?

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 Tatsuro Yamada 2026-01-21 08:46:45 Re: [PATCH] psql: add \dcs to list all constraints
Previous Message jian he 2026-01-21 08:38:24 Re: finish TODOs in to_json_is_immutable, to_jsonb_is_immutable also add tests on it