From: t.glaser@tarent.de
To: pgsql-bugs@postgresql.org
Subject: BUG #14628: regex description in online documentation misleadingly/wrong
Date: Thu, 20 Apr 2017 15:25:49 +0000
Message-ID: <20170420152549.24365.74331@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14628
Logged by: Thorsten Glaser
Email address: t.glaser@tarent.de
PostgreSQL version: 9.6.1
Operating system: GNU/Linux
Description:
https://www.postgresql.org/docs/9.6/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
clearly says that ~ matches a POSIX regular expression.
This is only somewhat true: this does match:
tarent=> SELECT 'a\bc' ~ '^[a\\b]*$';
?column?
----------
f
(1 row)
tarent=> SELECT 'a\b' ~ '^[a\\b]*$';
?column?
----------
t
(1 row)
But this does not match:
tarent=> SELECT 'a\b' ~ '^[a\b]*$';
?column?
----------
f
(1 row)
The cause is likely this statement, burrowed way down in another chapter:
“Note: PostgreSQL always initially presumes that a regular expression
follows the ARE rules.”
And indeed, it’s an ARE!
tarent=> SELECT 'a\b' ~ '(?e)^[a\b]*$';
?column?
----------
t
(1 row)
I find this extremely misleading (it also does not state whether it matches
BRE or ERE by default, just “POSIX re”), especially as it’s extremely
important to know precisely what RE syntax you’re targetting when escaping a
user-provided string into part of a RE (you have to precisely know where to
escape and where to not escape, for example), which is why I personally
always use POSIX standard RE (normally BRE).
Please indicate in *all* places in the documentation dealing with regular
expressions that it’s about ARE and link ARE to the section in the manual
explaining it -
https://www.postgresql.org/docs/9.6/static/functions-matching.html#POSIX-SYNTAX-DETAILS
- in all of those places. Also, make clear at the beginning of that section
how to force standard POSIX RE (i.e. BRE and ERE).
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: t.glaser@tarent.de
Subject: Re: BUG #14628: regex description in online documentation misleadingly/wrong
In-Reply-To: <20170420152549.24365.74331@wrigleys.postgresql.org>
References: <20170420152549.24365.74331@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox