BUG #15756: Seemingly inconsistent behavior of SUBSTRING(string FROM pattern FOR escape) function

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: auspex(at)rambler(dot)ru
Subject: BUG #15756: Seemingly inconsistent behavior of SUBSTRING(string FROM pattern FOR escape) function
Date: 2019-04-15 10:01:46
Message-ID: 15756-27768253d60f7e38@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: 15756
Logged by: Sergei Abramov
Email address: auspex(at)rambler(dot)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!

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2019-04-15 10:26:24 Re: BUG #15756: Seemingly inconsistent behavior of SUBSTRING(string FROM pattern FOR escape) function
Previous Message PG Bug reporting form 2019-04-15 08:02:55 BUG #15755: After upgrading to 9.6.12 using pg_upgrade, select query does not return the expected results.