Re: generating function default settings from pg_proc.dat

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: generating function default settings from pg_proc.dat
Date: 2026-02-16 18:08:23
Message-ID: 1143678.1771265303@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Motivated by Bug 19409 [1] I decided to do something about a wart that
> has bugged me for a while, namely the requirement to write stuff in
> system_views.sql if you need to specify default values for function
> arguments. Here's my attempt. The first patch here sets up the required
> infrastructure. genbki.pl creates a file called function_defaults.sql
> which is run by initdb at the appropriate time. There are two new fields
> in pg_proc.dat entries: proargdflts,and provariadicdflt. These are
> parsed and the appropriate CREATE OR REPLACE statement is generated and
> placed in function_defaults.sql. The second patch applies this treatment
> to 37 function definitions and removes the corresponding statements from
> system_views.sql. This gets us closer to having pg_proc.dat as a single
> source of truth.

Nice! I'll review this in more detail later, but it seems like
a great idea.

One nitpick is that it's not clear how someone would discover the
existence of this feature. We could of course add info to bki.sgml,
but I wish it were more organic. Is there a way that we could have
these entries appear in "proargdefaults" so that there's an obvious
connection to the actual catalog field?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Rafia Sabih 2026-02-16 18:13:57 Re: Add connection active, idle time to pg_stat_activity
Previous Message Corey Huinker 2026-02-16 18:08:22 Re: generating function default settings from pg_proc.dat