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

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

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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2012-11-30 04:52:29 Re: [PATCH] Patch to fix a crash of psql
Previous Message Bruce Momjian 2012-11-30 04:12:23 initdb.c::main() too large