[PATCH] Add inline comments to the pg_hba_file_rules view

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: [PATCH] Add inline comments to the pg_hba_file_rules view
Date: 2023-09-04 10:54:15
Message-ID: 4d623899-36ac-71b5-311d-2a4672d75736@uni-muenster.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi,

This patch proposes the column "comment" to the pg_hba_file_rules view.
It basically parses the inline comment (if any) of a valid pg_hba.conf
entry and displays it in the new column.

For such pg_hba entries ...

host db jim 127.0.0.1/32 md5 # foo
host db jim 127.0.0.1/32 md5 #bar
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
 host | {db}     | {jim}     | 127.0.0.1 | bar
 host | {db}     | {jim}     | 127.0.0.1 | #foo#
(3 rows)

This feature can come in quite handy when we need to read important
comments from the hba entries without having access to the pg_hba.conf
file directly.

The patch slightly changes the test 004_file_inclusion.pl to accommodate
the new column and the hba comments.

Discussion:
https://www.postgresql.org/message-id/flat/3fec6550-93b0-b542-b203-b0054aaee83b%40uni-muenster.de

Best regards,
Jim

Attachment Content-Type Size
v1-0001-Add-inline-comments-to-the-pg_hba_file_rules-view.patch text/x-patch 10.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2023-09-04 10:59:01 Re: Optimize planner memory consumption for huge arrays
Previous Message Dilip Kumar 2023-09-04 10:48:51 Re: Impact of checkpointer during pg_upgrade