Re: pg_hosts: Add pg_hosts_file_rules() - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: pg_hosts: Add pg_hosts_file_rules()
Date
Msg-id 6A1428E3-CB62-4135-8B57-9EBD39599E9F@yesql.se
Whole thread
In response to Re: pg_hosts: Add pg_hosts_file_rules()  (Zsolt Parragi <zsolt.parragi@percona.com>)
List pgsql-hackers
> On 16 Jul 2026, at 00:10, Zsolt Parragi <zsolt.parragi@percona.com> wrote:
>
>> If you can find a good way to do it without convoluting the testfile which
>> currently just does a skip_all in case of LibreSSL, then why not.  If it reduce
>> readability of the test file then it's probably not worth it since it's not
>> using any different codepaths from the OpenSSL counterpart.
>
> Done. I added an if with an early exit instead of the skip, it seems
> to work properly with a local LibreSSL build I tested and I think it
> looks okay.

Makes sense.

+   "SELECT count(*) FROM pg_hosts_file_rules() WHERE error IS NULL",

One thing I noticed (and had missed before) is that we should SELECT from the
view and not the function.

>> It also makes more sense to me to first test parsing, and then parsing+loading.
>
> Also done. I also modified the test to use a connection string so that
> I don't have to add a trust entry to pg_hba before the connection
> tests.

LGTM.  While at it I think we should take the opportunity to test selecting
from the view with the file missing before we populate it and test parsing.  It
will be a cheap test to add and will cover one more path.

One small nit wit the LibreSSL hunk in the patch:

../src/backend/utils/adt/hbafuncs.c:467:1: warning: unused function 'fill_hosts_line' [-Wunused-function]
fill_hosts_line(Tuplestorestate *tuple_store, TupleDesc tupdesc,
^
1 warning generated.

With those two small nitpicks addressed I think this patch is pretty much ready for v20.

--
Daniel Gustafsson




pgsql-hackers by date:

Previous
From: Thom Brown
Date:
Subject: Re: walsummarizer can get stuck when switching timelines
Next
From: Daniel Gustafsson
Date:
Subject: Re: PGLZ Compression Optimization