Re: pg_hosts: Add pg_hosts_file_rules()

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_hosts: Add pg_hosts_file_rules()
Date: 2026-07-16 11:56:51
Message-ID: 6A1428E3-CB62-4135-8B57-9EBD39599E9F@yesql.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 16 Jul 2026, at 00:10, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-07-16 12:03:02 Re: Type assertions without GCC builtins
Previous Message Thom Brown 2026-07-16 11:46:27 Re: walsummarizer can get stuck when switching timelines