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 b125628f7b
commit c6ca183247
8 changed files with 753 additions and 363 deletions

View File

@@ -15,6 +15,44 @@
See also: <xref linkend="upgrading-repmgr"/>
</para>
<sect1 id="release-4.5">
<title>Release 4.5</title>
<para><emphasis>?? ???, 2019</emphasis></para>
<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>
<sect1 id="release-4.4">
<title>Release 4.4</title>
<para><emphasis>27 June, 2019</emphasis></para>