From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | bvimalvictor(at)gmail(dot)com |
Subject: | Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments |
Date: | 2019-08-21 10:26:30 |
Message-ID: | 89fff570-c391-26ef-49d6-b1e9afd3f5db@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2019-08-21 10:44:31 | Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments |
Previous Message | Ashutosh Sharma | 2019-08-21 09:09:52 | Re: BUG #15971: Behaviour of SUBSTR function depending on its arguments |