This is a very useful feature. I applied the patch to the master branch,
and both make check and make check-world passed without any issues.
Just one comment here, based on the example below,
> host db jim 127.0.0.1/32 md5 # #foo#
>
> ... it returns the following pg_hba_file_rules records:
>
> postgres=# SELECT type, database, user_name, address, comment
> FROM pg_hba_file_rules
> WHERE user_name[1]='jim';
>
> type | database | user_name | address | comment
> ------+----------+-----------+-----------+---------
> host | {db} | {jim} | 127.0.0.1 | #foo#
Since "only the first #" and "any leading spaces" are removed, IMO, it
can be more accurate to say,
Text after the first <literal>#</literal> comment character in the end
of a valid <literal>pg_hba.conf</literal> entry, if any
Best regards,
David