1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

Doc: clarify description of regexp fields in pg_ident.conf.

The grammar was a little shaky and confusing here, so word-smith it
a bit.  Also, adjust the comments in pg_ident.conf.sample to use the
same terminology as the SGML docs, in particular "DATABASE-USERNAME"
not "PG-USERNAME".

Back-patch appropriate subsets.  I did not risk changing
pg_ident.conf.sample in released branches, but it still seems OK
to change it in v18.

Reported-by: Alexey Shishkin <alexey.shishkin@enterprisedb.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Discussion: https://postgr.es/m/175206279327.3157504.12519088928605422253@wrigleys.postgresql.org
Backpatch-through: 13
This commit is contained in:
Tom Lane
2025-07-15 18:53:00 -04:00
parent 2a3a396432
commit 5fe55a0fe4
2 changed files with 21 additions and 21 deletions

View File

@ -1003,8 +1003,9 @@ local db1,db2,@demodbs all md5
the remainder of the field is treated as a regular expression. the remainder of the field is treated as a regular expression.
(See <xref linkend="posix-syntax-details"/> for details of (See <xref linkend="posix-syntax-details"/> for details of
<productname>PostgreSQL</productname>'s regular expression syntax.) The regular <productname>PostgreSQL</productname>'s regular expression syntax.) The regular
expression can include a single capture, or parenthesized subexpression, expression can include a single capture, or parenthesized subexpression.
which can then be referenced in the <replaceable>database-username</replaceable> The portion of the system user name that matched the capture can then
be referenced in the <replaceable>database-username</replaceable>
field as <literal>\1</literal> (backslash-one). This allows the mapping of field as <literal>\1</literal> (backslash-one). This allows the mapping of
multiple user names in a single line, which is particularly useful for multiple user names in a single line, which is particularly useful for
simple syntax substitutions. For example, these entries simple syntax substitutions. For example, these entries
@ -1022,12 +1023,11 @@ mymap /^(.*)@otherdomain\.com$ guest
<para> <para>
If the <replaceable>database-username</replaceable> field starts with If the <replaceable>database-username</replaceable> field starts with
a slash (<literal>/</literal>), the remainder of the field is treated a slash (<literal>/</literal>), the remainder of the field is treated
as a regular expression (see <xref linkend="posix-syntax-details"/> as a regular expression.
for details of <productname>PostgreSQL</productname>'s regular When the <replaceable>database-username</replaceable> field is a regular
expression syntax). It is not possible to use <literal>\1</literal> expression, it is not possible to use <literal>\1</literal> within it to
to use a capture from regular expression on refer to a capture from the <replaceable>system-username</replaceable>
<replaceable>system-username</replaceable> for a regular expression field.
on <replaceable>database-username</replaceable>.
</para> </para>
<tip> <tip>

View File

@ -13,25 +13,25 @@
# user names to their corresponding PostgreSQL user names. Records # user names to their corresponding PostgreSQL user names. Records
# are of the form: # are of the form:
# #
# MAPNAME SYSTEM-USERNAME PG-USERNAME # MAPNAME SYSTEM-USERNAME DATABASE-USERNAME
# #
# (The uppercase quantities must be replaced by actual values.) # (The uppercase quantities must be replaced by actual values.)
# #
# MAPNAME is the (otherwise freely chosen) map name that was used in # MAPNAME is the (otherwise freely chosen) map name that was used in
# pg_hba.conf. SYSTEM-USERNAME is the detected user name of the # pg_hba.conf. SYSTEM-USERNAME is the detected user name of the
# client. PG-USERNAME is the requested PostgreSQL user name. The # client. DATABASE-USERNAME is the requested PostgreSQL user name.
# existence of a record specifies that SYSTEM-USERNAME may connect as # The existence of a record specifies that SYSTEM-USERNAME may connect
# PG-USERNAME. # as DATABASE-USERNAME.
# #
# If SYSTEM-USERNAME starts with a slash (/), it will be treated as a # If SYSTEM-USERNAME starts with a slash (/), the rest of it will be
# regular expression. Optionally this can contain a capture (a # treated as a regular expression. Optionally this can contain a capture
# parenthesized subexpression). The substring matching the capture # (a parenthesized subexpression). The substring matching the capture
# will be substituted for \1 (backslash-one) if present in # will be substituted for \1 (backslash-one) if that appears in
# PG-USERNAME. # DATABASE-USERNAME.
# #
# PG-USERNAME can be "all", a user name, a group name prefixed with "+", or # DATABASE-USERNAME can be "all", a user name, a group name prefixed with "+",
# a regular expression (if it starts with a slash (/)). If it is a regular # or a regular expression (if it starts with a slash (/)). If it is a regular
# expression, the substring matching with \1 has no effect. # expression, no substitution for \1 will occur.
# #
# Multiple maps may be specified in this file and used by pg_hba.conf. # Multiple maps may be specified in this file and used by pg_hba.conf.
# #
@ -69,4 +69,4 @@
# Put your actual configuration here # Put your actual configuration here
# ---------------------------------- # ----------------------------------
# MAPNAME SYSTEM-USERNAME PG-USERNAME # MAPNAME SYSTEM-USERNAME DATABASE-USERNAME