Re: Parsing config files in a directory

From: Greg Smith <gsmith(at)gregsmith(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Greg Stark <gsstark(at)mit(dot)edu>, Dimitri Fontaine <dfontaine(at)hi-media(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Parsing config files in a directory
Date: 2009-10-28 17:20:07
Message-ID: alpine.GSO.2.01.0910281304200.12952@westnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 28 Oct 2009, Tom Lane wrote:

> Why in the world are you looking at initdb? The standard reference for
> postgresql.conf-reading code, by definition, is guc-file.l. I think the
> odds of building something that works right, without borrowing that same
> flex logic, are about nil.

initdb was the only sample around that actually makes changes to the
postgresql.conf. It's also a nice simple standalone program that's easy
to borrow pieces from, which guc-file.l is not. That's the reason it
looks tempting at first.

If as you say the only right way to do this is to use the flex logic, that
just reinforced how high the bar is for someone who wants to write a tool
that modifies the file. Periodically we get people who show up saying
"hey, I'd like to write a little [web|cli|gui] tool to help people update
their postgresql.conf file", and when the answer they get incudes "first
you need to implement this grammar..." that's scares off almost all of
them. It didn't work on me because I used to write compilers for fun
before flex existed. But even I just skimmed it and pragmatically wrote a
simpler postgresql.conf parser implementation that worked well enough to
get a working prototype out the door, rather than properly the whole
grammar.

--
* Greg Smith gsmith(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2009-10-28 17:28:02 Re: Parsing config files in a directory
Previous Message Josh Berkus 2009-10-28 17:10:30 Re: Parsing config files in a directory