Re: initdb.c::main() too large

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: initdb.c::main() too large
Date: 2012-11-30 19:50:40
Message-ID: 20121130195040.GA27120@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 29, 2012 at 11:23:59PM -0500, Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > In looking to add an fsync-only option to initdb, I found its main()
> > function to be 743 lines long, and very hard to understand.
>
> > The attached patch moves much of that code into separate functions,
> > which will make initdb.c easier to understand, and easier to add an
> > fsync-only option. The original initdb.c author, Andrew Dunstan, has
> > accepted the restructuring, in principle.
>
> No objection to breaking it into multiple functions --- but I do say
> it's a lousy idea to put the long_options[] constant at the front of
> the file, thousands of lines away from the switch construct that it
> has to be in sync with. We don't do that in any other program AFAIR.
> Keep that in the main() function, please.

Good point. I had not noticed that. I fixed my initdb patch, and
adjusted a few other C files to be consistent.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-11-30 19:59:33 Re: Proposal for Allow postgresql.conf values to be changed via SQL
Previous Message Robert Haas 2012-11-30 19:41:14 Re: [PATCH] make -jN check fails / unset MAKEFLAGS in pg_regress.c