From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: bvimalvictor@gmail.com
Subject: BUG #15971: Behaviour of SUBSTR function depending on its arguments
Date: Wed, 21 Aug 2019 07:02:30 +0000
Message-ID: <15971-965406c5a667c01a@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15971
Logged by: VIMAL VICTOR B
Email address: bvimalvictor@gmail.com
PostgreSQL version: 10.4
Operating system: Linux
Description:
Hi,
select substr('abcdef',1,2) val1, substr('abcdef',0,2) val2,
substr('abcdef',-1,2) val3;
The above query in Postgres returns expected result for val1 ('ab') but for
val2 and val3, it returns 'a' and '' respectively. Oracle and most of other
RDBMS systems would return 'ab' for val1 and val2. When the start position
is -ve, then the start position will be considered from end of input string.
The start position can be considered either as 0 or 1 and substring from
that position can be returned by considering the max length of the input
string, which is logically correct. But when -ve value given for start
position and returning empty string '', which does not seem logically
correct. Kindly consider this case and let me know your thoughts.
Regards,
Vimal
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: noreply@postgresql.org, bvimalvictor@gmail.com
Subject: Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments
In-Reply-To: <15971-965406c5a667c01a@postgresql.org>
References: <15971-965406c5a667c01a@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