From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-bugs@lists.postgresql.org
Cc: bvimalvictor@gmail.com
Subject: Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments
Date: Wed, 21 Aug 2019 12:26:30 +0200
Message-ID: <89fff570-c391-26ef-49d6-b1e9afd3f5db@gmx.net> (raw)
In-Reply-To: <15971-965406c5a667c01a@postgresql.org>
References: <15971-965406c5a667c01a@postgresql.org>
PG Bug reporting form schrieb am 21.08.2019 um 09:02:
> 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.
The only "other" DBMS that behaves the way you describe it, is Oracle.
When I ran it on different systems, this is the result:
| val1 | val2 | val3 |
-----------|------|---------|---------|
Postgres | ab | a | <empty> |
SQL Server | ab | a | <empty> |
SQLite | ab | a | f |
MySQL | ab | <empty> | f |
Oracle | ab | ab | f |
DB2 and Firebird do not allow a starting position smaller than 1
So SQL Server works the same as Postgres and Oracle is the only one that returns 'ab' for the second case
So clearly the claim "most other" is wrong here.
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: spam_eater@gmx.net, bvimalvictor@gmail.com
Subject: Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments
In-Reply-To: <89fff570-c391-26ef-49d6-b1e9afd3f5db@gmx.net>
References: <15971-965406c5a667c01a@postgresql.org> <89fff570-c391-26ef-49d6-b1e9afd3f5db@gmx.net>
* 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