On Wed, 16 Jan 2019 at 17:45, Dmitry Dolgov <9erthali...@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