Re: pg_get_functiondef forgets about most GUC_LIST_INPUT GUCs

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: pavel(dot)stehule(at)gmail(dot)com
Cc: michael(at)paquier(dot)xyz, a(dot)zakirov(at)postgrespro(dot)ru, michael(dot)paquier(at)gmail(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_get_functiondef forgets about most GUC_LIST_INPUT GUCs
Date: 2018-03-14 08:30:59
Message-ID: 20180314.173059.04234659.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

At Tue, 6 Mar 2018 07:14:00 +0100, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote in <CAFj8pRB7u-D1NA8a22dytwicKv4RWrYqKCF=yiL5kKMKbssPSw(at)mail(dot)gmail(dot)com>
> 2018-03-06 2:32 GMT+01:00 Michael Paquier <michael(at)paquier(dot)xyz>:
>
> > On Mon, Mar 05, 2018 at 09:25:09PM +0100, Pavel Stehule wrote:
> > > I afraid so there is not good solution. Is possible to store options in
> > > original form? When the function will be displayed, then the original
> > value
> > > will be displayed. The current patch (with known extensions) can be used
> > as
> > > bug fix and back patched. In new version we store original value with
> > > quotes.
> >
> > You mean storing the values in pg_proc.proconfig at the creation time of
> > the function? That would basically work, except for the case of a
> > function using a parameter which is not from the same PL. The function
> > creation would fail because it cannot find the parameter it is looking
> > for as we need to look at loaded parameters to know it uses a list or
> > not :(
> >
>
> yes. It can fails on execution time, but it is something like runtime error.
>
> just dump should to produce same form like was input. So if on input we got
> quotes, then we should to use quotes on output. Without querying somewhere.
>
> The possible quotes can be removed in function compile time.

Doesn't it make sense if we provide a buildtime-script that
collects the function names and builds a .h file containing a
function using the list?

The attached perl script is a rush work of such script, which
works at the top of the source tree. It just prints the function
definition, does not generate a .h file.

I haven't confirmed anything about it but I had the following
output from the current master.

> inline bool
> IsConfigOptionIsAList(const char *name)
>
> {
> if (pg_strcasecmp(name, "DateStyle") == 0
> || pg_strcasecmp(name, "temp_tablespaces") == 0
> || pg_strcasecmp(name, "session_preload_libraries") == 0
> || pg_strcasecmp(name, "shared_preload_libraries") == 0
> || pg_strcasecmp(name, "local_preload_libraries") == 0
> || pg_strcasecmp(name, "search_path") == 0
> || pg_strcasecmp(name, "log_destination") == 0
> || pg_strcasecmp(name, "listen_addresses") == 0
> || pg_strcasecmp(name, "synchronous_standby_names") == 0
> || pg_strcasecmp(name, "wal_consistency_checking") == 0)
> return true;
> return false;
> }

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
unknown_filename text/plain 487 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2018-03-14 08:33:49 Re: [submit code] I develop a tool for pgsql, how can I submit it
Previous Message Etsuro Fujita 2018-03-14 08:25:44 Re: inserts into partitioned table may cause crash