Re: ArchiveEntry optional arguments refactoring - Mailing list pgsql-hackers

From Amit Khandekar
Subject Re: ArchiveEntry optional arguments refactoring
Date
Msg-id CAJ3gD9fqSX+zrkE2Z9bqv5Q4-3uQPC90gkmk-Oc6wR-sxi8UbQ@mail.gmail.com
Whole thread Raw
In response to ArchiveEntry optional arguments refactoring  (Dmitry Dolgov <9erthalion6@gmail.com>)
List pgsql-hackers
On Wed, 16 Jan 2019 at 17:45, Dmitry Dolgov <9erthalion6@gmail.com> wrote:
>
> Hi,
>
> During the discussion in [1] an idea about refactoring ArchiveEntry was
> suggested. The reason is that currently this function has significant number of
> arguments that are "optional", and every change that has to deal with it
> introduces a lot of useless diffs. In the thread, mentioned above, such an
> example is tracking current table access method, and I guess "Remove WITH OIDS"
> commit 578b229718e is also similar.
>
> Proposed idea is to refactor out all/optional arguments into a separate data
> structure, so that adding/removing a new argument wouldn't change that much of
> unrelated code. Then for every invocation of ArchiveEntry this structure needs
> to be prepared before the call, or as Andres suggested:
>
>     ArchiveEntry((ArchiveArgs){.tablespace = 3,
>                                .dumpFn = somefunc,
>                                ...});

I didn't know we could do it this way. I thought we would have to
declare a variable and have to initialize fields with non-const values
separately. This looks nice. We could even initialize fields with
non-const values. +1 from me.

I think, we could use the same TocEntry structure as parameter, rather
than a new structure. Most of the arguments already resemble fields of
this structure. Also, we could pass pointer to that structure :

     ArchiveEntry( &(TocEntry){.tablespace = 3,
                               .dumpFn = somefunc,
                               ...});



-- 
Thanks,
-Amit Khandekar
EnterpriseDB Corporation
The Postgres Database Company


pgsql-hackers by date:

Previous
From: Andrew Gierth
Date:
Subject: Re: draft patch for strtof()
Next
From: Amit Khandekar
Date:
Subject: Re: Pluggable Storage - Andres's take