Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-3804) Fix sort order of pg_hba_rule entries #1040

Merged
merged 1 commit into from
Jan 15, 2019

Conversation

olavmrk
Copy link
Contributor

@olavmrk olavmrk commented Dec 6, 2018

The $order-parameter to pg_hba_rule can be either an integer or a
string, but the corresponding concat-resource is configured to sort
the entries using alphanumeric sort.

The result is that a pg_hba_rule entry with order => 2 sorts after
an entry with order => 10.

This is also a problem with the default pg_hba_rule entries, which
uses numeric order values 1, 2, 3, 4, 100 and 101. These are sorted in
the incorrect order (1, 100, 101, 2, 3, 4).

Unfortunately, since string values are allowed in the
$order-parameter, we cannot simply change the concat-resource to
use numeric sort.

This patch fixes this issue by zero-padding all integer values to
three digits. E.g. 1 becomes 001, and 10 becomes 010. This should
work well for integer values from 0 through 999, and works well with
earlier versions of the module which used string values in that range
for the $order-parameter.

@david22swan
Copy link
Member

@olavmrk This looks like a good change that I would be happy to merge, but first could you update the documentation to mention the zero padding please?

The `$order`-parameter to `pg_hba_rule` can be either an integer or a
string, but the corresponding `concat`-resource is configured to sort
the entries using alphanumeric sort.

The result is that a `pg_hba_rule` entry with `order => 2` sorts after
an entry with `order => 10`.

This is also a problem with the default `pg_hba_rule` entries, which
uses numeric order values 1, 2, 3, 4, 100 and 101. These are sorted in
the incorrect order (1, 100, 101, 2, 3, 4).

Unfortunately, since string values are allowed in the
`$order`-parameter, we cannot simply change the `concat`-resource to
use numeric sort.

This patch fixes this issue by zero-padding all integer values to
three digits. E.g. 1 becomes `001`, and 10 becomes `010`. This should
work well for integer values from 0 through 999, and works well with
earlier versions of the module which used string values in that range
for the `$order`-parameter.
@olavmrk
Copy link
Contributor Author

olavmrk commented Jan 15, 2019

@david22swan: I have now updated the documentation for the order parameter. I now reads:

order

Sets an order for placing the rule in pg_hba.conf.

This can be either a string or an integer. If it is an integer, it will be converted to a string by zero-padding it to three digits. E.g. 42 will be zero-padded to the string '042'.

The pg_hba_rule fragments are sorted using the alpha sorting order.

Default value: 150.

@david22swan
Copy link
Member

@olavmrk Look's good to me. Thanks for putting in the work. :)

@david22swan david22swan merged commit ad6a877 into puppetlabs:master Jan 15, 2019
cegeka-jenkins pushed a commit to cegeka/puppet-postgresql that referenced this pull request Feb 3, 2022
(MODULES-3804) Fix sort order of pg_hba_rule entries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants