BUG #14628: regex description in online documentation misleadingly/wrong

From: t(dot)glaser(at)tarent(dot)de
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14628: regex description in online documentation misleadingly/wrong
Date: 2017-04-20 15:25:49
Message-ID: 20170420152549.24365.74331@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14628
Logged by: Thorsten Glaser
Email address: t(dot)glaser(at)tarent(dot)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).

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2017-04-20 16:02:08 Re: BUG #14628: regex description in online documentation misleadingly/wrong
Previous Message Alvaro Herrera 2017-04-20 13:31:19 Re: BUG #14627: fail initdb