[augeas-devel] having trouble with postgresql.conf

Marc Fournier marc.fournier at camptocamp.com
Mon Jan 17 08:39:15 UTC 2011


Hello,

I'm currently trying to build a lens to allow augeas to work with
postgresql's configuration file.

postgresql.conf is a simple "key = value" file, similar to many others. It
allows quite a bit of flexibility, which is why I'm having trouble with it.

The first problem I have is that ...

listen_addresses = 'localhost'
Listen_Addresses = 'localhost'
LISTEN_ADDRESSES = 'localhost'

... are the same from postgresql point of view.

Is there a way for augeas to consider all these possibilities as equal ? A
sort of case-insensitive switch for key resolution ?



The 2nd problem I have is that values matching /a-zA-Z0-9_\.-/ don't
necessarily require quotes. Quotes are only required when the value
contains characters not in this range. All these options are considered
valid:

log_filename = postgresql_log
log_filename='postgresql_log'
log_filename = 'postgresql_log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'

... which means that I'm forced to remove the optional single-quotes as
well as optional white-spaces using the "del" operator.

Matching something such as:

key=' \' '

... is already achieved in sysconfig.aug, but being able to match:

key = ' \' '

... is my problem. As the enclosing single quotes are optional, augeas
doesn't know which whitespace belongs to "del" and which one belongs to
"store".

I also tried to split the problem in 2 cases, one with the quotes and one
without, and tell the lens to match either of them. But then augeas
complains about overlapping lenses.

sysconfig.aug currently doesn't support comments such as:

FOO="bar" # a comment

I suspect the author hit the same sort of problem I'm facing with these
whitespaces and quotes. By the way, postgresql.conf also allows comments at
the end of the line...

I've made a complete mess of my various attempts to build this lens, but
I've attached the tests I've used and which should cover all the possible
cases (except comments).

Thanks for your advices !

Cheers,
Marc

-------------- next part --------------
module Test_postgresql =

  test Postgresql.assign get "enable_indexscan = 'on'\n" =
    { "enable_indexscan" = "on" }

  test Postgresql.assign get "enable_indexscan = tru\n" =
    { "enable_indexscan" = "tru" }

  test Postgresql.assign get "enable_indexscan = YES\n" =
    { "enable_indexscan" = "YES" }

  test Postgresql.assign get "enable_indexscan=yes\n" =
    { "enable_indexscan" = "yes" }

  test Postgresql.assign get "enable_indexscan='yes'\n" =
    { "enable_indexscan" = "yes" }

  test Postgresql.assign get "archive_timeout = '30'\n" =
    { "archive_timeout" = "30" }

  test Postgresql.assign get "archive_timeout = 30s\n" =
    { "archive_timeout" = "30s" }

  test Postgresql.assign get "archive_timeout = -1\n" =
    { "archive_timeout" = "-1" }

  test Postgresql.assign get "seq_page_cost = 2.0\n"=
    { "seq_page_cost" = "2.0" }

  test Postgresql.assign get "seq_page_cost = 2\n"=
    { "seq_page_cost" = "2" }

  test Postgresql.assign get "archive_command = tar\n" =
    { "archive_command" = "tar" }

  test Postgresql.assign get "archive_command = 'tar -cz'\n" =
    { "archive_command" = "tar -cz" }

  test Postgresql.assign get "archive_command = 'tar \'quoted option\''\n" =
    { "archive_command" = "tar \'quoted option\'" }

  test Postgresql.assign get "log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'\n" =
    { "log_filename" = "postgresql-%Y-%m-%d_%H%M%S.log" }



More information about the augeas-devel mailing list