Show inline comments from pg_hba lines in the pg_hba_file_rules view - Mailing list pgsql-hackers

From Jim Jones
Subject Show inline comments from pg_hba lines in the pg_hba_file_rules view
Date
Msg-id 3fec6550-93b0-b542-b203-b0054aaee83b@uni-muenster.de
Whole thread Raw
Responses Re: Show inline comments from pg_hba lines in the pg_hba_file_rules view
List pgsql-hackers
Hi,

Often we make changes in the pg_hba.conf and leave a #comment there, 
just in case we forget why the change was done. To avoid having to open 
the configuration file every time just to check the comments, it would 
be quite nice to have the option to read these comments in the 
pg_hba_file_rules view. Something like adding it in the end of the line 
and wrapping it with characters like "", '', {}, [], etc

For instance, this pg_hba.conf ...

# TYPE  DATABASE        USER   ADDRESS         METHOD
local   all             all                    trust [foo]
host    all             all    127.0.0.1/32    trust
host    all             all    ::1/128         trust [bar]
local   replication     all                    trust
host    replication     all    127.0.0.1/32    trust
hostssl replication     all    ::1/128         cert map=abc [this will 
fail :)]

... could be displayed like this

postgres=# SELECT type, database, user_name, address, comment, error 
FROM pg_hba_file_rules ;
   type   |   database    | user_name |  address  | comment      | error

---------+---------------+-----------+-----------+-------------------+-----------------------------------------------------
  local   | {all}         | {all}     |           | foo               |
  host    | {all}         | {all}     | 127.0.0.1 |                   |
  host    | {all}         | {all}     | ::1       | bar               |
  local   | {replication} | {all}     | |                   |
  host    | {replication} | {all}     | 127.0.0.1 |                   |
  hostssl | {replication} | {all}     | ::1       | this will fail :) | 
hostssl record cannot match because SSL is disabled
(6 rows)

I wrote a very quick&dirty PoC (attached) but before going any further I 
would like to ask if there is a better way to read these comments using 
SQL - or if it makes sense at all ;-)

Any feedback is much appreciated. Thanks!

Jim

Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Reducing connection overhead in pg_upgrade compat check phase
Next
From: Melanie Plageman
Date:
Subject: Re: Eliminate redundant tuple visibility check in vacuum