Convert configuration file parsing to use flex

Previously, repmgr was using a very simple ad-hoc string-based parser,
which had various limitations and allowed configuration files to be
created in a way which could cause confusion and/or unexpected
behaviour.

For example, it accepted strings enclosed in single quotes, but treated
strings enclosed in double quotes literally. A node_name defined thusly:

    node_name="somenode"

would result in the literal value '"somenode"' being used, which could
lead to unobvious errors along the lines of:

    no record found for ""somenode""

The configuration file parser has been adapted from the one used by
PostgreSQL itself, so behaves more-or-less identically (though some
functions such as file inclusion are not supported in repmgr).

This makes configuration parsing more robust and consistent;
additionally, error reporting will be more precise.

Note this does mean that some repmgr.conf items previously accepted
as valid by repmgr will now be rejected; in particular this includes
strings containing spaces which are not enclosed in single quotes.
This commit is contained in:
Ian Barwick
2019-07-03 12:18:01 +09:00
parent ab7e527af8
commit 8d55cab25e
8 changed files with 740 additions and 363 deletions

View File

@@ -24,6 +24,33 @@
<sect2>
<title>General enhancements</title>
<para>
<itemizedlist>
<listitem>
<para>
The &repmgr; configuration file is now parsed using
<command>flex</command>, meaning it will be parsed in
the same way as PostgreSQL parses its own configuration
files.
</para>
<para>
This makes configuration file parsing more robust
and consistent.
</para>
<note>
<para>
This change makes configuration file parsing somewhat stricter
than previously. When upgrading, be sure to check your
configuration file syntax.
<!-- XXX add notes in upgrade section -->
</para>
<para>
In particular, all string values containing spaces
<emphasis>must</emphasis> be contained within single quotes.
</para>
</note>
</listitem>
</itemizedlist>
</para>
</sect2>
</sect1>