BUG #15756: Seemingly inconsistent behavior of SUBSTRING(string FROM pattern FOR escape) function - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15756: Seemingly inconsistent behavior of SUBSTRING(string FROM pattern FOR escape) function
Date
Msg-id 15756-27768253d60f7e38@postgresql.org
Whole thread Raw
Responses Re: BUG #15756: Seemingly inconsistent behavior of SUBSTRING(stringFROM pattern FOR escape) function  (Daniel Gustafsson <dgustafsson@pivotal.io>)
Re: BUG #15756: Seemingly inconsistent behavior of SUBSTRING(stringFROM pattern FOR escape) function  (Francisco Olarte <folarte@peoplecall.com>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15756
Logged by:          Sergei Abramov
Email address:      auspex@rambler.ru
PostgreSQL version: 9.5.16
Operating system:   Linux, Windows
Description:

When statement SELECT SUBSTRING('+380481234567' FROM 5 FOR 9),
SUBSTRING('+380481234567' FROM '%#"[0-9]{9}#"' FOR '#') is issued in pgAdmin
III Query both functions give the same correct results which are expected
when psql command line tool is to be used:
psql --username=postgres --no-password --command="SELECT
SUBSTRING('+380481234567' FROM 5 FOR 9), SUBSTRING('+380481234567' FROM
'%#"[0-9]{9}#"' FOR '#')"
But here something strange occurs! The latter function invocation
permanently returns NULL value that can be easily seen when wrapped in
COALESCE:
psql --username=postgres --no-password --command="SELECT
COALESCE(SUBSTRING('+380481234567' FROM '%#"[0-9]{9}#"' FOR '#'), 'NULL')"
This behavior is reproduced in Windows XP 32-bit, Windows 7 32-bit (both
local PG-servers) and in Linux 64 bit (both local and remote PG-servers) for
PG versions 9.3.23, 9.4.9, and 9.5.16.

Thanks for your help!


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #15755: After upgrading to 9.6.12 using pg_upgrade, select query does not return the expected results.
Next
From: Daniel Gustafsson
Date:
Subject: Re: BUG #15756: Seemingly inconsistent behavior of SUBSTRING(stringFROM pattern FOR escape) function