Skip to content

Commit 091a971

Browse files
committed
Modify query on pg_hba_file_rules to check for errors in regression tests
The regression tests include a query to check the execution path of pg_hba_file_rules, but it has never checked that a given cluster has correct contents in pg_hba.conf. This commit extends the query of pg_hba_file_rules to report any errors if anything bad is found. For EXEC_BACKEND builds, any connection attempt would fail when loading pg_hba.conf if any incorrect content is found when parsed, so a failure would be detected before even running this query. However, this can become handy for clusters where pg_hba.conf can be reloaded, where new connection attempts are not subject to a fresh loading of pg_hba.conf. Author: Julien Rouhaud, based on an idea from me Discussion: https://postgr.es/m/YkFhpydhyeNNo3Xl@paquier.xyz
1 parent 33a3776 commit 091a971

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/test/regress/expected/sysviews.out

+6-5
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ select count(*) >= 0 as ok from pg_file_settings;
4848
t
4949
(1 row)
5050

51-
-- There will surely be at least one rule
52-
select count(*) > 0 as ok from pg_hba_file_rules;
53-
ok
54-
----
55-
t
51+
-- There will surely be at least one rule, with no errors.
52+
select count(*) > 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err
53+
from pg_hba_file_rules;
54+
ok | no_err
55+
----+--------
56+
t | t
5657
(1 row)
5758

5859
-- There will surely be at least one active lock

src/test/regress/sql/sysviews.sql

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ select count(*) = 0 as ok from pg_cursors;
2525

2626
select count(*) >= 0 as ok from pg_file_settings;
2727

28-
-- There will surely be at least one rule
29-
select count(*) > 0 as ok from pg_hba_file_rules;
28+
-- There will surely be at least one rule, with no errors.
29+
select count(*) > 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err
30+
from pg_hba_file_rules;
3031

3132
-- There will surely be at least one active lock
3233
select count(*) > 0 as ok from pg_locks;

0 commit comments

Comments
 (0)